mindspore.ops.get_vm_impl_fn

View Source On Gitee
mindspore.ops.get_vm_impl_fn(prim)[source]

Gets the virtual implementation function by a primitive object or primitive name.

Parameters

prim (Union[Primitive, str]) – primitive object or name for operator register.

Note

This mechanism applied for debugging currently.

Returns

function, vm function

Examples

>>> from mindspore.ops import vm_impl_registry, get_vm_impl_fn
...
>>> @vm_impl_registry.register("Type")
... def vm_impl_dtype(self):
...   def vm_impl(x):
...     return type(x)
...   return vm_impl
...
>>> fn = get_vm_impl_fn("Type")
>>> out = fn(1.0)
>>> print(out)
<class 'float'>