@@ -114,6 +114,17 @@ def __init_finalize__(self, *args, function=None, **kwargs):
114114
115115 _subs = Differentiable ._subs
116116
117+ def _create_data (self ):
118+ if self ._data is None :
119+ debug (f"Allocating host memory for { self .name } { self .shape_allocated } "
120+ f"[{ humanbytes (self .nbytes )} ]" )
121+
122+ self ._data = self ._DataType (self .shape_allocated , self .dtype ,
123+ modulo = self ._mask_modulo ,
124+ allocator = self ._allocator ,
125+ distributor = self ._distributor ,
126+ padding = self ._size_ghost )
127+
117128 def _allocate_memory (func ):
118129 """Allocate memory as a Data."""
119130 @wraps (func )
@@ -123,18 +134,11 @@ def wrapper(self):
123134 # Aliasing Functions must not allocate data
124135 return
125136
126- debug (f"Allocating host memory for { self .name } { self .shape_allocated } "
127- f"[{ humanbytes (self .nbytes )} ]" )
128-
129137 # Clear up both SymPy and Devito caches to drop unreachable data
130138 CacheManager .clear (force = False )
131139
132140 # Allocate the actual data object
133- self ._data = self ._DataType (self .shape_allocated , self .dtype ,
134- modulo = self ._mask_modulo ,
135- allocator = self ._allocator ,
136- distributor = self ._distributor ,
137- padding = self ._size_ghost )
141+ self ._create_data ()
138142
139143 # Initialize data
140144 if self ._first_touch :
@@ -149,7 +153,7 @@ def wrapper(self):
149153 # Perhaps user only wants to initialise the physical domain
150154 self ._initializer (self .data )
151155 else :
152- self .data_with_halo . fill ( 0 )
156+ self .data_with_halo [:] = 0
153157
154158 return func (self )
155159 return wrapper
0 commit comments