mindspore.ops.prim_attr_register
- mindspore.ops.prim_attr_register(fn)[source]
Primitive attributes register.
Register the decorator of the built-in operator primitive ‘__init__’. The function will add all the parameters of ‘__init__’ as operator attributes , and init primitive name.
- Parameters
fn (function) – __init__ function of primitive.
- Returns
function, original function.
Examples
>>> from mindspore.ops import prim_attr_register, PrimitiveWithCheck >>> class MatMul(PrimitiveWithCheck): ... @prim_attr_register ... def __init__(self, transpose_a=False, transpose_b=False): ... self.init_prim_io_names(inputs=['x1', 'x2'], outputs=['output']) ... >>> # init a Primitive obj >>> matmul = MatMul()