diff --git a/devito/ir/equations/algorithms.py b/devito/ir/equations/algorithms.py index 175311d22e..8913f81dde 100644 --- a/devito/ir/equations/algorithms.py +++ b/devito/ir/equations/algorithms.py @@ -8,7 +8,7 @@ ConditionalDimension) from devito.types.array import Array from devito.types.basic import AbstractFunction -from devito.types.dimension import MultiSubDimension, SubDimensionThickness +from devito.types.dimension import MultiSubDimension, Thickness from devito.data.allocators import DataReference from devito.logger import warning @@ -213,7 +213,7 @@ def _(expr, mapper, rebuilt, sregistry): _concretize_subdims(expr.implicit_dims, mapper, rebuilt, sregistry) -@_concretize_subdims.register(SubDimensionThickness) +@_concretize_subdims.register(Thickness) def _(tkn, mapper, rebuilt, sregistry): if tkn in mapper: # Already have a substitution for this thickness diff --git a/devito/operator/operator.py b/devito/operator/operator.py index 0a7e0dc7da..9bfdcdc255 100644 --- a/devito/operator/operator.py +++ b/devito/operator/operator.py @@ -31,7 +31,7 @@ split, timed_pass, timed_region, contains_val) from devito.types import (Buffer, Grid, Evaluable, host_layer, device_layer, disk_layer) -from devito.types.dimension import SubDimensionThickness +from devito.types.dimension import Thickness __all__ = ['Operator'] @@ -642,9 +642,9 @@ def _prepare_arguments(self, autotune=None, **kwargs): for d in reversed(toposort): args.update(d._arg_values(self._dspace[d], grid, **kwargs)) - # Process SubDimensionThicknesses + # Process Thicknesses for p in self.parameters: - if isinstance(p, SubDimensionThickness): + if isinstance(p, Thickness): args.update(p._arg_values(grid=grid, **kwargs)) # Process Objects diff --git a/devito/types/dimension.py b/devito/types/dimension.py index d3e531594a..6f7ae89c67 100644 --- a/devito/types/dimension.py +++ b/devito/types/dimension.py @@ -22,7 +22,7 @@ 'VirtualDimension', 'Spacing', 'dimensions'] -Thickness = namedtuple('Thickness', 'left right') +SubDimensionThickness = namedtuple('SubDimensionThickness', 'left right') class Dimension(ArgProvider): @@ -535,16 +535,12 @@ def _arg_check(self, *args, **kwargs): # The Dimensions below are exposed in the user API. They can only be created by # the user -class SubDimensionThickness(DataSymbol): +class Thickness(DataSymbol): """A DataSymbol to represent a thickness of a SubDimension""" __rkwargs__ = DataSymbol.__rkwargs__ + ('root', 'side', 'local', 'value') - def __new__(cls, *args, **kwargs): - root = kwargs.pop('root') - side = kwargs.pop('side') - local = kwargs.pop('local') - + def __new__(cls, *args, root=None, side=None, local=False, **kwargs): newobj = super().__new__(cls, *args, **kwargs) newobj._root = root newobj._side = side @@ -633,7 +629,7 @@ def __init_finalize__(self, name, parent, thickness, **kwargs): super().__init_finalize__(name, parent) thickness = thickness or (None, None) if any(isinstance(tkn, self._thickness_type) for tkn in thickness): - self._thickness = Thickness(*thickness) + self._thickness = SubDimensionThickness(*thickness) else: self._thickness = self._symbolic_thickness(thickness=thickness) @@ -648,7 +644,7 @@ def _symbolic_thickness(self, **kwargs): kwargs = {'dtype': np.int32, 'is_const': True, 'nonnegative': True} names = ["%s_%stkn" % (self.parent.name, s) for s in ('l', 'r')] - return Thickness(*[Symbol(name=n, **kwargs) for n in names]) + return SubDimensionThickness(*[Symbol(name=n, **kwargs) for n in names]) @cached_property def symbolic_min(self): @@ -735,7 +731,7 @@ class SubDimension(AbstractSubDimension): __rargs__ = AbstractSubDimension.__rargs__ + ('local',) - _thickness_type = SubDimensionThickness + _thickness_type = Thickness def __init_finalize__(self, name, parent, thickness, local, **kwargs): @@ -756,12 +752,13 @@ def middle(cls, name, parent, thickness_left, thickness_right, local=False): @memoized_meth def _symbolic_thickness(self, thickness=None): - kwargs = {'dtype': np.int64, 'is_const': True, 'nonnegative': True, + kwargs = {'dtype': np.int32, 'is_const': True, 'nonnegative': True, 'root': self.root, 'local': self.local} names = ["%s_%stkn" % (self.parent.name, s) for s in ('l', 'r')] - return Thickness(*[SubDimensionThickness(name=n, side=s, value=t, **kwargs) - for n, s, t in zip(names, (LEFT, RIGHT), thickness)]) + return SubDimensionThickness(*[Thickness(name=n, side=s, value=t, **kwargs) + for n, s, t + in zip(names, (LEFT, RIGHT), thickness)]) @cached_property def _interval(self):