diff --git a/mindinsight/mindconverter/README.md b/mindinsight/mindconverter/README.md index 5d7d598a4aded3ef7a2b59334560da7512cfdadd..42af758d3125adfa6c6f6fed8f7fdd00608222fd 100644 --- a/mindinsight/mindconverter/README.md +++ b/mindinsight/mindconverter/README.md @@ -4,11 +4,6 @@ MindConverter is a tool that converting PyTorch scripts to MindSpore scripts. Wi -### System Requirements - -* PyTorch v1.5.0 -* MindSpore v0.2.0 - ### Installation This tool is part of MindInsight and accessible to users after installing MindInsight, no extra installation is needed. @@ -24,8 +19,6 @@ mindconverter commandline usage: mindconverter [-h] [--version] --in_file IN_FILE [--output OUTPUT] [--report REPORT] -MindConverter CLI entry point (version: 0.2.0) - optional arguments: -h, --help show this help message and exit --version show program's version number and exit @@ -36,13 +29,32 @@ optional arguments: directorys ``` -Usage example: +#### Use example: + +We have a collection of PyTorch model scripts +```buildoutcfg +~$ ls +models +~$ ls models +lenet.py resnet.py vgg.py +``` + +Then we set the PYTHONPATH environment variable and convert alexnet.py +```buildoutcfg +~$ export PYTHONPATH=~/models +~$ mindconverter --in_file models/lenet.py +``` + +Then we will see a conversion report and the output MindSpore script ```buildoutcfg -export PYTHONPATH=~/my_pt_proj/models -mindconverter --in_file lenet.py +~$ ls +lenet_report.txt models output +~$ ls output +lenet.py ``` -Since the conversion is not 100% flawless, we encourage users to checkout the reports when fixing issues of the converted scripts. +Please checkout [models/lenet.py](../../tests/st/func/mindconverter/data/lenet_script.py) and [output/lenet.py](../../tests/st/func/mindconverter/data/lenet_converted.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. ### Unsupported Situation #1 diff --git a/tests/st/func/mindconverter/data/lenet_converted.py b/tests/st/func/mindconverter/data/lenet_converted.py index b3d470110fb361122d5850545e1aa15cc8ca3de9..1e6a458e40aa55b5883dcb78472dcbbf88eaf2ef 100644 --- a/tests/st/func/mindconverter/data/lenet_converted.py +++ b/tests/st/func/mindconverter/data/lenet_converted.py @@ -12,11 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -"""Test network script of LeNet.""" +"""Test network script of LeNet for ST test case data.""" import mindspore.nn as nn import mindspore.ops.operations as P -# import torch.nn as nn -# import torch.nn.functional as F class TestLeNet(nn.Cell): @@ -30,11 +28,6 @@ class TestLeNet(nn.Cell): def construct(self, input_x): """Callback method.""" - out = self.forward1(input_x) - return out - - def forward1(self, input_x): - """forward1 method.""" out = P.ReLU()(self.conv1(input_x)) out = P.MaxPool(2, None, 'valid')(out) out = P.ReLU()(self.conv2(out)) diff --git a/tests/st/func/mindconverter/data/lenet_script.py b/tests/st/func/mindconverter/data/lenet_script.py index 90f1e41f8b8fa6ad9cd526fb343b70300e9a87af..ff5d8fa1abe96c33ff2b298e629ccbaf99e2a1f4 100644 --- a/tests/st/func/mindconverter/data/lenet_script.py +++ b/tests/st/func/mindconverter/data/lenet_script.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -"""Test network script of LeNet.""" +"""Test network script of LeNet for ST test case data.""" import torch.nn as nn import torch.nn.functional as F @@ -28,11 +28,6 @@ class TestLeNet(nn.Module): def forward(self, input_x): """Callback method.""" - out = self.forward1(input_x) - return out - - def forward1(self, input_x): - """forward1 method.""" out = F.relu(self.conv1(input_x)) out = F.max_pool2d(out, 2) out = F.relu(self.conv2(out))