Class AscendDeviceInfo
#include <context.h>
派生自DeviceInfoContext,模型运行在Atlas 200/300/500推理产品、Atlas推理系列产品上的配置。
公有成员函数
函数 |
云侧推理是否支持 |
端侧推理是否支持 |
|---|---|---|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
inline void SetInsertOpConfigPath(const std::string &cfg_path) |
√ |
√ |
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
void SetInputShapeMap(const std::map<int, std::vector<int>> &shape) |
√ |
√ |
√ |
√ |
|
void SetDynamicBatchSize(const std::vector<size_t> &dynamic_batch_size) |
√ |
√ |
√ |
√ |
|
inline void SetDynamicImageSize(const std::string &dynamic_image_size) |
√ |
√ |
√ |
√ |
|
√ |
√ |
|
√ |
√ |
|
inline void SetPrecisionMode(const std::string &precision_mode) |
√ |
√ |
√ |
√ |
|
inline void SetOpSelectImplMode(const std::string &op_select_impl_mode) |
√ |
√ |
√ |
√ |
|
inline void SetFusionSwitchConfigPath(const std::string &cfg_path) |
√ |
√ |
√ |
√ |
|
inline void SetBufferOptimizeMode(const std::string &buffer_optimize_mode) |
√ |
√ |
√ |
√ |
GetDeviceType
enum DeviceType GetDeviceType() const override
返回值
DeviceType::kAscend
SetDeviceID
void SetDeviceType(uint32_t device_id)
用于指定设备ID。
参数
device_id: 设备ID。
GetDeviceID
uint32_t GetDeviceID() const
返回值
已配置的设备ID。
SetRankID
void SetRankID(uint32_t rank_id)
指定模型rank_id。
参数
rank_id: Rank ID。
GetRankID
uint32_t GetRankID() const
返回值
获取模型的rank_id。
SetInsertOpConfigPath
inline void SetInsertOpConfigPath(const std::string &cfg_path)
模型插入AIPP算子。
参数
cfg_path: AIPP配置文件路径。
GetInsertOpConfigPath
inline std::string GetInsertOpConfigPath() const
返回值
已配置的AIPP。
SetInputFormat
inline void SetInputFormat(const std::string &format)
指定模型输入格式。
参数
format: 输入格式,可选值有"NCHW"、"NHWC"和"ND"。
GetInputFormat
inline std::string GetInputFormat() const
返回值
已配置的模型输入格式。
SetInputShape
inline void SetInputShape(const std::string &shape)
指定模型输入shape,为字符串形式,需指定输入名称,每个shape值由,隔开,不同输入由;隔开。
参数
shape: 如"input_op_name1:1,2,3,4;input_op_name2:4,3,2,1"。
GetInputShape
inline std::string GetInputShape() const
返回值
已配置的模型输入shape。
SetInputShapeMap
inline void SetInputShapeMap(const std::map<int, std::vector<int>> &shape)
指定模型输入shape。
参数
shape: map的key对应输入的下标,例如第一个输入对应下标0,第二个对应下标1。value对应输入shape,为数组形式。
GetInputShapeMap
std::map<int, std::vector<int>> GetInputShapeMap() const
返回值
已配置模型输入shape。
SetDynamicBatchSize
void SetDynamicBatchSize(const std::vector<size_t> &dynamic_batch_size)
指定模型动态batch的档位,支持个数范围[2, 100],为数组形式。
参数
dynamic_batch_size: 如{1, 2}。
GetDynamicBatchSize
inline std::string GetDynamicBatchSize() const
返回值
已配置模型的动态batch。
SetDynamicImageSize
inline void SetDynamicImageSize(const std::string &dynamic_image_size)
指定模型动态分辨率的档位,支持个数范围[2, 100],为字符串形式,每个shape值由,隔开,不同输入由;隔开。
参数
dynamic_image_size: 如"64,64;128,128"。
GetDynamicImageSize
inline std::string GetDynamicImageSize() const
返回值
已配置模型的动态分辨率。
SetOutputType
void SetOutputType(enum DataType output_type)
指定模型输出type。
参数
output_type: 可选有"FP32"、"UINT8"或"FP16"。
GetOutputType
enum DataType GetOutputType() const
返回值
已配置模型的输出类型。
SetPrecisionMode
inline void SetPrecisionMode(const std::string &precision_mode)
配置模型精度模式。
参数
precision_mode: 可选有"enforce_fp16"、"preferred_fp32"、"enforce_origin"、"enforce_fp32"或者"preferred_optimal",默认为"enforce_fp16"。
GetPrecisionMode
inline std::string GetPrecisionMode() const
返回值
已配置模型的精度模式。
SetOpSelectImplMode
inline void SetOpSelectImplMode(const std::string &op_select_impl_mode)
配置算子实现方式。
参数
op_select_impl_mode: 可选有"high_performance"和"high_precision",默认为"high_performance"。
GetOpSelectImplMode
inline std::string GetOpSelectImplMode() const
返回值
已配置的算子选择模式。
SetFusionSwitchConfigPath
inline void SetFusionSwitchConfigPath(const std::string &cfg_path)
配置融合开关。
参数
cfg_path: 融合开关配置文件,可指定关闭特定融合规则。
GetFusionSwitchConfigPath
inline std::string GetFusionSwitchConfigPath() const
返回值
已配置的融合开关文件路径。
SetBufferOptimizeMode
inline void SetBufferOptimizeMode(const std::string &buffer_optimize_mode)
配置缓存优化模式。
参数
buffer_optimize_mode: 可选有"l1_optimize"、"l2_optimize"或"off_optimize",默认为"l2_optimize"。
GetBufferOptimizeMode
inline std::string GetBufferOptimizeMode() const
返回值
已配置的缓存优化模式。