microsoft / onnxscript

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

Envisioned/example use cases in readme #294

Open josephrocca opened 1 year ago

josephrocca commented 1 year ago

Hello, I've just stumbled upon this repo, and it looks like an interesting project! Initially I thought it was a JAX-like library, except using ONNX ops instead of numpy, but it looks like it's not trying to do that, since there isn't autodiff (IIUC).

It's already cool enough that it can convert back and forth between Python code and ONNX files, but from a newbie perspective it would be useful to have some examples in the readme which indicate expected broad classes of use cases. It'd be handy if it were also compared/contrasted against other libraries in the ecosystem like JAX in terms of where it "fits in".

Thanks!

josephrocca commented 1 year ago

@justinchuby Guessing from the thumbs up this will happen at some point, but is there any chance I could get a quick TL;DR in this issue in the meantime? Sorry for my impatience! :sweat_smile:

justinchuby commented 1 year ago

Its current main goal is very specific and listed in the description: ONNX Script enables developers to author ONNX functions and models using a subset of Python.

so it is currently designed for graph construction.

justinchuby commented 1 year ago

Are the experiences you think should exist in the ONNX ecosystem, or experiences this project should enable?

josephrocca commented 1 year ago

I see - my query might come from a misunderstanding: I tend to view ONNX as a "serving" format, rather than an "authoring" format, so I'm wondering what kind of workflow it would fit into. My current use case for ONNX is in getting ML models working in the browser (example), and I'm always on the lookout for new tools, converters, etc. which can help me get unstuck on issues that I have during that process.

gramalingam commented 1 year ago

One of the goals is to enable authoring ONNX functions: express the semantics of a more complex "op" in terms of more primitive ops. ONNX functions provide a way to enrich the ONNX operator surface area, without making requiring backend implementations to immediately implement such composite-ops.

Round-tripping between ONNX and Python could also enable: interactive debugging of ONNX models, as well as provide easier ways to edit an ONNX model.

The authoring capability is also intended to simplify defining ONNX exporters from frameworks such as pytorch.

josephrocca commented 1 year ago

Ah I see - that makes sense. I've been playing around with it and ended up making a web assembly build of onnxscript and onnx (via Pyodide), and getting it working in the browser (i.e. no server-side processing) with a live visualizer (powered by Netron). Quite nice to see the graph and the code side-by-side! It's very "hacked together" - just an initial proof of concept:

https://user-images.githubusercontent.com/1167575/212470731-7741452e-c0d4-4931-a996-f7c0e456c820.mp4