Updated on 2022-03-13 GMT+08:00

custom_op_run

Function

Entry function for the commissioning of a single custom operator. This function is defined in custom\custom_op.h.

The return value of custom_op_run is of the ErrorInfo type, including the error code and error description. If the error code is 0, the operation is successful. Other values indicate failure. The ErrorInfo type is defined as follows:

struct ErrorInfo
    {
        uint32_t    error_code;
        std::string error_msg;
    };

Syntax

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);

Parameter Description

Parameter

Input/Output

Description

name

Input

Operator kernel name

type

Input

Operator type:

  • 0 - TE_AICORE
  • 1 -TE_AICPU
  • 2 - AI CPU

bin_file

Input

Binary file path of an operator, including the file name.

A relative path is supported. In this case, the binary file must be stored in the directory where the program is located, for example ./*.bin.

in_files

Input

Path of the input data file, including the file name.

A relative path is supported. In this case, the data file must be stored in the directory where the program is located.

out_files

Input

Path of the output data file, including the file name.

A relative path is supported. In this case, the data file must be stored in the directory where the program is located.

out_buf_sizes

Input

Size of the output data, in bytes

workspace_sizes

Input

Size of the workspace, in bytes

op_cfg_file

Input

Input and output description of the operator specified by the user

param

Input

Address information of the parameter structure of the operator specified by the user

param_len

Input

Length of the parameter structure of the operator specified by the user, in bytes. The structure length can be obtained using sizeof(param).