inducer / loopy

A code generator for array-based code on CPUs and GPUs
http://mathema.tician.de/software/loopy
MIT License
565 stars 71 forks source link

[Bug] Callables inside substitutions are not type-specialized #746

Closed kaushikcfd closed 1 year ago

kaushikcfd commented 1 year ago

The following snippet:

import loopy as lp

knl = lp.make_kernel(
    "{[i]: 0<=i<10}",
    """
    subst_0(_0) := abs(10.0 * (_0-5))

    y[i] = subst_0(i)
    """)

print(lp.generate_code_v2(knl).device_code())

fails with:

File "/home/line/projects/ceesd/loopy/loopy/translation_unit.py", line 623, in finish_program
  old_func_id = history[new_id]
KeyError: 'abs'

This happens due to buggy implementation of loopy.type_inference.FunctionNameChanger.map_call.