mindspore.ops.CustomRegOp

class mindspore.ops.CustomRegOp(op_name='Custom')[source]

Class used for generating the registration information for the func parameter of mindspore.ops.Custom.

Parameters

op_name (str) – kernel name. No need to set this value as Custom, operator will generate a unique name automatically. Default: “Custom”.

Examples

>>> from mindspore.ops import CustomRegOp, DataType
>>> custom_op_ascend_info = CustomRegOp() \
...     .input(0, "x", "dynamic") \
...     .output(0, "y") \
...     .dtype_format(DataType.F16_Default, DataType.F16_Default) \
...     .dtype_format(DataType.F32_Default, DataType.F32_Default) \
...     .target("Ascend") \
...     .get_op_info()
attr(name=None, param_type=None, value_type=None, default_value=None, **kwargs)[source]

Register Custom op attribute information.

Parameters
  • name (str) – Name of the attribute. Default: None.

  • param_type (str) – Param type of the attribute. Default: None.

  • value_type (str) – Value type of the attribute. Default: None.

  • default_value (str) – Default value of attribute. If value is a list, each item should split by ‘,’. For example, if value_type is “listInt”, then default_value can be “1,2,3”. Default: None.

  • kwargs (dict) – Other information of the attribute.

input(index=None, name=None, param_type='required', **kwargs)[source]

Register Custom op input information.

Parameters
  • index (int) – Order of the input. Default: None.

  • name (str) – Name of the input. Default: None.

  • param_type (str) – Param type of the input. Default: “required”.

  • kwargs (dict) – Other information of the input.

output(index=None, name=None, param_type='required', **kwargs)[source]

Register Custom op output information.

Parameters
  • index (int) – Order of the output. Default: None.

  • name (str) – Name of the output. Default: None.

  • param_type (str) – Param type of the output. Default: “required”.

  • kwargs (dict) – Other information of the output.

target(target=None)[source]

Register Custom op target information.

Parameters

target (str) – Device target for current operator information, should be one of [“Ascend”, “GPU”, “CPU”]. Default: None.