非类成员函数
custom_op_run函数
函数功能
自定义算子的单算子调测入口函数。该函数在“custom\custom_op.h”中定义。
custom_op_run接口的返回值是ErrorInfo类型,包含错误码、错误描述。当错误码为0时,表示成功;当错误码为其它值时,表示失败。ErrorInfo类型的定义如下:
struct ErrorInfo { uint32_t error_code; std::string error_msg; };
函数原型
ErrorInfo custom_op_run(const std::string& name, int32_t type, const std::string& bin_file,
const std::vector< std::string >& in_files,
const std::vector< std::string >& out_files,
const std::vector< uint32_t >& out_buf_sizes,
const std::vector< uint32_t >& workspace_sizes = std::vector<uint32_t>(),
const std::string& op_cfg_file = "", void *param = nullptr, int param_len = 0);
参数说明
参数 |
输入/输出 |
说明 |
---|---|---|
name |
输入 |
算子kernel名称。 |
type |
输入 |
算子类型:
|
bin_file |
输入 |
算子二进制文件路径,包含文件名。 路径支持配置相对路径,此时二进制文件需存放在程序所在的目录下,如:./*.bin。 |
in_files |
输入 |
输入数据文件路径,包含文件名。 路径支持配置相对路径,此时数据文件需存放在程序所在的目录下。 |
out_files |
输入 |
输出数据文件路径,包含文件名。 路径支持配置相对路径,此时数据文件需存放在程序所在的目录下。 |
out_buf_sizes |
输入 |
输出数据大小,单位是字节。 |
workspace_sizes |
输入 |
workspace大小,单位是字节。 |
op_cfg_file |
输入 |
用户指定的算子的输入输出描述信息。 |
param |
输入 |
用户指定的算子参数结构体地址信息。 |
param_len |
输入 |
用户指定的算子参数结构体的长度,使用sizeof(param)取结构体长度,单位是字节。 |
custom_op_compare函数
函数功能
自定义算子的单算子校验接口,用于校验数据精度。该函数在“custom\custom_op.h”中定义。
custom_op_compare接口的返回值是ErrorInfo类型,包含错误码、错误描述。当错误码为0时,表示成功;当错误码为其它值时,表示失败。ErrorInfo类型的定义如下:
struct ErrorInfo { uint32_t error_code; std::string error_msg; };
函数原型
ErrorInfo custom_op_compare(const std::string& expect_file, const std::string& actual_file,
int32_t data_type, float precision_deviation,
float statistical_discrepancy, bool& compare_result);
参数说明
参数 |
输入/输出 |
说明 |
---|---|---|
expect_file |
输入 |
期望数据文件,包含文件名 |
actual_file |
输入 |
实际数据文件,包含文件名 |
data_type |
输入 |
算子类型,目前支持FP32(0)、FP16(1) |
precision_deviation |
输入 |
单数据精度偏差,数值范围(0,1),偏差越小,精度越高。 |
statistical_discrepancy |
输入 |
整个数据集的统计偏差,数值范围(0,1),偏差越小,精度越高。 |
compare_result |
输出 |
比较结果, true:对比成功;false:对比失败 |
GetContext函数
函数功能
获取OMG上下文,并返回。该函数在“framework\omg\omg_types.h”中定义。
GetContext接口的返回值是OmgContext类型,OmgContext类型的定义请参见“framework\omg\omg_types.h”。
函数原型
OmgContext& GetContext();
参数说明
无。
AutoMappingFn函数
函数功能
自动映射回调函数。该函数在“framework\omg\register.h”中定义。
函数原型
Status AutoMappingFn(const google::protobuf::Message* op_src, ge::Operator& op);
参数说明
参数 |
输入/输出 |
说明 |
---|---|---|
op_src |
输入 |
原始转换前算子 |
op |
输入 |
映射的算子 |
aicpu_run_func函数
函数功能
AI CPU自定义算子的函数指针,函数名称可以自定义。该函数在“cce\customize.h”中定义。
函数原型
void (*aicpu_run_func)(opTensor_t **, void **, int32_t,
opTensor_t **, void **, int32_t, void *, rtStream_t);
参数说明
参数 |
输入/输出 |
说明 |
---|---|---|
opTensor_t ** |
输入 |
输入描述符Tensor。 typedef struct tagOpTensor { // real dim info opTensorFormat_t format; //char align1[4]; opDataType_t data_type; //char align2[4]; int32_t dim_cnt; int32_t mm; //lint !e148 int32_t dim[CC_DEVICE_DIM_MAX]; //lint !e148 } opTensor_t; |
void ** |
输入 |
输入描述符Tensor的地址 |
int32_t |
输入 |
输入描述符个数 |
opTensor_t ** |
输入 |
输出描述符Tensor |
void ** |
输入 |
输出描述符Tensor的地址 |
int32_t |
输入 |
输出描述符个数 |
void * |
输入 |
属性handle地址 |
rtStream_t |
输入 |
stream 标识 |