mindspore.graph.register_custom_backend

View Source On Gitee
mindspore.graph.register_custom_backend(backend_name, backend_path)[source]

Register a custom backend with MindSpore and use it for model compilation and execution.

Note

  • Custom backend only takes effect when using @jit, and the backend parameter in the @jit decorator must be consistent with the registered backend name.

  • This interface only supports Linux systems.

Parameters
  • backend_name (str) – Name of the backend expected to be provided by the plugin.

  • backend_path (str) – Absolute path to the plugin shared library (.so file).

Returns

bool. Return True if the custom backend is successfully registered; otherwise, False is returned.

Raises

ValueError – If the custom backend path does not exist or the file is invalid.

Examples

>>> import mindspore.graph as graph
>>> from mindspore import mint, jit
>>> # Register a custom backend
>>> success = graph.register_custom_backend(
...     backend_name="my_backend",
...     backend_path="/path/to/my_backend.so",
... )
>>> print(f"Registration successful: {success}")
>>> # Use the custom backend
>>> @jit(backend="my_backend")
...     def my_func(x):
...         return mint.sin(x)