Overview
The X2MindSpore tool can migrate models developed in PyTorch and TensorFlow and their training scripts to code that can run in MindSpore based on specific adaptation rules, greatly accelerating script migration and minimizing the workload of developers.
Restrictions
- X2MindSpore can migrate the models listed in Model List (including but not limited to). After the migration is successful, some models can directly run in MindSpore while some others need small adaptation. After the migration, the models can be successfully trained and converged, but the final accuracy and performance are not guaranteed.
- X2MindSpore generates the adaptation layer file directory x2ms_adapter in the migrated script directory. This directory stores the MindSpore-implemented APIs used to replace PyTorch/TensorFlow APIs. The tool migrates the original PyTorch/TensorFlow APIs to the adaptation layer APIs according to the mapping. After the migration, the code runs depending on the adaptation layer.
- Training scripts migrated by the migration and analysis tools can run in MindSpore 1.7 to 1.10.
- MindSpore supports two run modes, Graph and PyNative. Due to Python syntax restrictions of the Graph mode, only the ResNet, BiT (PyTorch), and UNet (PyTorch) series models listed in Table 1 can be migrated to the Graph mode. Other models can be migrated only to the PyNative mode, which delivers lower performance. For details about their differences, see the MindSpore Documentation.
- To avoid the restriction that tensors cannot be created during data processing in MindSpore, the run mode is set to synchronous operator delivery during PyTorch migration. As a result, the training performance may deteriorate. In this case, you can remove pynative_synchronize=True from context.set_context and use asynchronous operator delivery to improve the performance. If an error is reported, check the data processing code, remove the tensor creation part, and use NumPy NDarray.
- If the current device is occupied by other programs and its available memory is insufficient, you can add device_id = * to the context.set_context statement in the training script. * indicates the ID of the specified device to be invoked.
- TensorFlow 1.x training scripts cannot be migrated to multi-device scripts.
Parent topic: X2MindSpore