Skip to content
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

[Feature request] Make OpSchema writable from Python #5019

Open
4 of 5 tasks
justinchuby opened this issue Mar 20, 2023 · 5 comments
Open
4 of 5 tasks

[Feature request] Make OpSchema writable from Python #5019

justinchuby opened this issue Mar 20, 2023 · 5 comments
Assignees
Labels
contributions welcome enhancement Request for new feature or operator

Comments

@justinchuby
Copy link
Contributor

justinchuby commented Mar 20, 2023

What is the problem that this feature solves?

Not being able to auto create OpSchema for functions in Python; not being able to do shape inference for custom ops.

Alternatives considered

Create a Python class that mirrors OpSchema. We can do that and expose a similar interface, but for onnx shape inference to work, we need to be able to create an OpSchema, register it and write shape inference functions in Python.

Describe the feature

Extend the OpSchema to be writable, and support registering this schema with ONNX.

Will this influence the current api (Y/N)?

Y. It will be an extension of the current OpSchema api.

Feature Area

API

Are you willing to contribute it (Y/N)

Yes

Notes

assigned to @justinchuby

@justinchuby justinchuby added the enhancement Request for new feature or operator label Mar 20, 2023
@jbachurski
Copy link
Member

I think this is a really interesting proposal towards recognising custom operators. Spox currently uses ONNX OpSchemas to generate opset modules, and as such custom operator libraries could register more and we could use Spox utilities directly to generate opset modules.
Maybe we could take this a step further and consider allowing defining/overriding type and shape inference in a similar manner? Then we wouldn’t be locked to custom operators always failing shape inference internally.

@justinchuby
Copy link
Contributor Author

I think that’s a great idea

@justinchuby
Copy link
Contributor Author

justinchuby commented Mar 23, 2023

We will create a single constructor and allow only shape inference overrides instead

@justinchuby
Copy link
Contributor Author

@justinchuby
Copy link
Contributor Author

Documentation: FormalParameter

github-merge-queue bot pushed a commit that referenced this issue Feb 23, 2024
### Description

 - Add a python interface to register the OpSchema.
 - Add a python interface to deregister the OpSchema.
- Avoid the value error when executing `OpSchema::Finalize` multiple
times
 - Add flag to enable check node for custom domain
 - overload `onnx.defs.has` with version parameter

example for register OpSchema:

```
op_schema = defs.OpSchema(
    "CustomOp",
    "",
    1,
)
onnx.defs.register_schema(op_schema)
```

example for deregister OpSchema:

```
onnx.defs.deregister_schema('CustomOp', 1)
```

### Motivation and Context

Follow up of #5019

---------

Signed-off-by: oPluss <opluss@qq.com>
Signed-off-by: opluss <opluss@qq.com>
Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com>
Co-authored-by: G. Ramalingam <grama@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributions welcome enhancement Request for new feature or operator
Projects
None yet
Development

No branches or pull requests

2 participants