提交 3c4ebe5b 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!943 add index of docs

Merge pull request !943 from TingWang/add-lite-api
# mindspore::lite
## Allocator
Allocator defines a memory pool for dynamic memory malloc and memory free.
## Context
Context is defined for holding environment variables during runtime.
**Constructors & Destructors**
```
Context()
```
Constructor of MindSpore Lite Context using default value for parameters.
```
Context(int thread_num, std::shared_ptr< Allocator > allocator, DeviceContext device_ctx)
```
Constructor of MindSpore Lite Context using input value for parameters.
- Parameters
- `thread_num`: Define the work thread number during the runtime.
- `allocator`: Define the allocator for malloc.
- `device_ctx`: Define device information during the runtime.
- Returns
The instance of MindSpore Lite Context.
```
~Context()
```
Destructor of MindSpore Lite Context.
**Public Attributes**
```
float16_priority
```
A **bool** value. Defaults to **false**. Prior enable float16 inference.
```
device_ctx_{DT_CPU}
```
A **DeviceContext** struct.
```
thread_num_
```
An **int** value. Defaults to **2**. Thread number config for thread pool.
```
allocator
```
A **std::shared_ptr<Allocator>** pointer.
```
cpu_bind_mode_
```
A **CpuBindMode** enum variable. Defaults to **MID_CPU**.
## CpuBindMode
An **enum** type. CpuBindMode defined for holding bind cpu strategy argument.
**Attributes**
```
MID_CPU = -1
```
Bind middle cpu first.
```
HIGHER_CPU = 1
```
Bind higher cpu first.
```
NO_BIND = 0
```
No bind.
## DeviceType
An **enum** type. DeviceType defined for holding user's preferred backend.
**Attributes**
```
DT_CPU = -1
```
CPU device type.
```
DT_GPU = 1
```
GPU device type.
```
DT_NPU = 0
```
NPU device type, not supported yet.
## DeviceContext
A **struct** . DeviceContext defined for holding DeviceType.
**Attributes**
```
type
```
A **DeviceType** variable. The device type.
\ No newline at end of file
# mindspore::lite
**Functions**
```
std::string Version()
```
Global method to get a version string.
- Returns
The version string of MindSpore Lite.
C++ API
=======
.. toctree::
:maxdepth: 1
class_list
lite
session
tensor
errorcode_and_metatype
\ No newline at end of file
Here is a list of all namespace members with links to the namespace documentation for each member: # Class List
Here is a list of all classes with links to the namespace documentation for each member:
| Namespace | Class Name | Description | | Namespace | Class Name | Description |
| --- | --- | --- | | --- | --- | --- |
| mindspore::lite | [Allocator](https://www.mindspore.cn/lite/docs/en/master/api/context.html#allocator) | Allocator defines a memory pool for dynamic memory malloc and memory free. | | mindspore::lite | [Allocator](https://www.mindspore.cn/lite/docs/en/master/apicc/lite.html#allocator) | Allocator defines a memory pool for dynamic memory malloc and memory free. |
| mindspore::lite | [Context](https://www.mindspore.cn/lite/docs/en/master/api/context.html#context) | Context defines for holding environment variables during runtime. | | mindspore::lite | [Context](https://www.mindspore.cn/lite/docs/en/master/apicc/lite.html#context) | Context defines for holding environment variables during runtime. |
| mindspore::lite | [ModelImpl](https://www.mindspore.cn/lite/docs/en/master/api/model.html#modelimpl) | ModelImpl defines the implement class of Model in MindSpore Lite. | | mindspore::lite | [ModelImpl](https://www.mindspore.cn/lite/docs/en/master/apicc/lite.html#modelimpl) | ModelImpl defines the implement class of Model in MindSpore Lite. |
| mindspore::lite | [PrimitiveC](https://www.mindspore.cn/lite/docs/en/master/api/model.html#primitivec) | Primitive defines as prototype of operator. | | mindspore::lite | [PrimitiveC](https://www.mindspore.cn/lite/docs/en/master/apicc/lite.html#primitivec) | Primitive defines as prototype of operator. |
| mindspore::lite | [Model](https://www.mindspore.cn/lite/docs/en/master/api/model.html#model) | Model defines model in MindSpore Lite for managing graph. | | mindspore::lite | [Model](https://www.mindspore.cn/lite/docs/en/master/apicc/lite.html#model) | Model defines model in MindSpore Lite for managing graph. |
| mindspore::lite | [ModelBuilder](https://www.mindspore.cn/lite/docs/en/master/api/model.html#modelbuilder) | ModelBuilder is defined by MindSpore Lite. | | mindspore::lite | [ModelBuilder](https://www.mindspore.cn/lite/docs/en/master/apicc/lite.html#modelbuilder) | ModelBuilder is defined by MindSpore Lite. |
| mindspore::session | [LiteSession](https://www.mindspore.cn/lite/docs/en/master/api/lite_session.html#litesession) | LiteSession defines session in MindSpore Lite for compiling Model and forwarding model. | | mindspore::session | [LiteSession](https://www.mindspore.cn/lite/docs/en/master/apicc/session.html#litesession) | LiteSession defines session in MindSpore Lite for compiling Model and forwarding model. |
| mindspore::tensor | [MSTensor](https://www.mindspore.cn/lite/docs/en/master/api/ms_tensor.html#mstensor) | MSTensor defines tensor in MindSpore Lite. | | mindspore::tensor | [MSTensor](https://www.mindspore.cn/lite/docs/en/master/apicc/tensor.html#mstensor) | MSTensor defines tensor in MindSpore Lite. |
\ No newline at end of file \ No newline at end of file
# ErrorCode and MetaType
Description of error code and meta type supported in MindSpore Lite. Description of error code and meta type supported in MindSpore Lite.
# ErrorCode ## ErrorCode
| Definition | Value | Description | | Definition | Value | Description |
| --- | --- | --- | | --- | --- | --- |
...@@ -23,7 +25,7 @@ Description of error code and meta type supported in MindSpore Lite. ...@@ -23,7 +25,7 @@ Description of error code and meta type supported in MindSpore Lite.
| RET_INFER_ERR | -501 | Failed to infer shape. | | RET_INFER_ERR | -501 | Failed to infer shape. |
| RET_INFER_INVALID | -502 | Invalid infer shape before runtime. | | RET_INFER_INVALID | -502 | Invalid infer shape before runtime. |
# MetaType ## MetaType
An **enum** type. An **enum** type.
| Type Name | Definition | Value | Description | | Type Name | Definition | Value | Description |
......
# mindspore::lite # mindspore::lite context
## ModelImpl
ModelImpl defines the implement class of Model in MindSpore Lite. ## Allocator
## PrimitiveC Allocator defines a memory pool for dynamic memory malloc and memory free.
Primitive is defined as prototype of operator.
## Context
## Model
Model defines model in MindSpore Lite for managing graph. Context is defined for holding environment variables during runtime.
**Constructors & Destructors** **Constructors & Destructors**
```
Model() ```
``` Context()
```
Constructor of MindSpore Lite Model using default value for parameters.
Constructor of MindSpore Lite Context using default value for parameters.
```
virtual ~Model() ```
``` Context(int thread_num, std::shared_ptr< Allocator > allocator, DeviceContext device_ctx)
```
Destructor of MindSpore Lite Model. Constructor of MindSpore Lite Context using input value for parameters.
**Public Member Functions** - Parameters
```
PrimitiveC* GetOp(const std::string &name) const - `thread_num`: Define the work thread number during the runtime.
```
Get MindSpore Lite Primitive by name. - `allocator`: Define the allocator for malloc.
- Parameters - `device_ctx`: Define device information during the runtime.
- `name`: Define name of primitive to be returned. - Returns
- Returns The instance of MindSpore Lite Context.
The pointer of MindSpore Lite Primitive. ```
~Context()
``` ```
const schema::MetaGraph* GetMetaGraph() const Destructor of MindSpore Lite Context.
```
Get graph defined in flatbuffers. **Public Attributes**
- Returns ```
float16_priority
The pointer of graph defined in flatbuffers. ```
A **bool** value. Defaults to **false**. Prior enable float16 inference.
```
void FreeMetaGraph() ```
``` device_ctx_{DT_CPU}
Free MetaGraph in MindSpore Lite Model. ```
A **DeviceContext** struct.
**Static Public Member Functions**
``` ```
static Model *Import(const char *model_buf, size_t size) thread_num_
``` ```
Static method to create a Model pointer.
An **int** value. Defaults to **2**. Thread number config for thread pool.
- Parameters
```
- `model_buf`: Define the buffer read from a model file. allocator
```
- `size`: variable. Define bytes number of model buffer.
A **std::shared_ptr<Allocator>** pointer.
- Returns
```
Pointer of MindSpore Lite Model. cpu_bind_mode_
```
**Public Attributes**
``` A **CpuBindMode** enum variable. Defaults to **MID_CPU**.
model_impl_
``` ## ModelImpl
The **pointer** of implement of model in MindSpore Lite. Defaults to **nullptr**. ModelImpl defines the implement class of Model in MindSpore Lite.
## ModelBuilder ## PrimitiveC
ModelBuilder is defined by MindSpore Lite. Primitive is defined as prototype of operator.
**Constructors & Destructors** ## Model
``` Model defines model in MindSpore Lite for managing graph.
ModelBuilder()
``` **Constructors & Destructors**
```
Constructor of MindSpore Lite ModelBuilder using default value for parameters. Model()
```
```
virtual ~ModelBuilder() Constructor of MindSpore Lite Model using default value for parameters.
```
```
Destructor of MindSpore Lite ModelBuilder. virtual ~Model()
```
**Public Member Functions**
``` Destructor of MindSpore Lite Model.
virtual std::string AddOp(const PrimitiveC &op, const std::vector<OutEdge> &inputs)
``` **Public Member Functions**
```
Add primitive into model builder for model building. PrimitiveC* GetOp(const std::string &name) const
```
- Parameters Get MindSpore Lite Primitive by name.
- `op`: Define the primitive to be added. - Parameters
- `inputs`: Define input edge of primitive to be added. - `name`: Define name of primitive to be returned.
- Returns - Returns
ID of the added primitive. The pointer of MindSpore Lite Primitive.
``` ```
const schema::MetaGraph* GetMetaGraph() const const schema::MetaGraph* GetMetaGraph() const
``` ```
Get graph defined in flatbuffers. Get graph defined in flatbuffers.
- Returns - Returns
The pointer of graph defined in flatbuffers. The pointer of graph defined in flatbuffers.
``` ```
virtual Model *Construct() void FreeMetaGraph()
``` ```
Finish constructing the model. Free MetaGraph in MindSpore Lite Model.
## OutEdge **Static Public Member Functions**
**Attributes** ```
``` static Model *Import(const char *model_buf, size_t size)
nodeId ```
``` Static method to create a Model pointer.
A **string** variable. ID of a node linked by this edge.
- Parameters
```
outEdgeIndex - `model_buf`: Define the buffer read from a model file.
```
A **size_t** variable. Index of this edge. - `size`: variable. Define bytes number of model buffer.
\ No newline at end of file
- Returns
Pointer of MindSpore Lite Model.
**Public Attributes**
```
model_impl_
```
The **pointer** of implement of model in MindSpore Lite. Defaults to **nullptr**.
## ModelBuilder
ModelBuilder is defined by MindSpore Lite.
**Constructors & Destructors**
```
ModelBuilder()
```
Constructor of MindSpore Lite ModelBuilder using default value for parameters.
```
virtual ~ModelBuilder()
```
Destructor of MindSpore Lite ModelBuilder.
**Public Member Functions**
```
virtual std::string AddOp(const PrimitiveC &op, const std::vector<OutEdge> &inputs)
```
Add primitive into model builder for model building.
- Parameters
- `op`: Define the primitive to be added.
- `inputs`: Define input edge of primitive to be added.
- Returns
ID of the added primitive.
```
const schema::MetaGraph* GetMetaGraph() const
```
Get graph defined in flatbuffers.
- Returns
The pointer of graph defined in flatbuffers.
```
virtual Model *Construct()
```
Finish constructing the model.
## OutEdge
**Attributes**
```
nodeId
```
A **string** variable. ID of a node linked by this edge.
```
outEdgeIndex
```
A **size_t** variable. Index of this edge.
## CpuBindMode
An **enum** type. CpuBindMode defined for holding bind cpu strategy argument.
**Attributes**
```
MID_CPU = -1
```
Bind middle cpu first.
```
HIGHER_CPU = 1
```
Bind higher cpu first.
```
NO_BIND = 0
```
No bind.
## DeviceType
An **enum** type. DeviceType defined for holding user's preferred backend.
**Attributes**
```
DT_CPU = -1
```
CPU device type.
```
DT_GPU = 1
```
GPU device type.
```
DT_NPU = 0
```
NPU device type, not supported yet.
## DeviceContext
A **struct** . DeviceContext defined for holding DeviceType.
**Attributes**
```
type
```
A **DeviceType** variable. The device type.
## Version
```
std::string Version()
```
Global method to get a version string.
- Returns
The version string of MindSpore Lite.
\ No newline at end of file
# mindspore::session # mindspore::session
## LiteSession ## LiteSession
LiteSession defines session in MindSpore Lite for compiling Model and forwarding model. LiteSession defines session in MindSpore Lite for compiling Model and forwarding model.
**Constructors & Destructors** **Constructors & Destructors**
``` ```
LiteSession() LiteSession()
``` ```
Constructor of MindSpore Lite LiteSession using default value for parameters. Constructor of MindSpore Lite LiteSession using default value for parameters.
``` ```
~LiteSession() ~LiteSession()
``` ```
Destructor of MindSpore Lite LiteSession. Destructor of MindSpore Lite LiteSession.
**Public Member Functions** **Public Member Functions**
``` ```
virtual void BindThread(bool if_bind) virtual void BindThread(bool if_bind)
``` ```
Attempt to bind or unbind threads in the thread pool to or from the specified cpu core. Attempt to bind or unbind threads in the thread pool to or from the specified cpu core.
- Parameters - Parameters
- `if_bind`: Define whether to bind or unbind threads. - `if_bind`: Define whether to bind or unbind threads.
``` ```
virtual int CompileGraph(lite::Model *model) virtual int CompileGraph(lite::Model *model)
``` ```
Compile MindSpore Lite model. Compile MindSpore Lite model.
> Note: CompileGraph should be called before RunGraph. > Note: CompileGraph should be called before RunGraph.
- Parameters - Parameters
- `model`: Define the model to be compiled. - `model`: Define the model to be compiled.
- Returns - Returns
STATUS as an error code of compiling graph, STATUS is defined in errorcode.h. STATUS as an error code of compiling graph, STATUS is defined in errorcode.h.
``` ```
virtual std::vector <tensor::MSTensor *> GetInputs() const virtual std::vector <tensor::MSTensor *> GetInputs() const
``` ```
Get input MindSpore Lite MSTensors of model. Get input MindSpore Lite MSTensors of model.
- Returns - Returns
The vector of MindSpore Lite MSTensor. The vector of MindSpore Lite MSTensor.
``` ```
std::vector <tensor::MSTensor *> GetInputsByName(const std::string &node_name) const std::vector <tensor::MSTensor *> GetInputsByName(const std::string &node_name) const
``` ```
Get input MindSpore Lite MSTensors of model by node name. Get input MindSpore Lite MSTensors of model by node name.
- Parameters - Parameters
- `node_name`: Define node name. - `node_name`: Define node name.
- Returns - Returns
The vector of MindSpore Lite MSTensor. The vector of MindSpore Lite MSTensor.
``` ```
virtual int RunGraph(const KernelCallBack &before = nullptr, const KernelCallBack &after = nullptr) virtual int RunGraph(const KernelCallBack &before = nullptr, const KernelCallBack &after = nullptr)
``` ```
Run session with callback. Run session with callback.
> Note: RunGraph should be called after CompileGraph. > Note: RunGraph should be called after CompileGraph.
- Parameters - Parameters
- `before`: Define a call_back_function to be called before running each node. - `before`: Define a call_back_function to be called before running each node.
- `after`: Define a call_back_function called after running each node. - `after`: Define a call_back_function called after running each node.
- Returns - Returns
STATUS as an error code of running graph, STATUS is defined in errorcode.h. STATUS as an error code of running graph, STATUS is defined in errorcode.h.
``` ```
virtual std::unordered_map<std::string, std::vector<mindspore::tensor::MSTensor *>> GetOutputMapByNode() const virtual std::unordered_map<std::string, std::vector<mindspore::tensor::MSTensor *>> GetOutputMapByNode() const
``` ```
Get output MindSpore Lite MSTensors of model mapped by node name. Get output MindSpore Lite MSTensors of model mapped by node name.
- Returns - Returns
The map of output node name and MindSpore Lite MSTensor. The map of output node name and MindSpore Lite MSTensor.
``` ```
virtual std::vector <tensor::MSTensor *> GetOutputsByNodeName(const std::string &node_name) const virtual std::vector <tensor::MSTensor *> GetOutputsByNodeName(const std::string &node_name) const
``` ```
Get output MindSpore Lite MSTensors of model by node name. Get output MindSpore Lite MSTensors of model by node name.
- Parameters - Parameters
- `node_name`: Define node name. - `node_name`: Define node name.
- Returns - Returns
The vector of MindSpore Lite MSTensor. The vector of MindSpore Lite MSTensor.
``` ```
virtual std::unordered_map <std::string, mindspore::tensor::MSTensor *> GetOutputMapByTensor() const virtual std::unordered_map <std::string, mindspore::tensor::MSTensor *> GetOutputMapByTensor() const
``` ```
Get output MindSpore Lite MSTensors of model mapped by tensor name. Get output MindSpore Lite MSTensors of model mapped by tensor name.
- Returns - Returns
The map of output tensor name and MindSpore Lite MSTensor. The map of output tensor name and MindSpore Lite MSTensor.
``` ```
virtual std::vector <std::string> GetOutputTensorNames() const virtual std::vector <std::string> GetOutputTensorNames() const
``` ```
Get name of output tensors of model compiled by this session. Get name of output tensors of model compiled by this session.
- Returns - Returns
The vector of string as output tensor names in order. The vector of string as output tensor names in order.
``` ```
virtual mindspore::tensor::MSTensor *GetOutputByTensorName(const std::string &tensor_name) const virtual mindspore::tensor::MSTensor *GetOutputByTensorName(const std::string &tensor_name) const
``` ```
Get output MindSpore Lite MSTensors of model by tensor name. Get output MindSpore Lite MSTensors of model by tensor name.
- Parameters - Parameters
- `tensor_name`: Define tensor name. - `tensor_name`: Define tensor name.
- Returns - Returns
Pointer of MindSpore Lite MSTensor. Pointer of MindSpore Lite MSTensor.
``` ```
virtual mindspore::tensor::MSTensor *GetOutputByTensorName(const std::string &tensor_name) const virtual mindspore::tensor::MSTensor *GetOutputByTensorName(const std::string &tensor_name) const
``` ```
Get output MindSpore Lite MSTensors of model by tensor name. Get output MindSpore Lite MSTensors of model by tensor name.
- Parameters - Parameters
- `tensor_name`: Define tensor name. - `tensor_name`: Define tensor name.
- Returns - Returns
Pointer of MindSpore Lite MSTensor. Pointer of MindSpore Lite MSTensor.
``` ```
virtual int Resize(const std::vector <tensor::MSTensor *> &inputs) virtual int Resize(const std::vector <tensor::MSTensor *> &inputs)
``` ```
Resize inputs shape. Resize inputs shape.
- Parameters - Parameters
- `inputs`: Define the new inputs shape. - `inputs`: Define the new inputs shape.
- Returns - Returns
STATUS as an error code of resize inputs, STATUS is defined in errorcode.h. STATUS as an error code of resize inputs, STATUS is defined in errorcode.h.
**Static Public Member Functions** **Static Public Member Functions**
``` ```
static LiteSession *CreateSession(lite::Context *context) static LiteSession *CreateSession(lite::Context *context)
``` ```
Static method to create a LiteSession pointer. Static method to create a LiteSession pointer.
- Parameters - Parameters
- `context`: Define the context of session to be created. - `context`: Define the context of session to be created.
- Returns - Returns
Pointer of MindSpore Lite LiteSession. Pointer of MindSpore Lite LiteSession.
## CallBackParam ## CallBackParam
CallBackParam defines input arguments for callBack function. CallBackParam defines input arguments for callBack function.
**Attributes** **Attributes**
``` ```
name_callback_param name_callback_param
``` ```
A **string** variable. Node name argument. A **string** variable. Node name argument.
``` ```
type_callback_param type_callback_param
``` ```
A **string** variable. Node type argument. A **string** variable. Node type argument.
\ No newline at end of file
...@@ -11,5 +11,6 @@ MindSpore Lite Documentation ...@@ -11,5 +11,6 @@ MindSpore Lite Documentation
:maxdepth: 1 :maxdepth: 1
architecture architecture
apicc/apicc
operator_list operator_list
glossary glossary
...@@ -36,6 +36,7 @@ MindSpore教程 ...@@ -36,6 +36,7 @@ MindSpore教程
advanced_use/synchronization_training_and_evaluation advanced_use/synchronization_training_and_evaluation
advanced_use/bert_poetry advanced_use/bert_poetry
advanced_use/optimize_the_performance_of_data_preparation advanced_use/optimize_the_performance_of_data_preparation
advanced_use/mobilenetv2_incremental_learning
.. toctree:: .. toctree::
:glob: :glob:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册