Skip to content

Parsing / pymbolic issue

On latest master (1e2467d6)

import loopy as lp
knl = lp.make_kernel('{[i]: 0 <= i < 1}', 'a[i] = b[i] & 1', ['...'], lang_version=(2018, 2))

yields:

>>> print(knl)
---------------------------------------------------------------------------
KERNEL: loopy_kernel
---------------------------------------------------------------------------
ARGUMENTS:
a: GlobalArg, type: <auto/runtime>, shape: (1), dim_tags: (N0:stride:1)
b: GlobalArg, type: <auto/runtime>, shape: (1), dim_tags: (N0:stride:1)
---------------------------------------------------------------------------
DOMAINS:
{ [i] : i = 0 }
---------------------------------------------------------------------------
INAME IMPLEMENTATION TAGS:
i: None
---------------------------------------------------------------------------
INSTRUCTIONS:
for i
  a[i] = b[i] ^ 1  {id=insn}
end i
---------------------------------------------------------------------------

Seems like it could be within the pymbolic parser? But a quick test:

from pymbolic import parse
parse('a[i] + b[i] & 1')

yields:

BitwiseAnd((Sum((Subscript(Variable('a'), Variable('i')), Subscript(Variable('b'), Variable('i')))), 1))

Using pymbolic==2017.1