From 733d9e8e2ca6d07eda381e5c8f2dcf7027c1600a Mon Sep 17 00:00:00 2001 From: hangq Date: Sat, 29 Aug 2020 17:29:00 +0800 Subject: [PATCH] 1. add some example in runtime 2. rename deploy to compile --- lite/tutorials/source_en/index.rst | 2 +- lite/tutorials/source_en/use/benchmark_tool.md | 4 ++-- lite/tutorials/source_en/use/converter_tool.md | 6 +++--- .../tutorials/source_en/use/timeprofiler_tool.md | 4 ++-- .../source_zh_cn/quick_start/quick_start.md | 2 +- .../tutorials/source_zh_cn/use/benchmark_tool.md | 4 ++-- .../tutorials/source_zh_cn/use/converter_tool.md | 12 ++++++------ lite/tutorials/source_zh_cn/use/runtime.md | 16 ++++++++++++++++ .../source_zh_cn/use/timeprofiler_tool.md | 4 ++-- 9 files changed, 35 insertions(+), 19 deletions(-) diff --git a/lite/tutorials/source_en/index.rst b/lite/tutorials/source_en/index.rst index 8d538a48..569f33de 100644 --- a/lite/tutorials/source_en/index.rst +++ b/lite/tutorials/source_en/index.rst @@ -11,7 +11,7 @@ MindSpore Lite Tutorials :maxdepth: 1 :caption: Quick Start - deploy + compile quick_start/quick_start .. toctree:: diff --git a/lite/tutorials/source_en/use/benchmark_tool.md b/lite/tutorials/source_en/use/benchmark_tool.md index 472c1c45..78cd3412 100644 --- a/lite/tutorials/source_en/use/benchmark_tool.md +++ b/lite/tutorials/source_en/use/benchmark_tool.md @@ -22,9 +22,9 @@ The Benchmark tool is used to perform benchmark testing on a MindSpore Lite mode To use the Benchmark tool, you need to prepare the environment as follows: -- Compilation: Install compilation dependencies and perform compilation. The code of the Benchmark tool is stored in the `mindspore/lite/tools/benchmark` directory of the MindSpore source code. For details about the compilation operations, see the [Environment Requirements](https://www.mindspore.cn/lite/docs/en/master/deploy.html#id2) and [Compilation Example](https://www.mindspore.cn/lite/docs/en/master/deploy.html#id5) in the deployment document. +- Compilation: Install compilation dependencies and perform compilation. The code of the Benchmark tool is stored in the `mindspore/lite/tools/benchmark` directory of the MindSpore source code. For details about the compilation operations, see the [Environment Requirements](https://www.mindspore.cn/lite/docs/en/master/deploy.html#id2) and [Compilation Example](https://www.mindspore.cn/lite/docs/en/master/deploy.html#id5) in the compilation document. -- Run: Obtain the `Benchmark` tool and configure environment variables. For details, see [Output Description](https://www.mindspore.cn/lite/docs/zh-CN/master/deploy.html#id4) in the deployment document. +- Run: Obtain the `Benchmark` tool and configure environment variables. For details, see [Output Description](https://www.mindspore.cn/lite/docs/zh-CN/master/compile.html#id4) in the compilation document. ## Parameter Description diff --git a/lite/tutorials/source_en/use/converter_tool.md b/lite/tutorials/source_en/use/converter_tool.md index 1966a6a6..7afc0f0a 100644 --- a/lite/tutorials/source_en/use/converter_tool.md +++ b/lite/tutorials/source_en/use/converter_tool.md @@ -22,9 +22,9 @@ Currently, the following input formats are supported: MindSpore, TensorFlow Lite To use the MindSpore Lite model conversion tool, you need to prepare the environment as follows: -- Compilation: Install basic and additional compilation dependencies and perform compilation. The compilation version is x86_64. The code of the model conversion tool is stored in the `mindspore/lite/tools/converter` directory of the MindSpore source code. For details about the compilation operations, see the [Environment Requirements] (https://www.mindspore.cn/lite/docs/zh-CN/master/deploy.html#id2) and [Compilation Example] (https://www.mindspore.cn/lite/docs/zh-CN/master/deploy.html#id5) in the deployment document. +- Compilation: Install basic and additional compilation dependencies and perform compilation. The compilation version is x86_64. The code of the model conversion tool is stored in the `mindspore/lite/tools/converter` directory of the MindSpore source code. For details about the compilation operations, see the [Environment Requirements] (https://www.mindspore.cn/lite/docs/zh-CN/master/compile.html#id2) and [Compilation Example] (https://www.mindspore.cn/lite/docs/zh-CN/master/deploy.html#id5) in the compilation document. -- Run: Obtain the `converter` tool and configure environment variables by referring to [Output Description](https://www.mindspore.cn/lite/docs/zh-CN/master/deploy.html#id4) in the deployment document. +- Run: Obtain the `converter` tool and configure environment variables by referring to [Output Description](https://www.mindspore.cn/lite/docs/zh-CN/master/compile.html#id4) in the compilation document. ## Parameter Description @@ -53,7 +53,7 @@ The following describes the parameters in detail. ## Example -First, in the root directory of the source code, run the following command to perform compilation. For details, see `deploy.md`. +First, in the root directory of the source code, run the following command to perform compilation. For details, see `compile.md`. ```bash bash build.sh -I x86_64 ``` diff --git a/lite/tutorials/source_en/use/timeprofiler_tool.md b/lite/tutorials/source_en/use/timeprofiler_tool.md index de20d349..506da616 100644 --- a/lite/tutorials/source_en/use/timeprofiler_tool.md +++ b/lite/tutorials/source_en/use/timeprofiler_tool.md @@ -20,9 +20,9 @@ The TimeProfiler tool can be used to analyze the time consumption of forward inf To use the TimeProfiler tool, you need to prepare the environment as follows: -- Compilation: Install compilation dependencies and perform compilation. The code of the TimeProfiler tool is stored in the `mindspore/lite/tools/time_profiler` directory of the MindSpore source code. For details about the compilation operations, see the [Environment Requirements](https://www.mindspore.cn/lite/docs/en/master/deploy.html#id2) and [Compilation Example](https://www.mindspore.cn/lite/docs/en/master/deploy.html#id5) in the deployment document. +- Compilation: Install compilation dependencies and perform compilation. The code of the TimeProfiler tool is stored in the `mindspore/lite/tools/time_profiler` directory of the MindSpore source code. For details about the compilation operations, see the [Environment Requirements](https://www.mindspore.cn/lite/docs/en/master/compile.html#id2) and [Compilation Example](https://www.mindspore.cn/lite/docs/en/master/compile.html#id5) in the compilation document. -- Run: Obtain the `time_profiler` tool and configure environment variables by referring to [Output Description](https://www.mindspore.cn/lite/docs/zh-CN/master/deploy.html#id4) in the deployment document. +- Run: Obtain the `time_profiler` tool and configure environment variables by referring to [Output Description](https://www.mindspore.cn/lite/docs/zh-CN/master/compile.html#id4) in the compilation document. ## Parameter Description diff --git a/lite/tutorials/source_zh_cn/quick_start/quick_start.md b/lite/tutorials/source_zh_cn/quick_start/quick_start.md index d3d0e439..50cdfc2d 100644 --- a/lite/tutorials/source_zh_cn/quick_start/quick_start.md +++ b/lite/tutorials/source_zh_cn/quick_start/quick_start.md @@ -136,7 +136,7 @@ app ### 配置MindSpore Lite依赖项 -Android JNI层调用MindSpore C++ API时,需要相关库文件支持。可通过MindSpore Lite[源码编译](https://www.mindspore.cn/lite/docs/zh-CN/master/deploy.html)生成`libmindspore-lite.so`库文件,或直接下载MindSpore Lite提供的已编译完成的AMR64、ARM32、x86等[软件包](#TODO)。 +Android JNI层调用MindSpore C++ API时,需要相关库文件支持。可通过MindSpore Lite[源码编译](https://www.mindspore.cn/lite/docs/zh-CN/master/compile.html)生成`libmindspore-lite.so`库文件,或直接下载MindSpore Lite提供的已编译完成的AMR64、ARM32、x86等[软件包](#TODO)。 在Android Studio中将编译完成的`libmindspore-lite.so`库文件(可包含多个兼容架构),分别放置在APP工程的`app/libs/ARM64-V8a`(ARM64)或`app/libs/armeabi-v7a`(ARM32)目录下,并在应用的`build.gradle`文件中配置CMake编译支持,以及`arm64-v8a`和`armeabi-v7a`的编译支持。   diff --git a/lite/tutorials/source_zh_cn/use/benchmark_tool.md b/lite/tutorials/source_zh_cn/use/benchmark_tool.md index 8d699f44..d7c86f7a 100644 --- a/lite/tutorials/source_zh_cn/use/benchmark_tool.md +++ b/lite/tutorials/source_zh_cn/use/benchmark_tool.md @@ -22,9 +22,9 @@ Benchmark工具是一款可以对MindSpore Lite模型进行基准测试的工具 使用Benchmark工具,需要进行如下环境准备工作。 -- 编译:Benchmark工具代码在MindSpore源码的`mindspore/lite/tools/benchmark`目录中,参考部署文档中的[环境要求](https://www.mindspore.cn/lite/tutorial/zh-CN/master/deploy.html#id2)和[编译示例](https://www.mindspore.cn/lite/tutorial/zh-CN/master/deploy.html#id5),安装编译依赖基本项,并执行编译。 +- 编译:Benchmark工具代码在MindSpore源码的`mindspore/lite/tools/benchmark`目录中,参考部署文档中的[环境要求](https://www.mindspore.cn/lite/tutorial/zh-CN/master/compile.html#id2)和[编译示例](https://www.mindspore.cn/lite/tutorial/zh-CN/master/deploy.html#id5),安装编译依赖基本项,并执行编译。 -- 运行:参考部署文档中的[输出件说明](https://www.mindspore.cn/lite/tutorial/zh-CN/master/deploy.html#id4),获得`benchmark`工具,并配置环境变量。 +- 运行:参考部署文档中的[输出件说明](https://www.mindspore.cn/lite/tutorial/zh-CN/master/compile.html#id4),获得`benchmark`工具,并配置环境变量。 ## 参数说明 diff --git a/lite/tutorials/source_zh_cn/use/converter_tool.md b/lite/tutorials/source_zh_cn/use/converter_tool.md index bce4c3bb..42ea5d2b 100644 --- a/lite/tutorials/source_zh_cn/use/converter_tool.md +++ b/lite/tutorials/source_zh_cn/use/converter_tool.md @@ -29,9 +29,9 @@ MindSpore Lite提供离线转换模型功能的工具,支持多种类型的模 使用MindSpore Lite模型转换工具,需要进行如下环境准备工作。 -- 编译:模型转换工具代码在MindSpore源码的`mindspore/lite/tools/converter`目录中,参考部署文档中的[环境要求](https://www.mindspore.cn/lite/tutorial/zh-CN/master/deploy.html#id2)和[编译示例](https://www.mindspore.cn/lite/tutorial/zh-CN/master/deploy.html#id5),安装编译依赖基本项与模型转换工具所需附加项,并编译x86_64版本。 +- 编译:模型转换工具代码在MindSpore源码的`mindspore/lite/tools/converter`目录中,参考部署文档中的[环境要求](https://www.mindspore.cn/lite/tutorial/zh-CN/master/compile.html#id2)和[编译示例](https://www.mindspore.cn/lite/tutorial/zh-CN/master/deploy.html#id5),安装编译依赖基本项与模型转换工具所需附加项,并编译x86_64版本。 -- 运行:参考部署文档中的[输出件说明](https://www.mindspore.cn/lite/tutorial/zh-CN/master/deploy.html#id4),获得`converter`工具,并配置环境变量。 +- 运行:参考部署文档中的[输出件说明](https://www.mindspore.cn/lite/tutorial/zh-CN/master/compile.html#id4),获得`converter`工具,并配置环境变量。 ### 参数说明 @@ -59,7 +59,7 @@ MindSpore Lite提供离线转换模型功能的工具,支持多种类型的模 ### 使用示例 -首先,在源码根目录下,输入命令进行编译,可参考`deploy.md`。 +首先,在源码根目录下,输入命令进行编译,可参考`compile.md`。 ```bash bash build.sh -I x86_64 ``` @@ -121,9 +121,9 @@ bash build.sh -I x86_64 使用MindSpore Lite模型转换工具,需要进行如下环境准备工作。 -- 编译:模型转换工具代码在MindSpore源码的`mindspore/lite/tools/converter`目录中,参考部署文档中的[环境要求](https://www.mindspore.cn/lite/docs/zh-CN/master/deploy.html#id7)和[编译示例](https://www.mindspore.cn/lite/docs/zh-CN/master/deploy.html#id10),安装编译依赖基本项与模型转换工具所需附加项,并编译Windows版本。 +- 编译:模型转换工具代码在MindSpore源码的`mindspore/lite/tools/converter`目录中,参考部署文档中的[环境要求](https://www.mindspore.cn/lite/docs/zh-CN/master/compile.html#id7)和[编译示例](https://www.mindspore.cn/lite/docs/zh-CN/master/deploy.html#id10),安装编译依赖基本项与模型转换工具所需附加项,并编译Windows版本。 -- 运行:参考部署文档中的[输出件说明](https://www.mindspore.cn/lite/docs/zh-CN/master/deploy.html#id9),获得`converter`工具,并将MinGW/bin目录下的几个依赖文件(libgcc_s_seh-1.dll、libwinpthread-1.dll、libssp-0.dll、libstdc++-6.dll)拷贝至`converter`工具的主目录。 +- 运行:参考部署文档中的[输出件说明](https://www.mindspore.cn/lite/docs/zh-CN/master/compile.html#id9),获得`converter`工具,并将MinGW/bin目录下的几个依赖文件(libgcc_s_seh-1.dll、libwinpthread-1.dll、libssp-0.dll、libstdc++-6.dll)拷贝至`converter`工具的主目录。 ### 参数说明 @@ -132,7 +132,7 @@ bash build.sh -I x86_64 ### 使用示例 -首先,使用cmd工具在源码根目录下,输入命令进行编译,可参考`deploy.md`。 +首先,使用cmd工具在源码根目录下,输入命令进行编译,可参考`compile.md`。 ```bash call build.bat lite ``` diff --git a/lite/tutorials/source_zh_cn/use/runtime.md b/lite/tutorials/source_zh_cn/use/runtime.md index 36a5af6d..7444b593 100644 --- a/lite/tutorials/source_zh_cn/use/runtime.md +++ b/lite/tutorials/source_zh_cn/use/runtime.md @@ -354,6 +354,22 @@ if (out_tensor == nullptr) { } ``` +下面示例代码演示了使用`GetOutputByTensorName`接口获取输出`MSTensor`的方法: + +```cpp +// We can use GetOutputTensorNames method to get all name of output tensor of model which is in order. +auto tensor_names = this->GetOutputTensorNames(); +// Assume we have created a LiteSession instance named session before. +// Use output tensor name returned by GetOutputTensorNames as key +for (auto tensor_name : tensor_names) { + auto out_tensor = this->GetOutputByTensorName(tensor_name); + if (out_tensor == nullptr) { + std::cerr << "Output tensor is nullptr" << std::endl; + return -1; + } +} +``` + ## 获取版本号 MindSpore Lite提供了`Version`方法可以获取版本号,包含在`include/version.h`头文件中,调用该方法可以得到版本号字符串。 diff --git a/lite/tutorials/source_zh_cn/use/timeprofiler_tool.md b/lite/tutorials/source_zh_cn/use/timeprofiler_tool.md index f542dbf4..14bcfb00 100644 --- a/lite/tutorials/source_zh_cn/use/timeprofiler_tool.md +++ b/lite/tutorials/source_zh_cn/use/timeprofiler_tool.md @@ -20,9 +20,9 @@ TimeProfiler工具可以对MindSpore Lite模型网络层的前向推理进行耗 使用TimeProfiler工具,需要进行如下环境准备工作。 -- 编译:TimeProfiler工具代码在MindSpore源码的`mindspore/lite/tools/time_profiler`目录中,参考部署文档中的[环境要求](https://www.mindspore.cn/lite/tutorial/zh-CN/master/deploy.html#id2)和[编译示例](https://www.mindspore.cn/lite/tutorial/zh-CN/master/deploy.html#id5),安装编译依赖基本项,并执行编译。 +- 编译:TimeProfiler工具代码在MindSpore源码的`mindspore/lite/tools/time_profiler`目录中,参考部署文档中的[环境要求](https://www.mindspore.cn/lite/tutorial/zh-CN/master/compile.html#id2)和[编译示例](https://www.mindspore.cn/lite/tutorial/zh-CN/master/deploy.html#id5),安装编译依赖基本项,并执行编译。 -- 运行:参考部署文档中的[输出件说明](https://www.mindspore.cn/lite/tutorial/zh-CN/master/deploy.html#id4),获得`time_profiler`工具,并配置环境变量。 +- 运行:参考部署文档中的[输出件说明](https://www.mindspore.cn/lite/tutorial/zh-CN/master/compile.html#id4),获得`time_profiler`工具,并配置环境变量。 ## 参数说明 -- GitLab