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

Unable to lower op 'tensor.from_elements' with multiple parameters #17086

Closed
Tracked by #566
NeverRaR opened this issue Apr 18, 2024 · 0 comments · Fixed by #18034
Closed
Tracked by #566

Unable to lower op 'tensor.from_elements' with multiple parameters #17086

NeverRaR opened this issue Apr 18, 2024 · 0 comments · Fixed by #18034
Assignees
Labels
bug 🐞 Something isn't working

Comments

@NeverRaR
Copy link

NeverRaR commented Apr 18, 2024

What happened?

I tried to use iree to compile my own ONNX model, but the compilation process aborted in the stream phase because the input ir contains code like:

%from_elements = tensor.from_elements %0, %c2_i32 : tensor<2xi32>

Actually, I noticed that in "ConvertTensorFromElementsPattern", only 'tensor.from_elements' with one parameter are supported for conversion, so:

  1. Is this due to some special consideration?
  2. How can I handle situations that contain multiple parameters?

Steps to reproduce your issue

There is the smallest test case:

module {
  util.func public @concat_dimension_size(%arg0: tensor<?x?xf32>) -> tensor<2xi32> {
    %c2_i32 = arith.constant 2 : i32
    %c1 = arith.constant 1 : index
    %dim = tensor.dim %arg0, %c1 : tensor<?x?xf32>
    %0 = arith.index_cast %dim : index to i32
    %from_elements = tensor.from_elements %0, %c2_i32 : tensor<2xi32>
    util.return %from_elements : tensor<2xi32>
  }
}

run

iree-compile --mlir-print-ir-after-failure --compile-from=input --compile-to=stream ./test.mlir

then i see:

./test_mlir/from_elements/test1.mlir:7:22: error: failed to legalize operation 'tensor.from_elements' that was explicitly marked illegal
    %from_elements = tensor.from_elements %0, %c2_i32 : tensor<2xi32>
                     ^
./test_mlir/from_elements/test1.mlir:2:3: note: called from
  util.func public @concat_dimension_size(%arg0: tensor<?x?xf32>) -> tensor<2xi32> {
  ^
./test_mlir/from_elements/test1.mlir:7:22: note: see current operation: %3 = "tensor.from_elements"(%2, %0) : (i32, i32) -> tensor<2xi32>
    %from_elements = tensor.from_elements %0, %c2_i32 : tensor<2xi32>
                     ^
// -----// IR Dump After ConvertToStreamPass Failed (iree-stream-conversion) //----- //
Please report issues to https://github.com/openxla/iree/issues and include the crash backtrace.
Stack dump:
0.      Program arguments: ../iree-build/tools/iree-compile --mlir-print-ir-after-failure --compile-from=input --compile-to=stream ./test_mlir/from_elements/test1.mlir

What component(s) does this issue relate to?

Compiler

Version information

iree candidate candidate-20240410.859

Additional context

No response

@NeverRaR NeverRaR added the bug 🐞 Something isn't working label Apr 18, 2024
rsuderman added a commit to rsuderman/iree that referenced this issue Jul 29, 2024
iree-org#17086

We can support multipel `tensor.from_elements` through using
`flow.tensor.store` for each elements into an empty array.
rsuderman added a commit that referenced this issue Jul 30, 2024
…nts (#18034)

#17086

We can support multipel `tensor.from_elements` through using
`flow.tensor.store` for each elements into an empty array.

---------

Signed-off-by: Rob Suderman <rob.suderman@gmail.com>
rsuderman added a commit to rsuderman/iree that referenced this issue Jul 30, 2024
iree-org#17086

We can support multipel `tensor.from_elements` through using
`flow.tensor.store` for each elements into an empty array.
rsuderman added a commit to rsuderman/iree that referenced this issue Jul 30, 2024
iree-org#17086

We can support multipel `tensor.from_elements` through using
`flow.tensor.store` for each elements into an empty array.

Signed-off-by: Rob Suderman <rob.suderman@gmail.com>
rsuderman added a commit that referenced this issue Jul 31, 2024
#17086

We can support multipel `tensor.from_elements` through using
`flow.tensor.store` for each elements into an empty array.

---------

Signed-off-by: Rob Suderman <rob.suderman@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants