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

Fix unregister pytorch export for contrib ops #5052

Merged
merged 1 commit into from
Sep 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tools/python/register_custom_ops_pytorch_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ def unregister_custom_op():

import torch.onnx.symbolic_registry as sym_registry

# TODO: replace this once PyTorch supports unregister natively.
def unregister(name, opset_version):
ns, kind = name.split("::")
if sym_registry.is_registered_op(kind, ns, opset_version):
del sym_registry._registry[(ns, opset_version)][kind]
from torch.onnx.symbolic_helper import _onnx_stable_opsets

for version in _onnx_stable_opsets:
if version >= opset_version and sym_registry.is_registered_op(kind, ns, version):
del sym_registry._registry[(ns, version)][kind]

unregister('::inverse', _onnx_opset_version)
unregister('::gelu', _onnx_opset_version)
Expand Down