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

custom_op_compare

Function

Verification function of a single custom operator, which is used to verify data precision. This function is defined in custom\custom_op.h.

The return value of custom_op_compare 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_compare(const std::string& expect_file, const std::string& actual_file,

int32_t data_type, float precision_deviation,

float statistical_discrepancy, bool& compare_result);

Parameter Description

Parameter

Input/Output

Description

expect_file

Input

Expected data file, including the file name

actual_file

Input

Actual data file, including the file name

data_type

Input

Operator type. Currently, FP32 (0) and FP16 (1) are supported.

precision_deviation

Input

Precision deviation of single data. The value range is (0, 1). A smaller deviation value indicates higher precision.

statistical_discrepancy

Input

Statistical deviation of the entire dataset. The value range is (0, 1). A smaller deviation value indicates higher precision.

compare_result

Output

Comparison result. true: The comparison is successful. false: The comparison failed.