GetAttr

Description

Obtains an attribute of an operator.

The name argument must be valid. If the operation fails, a null pointer is returned.

Prototype

AttrValue *GetAttr(std::string name) const

Parameters

Parameter

Input/Output

Description

name

Input

Supports the following inputs:

  • Name of the attribute to be obtained.
  • block_id: ID of the block participating in the current computation in the parallel computing scenario.
  • block_num: number of blocks in the parallel computing scenario.

Returns

An AttrValue * for the pointer to the AttrValue. If the operation fails, a null pointer is returned.

Restrictions

None

Examples

  • Obtain the value of the seed attribute.
    AttrValue *seed0 = ctx.GetAttr("seed");
  • Obtain the number of blocks and the block ID of the current computation in the parallel computing scenario.
    uint32_t blockdim = ctx.GetAttr("block_num")->GetInt();
    uint32_t blockid = ctx.GetAttr("block_id")->GetInt();