IrAttrDef

This struct is used for old APIs and contains the std::string field. You are advised to use the ABI-safe IrAttrDefV2 (see IrAttrDefV2) in new code.

The IR attribute definition structure is defined as follows:

struct IrAttrDef {
  std::string attr_name;
  IrAttrType ir_attr_type;
  std::string attr_data_type;  // see `kIrAttrTypesMap` in `operator.cc`
  AttrValue attr_default_value;
}

The parameters are described as follows.

Member

Type

Description

attr_name

std::string

Attribute name.

ir_attr_type

IrAttrType

Attribute type.

attr_data_type

std::string

Key value in kIrAttrTypesMap.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
const std::map<std::string, std::string> kIrAttrTypesMap = {
    {"Int", "VT_INT"},
    {"Float", "VT_FLOAT"},
    {"String", "VT_STRING"},
    {"Bool", "VT_BOOL"},
    {"Tensor", "VT_TENSOR"},
    {"NamedAttrs", "VT_NAMED_ATTRS"},
    {"ListInt", "VT_LIST_INT"},
    {"ListFloat", "VT_LIST_FLOAT"},
    {"ListString", "VT_LIST_STRING"},
    {"ListBool", "VT_LIST_BOOL"},
    {"ListTensor", "VT_LIST_TENSOR"},
    {"Bytes", "VT_BYTES"},
    {"ListListInt", "VT_LIST_LIST_INT"},
    {"ListNamedAttrs", "VT_LIST_NAMED_ATTRS"},
    {"Type", "VT_DATA_TYPE"},
    {"ListType", "VT_LIST_DATA_TYPE"},
}

attr_default_value

AttrValue

Default attribute value.