GithubHelp home page GithubHelp logo

Broadcasting about tflite2onnx HOT 2 CLOSED

zhenhuaw-me avatar zhenhuaw-me commented on May 22, 2024 1
Broadcasting

from tflite2onnx.

Comments (2)

zhenhuaw-me avatar zhenhuaw-me commented on May 22, 2024

Facts and general design

ONNX has two concepts of broadcasting:

By intuition, we can do something like a fake broadcasting for shape such that the resulted shape is always broadcastable but layout propagation compatible, while element size remains unchanged. That is prepending or appending 1 to both input shapes of the inputs, therefore the resulted shapes have same length which can be moved around by layout propagation without impact the semantic.

That sounds faire enough but there is a significant challenge: fake broadcasting may break semantic of other operators as the rank of the tensors has changed. For this, we can insert Reshape operator, the only open question is to transform the shape attribution of Reshape.

from tflite2onnx.

zhenhuaw-me avatar zhenhuaw-me commented on May 22, 2024

How to handle layout issue for Reshape

For Reshape, regardless of whether it is newly added or raw in TFLite model, we need to try to fix the shape attribution for it after layout propagation. Since the shape attribution describes the shape of output tensor, if the output as propagated to transform layout, so as the shape attribution.

The layouts for shape could be obtained during parsing, but not always. If it is avaiable during parsing, then the shape attribution (tensor actually) can be transformed directly. Otherwise, shape has no layout information even after layout propagation (unless shape is output of some other operators that have layout information, which is unusual case). For such issue, we perform sepcial handling in Reshape.transform() to update the shape tensor. Then, we are all set.

We may markup the layout of shape and re-propagate the layouts, but that is unnecessary and complicate commen scenarios.

from tflite2onnx.

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.