diff --git a/doc/tutorial.rst b/doc/tutorial.rst index dad7c1714ebb781989d8b0217d89782fb6bfbabf..a791bc8542c6f49874c9eb356c85cafe8c0c896c 100644 --- a/doc/tutorial.rst +++ b/doc/tutorial.rst @@ -1681,7 +1681,7 @@ Each line of output will look roughly like:: data type accessed. - lid_strides: A :class:`dict` of **{** :class:`int` **:** - :attr:`~pymbolic.typing.Expression` or :class:`int` **}** that specifies + :data:`~pymbolic.typing.Expression` or :class:`int` **}** that specifies local strides for each local id in the memory access index. Local ids not found will not be present in ``lid_strides.keys()``. Uniform access (i.e. work-items within a sub-group access the same item) is indicated by setting @@ -1689,7 +1689,7 @@ Each line of output will look roughly like:: which case the 0 key will not be present in lid_strides. - gid_strides: A :class:`dict` of **{** :class:`int` **:** - :attr:`~pymbolic.typing.Expression` or :class:`int` **}** that specifies + :data:`~pymbolic.typing.Expression` or :class:`int` **}** that specifies global strides for each global id in the memory access index. Global ids not found will not be present in ``gid_strides.keys()``. diff --git a/loopy/check.py b/loopy/check.py index f355e99c6bb0bf1c028ce3baf0584d824a166f41..5e4897235075079a7ff602c4eef6c72be36e9350 100644 --- a/loopy/check.py +++ b/loopy/check.py @@ -213,7 +213,8 @@ def check_separated_array_consistency(kernel: LoopKernel) -> None: @check_each_kernel def check_offsets_and_dim_tags(kernel: LoopKernel) -> None: - from pymbolic.primitives import Expression, Variable + from pymbolic.primitives import ExpressionNode, Variable + from pymbolic.typing import Expression from loopy.symbolic import DependencyMapper @@ -241,7 +242,7 @@ def check_offsets_and_dim_tags(kernel: LoopKernel) -> None: continue if arg.offset is auto: pass - elif isinstance(arg.offset, (int, np.integer, Expression, str)): + elif isinstance(arg.offset, (int, np.integer, ExpressionNode, str)): ensure_depends_only_on_arguments(what, arg.offset) else: @@ -259,7 +260,7 @@ def check_offsets_and_dim_tags(kernel: LoopKernel) -> None: if dim_tag.stride is auto: pass elif isinstance( - dim_tag.stride, (int, np.integer, Expression)): + dim_tag.stride, (int, np.integer, ExpressionNode)): ensure_depends_only_on_arguments(what, dim_tag.stride) else: raise LoopyError(f"invalid value of {what}") @@ -281,7 +282,7 @@ def check_offsets_and_dim_tags(kernel: LoopKernel) -> None: pass if tv.offset is auto: pass - elif isinstance(tv.offset, (int, np.integer, Expression, str)): + elif isinstance(tv.offset, (int, np.integer, ExpressionNode, str)): ensure_depends_only_on_arguments(what, tv.offset) else: raise LoopyError(f"invalid value of offset for '{tv.name}'") @@ -294,7 +295,7 @@ def check_offsets_and_dim_tags(kernel: LoopKernel) -> None: if dim_tag.stride is auto: raise LoopyError(f"The {what}" f" is 'auto', " "which is not allowed.") - elif isinstance(dim_tag.stride, (int, np.integer, Expression)): + elif isinstance(dim_tag.stride, (int, np.integer, ExpressionNode)): ensure_depends_only_on_arguments(what, dim_tag.stride) else: raise LoopyError(f"invalid value of {what}") diff --git a/loopy/kernel/array.py b/loopy/kernel/array.py index 64a9b857749f4adcefb8dee408490790a2da84fc..fa5ae6b192c1ea130cbdf40380312a36c4ae36a8 100644 --- a/loopy/kernel/array.py +++ b/loopy/kernel/array.py @@ -146,7 +146,7 @@ class FixedStrideArrayDimTag(_StrideArrayDimTagBase): May be one of the following: - - A :attr:`~pymbolic.typing.Expression`, including an + - A :data:`~pymbolic.typing.Expression`, including an integer, indicating the stride in units of the underlying array's :attr:`ArrayBase.dtype`. diff --git a/loopy/kernel/data.py b/loopy/kernel/data.py index 8ca5aa87a8ba276f54370acd86ee03191c212b86..9761a2946c1fbe2d793aec75d2d7be69ade59eed 100644 --- a/loopy/kernel/data.py +++ b/loopy/kernel/data.py @@ -109,10 +109,10 @@ def _names_from_expr(expr: Union[None, Expression, str]) -> FrozenSet[str]: from loopy.symbolic import DependencyMapper dep_mapper = DependencyMapper() - from pymbolic.primitives import Expression + from pymbolic.primitives import ExpressionNode if isinstance(expr, str): return frozenset({expr}) - elif isinstance(expr, Expression): + elif isinstance(expr, ExpressionNode): return frozenset(cast(Variable, v).name for v in dep_mapper(expr)) elif expr is None: return frozenset() diff --git a/loopy/kernel/instruction.py b/loopy/kernel/instruction.py index 32cf664b2086a41718096c698ff3f8006cdbcd3d..d6517adc4a85f40fbf73fdf1448282032842e28f 100644 --- a/loopy/kernel/instruction.py +++ b/loopy/kernel/instruction.py @@ -1372,7 +1372,7 @@ class CInstruction(InstructionBase): .. attribute:: assignees A sequence (typically a :class:`tuple`) of variable references (with or - without subscript) as :attr:`pymbolic.typing.Expression` instances + without subscript) as :data:`pymbolic.typing.Expression` instances that :attr:`code` writes to. This is optional and only used for figuring out dependencies. """ diff --git a/loopy/preprocess.py b/loopy/preprocess.py index 4dc824ead32d1158fa6f2101fd3578e28ab9dfd3..7eeae715d129bb6f348cceb7db95daf38789d53d 100644 --- a/loopy/preprocess.py +++ b/loopy/preprocess.py @@ -224,7 +224,7 @@ def make_args_for_offsets_and_strides(kernel: LoopKernel) -> LoopKernel: vng = kernel.get_var_name_generator() - from pymbolic.primitives import Expression, Variable + from pymbolic.primitives import ExpressionNode, Variable from loopy.kernel.array import FixedStrideArrayDimTag @@ -241,7 +241,7 @@ def make_args_for_offsets_and_strides(kernel: LoopKernel) -> LoopKernel: additional_args.append(ValueArg( offset_name, kernel.index_dtype)) arg = arg.copy(offset=offset_name) - elif isinstance(arg.offset, (int, np.integer, Expression, str)): + elif isinstance(arg.offset, (int, np.integer, ExpressionNode, str)): pass else: raise LoopyError(f"invalid value of {what}") @@ -261,7 +261,7 @@ def make_args_for_offsets_and_strides(kernel: LoopKernel) -> LoopKernel: additional_args.append(ValueArg( stride_name, kernel.index_dtype)) elif isinstance( - dim_tag.stride, (int, np.integer, Expression)): + dim_tag.stride, (int, np.integer, ExpressionNode)): pass else: raise LoopyError(f"invalid value of {what}") @@ -286,7 +286,7 @@ def make_args_for_offsets_and_strides(kernel: LoopKernel) -> LoopKernel: def zero_offsets_and_strides(kernel: LoopKernel) -> LoopKernel: made_changes = False - from pymbolic.primitives import Expression + from pymbolic.primitives import ExpressionNode # {{{ process arguments @@ -298,7 +298,7 @@ def zero_offsets_and_strides(kernel: LoopKernel) -> LoopKernel: if arg.offset is auto: made_changes = True arg = arg.copy(offset=0) - elif isinstance(arg.offset, (int, np.integer, Expression, str)): + elif isinstance(arg.offset, (int, np.integer, ExpressionNode, str)): from pymbolic.primitives import is_zero if not is_zero(arg.offset): raise LoopyError( diff --git a/loopy/statistics.py b/loopy/statistics.py index 94f8205802a313cb521a47a219c01a63e6500079..fd697bc47fcebcafd107a4756471bbfd4c4ed393 100755 --- a/loopy/statistics.py +++ b/loopy/statistics.py @@ -681,7 +681,7 @@ class MemAccess(ImmutableRecord): .. attribute:: lid_strides A :class:`dict` of **{** :class:`int` **:** - :attr:`~pymbolic.typing.Expression` or :class:`int` **}** that + :data:`~pymbolic.typing.Expression` or :class:`int` **}** that specifies local strides for each local id in the memory access index. Local ids not found will not be present in ``lid_strides.keys()``. Uniform access (i.e. work-items within a sub-group access the same @@ -692,7 +692,7 @@ class MemAccess(ImmutableRecord): .. attribute:: gid_strides A :class:`dict` of **{** :class:`int` **:** - :attr:`~pymbolic.typing.Expression` or :class:`int` **}** that + :data:`~pymbolic.typing.Expression` or :class:`int` **}** that specifies global strides for each global id in the memory access index. global ids not found will not be present in ``gid_strides.keys()``. diff --git a/loopy/symbolic.py b/loopy/symbolic.py index 1ef933ad676f61c746a7ec4265cbcecedfb03ea8..d30581db88d209a7430f71d13a13e3d5c939f816 100644 --- a/loopy/symbolic.py +++ b/loopy/symbolic.py @@ -127,7 +127,7 @@ References .. class:: Expression - See :attr:`pymbolic.typing.Expression`. + See :data:`pymbolic.typing.Expression`. .. class:: _Expression @@ -712,7 +712,7 @@ class Reduction(LoopyExpressionBase): """An expression which may have tuple type. If the expression has tuple type, it must be one of the following: - * a :class:`tuple` of :attr:`pymbolic.typing.Expression`, or + * a :class:`tuple` of :data:`pymbolic.typing.Expression`, or * a :class:`loopy.symbolic.Reduction`, or * a function call or substitution rule invocation. """ @@ -1993,7 +1993,7 @@ def simplify_using_aff(kernel, expr): """ Simplifies *expr* on *kernel*'s domain. - :arg expr: An instance of :attr:`pymbolic.typing.Expression`. + :arg expr: An instance of :data:`pymbolic.typing.Expression`. """ deps = get_dependencies(expr) @@ -2707,7 +2707,7 @@ def is_expression_equal(a, b): if a == b: return True - if isinstance(a, p.Expression) or isinstance(b, p.Expression): + if isinstance(a, p.ExpressionNode) or isinstance(b, p.ExpressionNode): if a is None or b is None: return False diff --git a/loopy/transform/data.py b/loopy/transform/data.py index 739717860d102f05e712ac69aa3dd44e3a9d9dc5..2e19eea75675ef70037211d10daa42cdf6ae717a 100644 --- a/loopy/transform/data.py +++ b/loopy/transform/data.py @@ -229,10 +229,10 @@ def add_prefetch_for_single_kernel(kernel, callables_table, var_name, from pymbolic import var uni_template = parsed_var_name if len(parameters) > 1: - uni_template = uni_template.index( - tuple(var(par_name) for par_name in parameters)) + uni_template = uni_template[ + tuple(var(par_name) for par_name in parameters)] elif len(parameters) == 1: - uni_template = uni_template.index(var(parameters[0])) + uni_template = uni_template[var(parameters[0])] # }}} diff --git a/loopy/transform/pack_and_unpack_args.py b/loopy/transform/pack_and_unpack_args.py index 2a82952c25293b8c174f1114c349f8b233d39a01..ae5339b5680bf4a16d29fa98ff99b9e67b22ed0d 100644 --- a/loopy/transform/pack_and_unpack_args.py +++ b/loopy/transform/pack_and_unpack_args.py @@ -222,9 +222,9 @@ def pack_and_unpack_args_for_call_for_single_kernel(kernel, new_indices = tuple(simplify_via_aff(i) for i in new_indices) pack_lhs_assignee = pack_subst_mapper( - var(pack_name).index(new_indices)) + var(pack_name)[new_indices]) unpack_rhs = unpack_subst_mapper( - var(pack_name).index(new_indices)) + var(pack_name)[new_indices]) # }}} @@ -272,7 +272,7 @@ def pack_and_unpack_args_for_call_for_single_kernel(kernel, new_id_to_parameters[arg_id] = SubArrayRef( tuple(updated_swept_inames), - (var(pack_name).index(tuple(updated_swept_inames)))) + (var(pack_name)[tuple(updated_swept_inames)])) else: new_id_to_parameters[arg_id] = p diff --git a/loopy/transform/precompute.py b/loopy/transform/precompute.py index 0982c43fdfee301eaf35f48483df738e881734d8..147b626523a334b8ebad2d049388ad6c54565364 100644 --- a/loopy/transform/precompute.py +++ b/loopy/transform/precompute.py @@ -101,9 +101,9 @@ def _get_called_names(insn): assert isinstance(insn, MultiAssignmentBase) from functools import reduce - from pymbolic.primitives import Expression + from pymbolic.primitives import ExpressionNode return ((_get_calls_in_expr(insn.expression) - if isinstance(insn.expression, Expression) + if isinstance(insn.expression, ExpressionNode) else frozenset()) # indices of assignees might call the subst rules | reduce(frozenset.union, @@ -113,7 +113,7 @@ def _get_called_names(insn): | reduce(frozenset.union, (_get_calls_in_expr(pred) for pred in insn.predicates - if isinstance(pred, Expression)), + if isinstance(pred, ExpressionNode)), frozenset()) ) @@ -922,8 +922,8 @@ def precompute_for_single_kernel( # should. if _enable_mirgecom_workaround: - from pymbolic.primitives import Expression - if is_length_1 and not isinstance(base_index, Expression): + from pymbolic.primitives import ExpressionNode + if is_length_1 and not isinstance(base_index, ExpressionNode): # I.e. base_index is an integer. from pytools import is_single_valued if is_single_valued(