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

PReLU op #1087

Closed
LucQueen opened this issue Jul 20, 2022 · 1 comment
Closed

PReLU op #1087

LucQueen opened this issue Jul 20, 2022 · 1 comment

Comments

@LucQueen
Copy link

LucQueen commented Jul 20, 2022

I added prelu op, and i run the code below, it is passed,

import torch
import torch_mlir
m = torch.nn.PReLU()
x = torch.randn([3,4,3])
res = m(x)
print(res.shape)
print("success")
module = torch_mlir.compile(m, x, output_type=torch_mlir.OutputType.LINALG_ON_TENSORS, use_tracing=True)

but i get error, when i run the other code

import torch

import torch_mlir

class PReLU(torch.nn.Module):
    def __init__(self):
        super().__init__()
    def forward(self, x, w):
        return torch.nn.functional.prelu(x, w)

m = PReLU()
x = torch.randn([3,4,3])
w = torch.randn([4])
res = m(x, w)
module = torch_mlir.compile(m, [x, w], output_type=torch_mlir.OutputType.LINALG_ON_TENSORS, use_tracing=True)
module = torch_mlir.compile(m, [x, w], output_type=torch_mlir.OutputType.LINALG_ON_TENSORS, use_tracing=True)
  File "/mnt/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/__init__.py", line 194, in compile
    run_pipeline_with_repro_report(
  File "/mnt/torch-mlir/build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/compiler_utils.py", line 49, in run_pipeline_with_repro_report
    raise Exception(f"""
Exception:
Lowering Torch Backend IR -> Linalg-on-Tensors Backend IR failed with the following diagnostics:
error: 'linalg.generic' op inferred input/output operand #1 has shape's dimension #0 to be 3, but found 4
note: see current operation: %13 = "linalg.generic"(%0, %1, %12) ({
^bb0(%arg2: f32, %arg3: f32, %arg4: f32):
  %16 = "arith.constant"() {value = 0.000000e+00 : f32} : () -> f32
  %17 = "arith.cmpf"(%arg2, %16) {predicate = 9 : i64} : (f32, f32) -> i1
  %18 = "arith.select"(%17, %arg2, %16) : (i1, f32, f32) -> f32
  %19 = "arith.select"(%17, %16, %arg2) : (i1, f32, f32) -> f32
  %20 = "arith.mulf"(%16, %19) : (f32, f32) -> f32
  %21 = "arith.addf"(%18, %20) : (f32, f32) -> f32
  "linalg.yield"(%21) : (f32) -> ()
}) {indexing_maps = [affine_map<(d0, d1, d2) -> (d0, d1, d2)>, affine_map<(d0, d1, d2) -> (d2)>, affine_map<(d0, d1, d2) -> (d0, d1, d2)>], iterator_types = ["parallel", "parallel", "parallel"], operand_segment_sizes = dense<[2, 1]> : vector<2xi32>} : (tensor<3x4x3xf32>, tensor<4xf32>, tensor<3x4x3xf32>) -> tensor<3x4x3xf32>


Error can be reproduced with:
$ torch-mlir-opt -pass-pipeline='torch-backend-to-linalg-on-tensors-backend-pipeline' /tmp/PReLU.mlir
Add '-mlir-print-ir-after-all -mlir-disable-threading' to get the IR dump for debugging purpose.

i am very confused,can someone help me?

@ramiro050
Copy link
Collaborator

Hi @LucQueen,

I just wanted to let you know that we have torch-MLIR office hours every Thursday where I can show you my approach for debugging issues like this one. If the time doesn't work you for you, I'm happy to help through github issues. I just wanted to make sure you were aware of that option! 😄

qedawkins pushed a commit to nod-ai/torch-mlir that referenced this issue Oct 3, 2022
Currently we ignore what targets llvm was built for in the lit tests, but recent changes to onnx-mlir explicitly initialize the available targets.
This makes the corresponding change to the lit configuration, so that we can filter out the lit tests based on the available targets.

Signed-off-by: Stella Stamenova <[email protected]>
qedawkins pushed a commit to nod-ai/torch-mlir that referenced this issue Oct 3, 2022
* Add check-onnx-backend to Mac CI. (llvm#1069)

* Add check-onnx-backend to Mac CI.

Signed-off-by: Ettore Tiotto <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* Additional Docker help and split README for easier reading (llvm#1084)

* initial docker documentation

Signed-off-by: Alexandre Eichenberger <[email protected]>

* split README with no redundant place for info

Signed-off-by: Alexandre Eichenberger <[email protected]>

* update

Signed-off-by: Alexandre Eichenberger <[email protected]>

* update

Signed-off-by: Alexandre Eichenberger <[email protected]>

* update

Signed-off-by: Alexandre Eichenberger <[email protected]>

* update

Signed-off-by: Alexandre Eichenberger <[email protected]>

* update

Signed-off-by: Alexandre Eichenberger <[email protected]>

* respond to suggestions

Signed-off-by: Alexandre Eichenberger <[email protected]>

* specify that onnx-mlir.py script generates only code suitable to be exec in Linux and/or Docker env

Signed-off-by: Alexandre Eichenberger <[email protected]>

* fix checkdocs

Signed-off-by: Alexandre Eichenberger <[email protected]>

* responded to review suggestion on onnx-mlir --help

Signed-off-by: Alexandre Eichenberger <[email protected]>

* use ONNX-MLIR everywhere

Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* add verify for concat

Signed-off-by: Ethan Wang <[email protected]>

* check all inputs

Signed-off-by: Ethan Wang <[email protected]>

* Support filtering out lit tests based on targets (llvm#1087)

Currently we ignore what targets llvm was built for in the lit tests, but recent changes to onnx-mlir explicitly initialize the available targets.
This makes the corresponding change to the lit configuration, so that we can filter out the lit tests based on the available targets.

Signed-off-by: Stella Stamenova <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* Switch URLs to use main instead of master (llvm#1094)

Signed-off-by: Charles Volzka <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* Fix MacOS build badge (llvm#1092)

Signed-off-by: Gong Su <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* onnx-mlir.py warning about binary output (.so and .jar) (llvm#1090)

not directly usable if host is not Linux

Signed-off-by: Gong Su <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* Make the doc example obey ONNX_MLIR_BUILD_TESTS (llvm#1083)

* Make the doc example obey ONNX_MLIR_BUILD_TESTS

Currently, ONNX_MLIR_BUILD_TESTS controls EXCLUDE_FROM_ALL, however, the targets added through add_executable will always build. We follow the llvm pattern and explicitly set EXCLUDE_FROM_ALL in the add_onnx_mlir_executable function if it is set for the directory, so that add_executable targets don't always build.

Signed-off-by: Stella Stamenova <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* Explicitly install into lib on all systems (llvm#1088)

Signed-off-by: Gong Su <[email protected]>

Co-authored-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* add check (llvm#1098)

Signed-off-by: Tong Chen <[email protected]>

Co-authored-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* fix typos and add ssh-client to dockerfile (llvm#1096)

* fix typos and add ssh-client to dockerfile

Signed-off-by: Ethan Wang <[email protected]>

* sync doc and script

Signed-off-by: Ethan Wang <[email protected]>

Co-authored-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* Emit print statement only when the verbose option is in effect. (llvm#1097)

Signed-off-by: Ettore Tiotto <[email protected]>

Co-authored-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* format & refine code by request

Signed-off-by: Ethan Wang <[email protected]>

* Support older versions 6, 11, 12 for Clip Op (llvm#1100)

Signed-off-by: Tung D. Le <[email protected]>

Co-authored-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* using front to get first input

Signed-off-by: Ethan Wang <[email protected]>

* add 3 lit test for concat  verifier

Signed-off-by: Ethan Wang <[email protected]>

* add newline

Signed-off-by: Ethan Wang <[email protected]>

* Add check-onnx-backend to Mac CI. (llvm#1069)

* Add check-onnx-backend to Mac CI.

Signed-off-by: Ettore Tiotto <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* Additional Docker help and split README for easier reading (llvm#1084)

* initial docker documentation

Signed-off-by: Alexandre Eichenberger <[email protected]>

* split README with no redundant place for info

Signed-off-by: Alexandre Eichenberger <[email protected]>

* update

Signed-off-by: Alexandre Eichenberger <[email protected]>

* update

Signed-off-by: Alexandre Eichenberger <[email protected]>

* update

Signed-off-by: Alexandre Eichenberger <[email protected]>

* update

Signed-off-by: Alexandre Eichenberger <[email protected]>

* update

Signed-off-by: Alexandre Eichenberger <[email protected]>

* respond to suggestions

Signed-off-by: Alexandre Eichenberger <[email protected]>

* specify that onnx-mlir.py script generates only code suitable to be exec in Linux and/or Docker env

Signed-off-by: Alexandre Eichenberger <[email protected]>

* fix checkdocs

Signed-off-by: Alexandre Eichenberger <[email protected]>

* responded to review suggestion on onnx-mlir --help

Signed-off-by: Alexandre Eichenberger <[email protected]>

* use ONNX-MLIR everywhere

Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* Switch URLs to use main instead of master (llvm#1094)

Signed-off-by: Charles Volzka <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* Fix MacOS build badge (llvm#1092)

Signed-off-by: Gong Su <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* fix typos and add ssh-client to dockerfile (llvm#1096)

* fix typos and add ssh-client to dockerfile

Signed-off-by: Ethan Wang <[email protected]>

* sync doc and script

Signed-off-by: Ethan Wang <[email protected]>

Co-authored-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* Update document (llvm#1077)

* create

Signed-off-by: Tong Chen <[email protected]>

* delete HowTOAddAnOperation.md

Signed-off-by: Tong Chen <[email protected]>

* modify testing

Signed-off-by: Tong Chen <[email protected]>

* create

Signed-off-by: Tong Chen <[email protected]>

* delete HowTOAddAnOperation.md

Signed-off-by: Tong Chen <[email protected]>

* modify testing

Signed-off-by: Tong Chen <[email protected]>

* fix

Signed-off-by: Tong Chen <[email protected]>

* create

Signed-off-by: Tong Chen <[email protected]>

* add comment

Signed-off-by: Tong Chen <[email protected]>

* delete HowTOAddAnOperation.md

Signed-off-by: Tong Chen <[email protected]>

* modify testing

Signed-off-by: Tong Chen <[email protected]>

* fix

Signed-off-by: Tong Chen <[email protected]>

* create

Signed-off-by: Tong Chen <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* Update LLVM level (llvm#1095)

* Update LLVM level to 700997a

Signed-off-by: Ettore Tiotto <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* Pass a type converter to all ONNX operations. (llvm#1102)

Signed-off-by: Ettore Tiotto <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* Nuke KrnlDummyCastOp now that we use MLIR's UnrealizedConversionCastOp (llvm#1103)

* Nuke KrnlDummyCastOp now that we use MLIR's UnrealizedConversionCastOp

Signed-off-by: Ettore Tiotto <[email protected]>

* Remove a dependency in src/Dialect/Krnl/CMakeList.txt.  Regenerate docs via 'ninja onnx-mlir-docs'.

Signed-off-by: Ettore Tiotto <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* Add --emitObj option to onnx-mlir (llvm#1104)

Signed-off-by: Ettore Tiotto <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* fix warnings (llvm#1093)

Signed-off-by: Ian Bearman <[email protected]>

Co-authored-by: Stella Stamenova <[email protected]>
Co-authored-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* Add -march option to onnx-mlir (llvm#1107)

Signed-off-by: Ettore Tiotto <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* Fix Doc spelling and broken links, removed warnings about using main (llvm#1106)

* removed warning about main vs master in CONTRIBUTING, fixed links and spelling mistakes

Signed-off-by: Alexandre Eichenberger <[email protected]>
Signed-off-by: Ethan Wang <[email protected]>

* Update BuildONNX.md

Signed-off-by: Ethan Wang <[email protected]>

Co-authored-by: Ettore Tiotto <[email protected]>
Co-authored-by: Alexandre Eichenberger <[email protected]>
Co-authored-by: Stella Stamenova <[email protected]>
Co-authored-by: Charles Volzka <[email protected]>
Co-authored-by: gongsu832 <[email protected]>
Co-authored-by: chentong319 <[email protected]>
Co-authored-by: Tung D. Le <[email protected]>
Co-authored-by: Ian Bearman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants