ATTR
Function Prototype
ATTR(x, default_value)
Function Description
Registers an operator attribute. The default value must be specified, so that the default value can be used if the attribute value of an operator object is not set.
After the operator attributes are successfully registered, three external APIs (for obtaining the attribute name, obtaining the attribute value, and setting the attribute value, respectively) are automatically generated.
The following describes the operator attribute APIs generated in int64_t and int64_t list scenarios:
- Register the attribute mode by calling ATTR(mode, AttrValue::INT{1}). The attribute type is int64_t and the default value is 1.
After the attribute is successfully registered, the following APIs are automatically generated:
static const string name_attr_mode(); // Returns the attribute name, that is, mode. int64_t get_attr_mode() const; // Returns the value of the mode attribute. _THIS_TYPE& set_attr_mode(int64_t v); // Sets the value of the mode attribute. The operator object is returned.
- Register the pad attribute by calling ATTR(pad, AttrValue::LIST_INT{0, 0, 0, 0}). The attribute type is int64_t list. The default value is {0,0,0,0}.
After the attribute is successfully registered, the following APIs are automatically generated:
static const string name_attr_pad(); // Returns the attribute name, that is, pad. vector<int64_t> get_attr_pad() const;; // Returns the value of the pad attribute. _THIS_TYPE& set_attr_pad(vector<int64_t> v); // Sets the value of the pad attribute. The operator object is returned.
Parameter Description
Parameter |
Input/Output |
Type |
Description |
---|---|---|---|
x |
Input |
- |
Macro parameter, attribute name of the operator |
default_value |
Input |
- |
Value of an operator attribute. The default value varies depending on the attribute type. The following attribute types are supported:
|
Return Value
None
Exception Handling
None
Restriction
For an operator, the registered attribute name must be unique.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot