mindspore.ops.op_info_register

mindspore.ops.op_info_register(op_info)[source]

A decorator which is used to register an operator.

Note

‘op_info’ should represent the operator information by string with json format. The ‘op_info’ will be added into oplib.

Parameters

op_info (Union[str, dict]) – operator information in json format.

Examples

>>> from mindspore.ops import op_info_register, TBERegOp, DataType
>>> abs_op_info = TBERegOp("Abs") \
...    .fusion_type("ELEMWISE") \
...    .async_flag(False) \
...    .binfile_name("abs.so") \
...    .compute_cost(10) \
...    .kernel_name("abs") \
...    .partial_flag(True) \
...    .op_pattern("formatAgnostic") \
...    .input(0, "x", None, "required", None) \
...    .output(0, "y", True, "required", "all") \
...    .dtype_format(DataType.F16_None, DataType.F16_None) \
...    .dtype_format(DataType.F32_None, DataType.F32_None) \
...    .dtype_format(DataType.I32_None, DataType.I32_None) \
...    .get_op_info()
>>>
>>> @op_info_register(abs_op_info)
... def _abs_tbe():
...    return
...
Returns

Function, returns a decorator for op info register.