Code Monkey home page Code Monkey logo

Comments (6)

marbre avatar marbre commented on May 24, 2024

This is indeed not possible with the passes we have right now. Is this relevant for the work on your side?

from mlir-emitc.

jpienaar avatar jpienaar commented on May 24, 2024

This would allow using the argmax from TOSA with a primarily MHLO model.

Is it a requirement that the lowering to EmitC be a one-shot?

from mlir-emitc.

marbre avatar marbre commented on May 24, 2024

I see. This is not a strict requirement, it just how we currently have implemented this. So far there wasn't a use case for mixed models on our side. Anyway, if it is helping we can think about refactoring this.

from mlir-emitc.

marbre avatar marbre commented on May 24, 2024

This is indeed not possible with the passes we have right now. Is this relevant for the work on your side?

I must correct my statement. The conversion passes are implemented as partial conversions and it is indeed possible to pass mixed input files. For example

func @mixed_dialects(%arg0: tensor<2xi32>) -> i32 {
  %0 = "mhlo.constant"() {value = dense<1> : tensor<2xi32>} : () -> tensor<2xi32>
  %1 = "tosa.const"() {value = dense<[3, 0, 1, 2]> : tensor<4xi32>} : () -> tensor<4xi32>
  %2 = emitc.call "func_a" (%0, %1) : (tensor<2xi32>, tensor<4xi32>) -> i32
  return %2 : i32
}

can be converted by passing --convert-tosa-to-emitc --convert-mhlo-to-emit to emitc-opt to

func @mixed_dialects(%arg0: tensor<2xi32>) -> i32 {
  %0 = "emitc.constant"() {value = dense<1> : tensor<2xi32>} : () -> tensor<2xi32>
  %1 = "emitc.constant"() {value = dense<[3, 0, 1, 2]> : tensor<4xi32>} : () -> tensor<4xi32>
  %2 = emitc.call "func_a"(%0, %1) : (tensor<2xi32>, tensor<4xi32>) -> i32
  return %2 : i32
}

Using emitc-translate or mlir-translate (from MLIR upstream) this can be translated to

int32_t mixed_dialects(Tensor<int32_t, 2> v1) {
  Tensor<int32_t, 2> v2 = {1, 1};
  Tensor<int32_t, 4> v3 = {3, 0, 1, 2};
  int32_t v4 = func_a(v2, v3);
  return v4;
}

from mlir-emitc.

marbre avatar marbre commented on May 24, 2024

This would allow using the argmax from TOSA with a primarily MHLO model.

The problem you were facing is that there is no conversion for tosa.argmax. I've created #279 to track this. Please re-open or fill a new issue if I got things wrong.

from mlir-emitc.

jpienaar avatar jpienaar commented on May 24, 2024

Ah I hadn't checked argmax support there. Thanks!

from mlir-emitc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.