mindspore.ops.get_vm_impl_fn
- mindspore.ops.get_vm_impl_fn(prim)[源代码]
通过Primitive对象或Primitive名称,获取虚拟实现函数。
- 参数:
prim (Union[Primitive, str]) - 算子注册的Primitive对象或名称。
Note
该机制目前适用于调试。
- 返回:
函数,虚拟实现函数。
样例:
>>> from mindspore.ops import vm_impl_registry >>> from mindspore.ops.vm_impl_registry import 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'>