microsoft / onnxscript

ONNX Script enables developers to naturally author ONNX functions and models using a subset of Python.
https://onnxscript.ai/
MIT License
285 stars 54 forks source link

How to include an ONNX model into onnxscript script? #1882

Closed kubaraczkowski closed 1 month ago

kubaraczkowski commented 1 month ago

Hi onnnxscript people,

Onnxscript is great, I love it, thanks! I currently use it e.g. for preprocessing tasks, but would want to include the 'real' model in the flow as well. More, I would e.g. like to include 3 models as an assembly in an onnxscript.

Until now I didn't find a way (tutorial, documentation) on how to do it. It's perhaps slightly related to https://github.com/microsoft/onnxscript/issues/952 which converts the ONNX model to a script, I guess to also be able to 'merge' it with other scripts (and tweak the whole thing).

Therefore, in essence - is it possible to include a 'compiled' (proto) ONNX model as a part of an onnxscript?

Thanks!

justinchuby commented 1 month ago

Cc @gramalingam

gramalingam commented 1 month ago

Agree, it would be great to have this feature. Unfortunately, onnxscript doesn't have it yet.

Ideally, we should have a wrapper function that allows us to treat an existing ONNX model as a function, and be able to call it from an onnxscript function. Would be great to add this feature.

kubaraczkowski commented 1 month ago

Yes! My workaround is the following:

Works, but misses the fantastic debuggability of onnxscript!

Looking forward to this happening :)

titaiwangms commented 1 month ago

Feel free to reopen if the question is not answered.