|
nndeploy C++ API
0.2.0
nndeploy C++ API
|
推理的基类 More...
#include <inference.h>
Public Member Functions | |
| virtual bool | canOpInput () |
| 是否可以操作推理框架内部分配的输入tensor More... | |
| virtual bool | canOpOutput () |
| 是否可以操作推理框架内部分配的输出tensor More... | |
| virtual base::Status | deinit ()=0 |
| 反初始化推理 More... | |
| virtual base::ShapeMap | getAllInputShape () |
| Get the Output Shape object. More... | |
| virtual std::map< std::string, device::Tensor * > | getAllInputTensorMap () |
| Get the All Input Tensor Map object. More... | |
| virtual std::vector< std::string > | getAllInputTensorName () |
| Get the All Input Tensor Name object. More... | |
| virtual std::vector< device::Tensor * > | getAllInputTensorVector () |
| Get the All Input Tensor Vector object. More... | |
| virtual std::map< std::string, device::Tensor * > | getAllOutputTensorMap () |
| Get the All Output Tensor Map object. More... | |
| virtual std::vector< std::string > | getAllOutputTensorName () |
| Get the All Output Tensor Name object. More... | |
| virtual std::vector< device::Tensor * > | getAllOutputTensorVector () |
| Get the All Output Tensor Vector object. More... | |
| base::DeviceType | getDeviceType () |
| virtual float | getGFLOPs () |
| 获得推理计算量 More... | |
| base::InferenceType | getInferenceType () |
| virtual std::string | getInputName (int i) |
| Get the Input Name object. More... | |
| virtual base::IntVector | getInputShape (const std::string &name) |
| Get the Input Shape object. More... | |
| virtual device::Tensor * | getInputTensor (const std::string &name) |
| Get the Input Tensor object. More... | |
| virtual device::TensorDesc | getInputTensorAlignDesc (const std::string &name) |
| Get the Input Tensor Align Desc object. More... | |
| virtual device::TensorDesc | getInputTensorDesc (const std::string &name) |
| Get the Input Tensor Desc object. More... | |
| base::ShapeMap | getMaxShape () |
| 针对动态输入的推理,获取输入tensor的max_shape More... | |
| virtual int64_t | getMemorySize () |
| 获取推理所需的内存大小 More... | |
| base::ShapeMap | getMinShape () |
| 针对动态输入的推理,获取输入tensor的min_shape More... | |
| virtual int | getNumOfInputTensor () |
| Get the Num Of Input Tensor object. More... | |
| virtual int | getNumOfOutputTensor () |
| Get the Num Of Output Tensor object. More... | |
| base::ShapeMap | getOptShape () |
| 针对动态输入的推理,获取输入tensor的opt_shape More... | |
| virtual std::string | getOutputName (int i) |
| Get the Output Name object. More... | |
| virtual device::Tensor * | getOutputTensor (const std::string &name) |
| Get the Output Tensor object. More... | |
| virtual device::Tensor * | getOutputTensorAfterRun (const std::string &name, base::DeviceType device_type, bool is_copy, base::DataFormat data_format=base::kDataFormatAuto)=0 |
| Get the Output Tensor object. More... | |
| virtual device::TensorDesc | getOutputTensorAlignDesc (const std::string &name) |
| Get the Output Tensor Align Desc object. More... | |
| virtual device::TensorDesc | getOutputTensorDesc (const std::string &name) |
| Get the Output Tensor Desc object. More... | |
| base::Param * | getParam () |
| Get the Inference Param(这里使用基类指针) More... | |
| std::shared_ptr< base::Param > | getParamSharedPtr () |
| device::Stream * | getStream () |
| Inference (base::InferenceType type) | |
| virtual base::Status | init ()=0 |
| 初始化推理 More... | |
| virtual bool | isBatch () |
| 是否为多batch推理 More... | |
| virtual bool | isInputDynamic () |
| 是否为动态输入 More... | |
| virtual bool | isOutputDynamic () |
| 是否为动态输出 More... | |
| virtual bool | isShareContext () |
| 该推理实例是否与nndeploy共享一个context More... | |
| virtual bool | isShareStream () |
| 该推理实例是否与nndeploy共享一个stream More... | |
| virtual base::Status | reshape (base::ShapeMap &shape_map)=0 |
| 针对动态输入的推理,设置输入tensor的shape More... | |
| virtual base::Status | run ()=0 |
| 推理 More... | |
| virtual base::Status | setInputTensor (const std::string &name, device::Tensor *input_tensor) |
| Set the Input Tensor object. More... | |
| virtual base::Status | setMemory (device::Buffer *buffer) |
| 设置推理所需的内存(推理内存由外部分配) More... | |
| base::Status | setParam (base::Param *param) |
| Set the Inference Param(这里使用基类指针) More... | |
| base::Status | setParamSharedPtr (std::shared_ptr< base::Param > param) |
| void | setStream (device::Stream *stream) |
| virtual | ~Inference () |
Protected Attributes | |
| std::map< std::string, device::Tensor * > | external_input_tensors_ |
| 外部输入tensor的map More... | |
| std::shared_ptr< InferenceParam > | inference_param_ |
| 推理框架的配置 More... | |
| std::map< std::string, device::Tensor * > | input_tensors_ |
| 输入tensor的map More... | |
| bool | is_external_stream_ = false |
| 第三方推理框架是否与应用层共用一个stream More... | |
| bool | is_share_context_ = true |
| 第三方推理框架是否与应用层共用一个context More... | |
| std::map< std::string, device::Tensor * > | output_tensors_ |
| 输出tensor的map More... | |
| device::Stream * | stream_ = nullptr |
| base::InferenceType | type_ |
| 推理框架的类型 More... | |
推理的基类
Definition at line 40 of file inference.h.
| nndeploy::inference::Inference::Inference | ( | base::InferenceType | type | ) |
|
virtual |
|
virtual |
是否可以操作推理框架内部分配的输入tensor
部分推理框架会为输入tensor分配内存,以TNN为例,其会为输入tensor分配内存,当为CPU推理时,可以操作这些内存 但是当为OpenCL推理时,这些内存是在OpenCL上分配的,TNN无法与外部共享GPU上下文,故无法操作这些内存
|
virtual |
是否可以操作推理框架内部分配的输出tensor
部分推理框架会为输出tensor分配内存,以TNN为例,其会为输出tensor分配内存,当为CPU推理时,可以操作这些内存 但是当为OpenCL推理时,这些内存是在OpenCL上分配的,TNN无法与外部共享GPU上下文,故无法操作这些内存
|
pure virtual |
反初始化推理
|
virtual |
|
virtual |
Get the All Input Tensor Map object.
|
virtual |
Get the All Input Tensor Name object.
|
virtual |
Get the All Input Tensor Vector object.
|
virtual |
Get the All Output Tensor Map object.
|
virtual |
Get the All Output Tensor Name object.
|
virtual |
Get the All Output Tensor Vector object.
|
inline |
Definition at line 64 of file inference.h.
|
virtual |
获得推理计算量
| base::InferenceType nndeploy::inference::Inference::getInferenceType | ( | ) |
|
virtual |
Get the Input Name object.
| i |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
| base::ShapeMap nndeploy::inference::Inference::getMaxShape | ( | ) |
针对动态输入的推理,获取输入tensor的max_shape
|
virtual |
获取推理所需的内存大小
| base::ShapeMap nndeploy::inference::Inference::getMinShape | ( | ) |
针对动态输入的推理,获取输入tensor的min_shape
|
virtual |
Get the Num Of Input Tensor object.
|
virtual |
Get the Num Of Output Tensor object.
| base::ShapeMap nndeploy::inference::Inference::getOptShape | ( | ) |
针对动态输入的推理,获取输入tensor的opt_shape
|
virtual |
Get the Output Name object.
| i |
|
virtual |
|
pure virtual |
|
virtual |
|
virtual |
| base::Param* nndeploy::inference::Inference::getParam | ( | ) |
Get the Inference Param(这里使用基类指针)
| std::shared_ptr<base::Param> nndeploy::inference::Inference::getParamSharedPtr | ( | ) |
| device::Stream* nndeploy::inference::Inference::getStream | ( | ) |
|
pure virtual |
初始化推理
|
virtual |
是否为多batch推理
|
virtual |
是否为动态输入
|
virtual |
是否为动态输出
|
virtual |
该推理实例是否与nndeploy共享一个context
|
virtual |
该推理实例是否与nndeploy共享一个stream
|
pure virtual |
|
pure virtual |
推理
|
virtual |
|
virtual |
| base::Status nndeploy::inference::Inference::setParam | ( | base::Param * | param | ) |
| base::Status nndeploy::inference::Inference::setParamSharedPtr | ( | std::shared_ptr< base::Param > | param | ) |
| void nndeploy::inference::Inference::setStream | ( | device::Stream * | stream | ) |
|
protected |
|
protected |
|
protected |
输入tensor的map
部分第三方推理框架(TNN、MNN、Openvino等)内部分配输入tensor,这是第三方推理框架内部分配的输入tensor的一个浅拷贝 部分推理框架(TensorRt、onnxruntime等)内部不分配输入tensor(也或许是外部无法获得到内部分配的输入tensor),nndeploy的推理将尝试为第三方推理框架分配输入tensor
Definition at line 363 of file inference.h.
|
protected |
第三方推理框架是否与应用层共用一个stream
Definition at line 354 of file inference.h.
|
protected |
第三方推理框架是否与应用层共用一个context
Definition at line 348 of file inference.h.
|
protected |
输出tensor的map
部分第三方推理框架(TNN、MNN、Openvino等)内部分配输出tensor,这是第三方推理框架内部分配的输出tensor的一个浅拷贝 部分推理框架(TensorRt、onnxruntime等)内部不分配输出tensor(也或许是外部无法获得到内部分配的输出tensor),nndeploy的推理将尝试为第三方推理框架分配输出tensor
Definition at line 370 of file inference.h.
|
protected |
Definition at line 355 of file inference.h.
|
protected |
推理框架的类型
Definition at line 336 of file inference.h.