MCPcopy
hub / github.com/hustvl/Vim / register_custom_op_onnx_export

Function register_custom_op_onnx_export

det/detectron2/utils/testing.py:194–205  ·  view source on GitHub ↗

Register `symbolic_fn` as PyTorch's symbolic `opname`-`opset_version` for ONNX export. The registration is performed only when current PyTorch's version is < `min_version.` IMPORTANT: symbolic must be manually unregistered after the caller function returns

(
    opname: str, symbolic_fn: Callable, opset_version: int, min_version: str
)

Source from the content-addressed store, hash-verified

192
193
194def register_custom_op_onnx_export(
195 opname: str, symbolic_fn: Callable, opset_version: int, min_version: str
196) -> None:
197 """
198 Register `symbolic_fn` as PyTorch&#x27;s symbolic `opname`-`opset_version` for ONNX export.
199 The registration is performed only when current PyTorch&#x27;s version is < `min_version.`
200 IMPORTANT: symbolic must be manually unregistered after the caller function returns
201 """
202 if min_torch_version(min_version):
203 return
204 register_custom_op_symbolic(opname, symbolic_fn, opset_version)
205 print(f"_register_custom_op_onnx_export({opname}, {opset_version}) succeeded.")
206
207
208def unregister_custom_op_onnx_export(opname: str, opset_version: int, min_version: str) -> None:

Callers 1

setUpMethod · 0.90

Calls 2

min_torch_versionFunction · 0.85
printFunction · 0.85

Tested by

no test coverage detected