@@ -59,13 +59,14 @@ def buffering(clusters, key, sregistry, options, **kwargs):
5959 Additional compilation options.
6060 Accepted: ['opt_init_onwrite', 'opt_buffer'].
6161 * 'opt_init_onwrite': By default, a written buffer does not trigger the
62- generation of an initializing Cluster. With `opt_init_onwrite=True`,
63- instead, the buffer gets initialized to zero.
62+ generation of an initializing Cluster. With `opt_init_onwrite=True`,
63+ instead, the buffer gets initialized to zero. A callable receives the
64+ buffered Function and the selected buffer.
6465 * 'opt_reuse': A callback that takes a buffering candidate `bf` as input
65- and returns True if the pass can reuse pre-existing Buffers for
66- buffering `bf`, which would otherwise default to False.
66+ and returns True if the pass can reuse pre-existing Buffers for
67+ buffering `bf`, which would otherwise default to False.
6768 * 'opt_buffer': A callback that takes a buffering candidate as input
68- and returns a buffer, which would otherwise default to an Array.
69+ and returns a buffer, which would otherwise default to an Array.
6970
7071 Examples
7172 --------
@@ -103,7 +104,7 @@ def key(f):
103104 assert callable (key )
104105
105106 v1 = kwargs .get ('opt_init_onwrite' , False )
106- init_onwrite = v1 if callable (v1 ) else lambda f : v1
107+ init_onwrite = v1 if callable (v1 ) else lambda f , b : v1
107108
108109 options = dict (options )
109110 options .update ({
@@ -893,7 +894,7 @@ def init_buffers(descriptors, options):
893894 lhs = b .indexify ()._subs (v .xd , v .first_idx .b )
894895 rhs = f .indexify ()._subs (v .dim , v .first_idx .f )
895896
896- elif v .is_write and init_onwrite (f ):
897+ elif v .is_write and init_onwrite (f , b ):
897898 lhs = b .indexify ()
898899 rhs = S .Zero
899900
0 commit comments