Skip to content

Parallel argmax fails with unsupported operand types error

This is desirable as a prelude to segmented scan support.

>>> import loopy as lp
>>> n = 10
>>> knl = lp.make_kernel(
...             "{[i]: 0<=i<%d}" % n,
...             """
...             max_val, max_indices = argmax(i, fabs(a[i]))
...             """)
>>> knl = lp.tag_inames(knl, dict(i="l.0"))
>>> lp.realize_reduction(knl)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/matt/src/loopy/loopy/preprocess.py", line 647, in realize_reduction
    new_expressions = cb_mapper(insn.expression, nresults=nresults)
  File "/home/matt/src/pymbolic/pymbolic/mapper/__init__.py", line 134, in __call__
    return method(expr, *args, **kwargs)
  File "/home/matt/src/loopy/loopy/symbolic.py", line 1352, in map_reduction
    result = self.callback(expr, self.rec, **kwargs)
  File "/home/matt/src/loopy/loopy/preprocess.py", line 607, in map_reduction
    reduction_dtypes)
  File "/home/matt/src/loopy/loopy/preprocess.py", line 456, in map_reduction_local
    arg_dtype, neutral, expr.expr, expr.inames),
  File "/home/matt/src/loopy/loopy/library/reduction.py", line 206, in __call__
    *(operand1 + (operand2, var(iname))))
TypeError: unsupported operand type(s) for +: 'Call' and 'tuple'