class OpAttrDef {
public:
explicit OpAttrDef(const char *name);
OpAttrDef(const OpAttrDef &attr_def);
~OpAttrDef();
OpAttrDef &operator=(const OpAttrDef &attr_def);
OpAttrDef &AttrType(Option attr_type);
OpAttrDef &Bool(void);
OpAttrDef &Bool(bool value);
OpAttrDef &Float(void);
OpAttrDef &Float(float value);
OpAttrDef &Int(void);
OpAttrDef &Int(int64_t value);
OpAttrDef &String(void);
OpAttrDef &String(const char *value);
OpAttrDef &ListBool(void);
OpAttrDef &ListBool(std::vector<bool> value);
OpAttrDef &ListFloat(void);
OpAttrDef &ListFloat(std::vector<float> value);
OpAttrDef &ListInt(void);
OpAttrDef &ListInt(std::vector<int64_t> value);
ge::AscendString &GetName(void) const;
bool IsRequired(void);
private:
// ...
}; Table 1 Member functions of the OpAttrDef class
| Function Name | Input Parameter | Function Description |
|---|---|---|
| AttrType | attr_type: attribute type. | Sets the operator attribute type. The value can be OPTIONAL or REQUIRED. |
| Bool | None | Sets the operator attribute data type to Bool. |
| Bool | value | Sets the operator attribute data type to Bool and the default attribute value to value. If the attribute type is set to OPTIONAL, this API class must be called to set the default value. |
| Float | None | Sets the operator attribute data type to Float. |
| Float | value | Sets the operator attribute data type to Float and the default attribute value to value. If the attribute type is set to OPTIONAL, this API class must be called to set the default value. |
| Int | None | Sets the operator attribute data type to Int. |
| Int | value | Sets the operator attribute data type to Int and the default attribute value to value. If the attribute type is set to OPTIONAL, this API class must be called to set the default value. |
| String | None | Sets the operator attribute data type to String. |
| String | value | Sets the operator attribute data type to String and the default attribute value to value. If the attribute type is set to OPTIONAL, this API class must be called to set the default value. |
| ListBool | None | Sets the operator attribute data type to ListBool. |
| ListBool | value | Sets the operator attribute data type to ListBool and the default attribute value to value. If the attribute type is set to OPTIONAL, this API class must be called to set the default value. |
| ListFloat | None | Sets the operator attribute data type to ListFloat. |
| ListFloat | value | Sets the operator attribute data type to ListFloat and the default attribute value to value. If the attribute type is set to OPTIONAL, this API class must be called to set the default value. |
| ListInt | None | Sets the operator attribute data type to ListInt. |
| ListInt | value | Sets the operator attribute data type to ListInt and the default attribute value to value. If the attribute type is set to OPTIONAL, this API class must be called to set the default value. |
| GetName | None | Obtains the attribute name. |
| IsRequired | None | Determines whether an operator attribute is mandatory. If it is, true is returned. If not, false is returned. |