Skip to content

Commit

Permalink
Merge pull request #2487 from devitocodes/patch-is-transient-vecttypes
Browse files Browse the repository at this point in the history
compiler: Expose Bundle's properties correctly
  • Loading branch information
mloubout authored Nov 15, 2024
2 parents e0e69d4 + 2042d86 commit f7a9e94
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 5 additions & 2 deletions devito/types/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ def __args_setup__(cls, *args, **kwargs):
raise ValueError("Component type must be subclass of AbstractFunction")
if len({i.__padding_dtype__ for i in components}) != 1:
raise ValueError("Components must have the same padding dtype")
if len({i.properties for i in components}) != 1:
raise ValueError("Components must have the same properties")

return args, kwargs

Expand Down Expand Up @@ -441,12 +443,13 @@ def initvalue(self):

# Overrides defaulting to self.c0's behaviour

for i in ['_mem_internal_eager', '_mem_internal_lazy', '_mem_local',
for i in ('_mem_internal_eager', '_mem_internal_lazy', '_mem_local',
'_mem_mapped', '_mem_host', '_mem_stack', '_mem_constant',
'_mem_shared', '__padding_dtype__', '_size_domain', '_size_halo',
'_size_owned', '_size_padding', '_size_nopad', '_size_nodomain',
'_offset_domain', '_offset_halo', '_offset_owned', '_dist_dimensions',
'_C_get_field', 'grid', 'symbolic_shape']:
'_C_get_field', 'grid', 'symbolic_shape',
*AbstractFunction.__properties__):
locals()[i] = property(lambda self, v=i: getattr(self.c0, v))

@property
Expand Down
8 changes: 6 additions & 2 deletions devito/types/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,8 @@ class AbstractFunction(sympy.Function, Basic, Pickable, Evaluable):
__rkwargs__ = ('name', 'dtype', 'grid', 'halo', 'padding', 'ghost',
'alias', 'space', 'function', 'is_transient', 'avg_mode')

__properties__ = ('is_const', 'is_transient')

def __new__(cls, *args, **kwargs):
# Preprocess arguments
args, kwargs = cls.__args_setup__(*args, **kwargs)
Expand Down Expand Up @@ -970,8 +972,6 @@ def __init_finalize__(self, *args, **kwargs):
# A `Distributor` to handle domain decomposition
self._distributor = self.__distributor_setup__(**kwargs)

# Symbol properties

# "Aliasing" another AbstractFunction means that `self` logically
# represents another object. For example, `self` might be used as the
# formal parameter of a routine generated by the compiler, where the
Expand Down Expand Up @@ -1274,6 +1274,10 @@ def is_const(self):
def is_transient(self):
return self._is_transient

@cached_property
def properties(self):
return frozendict([(i, getattr(self, i)) for i in self.__properties__])

@property
def avg_mode(self):
return self._avg_mode
Expand Down

0 comments on commit f7a9e94

Please sign in to comment.