llvm / torch-mlir

The Torch-MLIR project aims to provide first class support from the PyTorch ecosystem to the MLIR ecosystem.
Other
1.23k stars 449 forks source link

Issues with aten::arange.start_out abstract interpretation functions #1741

Open xgupta opened 1 year ago

xgupta commented 1 year ago

Hi,

While adding abstract interpretation function for arange.start_out, I am facing an python error-

$ ./build_tools/update_abstract_interp_lib.sh

Traceback (most recent call last):
  File "/home/mcw/anaconda3/lib/python3.9/runpy.py", line 188, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/home/mcw/anaconda3/lib/python3.9/runpy.py", line 158, in _get_module_details
    code = loader.get_code(mod_name)
  File "<frozen importlib._bootstrap_external>", line 983, in get_code
  File "<frozen importlib._bootstrap_external>", line 913, in source_to_code
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/mcw/shivam/llvm/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/dialects/torch/importer/jit_ir/build_tools/abstract_interp_lib_gen.py", line 625
    def aten〇arange〇start_out〡shape(start: float, end: float, step: float = 1, out: List[int]) -> List[int]:
                                                                                                   ^
SyntaxError: non-default argument follows default argument

Does someone know how to resolve this error since this definition is autogenerated with build_tools/update_torch_ods.sh.

Thanks

ramiro050 commented 1 year ago

Ops that take an out argument should not need a shape function, since the ops should be eventually replaced with the non-mutating version before reaching the backend contract. This is what is currently done with underscore ops, for example. We would need to add similar handling for out ops. See:

https://github.com/llvm/torch-mlir/blob/9dc09ac8c54dabadf703c37f7d3cf21486412d9e/lib/Dialect/Torch/Transforms/ReduceOpVariants.cpp#L196