diff --git a/loopy/kernel/creation.py b/loopy/kernel/creation.py index 6fe42dfffa97d14f36c40ccac66caf6a58d20261..ab2b2eeb964af26744a241d738d9725056cf5aab 100644 --- a/loopy/kernel/creation.py +++ b/loopy/kernel/creation.py @@ -774,12 +774,18 @@ def guess_arg_shape_if_requested(kernel, default_order): if isinstance(arg, ArrayBase) and arg.shape is lp.auto: armap = AccessRangeMapper(kernel, arg.name) - for insn in kernel.instructions: - if isinstance(insn, lp.ExpressionInstruction): - armap(submap(insn.assignee, insn.id), - kernel.insn_inames(insn)) - armap(submap(insn.expression, insn.id), - kernel.insn_inames(insn)) + try: + for insn in kernel.instructions: + if isinstance(insn, lp.ExpressionInstruction): + armap(submap(insn.assignee, insn.id), + kernel.insn_inames(insn)) + armap(submap(insn.expression, insn.id), + kernel.insn_inames(insn)) + except TypeError, e: + from loopy.diagnostic import LoopyError + raise LoopyError( + "failed to find access range for argument '%s': %s" + % (arg.name, str(e))) if armap.access_range is None: # no subscripts found, let's call it a scalar