提交 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 |
| --- | --- | --- |
| 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 | [Context](https://www.mindspore.cn/lite/docs/en/master/api/context.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 | [PrimitiveC](https://www.mindspore.cn/lite/docs/en/master/api/model.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 | [ModelBuilder](https://www.mindspore.cn/lite/docs/en/master/api/model.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::tensor | [MSTensor](https://www.mindspore.cn/lite/docs/en/master/api/ms_tensor.html#mstensor) | MSTensor defines tensor in MindSpore Lite. |
\ No newline at end of file
| 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/apicc/lite.html#context) | Context defines for holding environment variables during runtime. |
| 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/apicc/lite.html#primitivec) | Primitive defines as prototype of operator. |
| 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/apicc/lite.html#modelbuilder) | ModelBuilder is defined by MindSpore Lite. |
| 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/apicc/tensor.html#mstensor) | MSTensor defines tensor in MindSpore Lite. |
\ No newline at end of file
# ErrorCode and MetaType
Description of error code and meta type supported in MindSpore Lite.
# ErrorCode
## ErrorCode
| Definition | Value | Description |
| --- | --- | --- |
......@@ -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_INVALID | -502 | Invalid infer shape before runtime. |
# MetaType
## MetaType
An **enum** type.
| Type Name | Definition | Value | Description |
......
# mindspore::lite
## ModelImpl
ModelImpl defines the implement class of Model in MindSpore Lite.
## PrimitiveC
Primitive is defined as prototype of operator.
## Model
Model defines model in MindSpore Lite for managing graph.
**Constructors & Destructors**
```
Model()
```
Constructor of MindSpore Lite Model using default value for parameters.
```
virtual ~Model()
```
Destructor of MindSpore Lite Model.
**Public Member Functions**
```
PrimitiveC* GetOp(const std::string &name) const
```
Get MindSpore Lite Primitive by name.
- Parameters
- `name`: Define name of primitive to be returned.
- Returns
The pointer of MindSpore Lite Primitive.
```
const schema::MetaGraph* GetMetaGraph() const
```
Get graph defined in flatbuffers.
- Returns
The pointer of graph defined in flatbuffers.
```
void FreeMetaGraph()
```
Free MetaGraph in MindSpore Lite Model.
**Static Public Member Functions**
```
static Model *Import(const char *model_buf, size_t size)
```
Static method to create a Model pointer.
- Parameters
- `model_buf`: Define the buffer read from a model file.
- `size`: variable. Define bytes number of model buffer.
- 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.
\ No newline at end of file
# mindspore::lite context
## 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**.
## ModelImpl
ModelImpl defines the implement class of Model in MindSpore Lite.
## PrimitiveC
Primitive is defined as prototype of operator.
## Model
Model defines model in MindSpore Lite for managing graph.
**Constructors & Destructors**
```
Model()
```
Constructor of MindSpore Lite Model using default value for parameters.
```
virtual ~Model()
```
Destructor of MindSpore Lite Model.
**Public Member Functions**
```
PrimitiveC* GetOp(const std::string &name) const
```
Get MindSpore Lite Primitive by name.
- Parameters
- `name`: Define name of primitive to be returned.
- Returns
The pointer of MindSpore Lite Primitive.
```
const schema::MetaGraph* GetMetaGraph() const
```
Get graph defined in flatbuffers.
- Returns
The pointer of graph defined in flatbuffers.
```
void FreeMetaGraph()
```
Free MetaGraph in MindSpore Lite Model.
**Static Public Member Functions**
```
static Model *Import(const char *model_buf, size_t size)
```
Static method to create a Model pointer.
- Parameters
- `model_buf`: Define the buffer read from a model file.
- `size`: variable. Define bytes number of model buffer.
- 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
## LiteSession
LiteSession defines session in MindSpore Lite for compiling Model and forwarding model.
**Constructors & Destructors**
```
LiteSession()
```
Constructor of MindSpore Lite LiteSession using default value for parameters.
```
~LiteSession()
```
Destructor of MindSpore Lite LiteSession.
**Public Member Functions**
```
virtual void BindThread(bool if_bind)
```
Attempt to bind or unbind threads in the thread pool to or from the specified cpu core.
- Parameters
- `if_bind`: Define whether to bind or unbind threads.
```
virtual int CompileGraph(lite::Model *model)
```
Compile MindSpore Lite model.
> Note: CompileGraph should be called before RunGraph.
- Parameters
- `model`: Define the model to be compiled.
- Returns
STATUS as an error code of compiling graph, STATUS is defined in errorcode.h.
```
virtual std::vector <tensor::MSTensor *> GetInputs() const
```
Get input MindSpore Lite MSTensors of model.
- Returns
The vector of MindSpore Lite MSTensor.
```
std::vector <tensor::MSTensor *> GetInputsByName(const std::string &node_name) const
```
Get input MindSpore Lite MSTensors of model by node name.
- Parameters
- `node_name`: Define node name.
- Returns
The vector of MindSpore Lite MSTensor.
```
virtual int RunGraph(const KernelCallBack &before = nullptr, const KernelCallBack &after = nullptr)
```
Run session with callback.
> Note: RunGraph should be called after CompileGraph.
- Parameters
- `before`: Define a call_back_function to be called before running each node.
- `after`: Define a call_back_function called after running each node.
- Returns
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
```
Get output MindSpore Lite MSTensors of model mapped by node name.
- Returns
The map of output node name and MindSpore Lite MSTensor.
```
virtual std::vector <tensor::MSTensor *> GetOutputsByNodeName(const std::string &node_name) const
```
Get output MindSpore Lite MSTensors of model by node name.
- Parameters
- `node_name`: Define node name.
- Returns
The vector of MindSpore Lite MSTensor.
```
virtual std::unordered_map <std::string, mindspore::tensor::MSTensor *> GetOutputMapByTensor() const
```
Get output MindSpore Lite MSTensors of model mapped by tensor name.
- Returns
The map of output tensor name and MindSpore Lite MSTensor.
```
virtual std::vector <std::string> GetOutputTensorNames() const
```
Get name of output tensors of model compiled by this session.
- Returns
The vector of string as output tensor names in order.
```
virtual mindspore::tensor::MSTensor *GetOutputByTensorName(const std::string &tensor_name) const
```
Get output MindSpore Lite MSTensors of model by tensor name.
- Parameters
- `tensor_name`: Define tensor name.
- Returns
Pointer of MindSpore Lite MSTensor.
```
virtual mindspore::tensor::MSTensor *GetOutputByTensorName(const std::string &tensor_name) const
```
Get output MindSpore Lite MSTensors of model by tensor name.
- Parameters
- `tensor_name`: Define tensor name.
- Returns
Pointer of MindSpore Lite MSTensor.
```
virtual int Resize(const std::vector <tensor::MSTensor *> &inputs)
```
Resize inputs shape.
- Parameters
- `inputs`: Define the new inputs shape.
- Returns
STATUS as an error code of resize inputs, STATUS is defined in errorcode.h.
**Static Public Member Functions**
```
static LiteSession *CreateSession(lite::Context *context)
```
Static method to create a LiteSession pointer.
- Parameters
- `context`: Define the context of session to be created.
- Returns
Pointer of MindSpore Lite LiteSession.
## CallBackParam
CallBackParam defines input arguments for callBack function.
**Attributes**
```
name_callback_param
```
A **string** variable. Node name argument.
```
type_callback_param
```
# mindspore::session
## LiteSession
LiteSession defines session in MindSpore Lite for compiling Model and forwarding model.
**Constructors & Destructors**
```
LiteSession()
```
Constructor of MindSpore Lite LiteSession using default value for parameters.
```
~LiteSession()
```
Destructor of MindSpore Lite LiteSession.
**Public Member Functions**
```
virtual void BindThread(bool if_bind)
```
Attempt to bind or unbind threads in the thread pool to or from the specified cpu core.
- Parameters
- `if_bind`: Define whether to bind or unbind threads.
```
virtual int CompileGraph(lite::Model *model)
```
Compile MindSpore Lite model.
> Note: CompileGraph should be called before RunGraph.
- Parameters
- `model`: Define the model to be compiled.
- Returns
STATUS as an error code of compiling graph, STATUS is defined in errorcode.h.
```
virtual std::vector <tensor::MSTensor *> GetInputs() const
```
Get input MindSpore Lite MSTensors of model.
- Returns
The vector of MindSpore Lite MSTensor.
```
std::vector <tensor::MSTensor *> GetInputsByName(const std::string &node_name) const
```
Get input MindSpore Lite MSTensors of model by node name.
- Parameters
- `node_name`: Define node name.
- Returns
The vector of MindSpore Lite MSTensor.
```
virtual int RunGraph(const KernelCallBack &before = nullptr, const KernelCallBack &after = nullptr)
```
Run session with callback.
> Note: RunGraph should be called after CompileGraph.
- Parameters
- `before`: Define a call_back_function to be called before running each node.
- `after`: Define a call_back_function called after running each node.
- Returns
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
```
Get output MindSpore Lite MSTensors of model mapped by node name.
- Returns
The map of output node name and MindSpore Lite MSTensor.
```
virtual std::vector <tensor::MSTensor *> GetOutputsByNodeName(const std::string &node_name) const
```
Get output MindSpore Lite MSTensors of model by node name.
- Parameters
- `node_name`: Define node name.
- Returns
The vector of MindSpore Lite MSTensor.
```
virtual std::unordered_map <std::string, mindspore::tensor::MSTensor *> GetOutputMapByTensor() const
```
Get output MindSpore Lite MSTensors of model mapped by tensor name.
- Returns
The map of output tensor name and MindSpore Lite MSTensor.
```
virtual std::vector <std::string> GetOutputTensorNames() const
```
Get name of output tensors of model compiled by this session.
- Returns
The vector of string as output tensor names in order.
```
virtual mindspore::tensor::MSTensor *GetOutputByTensorName(const std::string &tensor_name) const
```
Get output MindSpore Lite MSTensors of model by tensor name.
- Parameters
- `tensor_name`: Define tensor name.
- Returns
Pointer of MindSpore Lite MSTensor.
```
virtual mindspore::tensor::MSTensor *GetOutputByTensorName(const std::string &tensor_name) const
```
Get output MindSpore Lite MSTensors of model by tensor name.
- Parameters
- `tensor_name`: Define tensor name.
- Returns
Pointer of MindSpore Lite MSTensor.
```
virtual int Resize(const std::vector <tensor::MSTensor *> &inputs)
```
Resize inputs shape.
- Parameters
- `inputs`: Define the new inputs shape.
- Returns
STATUS as an error code of resize inputs, STATUS is defined in errorcode.h.
**Static Public Member Functions**
```
static LiteSession *CreateSession(lite::Context *context)
```
Static method to create a LiteSession pointer.
- Parameters
- `context`: Define the context of session to be created.
- Returns
Pointer of MindSpore Lite LiteSession.
## CallBackParam
CallBackParam defines input arguments for callBack function.
**Attributes**
```
name_callback_param
```
A **string** variable. Node name argument.
```
type_callback_param
```
A **string** variable. Node type argument.
\ No newline at end of file
......@@ -11,5 +11,6 @@ MindSpore Lite Documentation
:maxdepth: 1
architecture
apicc/apicc
operator_list
glossary
......@@ -36,6 +36,7 @@ MindSpore教程
advanced_use/synchronization_training_and_evaluation
advanced_use/bert_poetry
advanced_use/optimize_the_performance_of_data_preparation
advanced_use/mobilenetv2_incremental_learning
.. toctree::
:glob:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册