Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
|
|
5 years ago | |
|---|---|---|
| .. | ||
| common | 5 years ago | |
| mappings | 5 years ago | |
| ops | 5 years ago | |
| README.md | 5 years ago | |
| __init__.py | 5 years ago | |
| cli.py | 5 years ago | |
| config.py | 5 years ago | |
| converter.py | 5 years ago | |
| forward_call.py | 5 years ago | |
| funcs.py | 5 years ago | |
MindConverter is a tool that converting PyTorch scripts to MindSpore scripts. With minial manual editing and the guidance from conversion reports, users may easily migrate their model from PyTorch framework to MindSpore.
This tool is part of MindInsight and accessible to users after installing MindInsight, no extra installation is needed.
Set the model scripts directory as the PYTHONPATH environment variable first:
export PYTHONPATH=<model scripts dir>
mindconverter commandline usage:
mindconverter [-h] [--version] --in_file IN_FILE [--output OUTPUT]
[--report REPORT]
optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
--in_file IN_FILE Specify path for script file.
--output OUTPUT Specify path for converted script file directory. Default
is output directory in the current working directory.
--report REPORT Specify report directory. Default is the current working
directorys
We have a collection of PyTorch model scripts
~$ ls
models
~$ ls models
lenet.py resnet.py vgg.py
Then we set the PYTHONPATH environment variable and convert alexnet.py
~$ export PYTHONPATH=~/models
~$ mindconverter --in_file models/lenet.py
Then we will see a conversion report and the output MindSpore script
~$ ls
lenet_report.txt models output
~$ ls output
lenet.py
Please checkout models/lenet.py and output/lenet.py as the input/output example representatively.
Since the conversion is not 100% flawless, we encourage users to checkout the report when fixing issues of the converted script.
Classes and functions that can't be converted:
Subclassing from the subclasses of nn.Module
e.g. (code snip from torchvision,models.mobilenet)
from torch import nn
class ConvBNReLU(nn.Sequential):
def __init__(self, in_planes, out_planes, kernel_size=3, stride=1, groups=1):
padding = (kernel_size - 1) // 2
super(ConvBNReLU, self).__init__(
nn.Conv2d(in_planes, out_planes, kernel_size, stride, padding, groups=groups, bias=False),
nn.BatchNorm2d(out_planes),
nn.ReLU6(inplace=True)
)
Unconventional import naming
e.g.
import torch.nn as mm
MindInsight为MindSpore提供了简单易用的调优调试能力。在训练过程中,可以将标量、张量、图像、计算图、模型超参、训练耗时等数据记录到文件中,通过MindInsight可视化页面进行查看及分析。
SVG Text Python Vue CSV other