-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[Proposal] ONNX Interface for Framework Integration (previously ONNX Backend API) header and docs #551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[Proposal] ONNX Interface for Framework Integration (previously ONNX Backend API) header and docs #551
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
4aa4cee
ONNX Backend API header and docs
9b2a21c
Fix numbering in Backend API readme
a5fc170
Refactor onnxGetBackendInfo interface
4a54b06
CMake target for backend interface header
4e4f26f
Fix include directory in CMake onnxbe_interface target
be54680
Remove limit on the number of tensor dimensions
6d08dc4
Generate compile warning for unchecked error code
371a51a
Add complex data types from TensorProto.DataType enum
bd4291e
Rename Backend API to ONNX Interface for Framework Integration (ONNXIFI)
8d9273a
Extend interface for additional use-cases
90761cd
Consistently refer to ONNXIFI objects as ONNXIFI backend/graph/event …
baa4316
Add missing event-related error codes:
6d38c59
Add new error code for unsupported tensor metainformation parameters
eca884b
More consistent handling of ONNXIFI_STATUS_INVALID_SHAPE and ONNXIFI_…
f4158e9
Add error codes for inconsistent shapes and data types
ea935da
Specify that onnxGraph and onnxEvent must be deinitialized before onn…
492a317
Clarify documentation that ModelProto message is not valid after onnx…
4e2353e
Introduce ONNXIFI_BACKEND_PROPERTY_OPTIMIZATION property for backend …
81aeb45
Support hot-pluggable backends
da8928c
Rename FRAMEWORK device type to HETEROGENEOUS device type
857c70a
Document ONNXIFI_STATUS_BACKEND_UNAVAILABLE in function return values
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # ONNX Interface for Framework Integration (ONNXIFI) Proposal | ||
|
|
||
| We propose a cross-platform API for loading and executing ONNX graphs on optimized backends. High-level frameworks and applications can use this API to execute neural network and machine learning models. Hardware vendors can implement this API to expose specialized hardware accelerators and highly optimized software infrastructure to the users. | ||
|
|
||
| ## Core Features | ||
|
|
||
| - Standardized interface for neural network inference on special-purpose accelerators, CPUs, GPUs, DSPs, and FPGAs | ||
| - Based on widely supported technologies | ||
| - C API for function calls | ||
| - ONNX format for passing model graphs | ||
| - NCHW tensor layout for passing inputs and outputs | ||
| - Dynamic discovery of available backends for model execution | ||
| - Multiple backends from different vendors can co-exist on the same system | ||
| - Dynamic discovery of supported ONNX Operators on each backend | ||
|
|
||
| ### Optional Features: | ||
|
|
||
| - Graphs with variable-shape inputs and/or outputs | ||
| - Graphs with data-dependendent output shapes | ||
|
|
||
| ## How to Use ONNX Interface for Framework Integration | ||
|
|
||
| 0. (Optional) Use `onnxifi_library_load` to dynamically load the ONNX Interface for Framework Integration library. | ||
| 1. Call `onnxGetNumBackends` to get the number of available backends. Note that it can be 0. | ||
| 2. Call `onnxGetBackendInfo` to check additional information about any available backend. | ||
| 3. Call `onnxGetBackendCompatibility` to check if your model, or parts of it, can run on the backend. | ||
| 4. Call `onnxInitBackend` to initialize a backend, then call `onnxInitGraph` to offload one or more model graphs to the backend. | ||
| 5. Call `onnxSetGraphIO` to set inputs and output for the graph, then call `onnxRunGraph` to execute the graph(s). If your model works with fixed-size inputs, one call to `onnxSetGraphIO` is sufficient for multiple `onnxRunGraph` calls. For models with variable-size inputs, you'd need to call `onnxSetGraphIO` before each `onnxRunGraph` call. | ||
| 6. When done using the model, release the model graph(s) with `onnxReleaseGraph`, then release the backend with `onnxReleaseBackend` | ||
|
|
||
| ## How to Implement ONNX Interface for Framework Integration | ||
|
|
||
| The minimum functionality an ONNXIFI implementation must provide is the following: | ||
|
|
||
| - Support ONNX 1.0 model format. | ||
| - There is no minimum list of Operators a backed has to support. | ||
| - Support graph inputs / outputs in CPU memory. | ||
| - Support graph inputs / outputs with fixed shape, specified in GraphProto message. | ||
|
|
||
| ### Discovery | ||
| Vendor-provided libraries should adhere to some rules to ensure discovery by ONNX-supported frameworks and applications: | ||
| - Use `libonnxifi-<backend>.so` filename on Linux/Android | ||
| - Use `libonnxifi-<backend>.dylib` filename on macOS | ||
| - Use `onnxifi-<backend>.dll` filename on Windows | ||
| - Append ONNX function names with `<BACKEND>` (a vendor may define `ONNXIFI_LIBRARY_SUFFIX=<BACKEND>` and when using `onnxifi.h` header). | ||
| `<backend>` is the vendor-specific name in lowercase, and `<BACKEND>` is the same name in uppercase. E.g. a vendor **Gamma** would provide `libonnxifi-gamma.so` for Linux systems, and this library would implement functions `onnxGetNumBackendsGAMMA`, `onnxGetBackendInfoGAMMA`, etc. | ||
|
|
||
| ### Extensions | ||
|
|
||
| Hardware vendors are welcome to add their own extensions to ONNX backend interface. The backend interface offers several extension mechanisms: | ||
| - Experimental, exotic, or vendor-specific operators can be supported in a private domain using NodeProto.domain attribute. | ||
| - Vendor-provided ONNXIFI implementation can expose additional functions | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe expand it a bit: "expose additional functions in the C API (for example separate calls to setup device-specific async execution)". Otherwise it's not clear which functions we're talking about |
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should put basic CNN here - but it's a separate discussion. @houseroad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave it to Compliance Working Group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dzhulgakov it's a great topic for the test and compliance working group. I have recorded it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backed -> backend