mindspore.graph.register_custom_pass

View Source On Gitee
mindspore.graph.register_custom_pass(pass_name, plugin_so_path, device='all', stage='')[source]

Register a custom pass to modify graph structure for default "ms_backend" backend.

Warning

This is an experimental API that is subject to change or deletion.

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

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

  • device (str, optional) – Target device for the pass. Supported values: "cpu" , "gpu" , "ascend" , or "all" . Default: "all" .

  • stage (str, optional) – Pass stage. Reserved field for future use. Default: "" .

Returns

bool. Returns True if the custom pass is registered successfully, otherwise returns False.

Examples

>>> import mindspore.graph as graph
>>> # Register a custom optimization pass
>>> success = graph.register_custom_pass(
...     pass_name="my_fusion_pass",
...     plugin_so_path="/path/to/my_plugin.so",
...     device="ascend"
... )
>>> print(f"Registration successful: {success}")