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

SetAttr

Function Prototype

Operator& SetAttr(const string& name, AttrValue&& attrValue);

Operator& SetAttr(const string& name, const UsrQuantizeFactorParams& attrValue);

Function Description

Sets the attribute value of an operator.

Parameter Description

Parameter

Input/Output

Type

Description

name

Input

const string&

Attribute name

attrValue

Input

AttrValue&&

Attribute value to be set

attrValue

Input

const UsrQuantizeFactorParams&

Quantization factor

For details about UsrQuantizeFactorParams, see Data Type Description.

Return Value

Parameter

Type

Description

-

Operator&

Object itself

Exception Handling

None

Restriction

None

Data Type Description

  • Struct UsrQuantizeFactorParams
    struct UsrQuantizeFactorParams
    {
        uint32_t quantize_algo{0};
        uint32_t scale_type{0};
        UsrQuantizeFactor quantize_param;
        UsrQuantizeFactor dequantize_param;
        UsrQuantizeFactor requantize_param;
        UsrQuantizeCalcFactor quantizecalc_param;
    };
  • Struct UsrQuantizeFactor
    struct UsrQuantizeFactor
    {
        //QuantizeScaleMode scale_mode;
        uint32_t scale_mode{0};
        std::vector<uint8_t> scale_value;
        int64_t scale_offset{0};
        std::vector<uint8_t> offset_data_value;
        int64_t offset_data_offset{0};
        std::vector<uint8_t> offset_weight_value;
        int64_t offset_weight_offset{0};
        std::vector<uint8_t> offset_pad_value;
        int64_t offset_pad_offset{0};
    };
  • Struct UsrQuantizeCalcFactor
    struct UsrQuantizeCalcFactor
    {
        std::vector<uint8_t> offsetw;
        int64_t offsetw_offset{0};
        std::vector<uint8_t> offsetd;
        int64_t offsetd_offset{0};
        std::vector<uint8_t> scalereq;
        int64_t scaledreq_offset{0};
        std::vector<uint8_t> offsetdnext;
        int64_t offsetdnext_offset{0};
    };