My Project
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
mlir::ElementsAttr Class Reference

#include <Attributes.h>

Inheritance diagram for mlir::ElementsAttr:
Inheritance graph
[legend]
Collaboration diagram for mlir::ElementsAttr:
Collaboration graph
[legend]

Public Types

template<typename T >
using iterator = detail::ElementsAttrIterator< T >
 
template<typename T >
using iterator_range = detail::ElementsAttrRange< T >
 
- Public Types inherited from mlir::Attribute
enum  Kind { DEFINE_SYM_KIND_RANGE, DEFINE_SYM_KIND_RANGE }
 Integer identifier for all the concrete attribute kinds. More...
 
template<typename ConcreteType , typename BaseType = Attribute, typename StorageType = AttributeStorage>
using AttrBase = detail::StorageUserBase< ConcreteType, BaseType, StorageType, detail::AttributeUniquer >
 Utility class for implementing attributes. More...
 
using ImplType = AttributeStorage
 
using ValueType = void
 

Public Member Functions

ShapedType getType () const
 
Attribute getValue (ArrayRef< uint64_t > index) const
 
template<typename T >
getValue (ArrayRef< uint64_t > index) const
 
template<typename T >
iterator_range< T > getValues () const
 
bool isValidIndex (ArrayRef< uint64_t > index) const
 Return if the given 'index' refers to a valid element in this attribute. More...
 
int64_t getNumElements () const
 Returns the number of elements held by this attribute. More...
 
ElementsAttr mapValues (Type newElementType, function_ref< APInt(const APInt &)> mapping) const
 
ElementsAttr mapValues (Type newElementType, function_ref< APInt(const APFloat &)> mapping) const
 
template<typename T >
auto getValues () const -> iterator_range< T >
 Return the elements of this attribute as a value of type 'T'. More...
 
- Public Member Functions inherited from mlir::Attribute
 Attribute ()
 
 Attribute (const ImplType *impl)
 
 Attribute (const Attribute &other)=default
 
Attributeoperator= (const Attribute &other)=default
 
bool operator== (Attribute other) const
 
bool operator!= (Attribute other) const
 
 operator bool () const
 
bool operator! () const
 
template<typename U >
bool isa () const
 
template<typename U >
dyn_cast () const
 
template<typename U >
dyn_cast_or_null () const
 
template<typename U >
cast () const
 
unsigned getKind () const
 Return the classification for this attribute. More...
 
Type getType () const
 Return the type of this attribute. More...
 
MLIRContextgetContext () const
 Return the context this attribute belongs to. More...
 
DialectgetDialect () const
 Get the dialect this attribute is registered to. More...
 
void print (raw_ostream &os) const
 Print the attribute. More...
 
void dump () const
 
const void * getAsOpaquePointer () const
 Get an opaque pointer to the attribute. More...
 

Static Public Member Functions

static bool classof (Attribute attr)
 Method for support type inquiry through isa, cast and dyn_cast. More...
 
- Static Public Member Functions inherited from mlir::Attribute
static bool classof (Attribute)
 
static Attribute getFromOpaquePointer (const void *ptr)
 Construct an attribute from the opaque pointer representation. More...
 

Protected Member Functions

uint64_t getFlattenedIndex (ArrayRef< uint64_t > index) const
 

Additional Inherited Members

- Protected Attributes inherited from mlir::Attribute
ImplTypeimpl
 

Detailed Description

A base attribute that represents a reference to a static shaped tensor or vector constant.

Member Typedef Documentation

◆ iterator

◆ iterator_range

Member Function Documentation

◆ classof()

static bool mlir::ElementsAttr::classof ( Attribute  attr)
inlinestatic

Method for support type inquiry through isa, cast and dyn_cast.

◆ getFlattenedIndex()

uint64_t ElementsAttr::getFlattenedIndex ( ArrayRef< uint64_t >  index) const
protected

Returns the 1 dimensional flattened row-major index from the given multi-dimensional index.

◆ getNumElements()

int64_t ElementsAttr::getNumElements ( ) const

Returns the number of elements held by this attribute.

◆ getType()

ShapedType ElementsAttr::getType ( ) const

Return the type of this ElementsAttr, guaranteed to be a vector or tensor with static shape.

◆ getValue() [1/2]

Attribute ElementsAttr::getValue ( ArrayRef< uint64_t >  index) const

Return the value at the given index. The index is expected to refer to a valid element.

Return the value at the given index. If index does not refer to a valid element, then a null attribute is returned.

◆ getValue() [2/2]

template<typename T >
T mlir::ElementsAttr::getValue ( ArrayRef< uint64_t >  index) const
inline

Return the value of type 'T' at the given index, where 'T' corresponds to an Attribute type.

◆ getValues() [1/2]

template<typename T >
iterator_range<T> mlir::ElementsAttr::getValues ( ) const

Return the elements of this attribute as a value of type 'T'. Note: Aborts if the subclass is OpaqueElementsAttrs, these attrs do not support iteration.

◆ getValues() [2/2]

template<typename T >
auto mlir::ElementsAttr::getValues ( ) const -> iterator_range<T>

Return the elements of this attribute as a value of type 'T'.

◆ isValidIndex()

bool ElementsAttr::isValidIndex ( ArrayRef< uint64_t >  index) const

Return if the given 'index' refers to a valid element in this attribute.

◆ mapValues() [1/2]

ElementsAttr ElementsAttr::mapValues ( Type  newElementType,
function_ref< APInt(const APInt &)>  mapping 
) const

Generates a new ElementsAttr by mapping each int value to a new underlying APInt. The new values can represent either a integer or float. This ElementsAttr should contain integers.

◆ mapValues() [2/2]

ElementsAttr ElementsAttr::mapValues ( Type  newElementType,
function_ref< APInt(const APFloat &)>  mapping 
) const

Generates a new ElementsAttr by mapping each float value to a new underlying APInt. The new values can represent either a integer or float. This ElementsAttr should contain floats.


The documentation for this class was generated from the following files: