AppendAttr

Function Usage

Adds the attribute information of the operator IR prototype, with the subscript starting from 0. It is used to build ExtendedInfo in the base class ExtendedKernelContext of each subclass Context.

After the build is complete, the sequence of attributes in RuntimeAttrs obtained through the base class API GetAttr of Context is the same as the sequence of attributes added during the construction.

Example:

1
2
3
4
bool attr0 = true;
int64_t attr1 = 1;
vector<int64_t> attr2 = {1, 2, 3, 4};
context_builder.AppendAttr(attr0).AppendAttr(attr1).AppendAttr(attr2);

The following shows the build result:

ctx->GetAttrs()->GetBool(0) -> attr0,
ctx->GetAttrs()->GetInt(1) -> attr1,
ctx->GetAttrs()->GetListInt(2) -> attr2

Prototype

1
2
3
4
5
6
7
8
9
T &AppendAttr(bool attr)
T &AppendAttr(int64_t attr)
T &AppendAttr(float attr)
T &AppendAttr(const ge::AscendString &attr)
T &AppendAttr(const std::vector<bool> &attr)
T &AppendAttr(const std::vector<int64_t> &attr)
T &AppendAttr(const std::vector<float> &attr)
T &AppendAttr(const std::vector<ge::AscendString> &attr)
T &AppendAttr(const std::vector<std::vector<int64_t>> &attr)

Parameters

Parameter

Input/Output

Description

attr

Input

Attribute value. Currently, only the following types are supported: bool, int64_t, float, AscendString, std::vector<bool>, std::vector<int64_t>, std::vector<float>, std::vector<AscendString>, and std::vector<std::vector<int64_t>>.

Returns

A reference to the subclass object of type T. It is used for subclass chain calls.

Constraints

None