inducer/loopy

lp.make_einsum fails parsing subscript expressions with spaces in them

kaushikcfd opened this issue · 0 comments

MWE:

import loopy as lp
knl = lp.make_einsum("ik, kj -> ij", ["A", "B"])

fails with

failed to parse domain '[N,Ni,Nj,Nk] -> {[ ,i,j,k]: 0 <= j < Nj and 0 <= k < Nk and 0 <=   < N  and 0 <= i < Ni}'
Traceback (most recent call last):
  File "/home/kgk2/temp/loopy_ensm_bug.py", line 4, in <module>
    knl = lp.make_einsum("ik, kj -> ij", ["A", "B"])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kgk2/projects/ceesd/loopy/loopy/__init__.py", line 600, in make_einsum
    return make_kernel("{[%s]: %s}" % (",".join(sorted(all_indices)), constraints),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kgk2/projects/ceesd/loopy/loopy/kernel/creation.py", line 2569, in make_kernel
    tunit = make_function(*args, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kgk2/projects/ceesd/loopy/loopy/kernel/creation.py", line 2410, in make_function
    domains = parse_domains(domains, defines)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kgk2/projects/ceesd/loopy/loopy/kernel/creation.py", line 1074, in parse_domains
    dom = isl.BasicSet.read_from_str(isl.DEFAULT_CONTEXT, dom)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
islpy._isl.Error: call to isl_basic_set_read_from_str failed: syntax error in isl_stream.c:140