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

Python API not passing custom ops and rewriters properly #1707

Closed
vloncar opened this issue Sep 10, 2021 · 3 comments · Fixed by #1708
Closed

Python API not passing custom ops and rewriters properly #1707

vloncar opened this issue Sep 10, 2021 · 3 comments · Fixed by #1708

Comments

@vloncar
Copy link

vloncar commented Sep 10, 2021

Describe the bug
from_keras(), from_function() and from_graph_def() functions incorrectly process custom_op_handlers and custom rewriter parameters (maybe others as well, but these two I need). The custom_op_handlers is not used, and instead custom_ops is passed to process_tf_graph in its place. The custom_rewriter is ignored altogether, removing the possibility to use this feature.

Urgency
None

System information
Doesn't matter

To Reproduce
Just try to pass something custom_op_handlers or custom_rewriter to tf2onnx.convert.from_keras()

Screenshots
Not needed

Additional context
Not needed

@TomWildenhain-Microsoft
Copy link
Contributor

Hi @vloncar, you are correct. Thanks for the investigation and report. #1708 should fix the issue.

By the way, custom_op_handlers is deprecated and you may find it easier to use @tf_op to register an op handler.

from tf2onnx.handler import tf_op

Example:

@tf_op("StringToHashBucketFast", domain=constants.CONTRIB_OPS_DOMAIN)

Just curious, what op handlers are you registering?

@vloncar
Copy link
Author

vloncar commented Sep 12, 2021

Hi, thanks for the quick fix. I'm using the feature to parse quantized layers to a custom onnx op.

One extra question: is there maybe a way to use the graph manipulation tools on an existing ONNX model? For example I would like to insert nodes after the model was fully optimized (i.e. it has gemm nodes and the bias has been fused into the conv layer)

@TomWildenhain-Microsoft
Copy link
Contributor

@vloncar Maybe the easiest thing would be cloning the tf2onnx repo. Then you can edit/add any editing steps you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants