You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to know if it is possible to define a custom operator with a different name that its function name.
Example:
importonnx# We use ONNX opset 15 to define the function below.fromonnxscriptimportFLOAT, scriptfromonnxscriptimportopset15asop@script(op_type="MY_NEW_NAME_OP")defcustom_op(X):
return5*Xdefsample_model(X: FLOAT[64, 128]) ->FLOAT[64, 128]:
returncustom_op(X)
# onnx_model is an in-memory ModelProtoonnx_model=sample_model.to_model_proto()
# Check node op_typeassertmodel.graph.node[0].op_type=="MY_NEW_NAME_OP"
The text was updated successfully, but these errors were encountered:
My use case can be explained with the gelu function. As a rule, function names in python are usually written in snake or camel cases, but ONNX legacy operators are capital case. That is why if I defined gelu function with onnscript :
@script()defgelu(X):
...
gelu.to_function_proto() method should map a ONNX function named 'gelu' and not 'Gelu'.
It is in this kind of cases that I think it is convenient to have the option to serialize the operator with a different name than the python function.
I would like to know if it is possible to define a custom operator with a different name that its function name.
Example:
The text was updated successfully, but these errors were encountered: