提交 20142a92 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!918 update lite toc

Merge pull request !918 from TingWang/update-lite
# Build
# Build MindSpore Lite
<!-- TOC -->
- [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)
<!-- /TOC -->
......
......@@ -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
......
# Benchmark Tool
# Perform Benchmark Testing
<!-- TOC -->
- [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)
<!-- /TOC -->
......@@ -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=<MODELPATH>] [--accuracyThreshold=<ACCURACYTHRESHOLD>]
[--calibDataPath=<CALIBDATAPATH>] [--cpuBindMode=<CPUBINDMODE>]
[--device=<DEVICE>] [--help] [--inDataPath=<INDATAPATH>]
[--inDataType=<INDATATYPE>] [--loopCount=<LOOPCOUNT>]
[--numThreads=<NUMTHREADS>] [--omModelPath=<OMMODELPATH>]
[--resizeDims=<RESIZEDIMS>] [--warmUpLoopCount=<WARMUPLOOPCOUNT>]
[--fp16Priority=<FP16PRIORITY>]
```
The following describes the parameters in detail.
| Parameter | Attribute | Function | Parameter Type | Default Value | Value Range |
| ----------------- | ---- | ------------------------------------------------------------ | ------ | -------- | ---------------------------------- |
| `--modelPath=<MODELPATH>` | Mandatory | Specifies the file path of the MindSpore Lite model for benchmark testing. | String | Null | - |
| `--accuracyThreshold=<ACCURACYTHRESHOLD>` | Optional | Specifies the accuracy threshold. | Float | 0.5 | - |
| `--calibDataPath=<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=<CPUBINDMODE>` | Optional | Specifies the type of the CPU core bound to the model inference program. | Integer | 1 | −1: medium core<br/>1: large core<br/>0: not bound |
| `--device=<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=<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=<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=<NUMTHREADS>` | Optional | Specifies the number of threads for running the model inference program. | Integer | 2 | - |
| `--warmUpLoopCount=<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=<FP16PIORITY>` | 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=<MODELPATH>] [--accuracyThreshold=<ACCURACYTHRESHOLD>]
[--calibDataPath=<CALIBDATAPATH>] [--cpuBindMode=<CPUBINDMODE>]
[--device=<DEVICE>] [--help] [--inDataPath=<INDATAPATH>]
[--inDataType=<INDATATYPE>] [--loopCount=<LOOPCOUNT>]
[--numThreads=<NUMTHREADS>] [--omModelPath=<OMMODELPATH>]
[--resizeDims=<RESIZEDIMS>] [--warmUpLoopCount=<WARMUPLOOPCOUNT>]
[--fp16Priority=<FP16PRIORITY>]
```
The following describes the parameters in detail.
| Parameter | Attribute | Function | Parameter Type | Default Value | Value Range |
| ----------------- | ---- | ------------------------------------------------------------ | ------ | -------- | ---------------------------------- |
| `--modelPath=<MODELPATH>` | Mandatory | Specifies the file path of the MindSpore Lite model for benchmark testing. | String | Null | - |
| `--accuracyThreshold=<ACCURACYTHRESHOLD>` | Optional | Specifies the accuracy threshold. | Float | 0.5 | - |
| `--calibDataPath=<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=<CPUBINDMODE>` | Optional | Specifies the type of the CPU core bound to the model inference program. | Integer | 1 | −1: medium core<br/>1: large core<br/>0: not bound |
| `--device=<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=<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=<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=<NUMTHREADS>` | Optional | Specifies the number of threads for running the model inference program. | Integer | 2 | - |
| `--warmUpLoopCount=<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=<FP16PIORITY>` | Optional | Specifies whether the float16 operator is preferred. | Bool | false | true, false |
\ No newline at end of file
# Converter Tool
# Convert to MindSpore Lite
<!-- TOC -->
- [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)
<!-- /TOC -->
......@@ -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=<FMK>` | Yes | Original format of the input model. | MS, CAFFE, TFLITE, or ONNX | - |
| `--modelFile=<MODELFILE>` | Yes | Path of the input model. | - | - |
| `--outputFile=<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=<WEIGHTFILE>` | Yes (for Caffe models only) | Path of the weight file of the input model. | - | - |
| `--quantType=<QUANTTYPE>` | No | Sets the quant type of the model. | PostTraining: quantization after training <br>AwareTraining: perceptual quantization | - |
|`--inputInferenceType=<INPUTRINFERENCETYPE>` | 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=<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=<STDDEV>`| No(supported by aware quant models only) | Sets the standard deviation of the input data. | (0,+∞) | 128 |
|`--mean=<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=<FMK>` | Yes | Original format of the input model. | MS, CAFFE, TFLITE, or ONNX | - |
| `--modelFile=<MODELFILE>` | Yes | Path of the input model. | - | - |
| `--outputFile=<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=<WEIGHTFILE>` | Yes (for Caffe models only) | Path of the weight file of the input model. | - | - |
| `--quantType=<QUANTTYPE>` | No | Sets the quant type of the model. | PostTraining: quantization after training <br>AwareTraining: perceptual quantization | - |
|`--inputInferenceType=<INPUTRINFERENCETYPE>` | 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=<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=<STDDEV>`| No(supported by aware quant models only) | Sets the standard deviation of the input data. | (0,+∞) | 128 |
|`--mean=<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
# Runtime User Guide
# Use Runtime for Model Inference
<!-- TOC -->
- [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)
......
# TimeProfiler Tool
# Use TimeProfiler to Analyze the Time Consumption
<!-- TOC -->
- [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)
......
# 编译
# 编译MindSpore Lite
<!-- TOC -->
- [编译](#编译)
- [编译MindSpore Lite](#编译mindspore-lite)
- [Linux环境编译](#linux环境编译)
- [环境要求](#环境要求)
- [编译选项](#编译选项)
- [编译示例](#编译示例)
- [编译示例](#编译示例)
- [编译输出](#编译输出)
- [模型转换工具converter目录结构说明](#模型转换工具converter目录结构说明)
- [模型推理框架runtime及其他工具目录结构说明](#模型推理框架runtime及其他工具目录结构说明)
- [模型推理框架runtime及其他工具目录结构说明](#模型推理框架runtime及其他工具目录结构说明)
<!-- /TOC -->
......
......@@ -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
# Benchmark工具
# 使用Benchmark进行基准测试
<!-- TOC -->
- [Benchmark工具](#benchmark工具)
- [使用Benchmark进行基准测试](#使用benchmark进行基准测试)
- [概述](#概述)
- [环境准备](#环境准备)
- [参数说明](#参数说明)
- [使用示例](#使用示例)
- [性能测试](#性能测试)
- [精度测试](#精度测试)
- [参数说明](#参数说明)
<!-- /TOC -->
......@@ -26,36 +26,6 @@ Benchmark工具是一款可以对MindSpore Lite模型进行基准测试的工具
- 运行:参考构建文档中的[编译输出](https://www.mindspore.cn/lite/tutorial/zh-CN/master/build.html#id5),获得`benchmark`工具,并配置环境变量。
## 参数说明
使用编译好的Benchmark工具进行模型的基准测试时,其命令格式如下所示。
```bash
./benchmark [--modelPath=<MODELPATH>] [--accuracyThreshold=<ACCURACYTHRESHOLD>]
[--calibDataPath=<CALIBDATAPATH>] [--cpuBindMode=<CPUBINDMODE>]
[--device=<DEVICE>] [--help] [--inDataPath=<INDATAPATH>]
[--inDataType=<INDATATYPE>] [--loopCount=<LOOPCOUNT>]
[--numThreads=<NUMTHREADS>] [--omModelPath=<OMMODELPATH>]
[--resizeDims=<RESIZEDIMS>] [--warmUpLoopCount=<WARMUPLOOPCOUNT>]
[--fp16Priority=<FP16PRIORITY>]
```
下面提供详细的参数说明。
| 参数名 | 属性 | 功能描述 | 参数类型 | 默认值 | 取值范围 |
| ----------------- | ---- | ------------------------------------------------------------ | ------ | -------- | ---------------------------------- |
| `--modelPath=<MODELPATH>` | 必选 | 指定需要进行基准测试的MindSpore Lite模型文件路径。 | String | null | - |
| `--accuracyThreshold=<ACCURACYTHRESHOLD>` | 可选 | 指定准确度阈值。 | Float | 0.5 | - |
| `--calibDataPath=<CALIBDATAPATH>` | 可选 | 指定标杆数据的文件路径。标杆数据作为该测试模型的对比输出,是该测试模型使用相同输入并由其它深度学习框架前向推理而来。 | String | null | - |
| `--cpuBindMode=<CPUBINDMODE>` | 可选 | 指定模型推理程序运行时绑定的CPU核类型。 | Integer | 1 | -1:表示中核<br/>1:表示大核<br/>0:表示不绑定 |
| `--device=<DEVICE>` | 可选 | 指定模型推理程序运行的设备类型。 | String | CPU | CPU、GPU |
| `--help` | 可选 | 显示`benchmark`命令的帮助信息。 | - | - | - |
| `--inDataPath=<INDATAPATH>` | 可选 | 指定测试模型输入数据的文件路径。如果未设置,则使用随机输入。 | String | null | - |
| `--loopCount=<LOOPCOUNT>` | 可选 | 指定Benchmark工具进行基准测试时,测试模型的前向推理运行次数,其值为正整数。 | Integer | 10 | - |
| `--numThreads=<NUMTHREADS>` | 可选 | 指定模型推理程序运行的线程数。 | Integer | 2 | - |
| `--warmUpLoopCount=<WARMUPLOOPCOUNT>` | 可选 | 指定测试模型在执行基准测试运行轮数前进行的模型预热推理次数。 | Integer | 3 | - |
| `--fp16Priority=<FP16PIORITY>` | 可选 | 指定是否优先使用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=<MODELPATH>] [--accuracyThreshold=<ACCURACYTHRESHOLD>]
[--calibDataPath=<CALIBDATAPATH>] [--cpuBindMode=<CPUBINDMODE>]
[--device=<DEVICE>] [--help] [--inDataPath=<INDATAPATH>]
[--inDataType=<INDATATYPE>] [--loopCount=<LOOPCOUNT>]
[--numThreads=<NUMTHREADS>] [--omModelPath=<OMMODELPATH>]
[--resizeDims=<RESIZEDIMS>] [--warmUpLoopCount=<WARMUPLOOPCOUNT>]
[--fp16Priority=<FP16PRIORITY>]
```
下面提供详细的参数说明。
| 参数名 | 属性 | 功能描述 | 参数类型 | 默认值 | 取值范围 |
| ----------------- | ---- | ------------------------------------------------------------ | ------ | -------- | ---------------------------------- |
| `--modelPath=<MODELPATH>` | 必选 | 指定需要进行基准测试的MindSpore Lite模型文件路径。 | String | null | - |
| `--accuracyThreshold=<ACCURACYTHRESHOLD>` | 可选 | 指定准确度阈值。 | Float | 0.5 | - |
| `--calibDataPath=<CALIBDATAPATH>` | 可选 | 指定标杆数据的文件路径。标杆数据作为该测试模型的对比输出,是该测试模型使用相同输入并由其它深度学习框架前向推理而来。 | String | null | - |
| `--cpuBindMode=<CPUBINDMODE>` | 可选 | 指定模型推理程序运行时绑定的CPU核类型。 | Integer | 1 | -1:表示中核<br/>1:表示大核<br/>0:表示不绑定 |
| `--device=<DEVICE>` | 可选 | 指定模型推理程序运行的设备类型。 | String | CPU | CPU、GPU |
| `--help` | 可选 | 显示`benchmark`命令的帮助信息。 | - | - | - |
| `--inDataPath=<INDATAPATH>` | 可选 | 指定测试模型输入数据的文件路径。如果未设置,则使用随机输入。 | String | null | - |
| `--loopCount=<LOOPCOUNT>` | 可选 | 指定Benchmark工具进行基准测试时,测试模型的前向推理运行次数,其值为正整数。 | Integer | 10 | - |
| `--numThreads=<NUMTHREADS>` | 可选 | 指定模型推理程序运行的线程数。 | Integer | 2 | - |
| `--warmUpLoopCount=<WARMUPLOOPCOUNT>` | 可选 | 指定测试模型在执行基准测试运行轮数前进行的模型预热推理次数。 | Integer | 3 | - |
| `--fp16Priority=<FP16PIORITY>` | 可选 | 指定是否优先使用float16算子。 | Bool | false | true, false |
\ No newline at end of file
# 模型转换工具
# 转换为MindSpore Lite模型
<!-- TOC -->
- [模型转换工具](#模型转换工具)
- [转换为MindSpore Lite模型](#转换为mindspore-lite模型)
- [概述](#概述)
- [Linux环境使用说明](#linux环境使用说明)
- [环境准备](#环境准备)
- [参数说明](#参数说明)
- [使用示例](#使用示例)
- [参数说明](#参数说明)
<!-- /TOC -->
......@@ -29,30 +29,6 @@ MindSpore Lite提供离线转换模型功能的工具,支持多种类型的模
- 运行:参考构建文档中的[编译输出](https://www.mindspore.cn/lite/tutorial/zh-CN/master/build.html#id5),获得`converter`工具,并配置环境变量。
### 参数说明
使用`./converter_lite <args>`即可完成转换,同时提供了多种参数设置,用户可根据需要来选择使用。
此外,用户可输入`./converter_lite --help`获取实时帮助。
下面提供详细的参数说明。
| 参数 | 是否必选 | 参数说明 | 取值范围 | 默认值 |
| -------- | ------- | ----- | --- | ---- |
| `--help` | 否 | 打印全部帮助信息。 | - | - |
| `--fmk=<FMK>` | 是 | 输入模型的原始格式。 | MS、CAFFE、TFLITE、ONNX | - |
| `--modelFile=<MODELFILE>` | 是 | 输入模型的路径。 | - | - |
| `--outputFile=<OUTPUTFILE>` | 是 | 输出模型的路径(不存在时将自动创建目录),不需加后缀,可自动生成`.ms`后缀。 | - | - |
| `--weightFile=<WEIGHTFILE>` | 转换Caffe模型时必选 | 输入模型weight文件的路径。 | - | - |
| `--quantType=<QUANTTYPE>` | 否 | 设置模型的量化类型。 | PostTraining:训练后量化<br>AwareTraining:感知量化。 | - |
|` --inputInferenceType=<INPUTINFERENCETYPE>` | 否 | 设置感知量化模型输入数据类型,如果和原模型不一致则转换工具会在模型前插转换算子,使得转换后的模型输入类型和inputInferenceType保持一致。 | FLOAT、INT8 | FLOAT |
| `--inferenceType=<INFERENCETYPE>` | 否 | 设置感知量化模型输出数据类型,如果和原模型不一致则转换工具会在模型前插转换算子,使得转换后的模型输出类型和inferenceType保持一致。 | FLOAT、INT8 | FLOAT |
| `--stdDev=<STDDEV> `| 否 | 感知量化模型转换时用于设置输入数据的标准差。 | (0,+∞) | 128 |
| `--mean=<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!
```
> 训练后量化示例请参考<https://www.mindspore.cn/lite/tutorial/zh-CN/master/use/post_training_quantization.html>。
### 参数说明
MindSpore Lite模型转换工具提供了多种参数设置,用户可根据需要来选择使用。此外,用户可输入`./converter_lite --help`获取实时帮助。
下面提供详细的参数说明。
| 参数 | 是否必选 | 参数说明 | 取值范围 | 默认值 |
| -------- | ------- | ----- | --- | ---- |
| `--help` | 否 | 打印全部帮助信息。 | - | - |
| `--fmk=<FMK>` | 是 | 输入模型的原始格式。 | MS、CAFFE、TFLITE、ONNX | - |
| `--modelFile=<MODELFILE>` | 是 | 输入模型的路径。 | - | - |
| `--outputFile=<OUTPUTFILE>` | 是 | 输出模型的路径(不存在时将自动创建目录),不需加后缀,可自动生成`.ms`后缀。 | - | - |
| `--weightFile=<WEIGHTFILE>` | 转换Caffe模型时必选 | 输入模型weight文件的路径。 | - | - |
| `--quantType=<QUANTTYPE>` | 否 | 设置模型的量化类型。 | PostTraining:训练后量化<br>AwareTraining:感知量化。 | - |
|` --inputInferenceType=<INPUTINFERENCETYPE>` | 否 | 设置感知量化模型输入数据类型,如果和原模型不一致则转换工具会在模型前插转换算子,使得转换后的模型输入类型和inputInferenceType保持一致。 | FLOAT、INT8 | FLOAT |
| `--inferenceType=<INFERENCETYPE>` | 否 | 设置感知量化模型输出数据类型,如果和原模型不一致则转换工具会在模型前插转换算子,使得转换后的模型输出类型和inferenceType保持一致。 | FLOAT、INT8 | FLOAT |
| `--stdDev=<STDDEV> `| 否 | 感知量化模型转换时用于设置输入数据的标准差。 | (0,+∞) | 128 |
| `--mean=<MEAN>` | 否 | 感知量化模型转换时用于设置输入数据的均值。 | [-128, 127] | -0.5 |
> - 参数名和参数值之间用等号连接,中间不能有空格。
> - Caffe模型一般分为两个文件:`*.prototxt`模型结构,对应`--modelFile`参数;`*.caffemodel`模型权值,对应`--weightFile`参数。
\ No newline at end of file
......@@ -4,8 +4,9 @@
- [训练后量化](#训练后量化)
- [概述](#概述)
- [参数说明](#参数说明)
- [使用示例](#使用示例)
- [部分模型精度结果](#部分模型精度结果)
- [参数说明](#参数说明)
<!-- /TOC -->
......@@ -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
# Runtime使用指南
# 使用Runtime执行推理
<!-- TOC -->
- [Runtime使用指南](#runtime使用指南)
- [使用Runtime执行推理](#使用runtime执行推理)
- [概述](#概述)
- [读取模型](#读取模型)
- [创建会话](#创建会话)
......
# TimeProfiler工具
# 使用TimeProfiler进行耗时分析
<!-- TOC -->
- [TimeProfiler工具](#timeprofiler工具)
- [使用TimeProfiler进行耗时分析](#使用timeprofiler进行耗时分析)
- [概述](#概述)
- [环境准备](#环境准备)
- [参数说明](#参数说明)
- [使用示例](#使用示例)
- [参数说明](#参数说明)
<!-- /TOC -->
......@@ -24,26 +24,6 @@ TimeProfiler工具可以对MindSpore Lite模型网络层的前向推理进行耗
- 运行:参考部署文档中的[编译输出](https://www.mindspore.cn/lite/tutorial/zh-CN/master/build.html#id5),获得`timeprofile`工具,并配置环境变量。
## 参数说明
使用编译好的TimeProfiler工具进行模型网络层耗时分析时,其命令格式如下所示。
```bash
./timeprofile --modelPath=<MODELPATH> [--help] [--loopCount=<LOOPCOUNT>] [--numThreads=<NUMTHREADS>] [--cpuBindMode=<CPUBINDMODE>] [--inDataPath=<INDATAPATH>] [--fp16Priority=<FP16PRIORITY>]
```
下面提供详细的参数说明。
| 参数名 | 属性 | 功能描述 | 参数类型 | 默认值 | 取值范围 |
| ----------------- | ---- | ------------------------------------------------------------ | ------ | -------- | ---------------------------------- |
| `--help` | 可选 | 显示`timeprofiler`命令的帮助信息。 | - | - | - |
| `--modelPath=<MODELPATH> ` | 必选 | 指定需要进行耗时分析的MindSpore Lite模型的文件路径。 | String | null | - |
| `--loopCount=<LOOPCOUNT>` | 可选 | 指定TimeProfiler工具进行耗时分析时,模型推理的运行次数,其值为正整数。 | Integer | 100 | - |
| `--numThreads=<NUMTHREADS>` | 可选 | 指定模型推理程序运行的线程数。 | Integer | 4 | - |
| `--cpuBindMode=<CPUBINDMODE>` | 可选 | 指定模型推理程序运行时绑定的CPU核类型。 | Integer | 1 | -1:表示中核<br>1:表示大核<br>0:表示不绑定 |
| `--inDataPath=<INDATAPATH>` | 可选 | 指定模型输入数据的文件路径。如果未设置,则使用随机输入。 | String | null | - |
| `--fp16Priority=<FP16PIORITY>` | 可选 | 指定是否优先使用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=<MODELPATH> [--help] [--loopCount=<LOOPCOUNT>] [--numThreads=<NUMTHREADS>] [--cpuBindMode=<CPUBINDMODE>] [--inDataPath=<INDATAPATH>] [--fp16Priority=<FP16PRIORITY>]
```
下面提供详细的参数说明。
| 参数名 | 属性 | 功能描述 | 参数类型 | 默认值 | 取值范围 |
| ----------------- | ---- | ------------------------------------------------------------ | ------ | -------- | ---------------------------------- |
| `--help` | 可选 | 显示`timeprofiler`命令的帮助信息。 | - | - | - |
| `--modelPath=<MODELPATH> ` | 必选 | 指定需要进行耗时分析的MindSpore Lite模型的文件路径。 | String | null | - |
| `--loopCount=<LOOPCOUNT>` | 可选 | 指定TimeProfiler工具进行耗时分析时,模型推理的运行次数,其值为正整数。 | Integer | 100 | - |
| `--numThreads=<NUMTHREADS>` | 可选 | 指定模型推理程序运行的线程数。 | Integer | 4 | - |
| `--cpuBindMode=<CPUBINDMODE>` | 可选 | 指定模型推理程序运行时绑定的CPU核类型。 | Integer | 1 | -1:表示中核<br>1:表示大核<br>0:表示不绑定 |
| `--inDataPath=<INDATAPATH>` | 可选 | 指定模型输入数据的文件路径。如果未设置,则使用随机输入。 | String | null | - |
| `--fp16Priority=<FP16PIORITY>` | 可选 | 指定是否优先使用float16算子。 | Bool | false | true, false |
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册