MLIR
20.0.0git
|
An attribute that represents a reference to a dense vector or tensor object. More...
#include "mlir/IR/BuiltinAttributes.h"
Classes | |
class | AttributeElementIterator |
A utility iterator that allows walking over the internal Attribute values of a DenseElementsAttr. More... | |
class | BoolElementIterator |
A utility iterator that allows walking over the internal bool values. More... | |
class | ComplexFloatElementIterator |
Iterator for walking over complex APFloat values. More... | |
class | ComplexIntElementIterator |
A utility iterator that allows walking over the internal raw complex APInt values. More... | |
struct | DerivedAttributeElementIterator |
class | ElementIterator |
Iterator for walking raw element values of the specified type 'T', which may be any c++ data type matching the stored representation: int32_t, float, etc. More... | |
class | FloatElementIterator |
Iterator for walking over APFloat values. More... | |
class | IntElementIterator |
A utility iterator that allows walking over the internal raw APInt values. More... | |
struct | is_valid_cpp_fp_type |
Type trait used to check if the given type T is a potentially valid C++ floating point type that can be used to access the underlying element types of a DenseElementsAttr. More... | |
Public Types | |
template<typename IteratorT > | |
using | iterator_range_impl = detail::ElementsAttrRange< IteratorT > |
The iterator range over the given iterator type T. More... | |
template<typename T , typename AttrT = DenseElementsAttr> | |
using | iterator = decltype(std::declval< AttrT >().template value_begin< T >()) |
The iterator for the given element type T. More... | |
template<typename T , typename AttrT = DenseElementsAttr> | |
using | iterator_range = decltype(std::declval< AttrT >().template getValues< T >()) |
The iterator range over the given element T. More... | |
template<typename T > | |
using | IntFloatValueTemplateCheckT = std::enable_if_t<(!std::is_same< T, bool >::value &&std::numeric_limits< T >::is_integer)||is_valid_cpp_fp_type< T >::value > |
Try to get the held element values as a range of integer or floating-point values. More... | |
template<typename T , typename ElementT > | |
using | ComplexValueTemplateCheckT = std::enable_if_t< detail::is_complex_t< T >::value &&(std::numeric_limits< ElementT >::is_integer||is_valid_cpp_fp_type< ElementT >::value)> |
Try to get the held element values as a range of std::complex. More... | |
template<typename T > | |
using | StringRefValueTemplateCheckT = std::enable_if_t< std::is_same< T, StringRef >::value > |
Try to get the held element values as a range of StringRef. More... | |
template<typename T > | |
using | AttributeValueTemplateCheckT = std::enable_if_t< std::is_same< T, Attribute >::value > |
Try to get the held element values as a range of Attributes. More... | |
template<typename T > | |
using | DerivedAttrValueTemplateCheckT = std::enable_if_t< std::is_base_of< Attribute, T >::value &&!std::is_same< Attribute, T >::value > |
Try to get the held element values a range of T, where T is a derived attribute type. More... | |
template<typename T > | |
using | BoolValueTemplateCheckT = std::enable_if_t< std::is_same< T, bool >::value > |
Try to get the held element values as a range of bool. More... | |
template<typename T > | |
using | APIntValueTemplateCheckT = std::enable_if_t< std::is_same< T, APInt >::value > |
Try to get the held element values as a range of APInts. More... | |
template<typename T > | |
using | ComplexAPIntValueTemplateCheckT = std::enable_if_t< std::is_same< T, std::complex< APInt > >::value > |
Try to get the held element values as a range of complex APInts. More... | |
template<typename T > | |
using | APFloatValueTemplateCheckT = std::enable_if_t< std::is_same< T, APFloat >::value > |
Try to get the held element values as a range of APFloat. More... | |
template<typename T > | |
using | ComplexAPFloatValueTemplateCheckT = std::enable_if_t< std::is_same< T, std::complex< APFloat > >::value > |
Try to get the held element values as a range of complex APFloat. More... | |
Public Types inherited from mlir::Attribute | |
template<typename ConcreteType , typename BaseType , typename StorageType , template< typename T > class... Traits> | |
using | AttrBase = detail::StorageUserBase< ConcreteType, BaseType, StorageType, detail::AttributeUniquer, Traits... > |
Utility class for implementing attributes. More... | |
using | ImplType = AttributeStorage |
using | ValueType = void |
using | AbstractTy = AbstractAttribute |
Public Member Functions | |
operator ElementsAttr () const | |
Allow implicit conversion to ElementsAttr. More... | |
operator TypedAttr () const | |
Allow implicit conversion to TypedAttr. More... | |
bool | isSplat () const |
Returns true if this attribute corresponds to a splat, i.e. More... | |
template<typename T > | |
std::enable_if_t<!std::is_base_of< Attribute, T >::value||std::is_same< Attribute, T >::value, T > | getSplatValue () const |
Return the splat value for this attribute. More... | |
template<typename T > | |
std::enable_if_t< std::is_base_of< Attribute, T >::value &&!std::is_same< Attribute, T >::value, T > | getSplatValue () const |
Return the splat value for derived attribute element types. More... | |
template<typename T > | |
auto | try_value_begin () const |
Try to get an iterator of the given type to the start of the held element values. More... | |
template<typename T > | |
auto | try_value_end () const |
Try to get an iterator of the given type to the end of the held element values. More... | |
template<typename T > | |
auto | getValues () const |
Return the held element values as a range of the given type. More... | |
template<typename T > | |
auto | value_begin () const |
Get an iterator of the given type to the start of the held element values. More... | |
template<typename T > | |
auto | value_end () const |
Get an iterator of the given type to the end of the held element values. More... | |
template<typename T , typename = IntFloatValueTemplateCheckT<T>> | |
FailureOr< iterator_range_impl< ElementIterator< T > > > | tryGetValues () const |
template<typename T , typename ElementT = typename T::value_type, typename = ComplexValueTemplateCheckT<T, ElementT>> | |
FailureOr< iterator_range_impl< ElementIterator< T > > > | tryGetValues () const |
template<typename T , typename = StringRefValueTemplateCheckT<T>> | |
FailureOr< iterator_range_impl< ElementIterator< StringRef > > > | tryGetValues () const |
template<typename T , typename = AttributeValueTemplateCheckT<T>> | |
FailureOr< iterator_range_impl< AttributeElementIterator > > | tryGetValues () const |
template<typename T , typename = DerivedAttrValueTemplateCheckT<T>> | |
FailureOr< iterator_range_impl< DerivedAttributeElementIterator< T > > > | tryGetValues () const |
template<typename T , typename = BoolValueTemplateCheckT<T>> | |
FailureOr< iterator_range_impl< BoolElementIterator > > | tryGetValues () const |
template<typename T , typename = APIntValueTemplateCheckT<T>> | |
FailureOr< iterator_range_impl< IntElementIterator > > | tryGetValues () const |
template<typename T , typename = ComplexAPIntValueTemplateCheckT<T>> | |
FailureOr< iterator_range_impl< ComplexIntElementIterator > > | tryGetValues () const |
template<typename T , typename = APFloatValueTemplateCheckT<T>> | |
FailureOr< iterator_range_impl< FloatElementIterator > > | tryGetValues () const |
template<typename T , typename = ComplexAPFloatValueTemplateCheckT<T>> | |
FailureOr< iterator_range_impl< ComplexFloatElementIterator > > | tryGetValues () const |
ArrayRef< char > | getRawData () const |
Return the raw storage data held by this attribute. More... | |
ArrayRef< StringRef > | getRawStringData () const |
Return the raw StringRef data held by this attribute. More... | |
ShapedType | getType () const |
Return the type of this ElementsAttr, guaranteed to be a vector or tensor with static shape. More... | |
Type | getElementType () const |
Return the element type of this DenseElementsAttr. More... | |
int64_t | getNumElements () const |
Returns the number of elements held by this attribute. More... | |
int64_t | size () const |
Returns the number of elements held by this attribute. More... | |
bool | empty () const |
Returns if the number of elements held by this attribute is 0. More... | |
DenseElementsAttr | reshape (ShapedType newType) |
Return a new DenseElementsAttr that has the same data as the current attribute, but has been reshaped to 'newType'. More... | |
DenseElementsAttr | resizeSplat (ShapedType newType) |
Return a new DenseElementsAttr that has the same data as the current attribute, but with a different shape for a splat type. More... | |
DenseElementsAttr | bitcast (Type newElType) |
Return a new DenseElementsAttr that has the same data as the current attribute, but has bitcast elements to 'newElType'. More... | |
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. More... | |
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. More... | |
constexpr | Attribute ()=default |
Attribute (const ImplType *impl) | |
Attribute (const Attribute &other)=default | |
Public Member Functions inherited from mlir::Attribute | |
constexpr | Attribute ()=default |
Attribute (const ImplType *impl) | |
Attribute (const Attribute &other)=default | |
Attribute & | operator= (const Attribute &other)=default |
bool | operator== (Attribute other) const |
bool | operator!= (Attribute other) const |
operator bool () const | |
bool | operator! () const |
template<typename... Tys> | |
bool | isa () const |
Casting utility functions. More... | |
template<typename... Tys> | |
bool | isa_and_nonnull () const |
template<typename U > | |
U | dyn_cast () const |
template<typename U > | |
U | dyn_cast_or_null () const |
template<typename U > | |
U | cast () const |
TypeID | getTypeID () |
Return a unique identifier for the concrete attribute type. More... | |
MLIRContext * | getContext () const |
Return the context this attribute belongs to. More... | |
Dialect & | getDialect () const |
Get the dialect this attribute is registered to. More... | |
void | print (raw_ostream &os, bool elideType=false) const |
Print the attribute. More... | |
void | print (raw_ostream &os, AsmState &state, bool elideType=false) const |
void | dump () const |
void | printStripped (raw_ostream &os) const |
Print the attribute without dialect wrapping. More... | |
void | printStripped (raw_ostream &os, AsmState &state) const |
const void * | getAsOpaquePointer () const |
Get an opaque pointer to the attribute. More... | |
template<typename InterfaceT > | |
bool | hasPromiseOrImplementsInterface () |
Returns true if InterfaceT has been promised by the dialect or implemented. More... | |
template<template< typename T > class Trait> | |
bool | hasTrait () |
Returns true if the type was registered with a particular trait. More... | |
const AbstractTy & | getAbstractAttribute () const |
Return the abstract descriptor for this attribute. More... | |
void | walkImmediateSubElements (function_ref< void(Attribute)> walkAttrsFn, function_ref< void(Type)> walkTypesFn) const |
Walk all of the immediately nested sub-attributes and sub-types. More... | |
auto | replaceImmediateSubElements (ArrayRef< Attribute > replAttrs, ArrayRef< Type > replTypes) const |
Replace the immediately nested sub-attributes and sub-types with those provided. More... | |
template<WalkOrder Order = WalkOrder::PostOrder, typename... WalkFns> | |
auto | walk (WalkFns &&...walkFns) |
Walk this attribute and all attibutes/types nested within using the provided walk functions. More... | |
template<typename... ReplacementFns> | |
auto | replace (ReplacementFns &&...replacementFns) |
Recursively replace all of the nested sub-attributes and sub-types using the provided map functions. More... | |
ImplType * | getImpl () const |
Return the internal Attribute implementation. More... | |
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) |
Constructs a dense elements attribute from an array of element values. More... | |
template<typename T , typename = std::enable_if_t<std::numeric_limits<T>::is_integer || is_valid_cpp_fp_type<T>::value>> | |
static DenseElementsAttr | get (const ShapedType &type, ArrayRef< T > values) |
Constructs a dense integer elements attribute from an array of integer or floating-point values. More... | |
template<typename T , typename = std::enable_if_t<std::numeric_limits<T>::is_integer || is_valid_cpp_fp_type<T>::value || detail::is_complex_t<T>::value>> | |
static DenseElementsAttr | get (const ShapedType &type, T value) |
Constructs a dense integer elements attribute from a single element. More... | |
template<typename T , typename ElementT = typename T::value_type, typename = std::enable_if_t<detail::is_complex_t<T>::value && (std::numeric_limits<ElementT>::is_integer || is_valid_cpp_fp_type<ElementT>::value)>> | |
static DenseElementsAttr | get (const ShapedType &type, ArrayRef< T > values) |
Constructs a dense complex elements attribute from an array of complex values. 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< StringRef > values) |
Overload of the above 'get' method that is specialized for StringRef values. More... | |
static DenseElementsAttr | get (ShapedType type, ArrayRef< APInt > values) |
Constructs a dense integer elements attribute from an array of APInt values. More... | |
static DenseElementsAttr | get (ShapedType type, ArrayRef< std::complex< APInt >> values) |
Constructs a dense complex elements attribute from an array of APInt values. More... | |
static DenseElementsAttr | get (ShapedType type, ArrayRef< APFloat > values) |
Constructs a dense float elements attribute from an array of APFloat values. More... | |
static DenseElementsAttr | get (ShapedType type, ArrayRef< std::complex< APFloat >> values) |
Constructs a dense complex elements attribute from an array of APFloat values. More... | |
template<typename T > | |
static DenseElementsAttr | get (const ShapedType &type, const std::initializer_list< T > &list) |
Construct a dense elements attribute for an initializer_list of values. More... | |
static DenseElementsAttr | getFromRawBuffer (ShapedType type, ArrayRef< char > rawBuffer) |
Construct a dense elements attribute from a raw buffer representing the data for this attribute. More... | |
static bool | isValidRawBuffer (ShapedType type, ArrayRef< char > rawBuffer, bool &detectedSplat) |
Returns true if the given buffer is a valid raw buffer for the given type. More... | |
Static Public Member Functions inherited from mlir::Attribute | |
static Attribute | getFromOpaquePointer (const void *ptr) |
Construct an attribute from the opaque pointer representation. More... | |
Protected Member Functions | |
IntElementIterator | raw_int_begin () const |
Iterators to various elements that require out-of-line definition. More... | |
IntElementIterator | raw_int_end () const |
FailureOr< iterator_range_impl< ComplexIntElementIterator > > | tryGetComplexIntValues () const |
FailureOr< iterator_range_impl< FloatElementIterator > > | tryGetFloatValues () const |
FailureOr< iterator_range_impl< ComplexFloatElementIterator > > | tryGetComplexFloatValues () const |
bool | isValidBool () const |
Check the information for a C++ data type, check if this type is valid for the current attribute. More... | |
bool | isValidIntOrFloat (int64_t dataEltSize, bool isInt, bool isSigned) const |
bool | isValidComplex (int64_t dataEltSize, bool isInt, bool isSigned) const |
Static Protected Member Functions | |
static DenseElementsAttr | getRawComplex (ShapedType type, ArrayRef< char > data, int64_t dataEltSize, bool isInt, bool isSigned) |
Overload of the raw 'get' method that asserts that the given type is of complex type. More... | |
static DenseElementsAttr | getRawIntOrFloat (ShapedType type, ArrayRef< char > data, int64_t dataEltSize, bool isInt, bool isSigned) |
Overload of the raw 'get' method that asserts that the given type is of integer or floating-point type. More... | |
Additional Inherited Members | |
Protected Attributes inherited from mlir::Attribute | |
ImplType * | impl {nullptr} |
An attribute that represents a reference to a dense vector or tensor object.
Definition at line 82 of file BuiltinAttributes.h.
using mlir::DenseElementsAttr::APFloatValueTemplateCheckT = std::enable_if_t<std::is_same<T, APFloat>::value> |
Try to get the held element values as a range of APFloat.
The element type of this attribute must be of float type.
Definition at line 571 of file BuiltinAttributes.h.
using mlir::DenseElementsAttr::APIntValueTemplateCheckT = std::enable_if_t<std::is_same<T, APInt>::value> |
Try to get the held element values as a range of APInts.
The element type of this attribute must be of integer type.
Definition at line 547 of file BuiltinAttributes.h.
using mlir::DenseElementsAttr::AttributeValueTemplateCheckT = std::enable_if_t<std::is_same<T, Attribute>::value> |
Try to get the held element values as a range of Attributes.
Definition at line 494 of file BuiltinAttributes.h.
using mlir::DenseElementsAttr::BoolValueTemplateCheckT = std::enable_if_t<std::is_same<T, bool>::value> |
Try to get the held element values as a range of bool.
The element type of this attribute must be of integer type of bitwidth 1.
Definition at line 533 of file BuiltinAttributes.h.
using mlir::DenseElementsAttr::ComplexAPFloatValueTemplateCheckT = std::enable_if_t<std::is_same<T, std::complex<APFloat> >::value> |
Try to get the held element values as a range of complex APFloat.
The element type of this attribute must be a complex of float type.
Definition at line 581 of file BuiltinAttributes.h.
using mlir::DenseElementsAttr::ComplexAPIntValueTemplateCheckT = std::enable_if_t<std::is_same<T, std::complex<APInt> >::value> |
Try to get the held element values as a range of complex APInts.
The element type of this attribute must be a complex of integer type.
Definition at line 560 of file BuiltinAttributes.h.
using mlir::DenseElementsAttr::ComplexValueTemplateCheckT = std::enable_if_t<detail::is_complex_t<T>::value && (std::numeric_limits<ElementT>::is_integer || is_valid_cpp_fp_type<ElementT>::value)> |
Try to get the held element values as a range of std::complex.
Definition at line 460 of file BuiltinAttributes.h.
using mlir::DenseElementsAttr::DerivedAttrValueTemplateCheckT = std::enable_if_t<std::is_base_of<Attribute, T>::value && !std::is_same<Attribute, T>::value> |
Try to get the held element values a range of T, where T is a derived attribute type.
Definition at line 507 of file BuiltinAttributes.h.
using mlir::DenseElementsAttr::IntFloatValueTemplateCheckT = std::enable_if_t<(!std::is_same<T, bool>::value && std::numeric_limits<T>::is_integer) || is_valid_cpp_fp_type<T>::value> |
Try to get the held element values as a range of integer or floating-point values.
Definition at line 442 of file BuiltinAttributes.h.
using mlir::DenseElementsAttr::iterator = decltype(std::declval<AttrT>().template value_begin<T>()) |
The iterator for the given element type T.
Definition at line 232 of file BuiltinAttributes.h.
using mlir::DenseElementsAttr::iterator_range = decltype(std::declval<AttrT>().template getValues<T>()) |
The iterator range over the given element T.
Definition at line 235 of file BuiltinAttributes.h.
using mlir::DenseElementsAttr::iterator_range_impl = detail::ElementsAttrRange<IteratorT> |
The iterator range over the given iterator type T.
Definition at line 228 of file BuiltinAttributes.h.
using mlir::DenseElementsAttr::StringRefValueTemplateCheckT = std::enable_if_t<std::is_same<T, StringRef>::value> |
Try to get the held element values as a range of StringRef.
Definition at line 479 of file BuiltinAttributes.h.
|
constexprdefault |
|
default |
|
inline |
Definition at line 38 of file Attributes.h.
DenseElementsAttr DenseElementsAttr::bitcast | ( | Type | newElType | ) |
Return a new DenseElementsAttr that has the same data as the current attribute, but has bitcast elements to 'newElType'.
Return a new DenseElementsAttr that has the same data as the current attribute, but has bitcast elements such that it is now 'newType'.
The new type must have the same bitwidth as the current element type.
The new type must have the same shape and element types of the same bitwidth as the current type.
Definition at line 1261 of file BuiltinAttributes.cpp.
References mlir::detail::getDenseElementBitWidth(), getRawData(), and getType().
|
static |
Method for support type inquiry through isa, cast and dyn_cast.
Definition at line 894 of file BuiltinAttributes.cpp.
|
inline |
Returns if the number of elements held by this attribute is 0.
Definition at line 611 of file BuiltinAttributes.h.
References size().
|
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.
Definition at line 121 of file BuiltinAttributes.h.
References getRawIntOrFloat().
|
inlinestatic |
Constructs a dense complex elements attribute from an array of complex 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.
Definition at line 145 of file BuiltinAttributes.h.
References getRawComplex().
|
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.
Definition at line 189 of file BuiltinAttributes.h.
References get().
|
inlinestatic |
Constructs a dense integer elements attribute from a single element.
Definition at line 133 of file BuiltinAttributes.h.
References get().
|
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.
Definition at line 1037 of file BuiltinAttributes.cpp.
References getDenseElementStorageWidth(), and hasSameElementsOrSplat().
|
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.
Each APInt value is expected to have the same bitwidth as the element type of 'type'.
Definition at line 1016 of file BuiltinAttributes.cpp.
References getDenseElementStorageWidth(), and hasSameElementsOrSplat().
|
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. If the element of type
is non-integer/index/float it is assumed to be a string type.
Definition at line 898 of file BuiltinAttributes.cpp.
References mlir::detail::divideCeil(), mlir::detail::getDenseElementBitWidth(), getDenseElementStorageWidth(), hasSameElementsOrSplat(), mlir::Type::isInteger(), mlir::Type::isIntOrIndexOrFloat(), and writeBits().
Referenced by mlir::constFoldBinaryOpConditional(), mlir::constFoldCastOp(), mlir::constFoldUnaryOpConditional(), convertConstantOpMmaSync(), createConst(), createConstantAllBitsSet(), createFloatConst(), createFPConstant(), createIntConst(), mlir::LLVM::createPrintStrCall(), mlir::createScalarOrSplatConstant(), mlir::DenseFPElementsAttr::get(), mlir::DenseIntElementsAttr::get(), get(), getBoolAttribute(), getCompressedMaskOp(), getDenseAttribute(), mlir::sparse_tensor::getOneAttr(), mlir::Builder::getOneAttr(), getScalarOrVectorConstInt(), mlir::Builder::getZeroAttr(), MaterializePadValue::matchAndRewrite(), mlirDenseElementsAttrBoolGet(), mlirDenseElementsAttrBoolSplatGet(), mlirDenseElementsAttrDoubleSplatGet(), mlirDenseElementsAttrFloatSplatGet(), mlirDenseElementsAttrGet(), mlirDenseElementsAttrInt32SplatGet(), mlirDenseElementsAttrInt64SplatGet(), mlirDenseElementsAttrInt8SplatGet(), mlirDenseElementsAttrSplatGet(), mlirDenseElementsAttrStringGet(), mlirDenseElementsAttrUInt32SplatGet(), mlirDenseElementsAttrUInt64SplatGet(), mlirDenseElementsAttrUInt8SplatGet(), mlir::detail::DenseArrayAttrImpl< T >::parse(), mlir::detail::Parser::parseSparseElementsAttr(), and mlir::detail::DenseArrayAttrImpl< T >::parseWithoutBraces().
|
static |
Overload of the above 'get' method that is specialized for boolean values.
Definition at line 982 of file BuiltinAttributes.cpp.
References mlir::detail::divideCeil(), hasSameElementsOrSplat(), isSplat(), and setBit().
|
static |
Constructs a dense complex 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.
Definition at line 1045 of file BuiltinAttributes.cpp.
References getDenseElementStorageWidth(), and hasSameElementsOrSplat().
|
static |
Constructs a dense complex 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.
Definition at line 1023 of file BuiltinAttributes.cpp.
References getDenseElementStorageWidth(), and hasSameElementsOrSplat().
|
static |
Overload of the above 'get' method that is specialized for StringRef values.
Definition at line 1007 of file BuiltinAttributes.cpp.
References mlir::get().
Type DenseElementsAttr::getElementType | ( | ) | const |
Return the element type of this DenseElementsAttr.
Definition at line 1291 of file BuiltinAttributes.cpp.
References getType().
Referenced by binaryFolder(), isComplexOfIntType(), isValidBool(), isValidComplex(), isValidIntOrFloat(), tryGetComplexFloatValues(), tryGetComplexIntValues(), tryGetFloatValues(), and tryGetValues().
|
static |
Construct a dense elements attribute from a raw buffer representing the data for this attribute.
Users are encouraged to use one of the constructors above, which provide more safeties. However, this constructor is useful for tools which may want to interop and can follow the precise definition.
The format of the raw buffer is a densely packed array of values that can be bitcast to the storage format of the element type specified. Types that are not byte aligned will be:
Users should generally not use this methods as the expected buffer format may not be a form the user expects.
Definition at line 1060 of file BuiltinAttributes.cpp.
Referenced by mlirDenseElementsAttrRawBufferGet().
int64_t DenseElementsAttr::getNumElements | ( | ) | const |
Returns the number of elements held by this attribute.
Definition at line 1295 of file BuiltinAttributes.cpp.
References getType().
Referenced by convertDenseElementsAttr(), raw_int_end(), size(), tryGetComplexFloatValues(), tryGetComplexIntValues(), and tryGetValues().
|
staticprotected |
Overload of the raw 'get' method that asserts that the given type is of complex type.
Defaults down the subclass implementation.
This method is used to verify type invariants that the templatized 'get' method cannot.
Definition at line 1149 of file BuiltinAttributes.cpp.
Referenced by get().
ArrayRef< char > DenseElementsAttr::getRawData | ( | ) | const |
Return the raw storage data held by this attribute.
Users should generally not use this directly, as the internal storage format is not always in the form the user might expect.
Definition at line 1222 of file BuiltinAttributes.cpp.
References mlir::Attribute::impl.
Referenced by bitcast(), convertDenseElementsAttr(), mlir::detail::DenseArrayAttrImpl< T >::operator ArrayRef< T >(), reshape(), resizeSplat(), and tryGetValues().
|
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.
Definition at line 1156 of file BuiltinAttributes.cpp.
Referenced by get().
ArrayRef< StringRef > DenseElementsAttr::getRawStringData | ( | ) | const |
Return the raw StringRef data held by this attribute.
Definition at line 1226 of file BuiltinAttributes.cpp.
References mlir::Attribute::impl.
Referenced by tryGetValues().
|
inline |
Return the splat value for this attribute.
This asserts that the attribute corresponds to a splat.
Definition at line 388 of file BuiltinAttributes.h.
References isSplat().
Referenced by binaryFolder(), convertDenseElementsAttr(), isSplatOne(), isSplatWriteConsistentWithMaskedRead(), isSplatZero(), and reshapeConstantSource().
|
inline |
Return the splat value for derived attribute element types.
Definition at line 397 of file BuiltinAttributes.h.
ShapedType DenseElementsAttr::getType | ( | ) | const |
Return the type of this ElementsAttr, guaranteed to be a vector or tensor with static shape.
Definition at line 1287 of file BuiltinAttributes.cpp.
References mlir::Attribute::impl.
Referenced by binaryFolder(), bitcast(), convertDenseElementsAttr(), getElementType(), getNumElements(), mlir::DenseFPElementsAttr::mapValues(), mlir::DenseIntElementsAttr::mapValues(), reshape(), resizeSplat(), tryGetComplexFloatValues(), tryGetComplexIntValues(), tryGetFloatValues(), and tryGetValues().
|
inline |
Return the held element values as a range of the given type.
Definition at line 421 of file BuiltinAttributes.h.
bool DenseElementsAttr::isSplat | ( | ) | const |
Returns true if this attribute corresponds to a splat, i.e.
if all element values are the same.
Definition at line 1178 of file BuiltinAttributes.cpp.
References mlir::Attribute::impl.
Referenced by binaryFolder(), convertDenseElementsAttr(), get(), getSplatValue(), isSplatOne(), isSplatWriteConsistentWithMaskedRead(), isSplatZero(), reshapeConstantSource(), resizeSplat(), and tryGetValues().
|
inlineprotected |
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.
Definition at line 680 of file BuiltinAttributes.h.
References getElementType(), and mlir::Type::isInteger().
Referenced by tryGetValues().
|
protected |
Definition at line 1169 of file BuiltinAttributes.cpp.
References getElementType(), and isValidIntOrFloat().
Referenced by tryGetValues().
|
protected |
Definition at line 1165 of file BuiltinAttributes.cpp.
References getElementType(), and isValidIntOrFloat().
Referenced by tryGetValues().
|
static |
Returns true if the given buffer is a valid raw buffer for the given type.
detectedSplat
is set if the buffer is valid and represents a splat buffer. The definition may be expanded over time, but currently, a splat buffer is detected if:
User code should be prepared for additional, conformant patterns to be identified as splats in the future.
Definition at line 1065 of file BuiltinAttributes.cpp.
References getDenseElementStorageWidth().
Referenced by mlirDenseElementsAttrRawBufferGet().
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 an integer or float. This underlying type must be an DenseFPElementsAttr.
Definition at line 1281 of file BuiltinAttributes.cpp.
References mapValues().
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 an integer or float. This underlying type must be an DenseIntElementsAttr.
Definition at line 1275 of file BuiltinAttributes.cpp.
References mapValues().
Referenced by mapValues().
|
inline |
Allow implicit conversion to ElementsAttr.
Definition at line 87 of file BuiltinAttributes.h.
|
inline |
Allow implicit conversion to TypedAttr.
Definition at line 89 of file BuiltinAttributes.h.
|
inlineprotected |
Iterators to various elements that require out-of-line definition.
These are hidden from the user to encourage consistent use of the getValues/value_begin/value_end API.
Definition at line 649 of file BuiltinAttributes.h.
Referenced by tryGetFloatValues(), and tryGetValues().
|
inlineprotected |
Definition at line 652 of file BuiltinAttributes.h.
References getNumElements().
Referenced by tryGetFloatValues(), and tryGetValues().
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.
Definition at line 1233 of file BuiltinAttributes.cpp.
References getRawData(), and getType().
DenseElementsAttr DenseElementsAttr::resizeSplat | ( | ShapedType | newType | ) |
Return a new DenseElementsAttr that has the same data as the current attribute, but with a different shape for a splat type.
The new type must have the same element type.
Definition at line 1245 of file BuiltinAttributes.cpp.
References getRawData(), getType(), and isSplat().
Referenced by reshapeConstantSource().
|
inline |
Returns the number of elements held by this attribute.
Definition at line 608 of file BuiltinAttributes.h.
References getNumElements().
Referenced by empty().
|
inline |
Try to get an iterator of the given type to the start of the held element values.
Return failure if the type cannot be iterated.
Definition at line 404 of file BuiltinAttributes.h.
|
inline |
Try to get an iterator of the given type to the end of the held element values.
Return failure if the type cannot be iterated.
Definition at line 413 of file BuiltinAttributes.h.
|
protected |
Definition at line 1207 of file BuiltinAttributes.cpp.
References getElementType(), getNumElements(), and getType().
Referenced by tryGetValues().
|
protected |
Definition at line 1187 of file BuiltinAttributes.cpp.
References getElementType(), getNumElements(), getType(), and isComplexOfIntType().
Referenced by tryGetValues().
|
protected |
Definition at line 1196 of file BuiltinAttributes.cpp.
References getElementType(), getType(), raw_int_begin(), and raw_int_end().
Referenced by tryGetValues().
|
inline |
Definition at line 447 of file BuiltinAttributes.h.
References getNumElements(), getRawData(), getType(), isSplat(), and isValidIntOrFloat().
|
inline |
Definition at line 466 of file BuiltinAttributes.h.
References getNumElements(), getRawData(), getType(), isSplat(), and isValidComplex().
|
inline |
Definition at line 483 of file BuiltinAttributes.h.
References getNumElements(), getRawStringData(), getType(), and isSplat().
|
inline |
Definition at line 498 of file BuiltinAttributes.h.
References getNumElements(), and getType().
|
inline |
Definition at line 523 of file BuiltinAttributes.h.
References getType().
|
inline |
Definition at line 536 of file BuiltinAttributes.h.
References getNumElements(), getType(), and isValidBool().
|
inline |
Definition at line 550 of file BuiltinAttributes.h.
References getElementType(), getType(), raw_int_begin(), and raw_int_end().
|
inline |
Definition at line 564 of file BuiltinAttributes.h.
References tryGetComplexIntValues().
|
inline |
Definition at line 574 of file BuiltinAttributes.h.
References tryGetFloatValues().
|
inline |
Definition at line 585 of file BuiltinAttributes.h.
References tryGetComplexFloatValues().
|
inline |
Get an iterator of the given type to the start of the held element values.
Definition at line 429 of file BuiltinAttributes.h.
|
inline |
Get an iterator of the given type to the end of the held element values.
Definition at line 435 of file BuiltinAttributes.h.