From 8cdd069581b270ac8d4a0761fb52cb6283aeea59 Mon Sep 17 00:00:00 2001 From: ggpolar Date: Thu, 28 May 2020 13:03:34 +0800 Subject: [PATCH] modify mindconverter/README.md and st. --- mindinsight/mindconverter/README.md | 34 +++++++++++++------ .../mindconverter/data/lenet_converted.py | 9 +---- .../func/mindconverter/data/lenet_script.py | 7 +--- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/mindinsight/mindconverter/README.md b/mindinsight/mindconverter/README.md index 5d7d598..42af758 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 b3d4701..1e6a458 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 90f1e41..ff5d8fa 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)) -- GitLab