Multi-backend Access
Overview
In order to meet the rapid docking requirements of new backend and new hardware, MindSpore supports plug-in, low-cost and rapid docking of third-party backend on the basis of MindIR through an open architecture. Third-party backend does not need to pay attention to the data structure and implementation of the current existing backend, and only needs to use MindIR as an input to realize its own backend and functionality, which will be loaded with independent so registration. The functionality of different backends will be isolated from each other.
Interface
Multi-backend implementation: for the specified backend to use via mindspore.jit(backend="xx"), see jit interface.
Basic Principle
The MindSpore multi-backend docking schematic is shown above, with the core idea being:
The backend management module provides C++ external interfaces (Build and Run for backendmanager) and internal interfaces (Build and Run for the base class backend).
backendmanager external interface, mainly provided to the front-end MindIR docking back-end functionality for front-end and back-end decoupling.
Base class backend internal interface, mainly provided to the respective backend to achieve Build and Run functions.
Each back-end function is an independent so for the back-end management module to dynamically load scheduling.
After understanding the core idea of MindSpore's multi-backend docking, the main tasks when adding a new backend are as follows:
mindspore.jit(backend="xx") interface adds new backend type.
The new backend class inherits from the base class backend and implements the corresponding Build and Run functions.
The new backend code is compiled into a separate so and registered to the backend management module.