spcl/pymlir

Pip install installs pymlir==0.4 which seems broken, whereas in repo setup.py works with pymlir==0.3

ed-baker opened this issue · 4 comments

Hi, just tried pip install pymlir and running the examples from this repo, specifically

import mlir
ast3 = mlir.parse_string('''
module {
  func.func @toy_func(%tensor: tensor<2x3xf64>) -> tensor<3x2xf64> {
    %t_tensor = "toy.transpose"(%tensor) { inplace = true } : (tensor<2x3xf64>) -> tensor<3x2xf64>
    return %t_tensor : tensor<3x2xf64>
  }
}
''')
print(ast3)

It throws this lovely stacktrace:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ed/.pyenv/versions/pymlir/lib/python3.11/site-packages/mlir/parser.py", line 133, in parse_string
    return parser.parse(code)
           ^^^^^^^^^^^^^^^^^^
  File "/Users/ed/.pyenv/versions/pymlir/lib/python3.11/site-packages/mlir/parser.py", line 93, in parse
    tree = self.parser.parse(code)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ed/.pyenv/versions/pymlir/lib/python3.11/site-packages/lark/lark.py", line 311, in parse
    return self.parser.parse(text, start=start)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ed/.pyenv/versions/pymlir/lib/python3.11/site-packages/lark/parser_frontends.py", line 185, in parse
    return self._parse(text, start)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ed/.pyenv/versions/pymlir/lib/python3.11/site-packages/lark/parser_frontends.py", line 54, in _parse
    return self.parser.parse(input, start, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ed/.pyenv/versions/pymlir/lib/python3.11/site-packages/lark/parsers/earley.py", line 292, in parse
    to_scan = self._parse(stream, columns, to_scan, start_symbol)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ed/.pyenv/versions/pymlir/lib/python3.11/site-packages/lark/parsers/xearley.py", line 137, in _parse
    to_scan = scan(i, to_scan)
              ^^^^^^^^^^^^^^^^
  File "/Users/ed/.pyenv/versions/pymlir/lib/python3.11/site-packages/lark/parsers/xearley.py", line 114, in scan
    raise UnexpectedCharacters(stream, i, text_line, text_column, {item.expect.name for item in to_scan}, set(to_scan))
lark.exceptions.UnexpectedCharacters: No terminal defined for '@' at line 3 col 13

  func.func @toy_func(%tensor: tensor<2x3xf64>) -> t
            ^

Expecting: {'DOT', '__ANON_10', '__ANON_9', 'ESCAPED_STRING', '__ANON_4', 'PERCENT', 'TRUE', '__ANON_1', '__ANON_8', '__ANON_7', 'FALSE', '__ANON_0', 'COLON'}

However cloning the repo and running it in the repo/doing a pip install . works as expected. Just wanted to flag this.

Thanks for the work!

Thank you, I'll release a new version and hopefully this would solve it.

I think this has to do with the fact that the README on the github page was updated after the changes to MLIR (func -> func.func). If you had used the example from the README of pymlir 0.4, it would work.

@ed-baker pymlir v0.5 was now released on PyPI. Please try it out and let me know if it works.

@ed-baker I will close the issue as resolved now. I am happy to reopen it if you comment that we should.