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

TOSA dialect type inference error #371

Open
raviqqe opened this issue Dec 4, 2023 Discussed in #370 · 0 comments
Open

TOSA dialect type inference error #371

raviqqe opened this issue Dec 4, 2023 Discussed in #370 · 0 comments
Labels
bug Something isn't working

Comments

@raviqqe
Copy link
Owner

raviqqe commented Dec 4, 2023

Discussed in #370

Originally posted by gmmyung December 2, 2023
Hi,

I am currently working on a PoC of a AOT compiled ML framework in Rust using eerie (Rust binding to IREE).

I am fairly new to MLIR, and struggling from the following error:

pub fn new_tensor<'a, T>(&'a mut self, shape: &'a [u64]) -> impl Tensor + 'a {
      let location = Location::unknown(&self.melior_context);
      let values: Vec<_> = vec![1.0f32, 2.0f32, 3.0f32, 4.0f32]
          .iter()
          .map(|x| {
              FloatAttribute::new(
                  &self.melior_context,
                  *x as f64,
                  Type::float32(&self.melior_context),
              )
              .into()
          })
          .collect();
      let mlir_type = RankedTensorType::new(shape, Type::float32(&self.melior_context), None);
      let attr =
          DenseElementsAttribute::new(mlir_type.into(), &values).unwrap();
      println!("{:?}", attr);
      let op = tosa::r#const(&self.melior_context, attr.into(), location);
      ConstTensor { op, shape }
 }
warning: `eerietest` (bin "eerietest") generated 3 warnings (run `cargo fix --bin "eerietest"` to apply 2 suggestions)
    Finished dev [unoptimized + debuginfo] target(s) in 1.36s
     Running `target/debug/eerietest`
dense<[[1.000000e+00, 2.000000e+00], [3.000000e+00, 4.000000e+00]]> : tensor<2x2xf32>
error: type inference was requested for the operation tosa.const, but the operation does not support type inference; result types must be specified explicitly
thread 'main' panicked at /Users/gmmyung/.cargo/registry/src/index.crates.io-6f17d22bba15001f/melior-0.13.0/src/dialect/ods.rs:99:1:
valid operation: OperationBuild

What am I doing wrong? Any suggestions will be appreciated!

@raviqqe raviqqe added the bug Something isn't working label Dec 4, 2023
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

No branches or pull requests

1 participant