webonnx / wonnx

A WebGPU-accelerated ONNX inference run-time written 100% in Rust, ready for native and the web
Other
1.54k stars 54 forks source link

Support for Boolean Data Types #207

Open astnmsn opened 3 months ago

astnmsn commented 3 months ago

Is your feature request related to a problem? Please describe.

I am currently trying to run segment anything in the browser in a rust binary that is targeting wasm. I am using the vit_b onnx model provided in the list here (direct download)

It took many iterations to get the model into the state where i hit this issue.

  1. Removed all dynamically sized inputs and intermediaries
  2. Ran through onnx-simplifier to remove some of the operations that nnx was not able to infer the shape of
  3. Hacked in support for inference on Not and Equal operators (some likelihood this was not done correctly, but should not be the source of the main issue)
  4. Removed the dynamically sized outputs when running nnx prepare on the model

At this point when running the model I was faced with a IrError(Type(NotSupported(BOOL)) which indicates the model is expecting a data type that does not fit into the existing supported list.

Each of these workarounds does pose a serious limitation to use wonnx for this task. But it doesn't seem this final one can be worked around.

It is possible that after this, the model is still unusable for other reasons.

Describe the solution you'd like

Implementation of BOOL data type support

Describe alternatives you've considered

Restructuring the model in various ways to fit current support.

Additional context

While this issue is strictly looking at the BOOL data type, it would be awesome to have the other shortcomings mentioned looked at as well.