|
nndeploy C++ API
0.2.0
nndeploy C++ API
|
Op的基类 More...
#include <op.h>
Protected Attributes | |
| bool | constructed_ = false |
| base::DeviceType | device_type_ |
| op的设备类型 More... | |
| uint64_t | flops_ = 0 |
| bool | initialized_ = false |
| std::vector< device::Tensor * > | inputs_ |
| op的输入tensor note: 当权重为tensor时,权重tensor也会在这里 eg: More... | |
| bool | is_changed_ = false |
| bool | is_debug_ = false |
| bool | is_external_stream_ = false |
| op的stream note: 当stream为外部传入时,is_external_stream_为true More... | |
| bool | is_inner_ = false |
| bool | is_inplace_ = false |
| bool | is_running_ = false |
| bool | is_time_profile_ = false |
| ir::OpDesc | op_desc_ |
| op的描述 包含op的类型、名称、输入名称、输出名称、参数 More... | |
| std::vector< device::Tensor * > | outputs_ |
| op的输出tensor More... | |
| base::ParallelType | parallel_type_ = base::kParallelTypeNone |
| base::PrecisionType | precision_type_ = base::kPrecisionTypeFp32 |
| op的精度类型 note: 精度类型与输入输出tensor的data_type的不同 More... | |
| device::Stream * | stream_ = nullptr |
| void * | workspace_ = nullptr |
| bool | workspace_is_external_ = false |
| op的workspace大小 note: op在运行时的workspace大小, 在preRun中确定 eg:例如Conv,当存在padding时,需要分配额外的内存,存放padding后的内存 More... | |
| uint64_t | workspace_size_ = 0 |
Op的基类
当输出tensor不为空时,检测当前输出tensor的内存是否足够,如果足够,则直接使用,否则报错
pool按最大shape分配,调用reshape函数时,只是重新调整了tensor逻辑shape的大小
未指定max_shape,每次调用reshape函数时,在计算图层面都会:先释放上一次分配的内存,再重新分配内存
| nndeploy::op::Op::Op | ( | ) |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Reimplemented in nndeploy::net::Net.
| std::vector<device::Tensor *> nndeploy::op::Op::getAllInput | ( | ) |
| std::vector<std::string> nndeploy::op::Op::getAllInputName | ( | ) |
| std::vector<device::Tensor *> nndeploy::op::Op::getAllOutput | ( | ) |
| std::vector<std::string> nndeploy::op::Op::getAllOutputName | ( | ) |
| bool nndeploy::op::Op::getConstructed | ( | ) |
| bool nndeploy::op::Op::getDebugFlag | ( | ) |
| base::DeviceType nndeploy::op::Op::getDeviceType | ( | ) |
|
virtual |
| bool nndeploy::op::Op::getInitialized | ( | ) |
| device::Tensor* nndeploy::op::Op::getInput | ( | int | index = 0 | ) |
| std::string nndeploy::op::Op::getInputName | ( | int | index = 0 | ) |
| device::Tensor* nndeploy::op::Op::getInputTensor | ( | const std::string & | name | ) |
| std::string nndeploy::op::Op::getName | ( | ) |
| ir::OpType nndeploy::op::Op::getOpType | ( | ) |
| device::Tensor* nndeploy::op::Op::getOutput | ( | int | index = 0 | ) |
| std::string nndeploy::op::Op::getOutputName | ( | int | index = 0 | ) |
| device::Tensor* nndeploy::op::Op::getOutputTensor | ( | const std::string & | name | ) |
| base::ParallelType nndeploy::op::Op::getParallelType | ( | ) |
|
virtual |
| base::PrecisionType nndeploy::op::Op::getPrecisionType | ( | ) |
| device::Stream* nndeploy::op::Op::getStream | ( | ) |
| bool nndeploy::op::Op::getTimeProfileFlag | ( | ) |
|
virtual |
得到op的workspace大小 note: op在运行时的workspace大小,在输入确定后调用 eg:例如Conv,当存在padding时,需要分配额外的内存,存放padding后的内存
|
virtual |
数据格式推理
Reimplemented in nndeploy::op::OpTranspose, nndeploy::op::OpReshape, nndeploy::op::OpMuls, nndeploy::op::OpBinary, and nndeploy::net::Net.
|
virtual |
类型推理
Reimplemented in nndeploy::op::OpShape, nndeploy::op::OpQuantizeLinear, nndeploy::op::OpMuls, nndeploy::op::OpEqual, nndeploy::op::OpDequantizeLinear, nndeploy::op::OpConstantOfShape, and nndeploy::net::Net.
|
virtual |
形状推理
Reimplemented in nndeploy::op::OpWhere, nndeploy::op::OpUnsqueeze, nndeploy::op::OpUnary, nndeploy::op::OpTranspose, nndeploy::op::OpSwiGLU, nndeploy::op::OpSplit, nndeploy::op::OpSoftmax, nndeploy::op::OpSlice, nndeploy::op::OpShape, nndeploy::op::OpRMSNorm, nndeploy::op::OpResize, nndeploy::op::OpReshape, nndeploy::op::OpReduceMean, nndeploy::op::OpQuantizeLinear, nndeploy::op::OpQLinearConv, nndeploy::op::OpPow, nndeploy::op::OpMuls, nndeploy::op::OpMaxPool, nndeploy::op::OpMatMul, nndeploy::op::OpLayerNorm, nndeploy::op::OpGlobalAveragepool, nndeploy::op::OpGemm, nndeploy::op::OpGather, nndeploy::op::OpFlatten, nndeploy::op::OpExpand, nndeploy::op::OpEqual, nndeploy::op::OpEmbedding, nndeploy::op::OpDequantizeLinear, nndeploy::op::OpConv, nndeploy::op::OpConstantOfShape, nndeploy::op::OpConcat, nndeploy::op::OpBinary, nndeploy::op::OpBatchNorm, and nndeploy::net::Net.
|
virtual |
| bool nndeploy::op::Op::isRunning | ( | ) |
|
virtual |
Reimplemented in nndeploy::net::Net.
|
virtual |
Reimplemented in nndeploy::net::Net.
| base::Status nndeploy::op::Op::replaceInputTensor | ( | const std::string & | name, |
| device::Tensor * | tensor | ||
| ) |
| base::Status nndeploy::op::Op::replaceOutputTensor | ( | const std::string & | name, |
| device::Tensor * | tensor | ||
| ) |
|
virtual |
重新推理形状,通常在初始化之后、preRun前调用
| shape_map |
Reimplemented in nndeploy::net::Net.
| base::Status nndeploy::op::Op::rmInput | ( | device::Tensor * | tensor | ) |
|
pure virtual |
Implemented in nndeploy::op::OpWhere, nndeploy::op::OpUnsqueeze, nndeploy::op::OpTranspose, nndeploy::op::OpTanh, nndeploy::op::OpTan, nndeploy::op::OpSwiGLU, nndeploy::op::OpSub, nndeploy::op::OpSqrt, nndeploy::op::OpSplit, nndeploy::op::OpSoftmax, nndeploy::op::OpSlice, nndeploy::op::OpSinh, nndeploy::op::OpSin, nndeploy::op::OpSilu, nndeploy::op::OpSign, nndeploy::op::OpSigmoid, nndeploy::op::OpShape, nndeploy::op::OpSelu, nndeploy::op::OpRound, nndeploy::op::OpRMSNorm, nndeploy::op::OpResize, nndeploy::op::OpReshape, nndeploy::op::OpRelu, nndeploy::op::OpReduceMean, nndeploy::op::OpReciprocal, nndeploy::op::OpQuantizeLinear, nndeploy::op::OpQLinearConv, nndeploy::op::OpPow, nndeploy::op::OpNeg, nndeploy::op::OpMuls, nndeploy::op::OpMul, nndeploy::op::OpMaxPool, nndeploy::op::OpMatMul, nndeploy::op::OpLog, nndeploy::op::OpLayerNorm, nndeploy::op::OpHardSigmoid, nndeploy::op::OpGlobalAveragepool, nndeploy::op::OpGemm, nndeploy::op::OpGelu, nndeploy::op::OpGather, nndeploy::op::OpFloor, nndeploy::op::OpFlatten, nndeploy::op::OpExpand, nndeploy::op::OpExp, nndeploy::op::OpErf, nndeploy::op::OpEqual, nndeploy::op::OpEmbedding, nndeploy::op::OpDiv, nndeploy::op::OpDequantizeLinear, nndeploy::op::OpCosh, nndeploy::op::OpCos, nndeploy::op::OpConv, nndeploy::op::OpConstantOfShape, nndeploy::op::OpConcat, nndeploy::op::OpCeil, nndeploy::op::OpCast, nndeploy::op::OpBatchNorm, nndeploy::op::OpAtan, nndeploy::op::OpAsin, nndeploy::op::OpAdd, nndeploy::op::OpAcos, nndeploy::op::OpAbs, and nndeploy::net::Net.
| base::Status nndeploy::op::Op::setAllInput | ( | std::vector< device::Tensor * > | inputs | ) |
| base::Status nndeploy::op::Op::setAllInputName | ( | std::initializer_list< std::string > | ) |
| base::Status nndeploy::op::Op::setAllInputName | ( | std::vector< std::string > & | ) |
| base::Status nndeploy::op::Op::setAllOutput | ( | std::vector< device::Tensor * > | outputs | ) |
| base::Status nndeploy::op::Op::setAllOutputName | ( | std::initializer_list< std::string > | ) |
| base::Status nndeploy::op::Op::setAllOutputName | ( | std::vector< std::string > & | ) |
| void nndeploy::op::Op::setDebugFlag | ( | bool | flag | ) |
| base::Status nndeploy::op::Op::setDeviceType | ( | base::DeviceType | device_type | ) |
| void nndeploy::op::Op::setInitializedFlag | ( | bool | flag | ) |
| void nndeploy::op::Op::setInnerFlag | ( | bool | flag | ) |
|
virtual |
| base::Status nndeploy::op::Op::setInput | ( | device::Tensor * | input, |
| int | index | ||
| ) |
| base::Status nndeploy::op::Op::setName | ( | std::string | name | ) |
| base::Status nndeploy::op::Op::setOpType | ( | ir::OpType | op_type | ) |
|
virtual |
| base::Status nndeploy::op::Op::setOutput | ( | device::Tensor * | output, |
| int | index | ||
| ) |
| base::Status nndeploy::op::Op::setParallelType | ( | const base::ParallelType & | paralle_type | ) |
|
virtual |
|
virtual |
设置精度类型 精度不同,计算方式不同,内存分配不同
| precision_type |
| void nndeploy::op::Op::setRunningFlag | ( | bool | flag | ) |
| void nndeploy::op::Op::setStream | ( | device::Stream * | stream | ) |
| void nndeploy::op::Op::setTimeProfileFlag | ( | bool | flag | ) |
|
virtual |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
op的输出tensor
当输出tensor不为空时,检测当前输出tensor的内存是否足够,如果足够,则直接使用,否则报错
pool按最大shape分配,调用reshape函数时,只是重新调整了tensor逻辑shape的大小
未指定max_shape,每次调用reshape函数时,在计算图层面都会:先释放上一次分配的内存,再重新分配内存
|
protected |
|
protected |
|
protected |
|
protected |