diff --git a/lite/tutorials/source_en/build.md b/lite/tutorials/source_en/build.md index a6731a0c96e159fecdccda198efe50e7e17166f6..b172042cd38196c11cf77db85d35c6b2fe9330c3 100644 --- a/lite/tutorials/source_en/build.md +++ b/lite/tutorials/source_en/build.md @@ -1,14 +1,14 @@ -# Build +# Build MindSpore Lite -- [compilation](#compilation) +- [Build MindSpore Lite](#build-mindspore-lite) - [Linux Environment Compilation](#linux-environment-compilation) - [Environment Requirements](#environment-requirements) - [Compilation Options](#compilation-options) - [Compilation Example](#compilation-example) - [Output Description](#output-description) - - [Description of Converter's Directory Structure](#description-of-converter-directory-structure) + - [Description of Converter's Directory Structure](#description-of-converters-directory-structure) - [Description of Runtime and Other tools' Directory Structure](#description-of-runtime-and-other-tools-directory-structure) diff --git a/lite/tutorials/source_en/index.rst b/lite/tutorials/source_en/index.rst index 976ba9a3c6896dff60c0b32f7bc537c5f5437815..a4b514338d31177f19f1e146af18d192056dad7e 100644 --- a/lite/tutorials/source_en/index.rst +++ b/lite/tutorials/source_en/index.rst @@ -11,7 +11,6 @@ MindSpore Lite Tutorials :maxdepth: 1 :caption: Quick Start - build quick_start/quick_start .. toctree:: @@ -19,6 +18,7 @@ MindSpore Lite Tutorials :maxdepth: 1 :caption: Use + build use/converter_tool use/runtime use/benchmark_tool diff --git a/lite/tutorials/source_en/use/benchmark_tool.md b/lite/tutorials/source_en/use/benchmark_tool.md index 48151bda5ed26753441a911ff0832bdb1fe7c239..31dedaa6dfa5e0580ff798dc8ecbf1d6274a23cb 100644 --- a/lite/tutorials/source_en/use/benchmark_tool.md +++ b/lite/tutorials/source_en/use/benchmark_tool.md @@ -1,14 +1,14 @@ -# Benchmark Tool +# Perform Benchmark Testing -- [Benchmark Tool](#benchmark-tool) +- [Perform Benchmark Testing](#perform-benchmark-testing) - [Overview](#overview) - [Environment Preparation](#environment-preparation) - - [Parameter Description](#parameter-description) - [Example](#example) - [Performance Test](#performance-test) - [Accuracy Test](#accuracy-test) + - [Parameter Description](#parameter-description) @@ -26,36 +26,6 @@ To use the Benchmark tool, you need to prepare the environment as follows: - Run: Obtain the `Benchmark` tool and configure environment variables. For details, see [Output Description](https://www.mindspore.cn/lite/tutorial/en/master/build.html#output-description) in the build document. -## Parameter Description - -The command used for benchmark testing based on the compiled Benchmark tool is as follows: - -```bash -./benchmark [--modelPath=] [--accuracyThreshold=] - [--calibDataPath=] [--cpuBindMode=] - [--device=] [--help] [--inDataPath=] - [--inDataType=] [--loopCount=] - [--numThreads=] [--omModelPath=] - [--resizeDims=] [--warmUpLoopCount=] - [--fp16Priority=] -``` - -The following describes the parameters in detail. - -| Parameter | Attribute | Function | Parameter Type | Default Value | Value Range | -| ----------------- | ---- | ------------------------------------------------------------ | ------ | -------- | ---------------------------------- | -| `--modelPath=` | Mandatory | Specifies the file path of the MindSpore Lite model for benchmark testing. | String | Null | - | -| `--accuracyThreshold=` | Optional | Specifies the accuracy threshold. | Float | 0.5 | - | -| `--calibDataPath=` | Optional | Specifies the file path of the benchmark data. The benchmark data, as the comparison output of the tested model, is output from the forward inference of the tested model under other deep learning frameworks using the same input. | String | Null | - | -| `--cpuBindMode=` | Optional | Specifies the type of the CPU core bound to the model inference program. | Integer | 1 | −1: medium core
1: large core
0: not bound | -| `--device=` | Optional | Specifies the type of the device on which the model inference program runs. | String | CPU | CPU or GPU | -| `--help` | Optional | Displays the help information about the `benchmark` command. | - | - | - | -| `--inDataPath=` | Optional | Specifies the file path of the input data of the tested model. If this parameter is not set, a random value will be used. | String | Null | - | -| `--loopCount=` | Optional | Specifies the number of forward inference times of the tested model when the Benchmark tool is used for the benchmark testing. The value is a positive integer. | Integer | 10 | - | -| `--numThreads=` | Optional | Specifies the number of threads for running the model inference program. | Integer | 2 | - | -| `--warmUpLoopCount=` | Optional | Specifies the number of preheating inference times of the tested model before multiple rounds of the benchmark test are executed. | Integer | 3 | - | -| `--fp16Priority=` | Optional | Specifies whether the float16 operator is preferred. | Bool | false | true, false | - ## Example When using the Benchmark tool to perform benchmark testing on different MindSpore Lite models, you can set different parameters to implement different test functions. The testing is classified into performance test and accuracy test. @@ -92,3 +62,33 @@ Mean bias of node age_out : 0% Mean bias of all nodes: 0% ======================================================= ``` + +## Parameter Description + +The command used for benchmark testing based on the compiled Benchmark tool is as follows: + +```bash +./benchmark [--modelPath=] [--accuracyThreshold=] + [--calibDataPath=] [--cpuBindMode=] + [--device=] [--help] [--inDataPath=] + [--inDataType=] [--loopCount=] + [--numThreads=] [--omModelPath=] + [--resizeDims=] [--warmUpLoopCount=] + [--fp16Priority=] +``` + +The following describes the parameters in detail. + +| Parameter | Attribute | Function | Parameter Type | Default Value | Value Range | +| ----------------- | ---- | ------------------------------------------------------------ | ------ | -------- | ---------------------------------- | +| `--modelPath=` | Mandatory | Specifies the file path of the MindSpore Lite model for benchmark testing. | String | Null | - | +| `--accuracyThreshold=` | Optional | Specifies the accuracy threshold. | Float | 0.5 | - | +| `--calibDataPath=` | Optional | Specifies the file path of the benchmark data. The benchmark data, as the comparison output of the tested model, is output from the forward inference of the tested model under other deep learning frameworks using the same input. | String | Null | - | +| `--cpuBindMode=` | Optional | Specifies the type of the CPU core bound to the model inference program. | Integer | 1 | −1: medium core
1: large core
0: not bound | +| `--device=` | Optional | Specifies the type of the device on which the model inference program runs. | String | CPU | CPU or GPU | +| `--help` | Optional | Displays the help information about the `benchmark` command. | - | - | - | +| `--inDataPath=` | Optional | Specifies the file path of the input data of the tested model. If this parameter is not set, a random value will be used. | String | Null | - | +| `--loopCount=` | Optional | Specifies the number of forward inference times of the tested model when the Benchmark tool is used for the benchmark testing. The value is a positive integer. | Integer | 10 | - | +| `--numThreads=` | Optional | Specifies the number of threads for running the model inference program. | Integer | 2 | - | +| `--warmUpLoopCount=` | Optional | Specifies the number of preheating inference times of the tested model before multiple rounds of the benchmark test are executed. | Integer | 3 | - | +| `--fp16Priority=` | Optional | Specifies whether the float16 operator is preferred. | Bool | false | true, false | \ No newline at end of file diff --git a/lite/tutorials/source_en/use/converter_tool.md b/lite/tutorials/source_en/use/converter_tool.md index b699700af4e13bcc7b53644f5fe0f26943dff597..8a9a0d1c503687a7ac2b60e21e5ad56990c49c9a 100644 --- a/lite/tutorials/source_en/use/converter_tool.md +++ b/lite/tutorials/source_en/use/converter_tool.md @@ -1,13 +1,17 @@ -# Converter Tool +# Convert to MindSpore Lite -- [Model Conversion Tool](#model-conversion-tool) +- [Convert to MindSpore Lite](#convert-to-mindspore-lite) - [Overview](#overview) - - [Linux Environment Instructions](#linux-environment-instructions) + - [Linux Environment Instructions](#linux-environment-instructions) - [Environment Preparation](#environment-preparation) + - [Example](#example) + - [Windows Environment Instructions](#windows-environment-instructions) + - [Environment Preparation](#environment-preparation-1) - [Parameter Description](#parameter-description) - - [Example](#example) + - [Example](#example-1) + - [Parameter Description](#parameter-description-1) @@ -29,31 +33,6 @@ To use the MindSpore Lite model conversion tool, you need to prepare the environ - Run: Obtain the `converter` tool and configure environment variables by referring to [Output Description](https://www.mindspore.cn/lite/tutorial/en/master/build.html#output-description) in the build document. -### Parameter Description - -You can use `./converter_lite ` to complete the conversion. In addition, you can set multiple parameters as required. -You can enter `./converter_lite --help` to obtain help information in real time. - -The following describes the parameters in detail. - - -| Parameter | Mandatory or Not | Parameter Description | Value Range | Default Value | -| -------- | ------- | ----- | --- | ---- | -| `--help` | No | Prints all help information. | - | - | -| `--fmk=` | Yes | Original format of the input model. | MS, CAFFE, TFLITE, or ONNX | - | -| `--modelFile=` | Yes | Path of the input model. | - | - | -| `--outputFile=` | Yes | Path of the output model. (If the path does not exist, a directory will be automatically created.) The suffix `.ms` can be automatically generated. | - | - | -| `--weightFile=` | Yes (for Caffe models only) | Path of the weight file of the input model. | - | - | -| `--quantType=` | No | Sets the quant type of the model. | PostTraining: quantization after training
AwareTraining: perceptual quantization | - | -|`--inputInferenceType=` | No(supported by aware quant models only) | Sets the input data type of the converted model. If the type is different from the origin model, the convert tool will insert data type convert op before the model to make sure the input data type is same as the input of origin model. | FLOAT or INT8 | FLOAT | -|`--inferenceType= `| No(supported by aware quant models only) | Sets the output data type of the converted model. If the type is different from the origin model, the convert tool will insert data type convert op before the model to make sure the output data type is same as the input of origin model. | FLOAT or INT8 | FLOAT | -|`--stdDev=`| No(supported by aware quant models only) | Sets the standard deviation of the input data. | (0,+∞) | 128 | -|`--mean=`| No(supported by aware quant models only) | Sets the mean value of the input data. | [-128, 127] | -0.5 | - -> - The parameter name and parameter value are separated by an equal sign (=) and no space is allowed between them. -> - The Caffe model is divided into two files: model structure `*.prototxt`, corresponding to the `--modelFile` parameter; model weight `*.caffemodel`, corresponding to the `--weightFile` parameter - - ### Example First, in the root directory of the source code, run the following command to perform compilation. For details, see `compile.md`. @@ -179,3 +158,26 @@ Several common examples are selected below to illustrate the use of conversion c INFO [converter/converter.cc:190] Runconverter] CONVERTER RESULT: SUCCESS! ``` +### Parameter Description + +MindSpore Lite model conversion tool provides multiple parameters. +You can enter `./converter_lite --help` to obtain help information in real time. + +The following describes the parameters in detail. + + +| Parameter | Mandatory or Not | Parameter Description | Value Range | Default Value | +| -------- | ------- | ----- | --- | ---- | +| `--help` | No | Prints all help information. | - | - | +| `--fmk=` | Yes | Original format of the input model. | MS, CAFFE, TFLITE, or ONNX | - | +| `--modelFile=` | Yes | Path of the input model. | - | - | +| `--outputFile=` | Yes | Path of the output model. (If the path does not exist, a directory will be automatically created.) The suffix `.ms` can be automatically generated. | - | - | +| `--weightFile=` | Yes (for Caffe models only) | Path of the weight file of the input model. | - | - | +| `--quantType=` | No | Sets the quant type of the model. | PostTraining: quantization after training
AwareTraining: perceptual quantization | - | +|`--inputInferenceType=` | No(supported by aware quant models only) | Sets the input data type of the converted model. If the type is different from the origin model, the convert tool will insert data type convert op before the model to make sure the input data type is same as the input of origin model. | FLOAT or INT8 | FLOAT | +|`--inferenceType= `| No(supported by aware quant models only) | Sets the output data type of the converted model. If the type is different from the origin model, the convert tool will insert data type convert op before the model to make sure the output data type is same as the input of origin model. | FLOAT or INT8 | FLOAT | +|`--stdDev=`| No(supported by aware quant models only) | Sets the standard deviation of the input data. | (0,+∞) | 128 | +|`--mean=`| No(supported by aware quant models only) | Sets the mean value of the input data. | [-128, 127] | -0.5 | + +> - The parameter name and parameter value are separated by an equal sign (=) and no space is allowed between them. +> - The Caffe model is divided into two files: model structure `*.prototxt`, corresponding to the `--modelFile` parameter; model weight `*.caffemodel`, corresponding to the `--weightFile` parameter \ No newline at end of file diff --git a/lite/tutorials/source_en/use/runtime.md b/lite/tutorials/source_en/use/runtime.md index 6b12ed59755c3978fc455c44a337cbc1a6bcc025..c1df60ba2bbcdf57cbb16708f6186c0a4fcd3719 100644 --- a/lite/tutorials/source_en/use/runtime.md +++ b/lite/tutorials/source_en/use/runtime.md @@ -1,13 +1,13 @@ -# Runtime User Guide +# Use Runtime for Model Inference -- [Runtime User Guide](#runtime-user-guide) +- [Use Runtime for Model Inference](#use-runtime-for-model-inference) - [Overview](#overview) - [Reading Models](#reading-models) - [Session Creation](#session-creation) - [Creating Contexts](#creating-contexts) - - [Creating Sessions](#creating-sessions-1) + - [Creating Sessions](#creating-sessions) - [Example](#example) - [Graph Compilation](#graph-compilation) - [Variable Dimension](#variable-dimension) diff --git a/lite/tutorials/source_en/use/timeprofiler_tool.md b/lite/tutorials/source_en/use/timeprofiler_tool.md index c601481605864367b1ec178d687cb94728cd83d4..905afcf985f9c704a6b47ff92c5469ea89b335df 100644 --- a/lite/tutorials/source_en/use/timeprofiler_tool.md +++ b/lite/tutorials/source_en/use/timeprofiler_tool.md @@ -1,8 +1,8 @@ -# TimeProfiler Tool +# Use TimeProfiler to Analyze the Time Consumption -- [TimeProfiler Tool](#timeprofiler-tool) +- [Use TimeProfiler to Analyze the Time Consumption](#use-timeprofiler-to-analyze-the-time-consumption) - [Overview](#overview) - [Environment Preparation](#environment-preparation) - [Parameter Description](#parameter-description) diff --git a/lite/tutorials/source_zh_cn/build.md b/lite/tutorials/source_zh_cn/build.md index 0bf52616ba6c7327b2a0991a759b1ffa66d258c0..de73ee913b5d449057ed47362b613bc141ea3780 100644 --- a/lite/tutorials/source_zh_cn/build.md +++ b/lite/tutorials/source_zh_cn/build.md @@ -1,15 +1,15 @@ -# 编译 +# 编译MindSpore Lite -- [编译](#编译) +- [编译MindSpore Lite](#编译mindspore-lite) - [Linux环境编译](#linux环境编译) - [环境要求](#环境要求) - [编译选项](#编译选项) - - [编译示例](#编译示例) + - [编译示例](#编译示例) - [编译输出](#编译输出) - [模型转换工具converter目录结构说明](#模型转换工具converter目录结构说明) - - [模型推理框架runtime及其他工具目录结构说明](#模型推理框架runtime及其他工具目录结构说明) + - [模型推理框架runtime及其他工具目录结构说明](#模型推理框架runtime及其他工具目录结构说明) diff --git a/lite/tutorials/source_zh_cn/index.rst b/lite/tutorials/source_zh_cn/index.rst index dacac7e5e29e0158579425c43f5a3e375564bfda..eee68c7c17a6f4e9692b533db025cdae1f63b422 100644 --- a/lite/tutorials/source_zh_cn/index.rst +++ b/lite/tutorials/source_zh_cn/index.rst @@ -11,7 +11,6 @@ MindSpore端侧教程 :maxdepth: 1 :caption: 快速入门 - build quick_start/quick_start .. toctree:: @@ -19,8 +18,8 @@ MindSpore端侧教程 :maxdepth: 1 :caption: 使用指南 + build use/converter_tool use/runtime use/benchmark_tool use/timeprofiler_tool - use/post_training_quantization diff --git a/lite/tutorials/source_zh_cn/use/benchmark_tool.md b/lite/tutorials/source_zh_cn/use/benchmark_tool.md index 52ac1654a38de1495ebc8181539213255b5e7e43..60b41232bef8f7f9374ebb2e3a8f91fd12c0ec66 100644 --- a/lite/tutorials/source_zh_cn/use/benchmark_tool.md +++ b/lite/tutorials/source_zh_cn/use/benchmark_tool.md @@ -1,14 +1,14 @@ -# Benchmark工具 +# 使用Benchmark进行基准测试 -- [Benchmark工具](#benchmark工具) +- [使用Benchmark进行基准测试](#使用benchmark进行基准测试) - [概述](#概述) - [环境准备](#环境准备) - - [参数说明](#参数说明) - [使用示例](#使用示例) - [性能测试](#性能测试) - [精度测试](#精度测试) + - [参数说明](#参数说明) @@ -26,36 +26,6 @@ Benchmark工具是一款可以对MindSpore Lite模型进行基准测试的工具 - 运行:参考构建文档中的[编译输出](https://www.mindspore.cn/lite/tutorial/zh-CN/master/build.html#id5),获得`benchmark`工具,并配置环境变量。 -## 参数说明 - -使用编译好的Benchmark工具进行模型的基准测试时,其命令格式如下所示。 - -```bash -./benchmark [--modelPath=] [--accuracyThreshold=] - [--calibDataPath=] [--cpuBindMode=] - [--device=] [--help] [--inDataPath=] - [--inDataType=] [--loopCount=] - [--numThreads=] [--omModelPath=] - [--resizeDims=] [--warmUpLoopCount=] - [--fp16Priority=] -``` - -下面提供详细的参数说明。 - -| 参数名 | 属性 | 功能描述 | 参数类型 | 默认值 | 取值范围 | -| ----------------- | ---- | ------------------------------------------------------------ | ------ | -------- | ---------------------------------- | -| `--modelPath=` | 必选 | 指定需要进行基准测试的MindSpore Lite模型文件路径。 | String | null | - | -| `--accuracyThreshold=` | 可选 | 指定准确度阈值。 | Float | 0.5 | - | -| `--calibDataPath=` | 可选 | 指定标杆数据的文件路径。标杆数据作为该测试模型的对比输出,是该测试模型使用相同输入并由其它深度学习框架前向推理而来。 | String | null | - | -| `--cpuBindMode=` | 可选 | 指定模型推理程序运行时绑定的CPU核类型。 | Integer | 1 | -1:表示中核
1:表示大核
0:表示不绑定 | -| `--device=` | 可选 | 指定模型推理程序运行的设备类型。 | String | CPU | CPU、GPU | -| `--help` | 可选 | 显示`benchmark`命令的帮助信息。 | - | - | - | -| `--inDataPath=` | 可选 | 指定测试模型输入数据的文件路径。如果未设置,则使用随机输入。 | String | null | - | -| `--loopCount=` | 可选 | 指定Benchmark工具进行基准测试时,测试模型的前向推理运行次数,其值为正整数。 | Integer | 10 | - | -| `--numThreads=` | 可选 | 指定模型推理程序运行的线程数。 | Integer | 2 | - | -| `--warmUpLoopCount=` | 可选 | 指定测试模型在执行基准测试运行轮数前进行的模型预热推理次数。 | Integer | 3 | - | -| `--fp16Priority=` | 可选 | 指定是否优先使用float16算子。 | Bool | false | true, false | - ## 使用示例 对于不同的MindSpore Lite模型,在使用Benchmark工具对其进行基准测试时,可通过设置不同的参数,实现对其不同的测试功能。主要分为性能测试和精度测试。 @@ -92,3 +62,33 @@ Mean bias of node age_out : 0% Mean bias of all nodes: 0% ======================================================= ``` + +## 参数说明 + +使用编译好的Benchmark工具进行模型的基准测试时,其命令格式如下所示。 + +```bash +./benchmark [--modelPath=] [--accuracyThreshold=] + [--calibDataPath=] [--cpuBindMode=] + [--device=] [--help] [--inDataPath=] + [--inDataType=] [--loopCount=] + [--numThreads=] [--omModelPath=] + [--resizeDims=] [--warmUpLoopCount=] + [--fp16Priority=] +``` + +下面提供详细的参数说明。 + +| 参数名 | 属性 | 功能描述 | 参数类型 | 默认值 | 取值范围 | +| ----------------- | ---- | ------------------------------------------------------------ | ------ | -------- | ---------------------------------- | +| `--modelPath=` | 必选 | 指定需要进行基准测试的MindSpore Lite模型文件路径。 | String | null | - | +| `--accuracyThreshold=` | 可选 | 指定准确度阈值。 | Float | 0.5 | - | +| `--calibDataPath=` | 可选 | 指定标杆数据的文件路径。标杆数据作为该测试模型的对比输出,是该测试模型使用相同输入并由其它深度学习框架前向推理而来。 | String | null | - | +| `--cpuBindMode=` | 可选 | 指定模型推理程序运行时绑定的CPU核类型。 | Integer | 1 | -1:表示中核
1:表示大核
0:表示不绑定 | +| `--device=` | 可选 | 指定模型推理程序运行的设备类型。 | String | CPU | CPU、GPU | +| `--help` | 可选 | 显示`benchmark`命令的帮助信息。 | - | - | - | +| `--inDataPath=` | 可选 | 指定测试模型输入数据的文件路径。如果未设置,则使用随机输入。 | String | null | - | +| `--loopCount=` | 可选 | 指定Benchmark工具进行基准测试时,测试模型的前向推理运行次数,其值为正整数。 | Integer | 10 | - | +| `--numThreads=` | 可选 | 指定模型推理程序运行的线程数。 | Integer | 2 | - | +| `--warmUpLoopCount=` | 可选 | 指定测试模型在执行基准测试运行轮数前进行的模型预热推理次数。 | Integer | 3 | - | +| `--fp16Priority=` | 可选 | 指定是否优先使用float16算子。 | Bool | false | true, false | \ No newline at end of file diff --git a/lite/tutorials/source_zh_cn/use/converter_tool.md b/lite/tutorials/source_zh_cn/use/converter_tool.md index 8ad4fe72823c3ed9d73510ed86b7229a36f23c10..d92a46803b1390a44343b8d8bb785c1937dca3b0 100644 --- a/lite/tutorials/source_zh_cn/use/converter_tool.md +++ b/lite/tutorials/source_zh_cn/use/converter_tool.md @@ -1,13 +1,13 @@ -# 模型转换工具 +# 转换为MindSpore Lite模型 -- [模型转换工具](#模型转换工具) +- [转换为MindSpore Lite模型](#转换为mindspore-lite模型) - [概述](#概述) - [Linux环境使用说明](#linux环境使用说明) - [环境准备](#环境准备) - - [参数说明](#参数说明) - [使用示例](#使用示例) + - [参数说明](#参数说明) @@ -29,30 +29,6 @@ MindSpore Lite提供离线转换模型功能的工具,支持多种类型的模 - 运行:参考构建文档中的[编译输出](https://www.mindspore.cn/lite/tutorial/zh-CN/master/build.html#id5),获得`converter`工具,并配置环境变量。 -### 参数说明 - -使用`./converter_lite `即可完成转换,同时提供了多种参数设置,用户可根据需要来选择使用。 -此外,用户可输入`./converter_lite --help`获取实时帮助。 - -下面提供详细的参数说明。 - -| 参数 | 是否必选 | 参数说明 | 取值范围 | 默认值 | -| -------- | ------- | ----- | --- | ---- | -| `--help` | 否 | 打印全部帮助信息。 | - | - | -| `--fmk=` | 是 | 输入模型的原始格式。 | MS、CAFFE、TFLITE、ONNX | - | -| `--modelFile=` | 是 | 输入模型的路径。 | - | - | -| `--outputFile=` | 是 | 输出模型的路径(不存在时将自动创建目录),不需加后缀,可自动生成`.ms`后缀。 | - | - | -| `--weightFile=` | 转换Caffe模型时必选 | 输入模型weight文件的路径。 | - | - | -| `--quantType=` | 否 | 设置模型的量化类型。 | PostTraining:训练后量化
AwareTraining:感知量化。 | - | -|` --inputInferenceType=` | 否 | 设置感知量化模型输入数据类型,如果和原模型不一致则转换工具会在模型前插转换算子,使得转换后的模型输入类型和inputInferenceType保持一致。 | FLOAT、INT8 | FLOAT | -| `--inferenceType=` | 否 | 设置感知量化模型输出数据类型,如果和原模型不一致则转换工具会在模型前插转换算子,使得转换后的模型输出类型和inferenceType保持一致。 | FLOAT、INT8 | FLOAT | -| `--stdDev= `| 否 | 感知量化模型转换时用于设置输入数据的标准差。 | (0,+∞) | 128 | -| `--mean=` | 否 | 感知量化模型转换时用于设置输入数据的均值。 | [-128, 127] | -0.5 | - -> - 参数名和参数值之间用等号连接,中间不能有空格。 -> - Caffe模型一般分为两个文件:`*.prototxt`模型结构,对应`--modelFile`参数;`*.caffemodel`模型权值,对应`--weightFile`参数。 - - ### 使用示例 首先,在源码根目录下,输入命令进行编译,可参考`build.md`。 @@ -109,3 +85,27 @@ bash build.sh -I x86_64 ``` INFO [converter/converter.cc:190] Runconverter] CONVERTER RESULT: SUCCESS! ``` + +> 训练后量化示例请参考。 + +### 参数说明 + +MindSpore Lite模型转换工具提供了多种参数设置,用户可根据需要来选择使用。此外,用户可输入`./converter_lite --help`获取实时帮助。 + +下面提供详细的参数说明。 + +| 参数 | 是否必选 | 参数说明 | 取值范围 | 默认值 | +| -------- | ------- | ----- | --- | ---- | +| `--help` | 否 | 打印全部帮助信息。 | - | - | +| `--fmk=` | 是 | 输入模型的原始格式。 | MS、CAFFE、TFLITE、ONNX | - | +| `--modelFile=` | 是 | 输入模型的路径。 | - | - | +| `--outputFile=` | 是 | 输出模型的路径(不存在时将自动创建目录),不需加后缀,可自动生成`.ms`后缀。 | - | - | +| `--weightFile=` | 转换Caffe模型时必选 | 输入模型weight文件的路径。 | - | - | +| `--quantType=` | 否 | 设置模型的量化类型。 | PostTraining:训练后量化
AwareTraining:感知量化。 | - | +|` --inputInferenceType=` | 否 | 设置感知量化模型输入数据类型,如果和原模型不一致则转换工具会在模型前插转换算子,使得转换后的模型输入类型和inputInferenceType保持一致。 | FLOAT、INT8 | FLOAT | +| `--inferenceType=` | 否 | 设置感知量化模型输出数据类型,如果和原模型不一致则转换工具会在模型前插转换算子,使得转换后的模型输出类型和inferenceType保持一致。 | FLOAT、INT8 | FLOAT | +| `--stdDev= `| 否 | 感知量化模型转换时用于设置输入数据的标准差。 | (0,+∞) | 128 | +| `--mean=` | 否 | 感知量化模型转换时用于设置输入数据的均值。 | [-128, 127] | -0.5 | + +> - 参数名和参数值之间用等号连接,中间不能有空格。 +> - Caffe模型一般分为两个文件:`*.prototxt`模型结构,对应`--modelFile`参数;`*.caffemodel`模型权值,对应`--weightFile`参数。 \ No newline at end of file diff --git a/lite/tutorials/source_zh_cn/use/post_training_quantization.md b/lite/tutorials/source_zh_cn/use/post_training_quantization.md index 85727942f47b28b6befecfffa71a9dc29bee0ec4..839a7347ac9387f3b7de95852484447a65f1f75c 100644 --- a/lite/tutorials/source_zh_cn/use/post_training_quantization.md +++ b/lite/tutorials/source_zh_cn/use/post_training_quantization.md @@ -4,8 +4,9 @@ - [训练后量化](#训练后量化) - [概述](#概述) - - [参数说明](#参数说明) - [使用示例](#使用示例) + - [部分模型精度结果](#部分模型精度结果) + - [参数说明](#参数说明) @@ -19,22 +20,6 @@ ``` ./converter_lite --fmk=ModelType --modelFile=ModelFilePath --outputFile=ConvertedModelPath --quantType=PostTraining --config_file=config.cfg ``` -## 参数说明 - -| 参数 | 属性 | 功能描述 | 参数类型 | 默认值 | 取值范围 | -| -------- | ------- | ----- | ----- |----- | ----- | -| --quantType | 必选 | 设置为PostTraining,启用训练后量化 | String | - | 必须设置为PostTraining | -| --config_file | 必选 | 校准数据集配置文件路径 | String | - | - | - -为了计算激活值的量化参数,用户需要提供校准数据集。校准数据集最好来自真实推理场景,能表征模型的实际输入情况,数量在100个左右。 -校准数据集配置文件采用`key=value`的方式定义相关参数,需要配置的`key`如下: - -| 参数名 | 属性 | 功能描述 | 参数类型 | 默认值 | 取值范围 | -| -------- | ------- | ----- | ----- | ----- | ----- | -| image_path | 必选 | 存放校准数据集的目录 | String | - | 该目录存放可直接用于执行推理的输入数据。由于目前框架还不支持数据预处理,所有数据必须事先完成所需的转换,使得它们满足推理的输入要求。 | -| batch_count | 可选 | 使用的输入数目 | Integer | 100 | 大于0 | -| method_x | 可选 | 网络层输入输出数据量化算法 | String | KL | KL,MAX_MIN。 KL: 基于[KL散度](http://on-demand.gputechconf.com/gtc/2017/presentation/s7310-8-bit-inference-with-tensorrt.pdf)对数据范围作量化校准; MAX_MIN:基于最大值、最小值计算数据的量化参数。 在模型以及数据集比较较简单的情况下,推荐使用MAX_MIN | -| thread_num | 可选 | 使用校准数据集执行推理流程时的线程数 | Integer | 1 | 大于0 | ## 使用示例 @@ -61,3 +46,20 @@ | [Mobilenet_V1_1.0_224](https://storage.googleapis.com/download.tensorflow.org/models/mobilenet_v1_2018_02_22/mobilenet_v1_1.0_224.tgz) | [ImageNet](http://image-net.org/) | KL | 70.96% | 70.69% | 校准数据集随机选择ImageNet Validation数据集中的100张 | > 以上所有结果均在x86环境上测得。 + +## 参数说明 + +| 参数 | 属性 | 功能描述 | 参数类型 | 默认值 | 取值范围 | +| -------- | ------- | ----- | ----- |----- | ----- | +| --quantType | 必选 | 设置为PostTraining,启用训练后量化 | String | - | 必须设置为PostTraining | +| --config_file | 必选 | 校准数据集配置文件路径 | String | - | - | + +为了计算激活值的量化参数,用户需要提供校准数据集。校准数据集最好来自真实推理场景,能表征模型的实际输入情况,数量在100个左右。 +校准数据集配置文件采用`key=value`的方式定义相关参数,需要配置的`key`如下: + +| 参数名 | 属性 | 功能描述 | 参数类型 | 默认值 | 取值范围 | +| -------- | ------- | ----- | ----- | ----- | ----- | +| image_path | 必选 | 存放校准数据集的目录 | String | - | 该目录存放可直接用于执行推理的输入数据。由于目前框架还不支持数据预处理,所有数据必须事先完成所需的转换,使得它们满足推理的输入要求。 | +| batch_count | 可选 | 使用的输入数目 | Integer | 100 | 大于0 | +| method_x | 可选 | 网络层输入输出数据量化算法 | String | KL | KL,MAX_MIN。 KL: 基于[KL散度](http://on-demand.gputechconf.com/gtc/2017/presentation/s7310-8-bit-inference-with-tensorrt.pdf)对数据范围作量化校准; MAX_MIN:基于最大值、最小值计算数据的量化参数。 在模型以及数据集比较较简单的情况下,推荐使用MAX_MIN | +| thread_num | 可选 | 使用校准数据集执行推理流程时的线程数 | Integer | 1 | 大于0 | \ No newline at end of file diff --git a/lite/tutorials/source_zh_cn/use/runtime.md b/lite/tutorials/source_zh_cn/use/runtime.md index 8a6b43827a37a3651449bbaba65bdbe30bd618e1..e76cf000d0ccc6a87ecaecb771678faeaa5dac67 100644 --- a/lite/tutorials/source_zh_cn/use/runtime.md +++ b/lite/tutorials/source_zh_cn/use/runtime.md @@ -1,8 +1,8 @@ -# Runtime使用指南 +# 使用Runtime执行推理 -- [Runtime使用指南](#runtime使用指南) +- [使用Runtime执行推理](#使用runtime执行推理) - [概述](#概述) - [读取模型](#读取模型) - [创建会话](#创建会话) diff --git a/lite/tutorials/source_zh_cn/use/timeprofiler_tool.md b/lite/tutorials/source_zh_cn/use/timeprofiler_tool.md index 591de18f2720cb921ccd06bd9c3b8063d4f0290a..1b2e3b2fdeef56429cfe5c6a4850b3a141eb5bbd 100644 --- a/lite/tutorials/source_zh_cn/use/timeprofiler_tool.md +++ b/lite/tutorials/source_zh_cn/use/timeprofiler_tool.md @@ -1,12 +1,12 @@ -# TimeProfiler工具 +# 使用TimeProfiler进行耗时分析 -- [TimeProfiler工具](#timeprofiler工具) +- [使用TimeProfiler进行耗时分析](#使用timeprofiler进行耗时分析) - [概述](#概述) - [环境准备](#环境准备) - - [参数说明](#参数说明) - [使用示例](#使用示例) + - [参数说明](#参数说明) @@ -24,26 +24,6 @@ TimeProfiler工具可以对MindSpore Lite模型网络层的前向推理进行耗 - 运行:参考部署文档中的[编译输出](https://www.mindspore.cn/lite/tutorial/zh-CN/master/build.html#id5),获得`timeprofile`工具,并配置环境变量。 -## 参数说明 - -使用编译好的TimeProfiler工具进行模型网络层耗时分析时,其命令格式如下所示。 - -```bash -./timeprofile --modelPath= [--help] [--loopCount=] [--numThreads=] [--cpuBindMode=] [--inDataPath=] [--fp16Priority=] -``` - -下面提供详细的参数说明。 - -| 参数名 | 属性 | 功能描述 | 参数类型 | 默认值 | 取值范围 | -| ----------------- | ---- | ------------------------------------------------------------ | ------ | -------- | ---------------------------------- | -| `--help` | 可选 | 显示`timeprofiler`命令的帮助信息。 | - | - | - | -| `--modelPath= ` | 必选 | 指定需要进行耗时分析的MindSpore Lite模型的文件路径。 | String | null | - | -| `--loopCount=` | 可选 | 指定TimeProfiler工具进行耗时分析时,模型推理的运行次数,其值为正整数。 | Integer | 100 | - | -| `--numThreads=` | 可选 | 指定模型推理程序运行的线程数。 | Integer | 4 | - | -| `--cpuBindMode=` | 可选 | 指定模型推理程序运行时绑定的CPU核类型。 | Integer | 1 | -1:表示中核
1:表示大核
0:表示不绑定 | -| `--inDataPath=` | 可选 | 指定模型输入数据的文件路径。如果未设置,则使用随机输入。 | String | null | - | -| `--fp16Priority=` | 可选 | 指定是否优先使用float16算子。 | Bool | false | true, false | - ## 使用示例 使用TimeProfiler对`test_timeprofiler.ms`模型的网络层进行耗时分析,并且设置模型推理循环运行次数为10,则其命令代码如下: @@ -90,4 +70,24 @@ StridedSlice 0.009700 0.003529 10 0.097000 total time : 2.90800 ms, kernel cost : 2.74851 ms ----------------------------------------------------------------------------------------- -``` \ No newline at end of file +``` + +## 参数说明 + +使用编译好的TimeProfiler工具进行模型网络层耗时分析时,其命令格式如下所示。 + +```bash +./timeprofile --modelPath= [--help] [--loopCount=] [--numThreads=] [--cpuBindMode=] [--inDataPath=] [--fp16Priority=] +``` + +下面提供详细的参数说明。 + +| 参数名 | 属性 | 功能描述 | 参数类型 | 默认值 | 取值范围 | +| ----------------- | ---- | ------------------------------------------------------------ | ------ | -------- | ---------------------------------- | +| `--help` | 可选 | 显示`timeprofiler`命令的帮助信息。 | - | - | - | +| `--modelPath= ` | 必选 | 指定需要进行耗时分析的MindSpore Lite模型的文件路径。 | String | null | - | +| `--loopCount=` | 可选 | 指定TimeProfiler工具进行耗时分析时,模型推理的运行次数,其值为正整数。 | Integer | 100 | - | +| `--numThreads=` | 可选 | 指定模型推理程序运行的线程数。 | Integer | 4 | - | +| `--cpuBindMode=` | 可选 | 指定模型推理程序运行时绑定的CPU核类型。 | Integer | 1 | -1:表示中核
1:表示大核
0:表示不绑定 | +| `--inDataPath=` | 可选 | 指定模型输入数据的文件路径。如果未设置,则使用随机输入。 | String | null | - | +| `--fp16Priority=` | 可选 | 指定是否优先使用float16算子。 | Bool | false | true, false | \ No newline at end of file