Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mlir][tosa]Tosa to Linalg indexingmap bug fix #58154

Open
AmosLewis opened this issue Oct 4, 2022 · 1 comment
Open

[mlir][tosa]Tosa to Linalg indexingmap bug fix #58154

AmosLewis opened this issue Oct 4, 2022 · 1 comment

Comments

@AmosLewis
Copy link

AmosLewis commented Oct 4, 2022

main...AmosLewis:llvm-project:tosa-to-linalg

I meet this bug when I tried to add aten.where.self ops to tosa in torch-mlir project. I write a wip patch to fix this.


> (mlir_venv) nod% python -m e2e_testing.main -f 'ElementwiseAtenWhereSelf' --config=tosa -v 
> Compiling ElementwiseAtenWhereSelfModule_basic...
> FAIL - "ElementwiseAtenWhereSelfModule_basic"
> 
> Unexpected outcome summary:
> 
> ****** Failed tests - 1 tests
>     FAIL - "ElementwiseAtenWhereSelfModule_basic"
>         Compilation error: Traceback (most recent call last):
>           File "/home/chi/src/ubuntu20/shark/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir_e2e_test/framework.py", line 290, in compile_and_run_test
>             compiled = config.compile(test.program_factory())
>           File "/home/chi/src/ubuntu20/shark/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir_e2e_test/configs/tosa_backend.py", line 35, in compile
>             return self.backend.compile(module)
>           File "/home/chi/src/ubuntu20/shark/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir_e2e_test/tosa_backends/linalg_on_tensors.py", line 57, in compile
>             run_pipeline_with_repro_report(
>           File "/home/chi/src/ubuntu20/shark/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/compiler_utils.py", line 73, in run_pipeline_with_repro_report
>             raise TorchMlirCompilerError(trimmed_message) from None
>         torch_mlir.compiler_utils.TorchMlirCompilerError: Lowering TOSA to Linalg-on-Tensors failed with the following diagnostics:
>         error: 'linalg.generic' op expected indexing_map #2 to have 4 dim(s) to match the number of loops
>         note: see current operation: 
>         %2 = "linalg.generic"(%1, %arg1, %arg2, %0) ({
>         ^bb0(%arg3: i1, %arg4: f32, %arg5: f32, %arg6: f32):
>         %3 = "arith.select"(%arg3, %arg4, %arg5) : (i1, f32, f32) -> f32
>         "linalg.yield"(%3) : (f32) -> ()
>         }) {indexing_maps = [affine_map<(d0, d1, d2, d3) -> (d0, d2, d3)>, affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>, affine_map<() -> ()>, affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>], iterator_types = ["parallel", "parallel", "parallel", "parallel"], operand_segment_sizes = array<i32: 3, 1>} : (tensor<1x5x5xi1>, tensor<1x12x5x5xf32>, tensor<f32>, tensor<1x12x5x5xf32>) -> tensor<1x12x5x5xf32>
@AmosLewis
Copy link
Author

@rsuderman here is my commit for review https://reviews.llvm.org/D135343

@AmosLewis AmosLewis changed the title Tosa to Linalg indexingmap bug fix [mlir][tosa]Tosa to Linalg indexingmap bug fix Oct 6, 2022
AmosLewis pushed a commit to AmosLewis/llvm-project that referenced this issue Oct 6, 2022
The tosa to linalg generic ops indexingMaps rank use is wrong.
	 Find this bug in gpt2 pytorch model lowering to tosa.
	 issue link is here llvm#58154

Differential Revision: https://reviews.llvm.org/D135343
jpienaar pushed a commit that referenced this issue Oct 10, 2022
The tosa to linalg generic ops indexingMaps rank use is wrong.
	 Find this bug in gpt2 pytorch model lowering to tosa.
	 issue link is here #58154

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D135343
veselypeta pushed a commit to veselypeta/cherillvm that referenced this issue May 27, 2024
The tosa to linalg generic ops indexingMaps rank use is wrong.
	 Find this bug in gpt2 pytorch model lowering to tosa.
	 issue link is here llvm/llvm-project#58154

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D135343
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants