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

#include <Attributes.h>

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

Classes

class  AttributeElementIterator
 
class  BoolElementIterator
 A utility iterator that allows walking over the internal bool values. More...
 
class  ElementIterator
 
class  FloatElementIterator
 Iterator for walking over APFloat values. More...
 
class  IntElementIterator
 A utility iterator that allows walking over the internal raw APInt values. More...
 

Public Types

template<typename T >
using DerivedAttributeElementIterator = llvm::mapped_iterator< AttributeElementIterator, T(*)(Attribute)>
 
- Public Types inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT >
using Base = StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT >
 Utility declarations for the concrete attribute class. More...
 
using ImplType = StorageT
 

Public Member Functions

bool isSplat () const
 
Attribute getSplatValue () const
 
template<typename T >
std::enable_if<!std::is_base_of< Attribute, T >::value||std::is_same< Attribute, T >::value, T >::type getSplatValue () const
 
template<typename T >
std::enable_if< std::is_base_of< Attribute, T >::value &&!std::is_same< Attribute, T >::value, T >::type getSplatValue () const
 Return the splat value for derived attribute element types. More...
 
Attribute getValue (ArrayRef< uint64_t > index) const
 
template<typename T >
getValue (ArrayRef< uint64_t > index) const
 
template<typename T , typename = typename std::enable_if< (!std::is_same<T, bool>::value && std::numeric_limits<T>::is_integer) || llvm::is_one_of<T, float, double>::value>::type>
llvm::iterator_range< ElementIterator< T > > getValues () const
 
llvm::iterator_range< AttributeElementIteratorgetAttributeValues () const
 Return the held element values as a range of Attributes. More...
 
template<typename T , typename = typename std::enable_if< std::is_same<T, Attribute>::value>::type>
llvm::iterator_range< AttributeElementIteratorgetValues () const
 
AttributeElementIterator attr_value_begin () const
 
AttributeElementIterator attr_value_end () const
 
template<typename T , typename = typename std::enable_if< std::is_base_of<Attribute, T>::value && !std::is_same<Attribute, T>::value>::type>
llvm::iterator_range< DerivedAttributeElementIterator< T > > getValues () const
 
llvm::iterator_range< BoolElementIteratorgetBoolValues () const
 
template<typename T , typename = typename std::enable_if< std::is_same<T, bool>::value>::type>
llvm::iterator_range< BoolElementIteratorgetValues () const
 
llvm::iterator_range< IntElementIteratorgetIntValues () const
 
template<typename T , typename = typename std::enable_if< std::is_same<T, APInt>::value>::type>
llvm::iterator_range< IntElementIteratorgetValues () const
 
IntElementIterator int_value_begin () const
 
IntElementIterator int_value_end () const
 
llvm::iterator_range< FloatElementIteratorgetFloatValues () const
 
template<typename T , typename = typename std::enable_if< std::is_same<T, APFloat>::value>::type>
llvm::iterator_range< FloatElementIteratorgetValues () const
 
FloatElementIterator float_value_begin () const
 
FloatElementIterator float_value_end () const
 
DenseElementsAttr reshape (ShapedType newType)
 
DenseElementsAttr mapValues (Type newElementType, function_ref< APInt(const APInt &)> mapping) const
 
DenseElementsAttr mapValues (Type newElementType, function_ref< APInt(const APFloat &)> mapping) const
 

Static Public Member Functions

static bool classof (Attribute attr)
 Method for support type inquiry through isa, cast and dyn_cast. More...
 
static DenseElementsAttr get (ShapedType type, ArrayRef< Attribute > values)
 
template<typename T , typename = typename std::enable_if< std::numeric_limits<T>::is_integer || llvm::is_one_of<T, float, double>::value>::type>
static DenseElementsAttr get (const ShapedType &type, ArrayRef< T > values)
 
template<typename T , typename = typename std::enable_if< std::numeric_limits<T>::is_integer || llvm::is_one_of<T, float, double>::value>::type>
static DenseElementsAttr get (const ShapedType &type, T value)
 Constructs a dense integer elements attribute from a single element. More...
 
static DenseElementsAttr get (ShapedType type, ArrayRef< bool > values)
 Overload of the above 'get' method that is specialized for boolean values. More...
 
static DenseElementsAttr get (ShapedType type, ArrayRef< APInt > values)
 
static DenseElementsAttr get (ShapedType type, ArrayRef< APFloat > values)
 
template<typename T >
static DenseElementsAttr get (const ShapedType &type, const std::initializer_list< T > &list)
 
- Static Public Member Functions inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT >
static ClassIDgetClassID ()
 Return a unique identifier for the concrete type. More...
 
template<typename T >
static bool classof (T val)
 

Protected Member Functions

ArrayRef< char > getRawData () const
 Return the raw storage data held by this attribute. More...
 
IntElementIterator raw_int_begin () const
 Get iterators to the raw APInt values for each element in this attribute. More...
 
IntElementIterator raw_int_end () const
 
bool isValidIntOrFloat (int64_t dataEltSize, bool isInt) const
 
- Protected Member Functions inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT >
ImplTypegetImpl () const
 Utility for easy access to the storage instance. More...
 

Static Protected Member Functions

static DenseElementsAttr getRaw (ShapedType type, ArrayRef< APInt > values)
 
static DenseElementsAttr getRaw (ShapedType type, ArrayRef< char > data, bool isSplat)
 
static DenseElementsAttr getRawIntOrFloat (ShapedType type, ArrayRef< char > data, int64_t dataEltSize, bool isInt)
 
- Static Protected Member Functions inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT >
template<typename... Args>
static ConcreteT get (MLIRContext *ctx, unsigned kind, Args... args)
 
template<typename... Args>
static ConcreteT getChecked (const Location &loc, MLIRContext *ctx, unsigned kind, Args... args)
 
template<typename... Args>
static LogicalResult verifyConstructionInvariants (Args... args)
 Default implementation that just returns success. More...
 

Detailed Description

An attribute that represents a reference to a dense vector or tensor object.

Member Typedef Documentation

◆ DerivedAttributeElementIterator

template<typename T >
using mlir::DenseElementsAttr::DerivedAttributeElementIterator = llvm::mapped_iterator<AttributeElementIterator, T (*)(Attribute)>

Return the held element values a range of T, where T is a derived attribute type.

Member Function Documentation

◆ attr_value_begin()

auto DenseElementsAttr::attr_value_begin ( ) const

◆ attr_value_end()

auto DenseElementsAttr::attr_value_end ( ) const

◆ classof()

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

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

◆ float_value_begin()

auto DenseElementsAttr::float_value_begin ( ) const

◆ float_value_end()

auto DenseElementsAttr::float_value_end ( ) const

◆ get() [1/7]

DenseElementsAttr DenseElementsAttr::get ( ShapedType  type,
ArrayRef< Attribute values 
)
static

Constructs a dense elements attribute from an array of element values. Each element attribute value is expected to be an element of 'type'. 'type' must be a vector or tensor with static shape.

◆ get() [2/7]

template<typename T , typename = typename std::enable_if< std::numeric_limits<T>::is_integer || llvm::is_one_of<T, float, double>::value>::type>
static DenseElementsAttr mlir::DenseElementsAttr::get ( const ShapedType type,
ArrayRef< T >  values 
)
inlinestatic

Constructs a dense integer elements attribute from an array of integer or floating-point values. Each value is expected to be the same bitwidth of the element type of 'type'. 'type' must be a vector or tensor with static shape.

◆ get() [3/7]

template<typename T , typename = typename std::enable_if< std::numeric_limits<T>::is_integer || llvm::is_one_of<T, float, double>::value>::type>
static DenseElementsAttr mlir::DenseElementsAttr::get ( const ShapedType type,
value 
)
inlinestatic

Constructs a dense integer elements attribute from a single element.

◆ get() [4/7]

DenseElementsAttr DenseElementsAttr::get ( ShapedType  type,
ArrayRef< bool >  values 
)
static

Overload of the above 'get' method that is specialized for boolean values.

◆ get() [5/7]

DenseElementsAttr DenseElementsAttr::get ( ShapedType  type,
ArrayRef< APInt >  values 
)
static

Constructs a dense integer elements attribute from an array of APInt values. Each APInt value is expected to have the same bitwidth as the element type of 'type'. 'type' must be a vector or tensor with static shape.

Constructs a dense integer elements attribute from an array of APInt values. Each APInt value is expected to have the same bitwidth as the element type of 'type'.

◆ get() [6/7]

DenseElementsAttr DenseElementsAttr::get ( ShapedType  type,
ArrayRef< APFloat >  values 
)
static

Constructs a dense float elements attribute from an array of APFloat values. Each APFloat value is expected to have the same bitwidth as the element type of 'type'. 'type' must be a vector or tensor with static shape.

◆ get() [7/7]

template<typename T >
static DenseElementsAttr mlir::DenseElementsAttr::get ( const ShapedType type,
const std::initializer_list< T > &  list 
)
inlinestatic

Construct a dense elements attribute for an initializer_list of values. Each value is expected to be the same bitwidth of the element type of 'type'. 'type' must be a vector or tensor with static shape.

◆ getAttributeValues()

auto DenseElementsAttr::getAttributeValues ( ) const

Return the held element values as a range of Attributes.

◆ getBoolValues()

auto DenseElementsAttr::getBoolValues ( ) const

Return the held element values as a range of bool. The element type of this attribute must be of integer type of bitwidth 1.

◆ getFloatValues()

auto DenseElementsAttr::getFloatValues ( ) const

Return the held element values as a range of APFloat. The element type of this attribute must be of float type.

◆ getIntValues()

auto DenseElementsAttr::getIntValues ( ) const

Return the held element values as a range of APInts. The element type of this attribute must be of integer type.

◆ getRaw() [1/2]

DenseElementsAttr DenseElementsAttr::getRaw ( ShapedType  type,
ArrayRef< APInt >  values 
)
staticprotected

Constructs a dense elements attribute from an array of raw APInt values. Each APInt value is expected to have the same bitwidth as the element type of 'type'. 'type' must be a vector or tensor with static shape.

◆ getRaw() [2/2]

DenseElementsAttr DenseElementsAttr::getRaw ( ShapedType  type,
ArrayRef< char >  data,
bool  isSplat 
)
staticprotected

Get or create a new dense elements attribute instance with the given raw data buffer. 'type' must be a vector or tensor with static shape.

◆ getRawData()

ArrayRef< char > DenseElementsAttr::getRawData ( ) const
protected

Return the raw storage data held by this attribute.

◆ getRawIntOrFloat()

DenseElementsAttr DenseElementsAttr::getRawIntOrFloat ( ShapedType  type,
ArrayRef< char >  data,
int64_t  dataEltSize,
bool  isInt 
)
staticprotected

Overload of the raw 'get' method that asserts that the given type is of integer or floating-point type. This method is used to verify type invariants that the templatized 'get' method cannot.

Overload of the 'getRaw' method that asserts that the given type is of integer type. This method is used to verify type invariants that the templatized 'get' method cannot.

◆ getSplatValue() [1/3]

Attribute mlir::DenseElementsAttr::getSplatValue ( ) const
inline

Return the splat value for this attribute. This asserts that the attribute corresponds to a splat.

◆ getSplatValue() [2/3]

template<typename T >
std::enable_if<!std::is_base_of<Attribute, T>::value || std::is_same<Attribute, T>::value, T>::type mlir::DenseElementsAttr::getSplatValue ( ) const
inline

◆ getSplatValue() [3/3]

template<typename T >
std::enable_if<std::is_base_of<Attribute, T>::value && !std::is_same<Attribute, T>::value, T>::type mlir::DenseElementsAttr::getSplatValue ( ) const
inline

Return the splat value for derived attribute element types.

◆ getValue() [1/2]

Attribute mlir::DenseElementsAttr::getValue ( ArrayRef< uint64_t >  index) const
inline

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

◆ getValue() [2/2]

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

◆ getValues() [1/6]

template<typename T , typename = typename std::enable_if< (!std::is_same<T, bool>::value && std::numeric_limits<T>::is_integer) || llvm::is_one_of<T, float, double>::value>::type>
llvm::iterator_range<ElementIterator<T> > mlir::DenseElementsAttr::getValues ( ) const
inline

Return the held element values as a range of integer or floating-point values.

◆ getValues() [2/6]

template<typename T , typename = typename std::enable_if< std::is_same<T, Attribute>::value>::type>
llvm::iterator_range<AttributeElementIterator> mlir::DenseElementsAttr::getValues ( ) const
inline

◆ getValues() [3/6]

template<typename T , typename = typename std::enable_if< std::is_base_of<Attribute, T>::value && !std::is_same<Attribute, T>::value>::type>
llvm::iterator_range<DerivedAttributeElementIterator<T> > mlir::DenseElementsAttr::getValues ( ) const
inline

◆ getValues() [4/6]

template<typename T , typename = typename std::enable_if< std::is_same<T, bool>::value>::type>
llvm::iterator_range<BoolElementIterator> mlir::DenseElementsAttr::getValues ( ) const
inline

◆ getValues() [5/6]

template<typename T , typename = typename std::enable_if< std::is_same<T, APInt>::value>::type>
llvm::iterator_range<IntElementIterator> mlir::DenseElementsAttr::getValues ( ) const
inline

◆ getValues() [6/6]

template<typename T , typename = typename std::enable_if< std::is_same<T, APFloat>::value>::type>
llvm::iterator_range<FloatElementIterator> mlir::DenseElementsAttr::getValues ( ) const
inline

◆ int_value_begin()

auto DenseElementsAttr::int_value_begin ( ) const

◆ int_value_end()

auto DenseElementsAttr::int_value_end ( ) const

◆ isSplat()

bool DenseElementsAttr::isSplat ( ) const

Returns if this attribute corresponds to a splat, i.e. if all element values are the same.

◆ isValidIntOrFloat()

bool DenseElementsAttr::isValidIntOrFloat ( int64_t  dataEltSize,
bool  isInt 
) const
protected

Check the information for a c++ data type, check if this type is valid for the current attribute. This method is used to verify specific type invariants that the templatized 'getValues' method cannot.

A method used to verify specific type invariants that the templatized 'get' method cannot.

◆ mapValues() [1/2]

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

Generates a new DenseElementsAttr by mapping each int value to a new underlying APInt. The new values can represent either a integer or float. This underlying type must be an DenseIntElementsAttr.

◆ mapValues() [2/2]

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

Generates a new DenseElementsAttr by mapping each float value to a new underlying APInt. the new values can represent either a integer or float. This underlying type must be an DenseFPElementsAttr.

◆ raw_int_begin()

IntElementIterator mlir::DenseElementsAttr::raw_int_begin ( ) const
inlineprotected

Get iterators to the raw APInt values for each element in this attribute.

◆ raw_int_end()

IntElementIterator mlir::DenseElementsAttr::raw_int_end ( ) const
inlineprotected

◆ reshape()

DenseElementsAttr DenseElementsAttr::reshape ( ShapedType  newType)

Return a new DenseElementsAttr that has the same data as the current attribute, but has been reshaped to 'newType'. The new type must have the same total number of elements as well as element type.


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