29 return llvm::isa<LocationAttr>(
unwrap(attr));
37 return llvm::isa<AffineMapAttr>(
unwrap(attr));
45 return wrap(AffineMapAttr::name);
49 return wrap(llvm::cast<AffineMapAttr>(
unwrap(attr)).getValue());
53 return wrap(AffineMapAttr::getTypeID());
61 return llvm::isa<ArrayAttr>(
unwrap(attr));
65 MlirAttribute
const *elements) {
75 return static_cast<intptr_t>(llvm::cast<ArrayAttr>(
unwrap(attr)).size());
79 return wrap(llvm::cast<ArrayAttr>(
unwrap(attr)).getValue()[pos]);
89 return llvm::isa<DictionaryAttr>(
unwrap(attr));
95 attributes.reserve(numElements);
96 for (
intptr_t i = 0; i < numElements; ++i)
97 attributes.emplace_back(
unwrap(elements[i].name),
98 unwrap(elements[i].attribute));
99 return wrap(DictionaryAttr::get(
unwrap(ctx), attributes));
103 return wrap(DictionaryAttr::name);
107 return static_cast<intptr_t>(llvm::cast<DictionaryAttr>(
unwrap(attr)).size());
123 return wrap(DictionaryAttr::getTypeID());
131 return llvm::isa<FloatAttr>(
unwrap(attr));
136 return wrap(FloatAttr::get(
unwrap(type), value));
145 return llvm::cast<FloatAttr>(
unwrap(attr)).getValueAsDouble();
155 return llvm::isa<IntegerAttr>(
unwrap(attr));
159 return wrap(IntegerAttr::get(
unwrap(type), value));
165 return llvm::cast<IntegerAttr>(
unwrap(attr)).getInt();
169 return llvm::cast<IntegerAttr>(
unwrap(attr)).getSInt();
173 return llvm::cast<IntegerAttr>(
unwrap(attr)).getUInt();
177 return wrap(IntegerAttr::getTypeID());
185 return llvm::isa<BoolAttr>(
unwrap(attr));
193 return llvm::cast<BoolAttr>(
unwrap(attr)).getValue();
201 return llvm::isa<IntegerSetAttr>(
unwrap(attr));
205 return wrap(IntegerSetAttr::getTypeID());
209 return wrap(IntegerSetAttr::get(
unwrap(set)));
213 return wrap(IntegerSetAttr::name);
217 return wrap(llvm::cast<IntegerSetAttr>(
unwrap(attr)).getValue());
225 return llvm::isa<OpaqueAttr>(
unwrap(attr));
229 intptr_t dataLength,
const char *data,
232 OpaqueAttr::get(StringAttr::get(
unwrap(ctx),
unwrap(dialectNamespace)),
233 StringRef(data, dataLength),
unwrap(type)));
240 llvm::cast<OpaqueAttr>(
unwrap(attr)).getDialectNamespace().strref());
244 return wrap(llvm::cast<OpaqueAttr>(
unwrap(attr)).getAttrData());
248 return wrap(OpaqueAttr::getTypeID());
256 return llvm::isa<StringAttr>(
unwrap(attr));
270 return wrap(llvm::cast<StringAttr>(
unwrap(attr)).getValue());
274 return wrap(StringAttr::getTypeID());
282 return llvm::isa<SymbolRefAttr>(
unwrap(attr));
287 MlirAttribute
const *references) {
289 refs.reserve(numReferences);
290 for (
intptr_t i = 0; i < numReferences; ++i)
291 refs.push_back(llvm::cast<FlatSymbolRefAttr>(
unwrap(references[i])));
292 auto symbolAttr = StringAttr::get(
unwrap(ctx),
unwrap(symbol));
293 return wrap(SymbolRefAttr::get(symbolAttr, refs));
297 return wrap(SymbolRefAttr::name);
302 llvm::cast<SymbolRefAttr>(
unwrap(attr)).getRootReference().getValue());
307 llvm::cast<SymbolRefAttr>(
unwrap(attr)).getLeafReference().getValue());
312 llvm::cast<SymbolRefAttr>(
unwrap(attr)).getNestedReferences().size());
318 llvm::cast<SymbolRefAttr>(
unwrap(attr)).getNestedReferences()[pos]);
322 return wrap(SymbolRefAttr::getTypeID());
334 return llvm::isa<FlatSymbolRefAttr>(
unwrap(attr));
342 return wrap(FlatSymbolRefAttr::name);
346 return wrap(llvm::cast<FlatSymbolRefAttr>(
unwrap(attr)).getValue());
354 return llvm::isa<TypeAttr>(
unwrap(attr));
364 return wrap(llvm::cast<TypeAttr>(
unwrap(attr)).getValue());
374 return llvm::isa<UnitAttr>(
unwrap(attr));
390 return llvm::isa<ElementsAttr>(
unwrap(attr));
395 return wrap(llvm::cast<ElementsAttr>(
unwrap(attr))
401 return llvm::cast<ElementsAttr>(
unwrap(attr))
406 return llvm::cast<ElementsAttr>(
unwrap(attr)).getNumElements();
414 return wrap(DenseArrayAttr::getTypeID());
422 return llvm::isa<DenseBoolArrayAttr>(
unwrap(attr));
425 return llvm::isa<DenseI8ArrayAttr>(
unwrap(attr));
428 return llvm::isa<DenseI16ArrayAttr>(
unwrap(attr));
431 return llvm::isa<DenseI32ArrayAttr>(
unwrap(attr));
434 return llvm::isa<DenseI64ArrayAttr>(
unwrap(attr));
437 return llvm::isa<DenseF32ArrayAttr>(
unwrap(attr));
440 return llvm::isa<DenseF64ArrayAttr>(
unwrap(attr));
453 int8_t
const *values) {
458 int16_t
const *values) {
463 int32_t
const *values) {
473 float const *values) {
478 double const *values) {
488 return llvm::cast<DenseArrayAttr>(
unwrap(attr)).size();
496 return llvm::cast<DenseBoolArrayAttr>(
unwrap(attr))[pos];
499 return llvm::cast<DenseI8ArrayAttr>(
unwrap(attr))[pos];
502 return llvm::cast<DenseI16ArrayAttr>(
unwrap(attr))[pos];
505 return llvm::cast<DenseI32ArrayAttr>(
unwrap(attr))[pos];
508 return llvm::cast<DenseI64ArrayAttr>(
unwrap(attr))[pos];
511 return llvm::cast<DenseF32ArrayAttr>(
unwrap(attr))[pos];
514 return llvm::cast<DenseF64ArrayAttr>(
unwrap(attr))[pos];
526 return llvm::isa<DenseElementsAttr>(
unwrap(attr));
530 return llvm::isa<DenseIntElementsAttr>(
unwrap(attr));
534 return llvm::isa<DenseFPElementsAttr>(
unwrap(attr));
538 return wrap(DenseIntOrFPElementsAttr::getTypeID());
547 MlirAttribute
const *elements) {
551 unwrapList(numElements, elements, attributes)));
555 size_t rawBufferSize,
556 const void *rawBuffer) {
557 auto shapedTypeCpp = llvm::cast<ShapedType>(
unwrap(shapedType));
560 bool isSplat =
false;
568 MlirAttribute element) {
620 const int *elements) {
637 const uint8_t *elements) {
642 const int8_t *elements) {
647 const uint16_t *elements) {
652 const int16_t *elements) {
657 const uint32_t *elements) {
662 const int32_t *elements) {
667 const uint64_t *elements) {
677 const float *elements) {
682 const double *elements) {
687 const uint16_t *elements) {
688 size_t bufferSize = numElements * 2;
689 const void *buffer =
static_cast<const void *
>(elements);
694 const uint16_t *elements) {
695 size_t bufferSize = numElements * 2;
696 const void *buffer =
static_cast<const void *
>(elements);
704 values.reserve(numElements);
705 for (
intptr_t i = 0; i < numElements; ++i)
706 values.push_back(
unwrap(strs[i]));
713 MlirType shapedType) {
714 return wrap(llvm::cast<DenseElementsAttr>(
unwrap(attr))
715 .reshape(llvm::cast<ShapedType>(
unwrap(shapedType))));
723 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).isSplat();
728 llvm::cast<DenseElementsAttr>(
unwrap(attr)).getSplatValue<Attribute>());
731 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getSplatValue<
bool>();
734 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getSplatValue<int8_t>();
737 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getSplatValue<uint8_t>();
740 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getSplatValue<int32_t>();
743 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getSplatValue<uint32_t>();
746 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getSplatValue<
int64_t>();
749 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getSplatValue<uint64_t>();
752 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getSplatValue<
float>();
755 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getSplatValue<
double>();
759 llvm::cast<DenseElementsAttr>(
unwrap(attr)).getSplatValue<StringRef>());
767 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getValues<
bool>()[pos];
770 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getValues<int8_t>()[pos];
773 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getValues<uint8_t>()[pos];
776 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getValues<int16_t>()[pos];
779 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getValues<uint16_t>()[pos];
782 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getValues<int32_t>()[pos];
785 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getValues<uint32_t>()[pos];
788 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getValues<
int64_t>()[pos];
791 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getValues<uint64_t>()[pos];
794 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getValues<uint64_t>()[pos];
797 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getValues<
float>()[pos];
800 return llvm::cast<DenseElementsAttr>(
unwrap(attr)).getValues<
double>()[pos];
805 llvm::cast<DenseElementsAttr>(
unwrap(attr)).getValues<StringRef>()[pos]);
813 return static_cast<const void *
>(
814 llvm::cast<DenseElementsAttr>(
unwrap(attr)).getRawData().data());
822 return llvm::isa<DenseResourceElementsAttr>(
unwrap(attr));
826 MlirType shapedType,
MlirStringRef name,
void *data,
size_t dataLength,
827 size_t dataAlignment,
bool dataIsMutable,
828 void (*deleter)(
void *userData,
const void *data,
size_t size,
833 cppDeleter = [deleter, userData](
void *data,
size_t size,
size_t align) {
834 deleter(userData, data, size, align);
839 dataAlignment, std::move(cppDeleter), dataIsMutable);
841 DenseResourceElementsAttr::get(llvm::cast<ShapedType>(
unwrap(shapedType)),
842 unwrap(name), std::move(blob)));
846 return wrap(DenseResourceElementsAttr::name);
849template <
typename U,
typename T>
851 intptr_t numElements,
const T *elements) {
852 return wrap(U::get(llvm::cast<ShapedType>(
unwrap(shapedType)),
unwrap(name),
859 const int *elements) {
861 numElements, elements);
865 const uint8_t *elements) {
867 numElements, elements);
871 const uint16_t *elements) {
873 numElements, elements);
877 const uint32_t *elements) {
879 numElements, elements);
883 const uint64_t *elements) {
885 numElements, elements);
889 const int8_t *elements) {
891 numElements, elements);
895 const int16_t *elements) {
897 numElements, elements);
901 const int32_t *elements) {
903 numElements, elements);
909 numElements, elements);
913 const float *elements) {
915 numElements, elements);
919 const double *elements) {
921 numElements, elements);
923template <
typename U,
typename T>
925 return (*llvm::cast<U>(
unwrap(attr)).tryGetAsArrayRef())[pos];
981 return llvm::isa<SparseElementsAttr>(
unwrap(attr));
985 MlirAttribute denseIndices,
986 MlirAttribute denseValues) {
987 return wrap(SparseElementsAttr::get(
988 llvm::cast<ShapedType>(
unwrap(shapedType)),
989 llvm::cast<DenseElementsAttr>(
unwrap(denseIndices)),
990 llvm::cast<DenseElementsAttr>(
unwrap(denseValues))));
994 return wrap(llvm::cast<SparseElementsAttr>(
unwrap(attr)).getIndices());
998 return wrap(llvm::cast<SparseElementsAttr>(
unwrap(attr)).getValues());
1002 return wrap(SparseElementsAttr::getTypeID());
1010 return llvm::isa<StridedLayoutAttr>(
unwrap(attr));
1016 return wrap(StridedLayoutAttr::get(
unwrap(ctx), offset,
1021 return wrap(StridedLayoutAttr::name);
1025 return llvm::cast<StridedLayoutAttr>(
unwrap(attr)).getOffset();
1030 llvm::cast<StridedLayoutAttr>(
unwrap(attr)).getStrides().size());
1034 return llvm::cast<StridedLayoutAttr>(
unwrap(attr)).getStrides()[pos];
1038 return wrap(StridedLayoutAttr::getTypeID());
bool mlirAttributeIsAFlatSymbolRef(MlirAttribute attr)
Checks whether the given attribute is a flat symbol reference attribute.
MlirAffineMap mlirAffineMapAttrGetValue(MlirAttribute attr)
Returns the affine map wrapped in the given affine map attribute.
MlirAttribute mlirDenseElementsAttrGet(MlirType shapedType, intptr_t numElements, MlirAttribute const *elements)
Creates a dense elements attribute with the given Shaped type and elements in the same context as the...
intptr_t mlirDictionaryAttrGetNumElements(MlirAttribute attr)
Returns the number of attributes contained in a dictionary attribute.
MlirAttribute mlirBoolAttrGet(MlirContext ctx, int value)
Creates a bool attribute in the given context with the given value.
float mlirDenseElementsAttrGetFloatValue(MlirAttribute attr, intptr_t pos)
int64_t mlirDenseInt64ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
MlirStringRef mlirFlatSymbolRefAttrGetValue(MlirAttribute attr)
Returns the referenced symbol as a string reference.
MlirAttribute mlirDenseF32ArrayGet(MlirContext ctx, intptr_t size, float const *values)
int16_t mlirDenseElementsAttrGetInt16Value(MlirAttribute attr, intptr_t pos)
MlirAttribute mlirSparseElementsAttrGetIndices(MlirAttribute attr)
Returns the dense elements attribute containing 64-bit integer indices of non-null elements in the gi...
MlirAttribute mlirUnmanagedDenseDoubleResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const double *elements)
uint32_t mlirDenseElementsAttrGetUInt32SplatValue(MlirAttribute attr)
bool mlirAttributeIsALocation(MlirAttribute attr)
bool mlirAttributeIsAString(MlirAttribute attr)
Checks whether the given attribute is a string attribute.
MlirStringRef mlirStringAttrGetName(void)
MlirStringRef mlirDenseElementsAttrGetStringValue(MlirAttribute attr, intptr_t pos)
const void * mlirDenseElementsAttrGetRawData(MlirAttribute attr)
Returns the raw data of the given dense elements attribute.
int8_t mlirDenseI8ArrayGetElement(MlirAttribute attr, intptr_t pos)
uint32_t mlirDenseElementsAttrGetUInt32Value(MlirAttribute attr, intptr_t pos)
MlirStringRef mlirArrayAttrGetName(void)
MlirIntegerSet mlirIntegerSetAttrGetValue(MlirAttribute attr)
Returns the integer set wrapped in the given integer set attribute.
bool mlirAttributeIsADenseI32Array(MlirAttribute attr)
MlirStringRef mlirTypeAttrGetName(void)
int64_t mlirIntegerAttrGetValueInt(MlirAttribute attr)
Returns the value stored in the given integer attribute, assuming the value is of signless type and f...
MlirStringRef mlirSymbolRefAttrGetRootReference(MlirAttribute attr)
Returns the string reference to the root referenced symbol.
MlirAttribute mlirAffineMapAttrGet(MlirAffineMap map)
Creates an affine map attribute wrapping the given map.
int mlirDenseElementsAttrGetBoolSplatValue(MlirAttribute attr)
MlirAttribute mlirStridedLayoutAttrGet(MlirContext ctx, int64_t offset, intptr_t numStrides, const int64_t *strides)
MlirStringRef mlirIntegerSetAttrGetName(void)
double mlirDenseDoubleResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
MlirAttribute mlirDisctinctAttrCreate(MlirAttribute referencedAttr)
Creates a DisctinctAttr with the referenced attribute.
uint16_t mlirDenseElementsAttrGetUInt16Value(MlirAttribute attr, intptr_t pos)
MlirAttribute mlirDenseElementsAttrFloat16Get(MlirType shapedType, intptr_t numElements, const uint16_t *elements)
float mlirDenseFloatResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
float mlirDenseF32ArrayGetElement(MlirAttribute attr, intptr_t pos)
uint8_t mlirDenseElementsAttrGetUInt8SplatValue(MlirAttribute attr)
uint64_t mlirIntegerAttrGetValueUInt(MlirAttribute attr)
Returns the value stored in the given integer attribute, assuming the value is of unsigned type and f...
bool mlirDenseBoolArrayGetElement(MlirAttribute attr, intptr_t pos)
Get an element of a dense array.
MlirAttribute mlirSparseElementsAttribute(MlirType shapedType, MlirAttribute denseIndices, MlirAttribute denseValues)
Creates a sparse elements attribute of the given shape from a list of indices and a list of associate...
MlirAttribute mlirIntegerSetAttrGet(MlirIntegerSet set)
Creates an integer set attribute wrapping the given set.
bool mlirAttributeIsADictionary(MlirAttribute attr)
Checks whether the given attribute is a dictionary attribute.
bool mlirDenseBoolResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
Returns the pos-th value (flat contiguous indexing) of a specific type contained by the given dense r...
MlirAttribute mlirFlatSymbolRefAttrGet(MlirContext ctx, MlirStringRef symbol)
Creates a flat symbol reference attribute in the given context referencing a symbol identified by the...
MlirAttribute mlirDenseElementsAttrInt16Get(MlirType shapedType, intptr_t numElements, const int16_t *elements)
bool mlirAttributeIsADenseElements(MlirAttribute attr)
Checks whether the given attribute is a dense elements attribute.
uint16_t mlirDenseUInt16ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
MlirTypeID mlirFloatAttrGetTypeID(void)
Returns the typeID of a Float attribute.
MlirAttribute mlirSymbolRefAttrGet(MlirContext ctx, MlirStringRef symbol, intptr_t numReferences, MlirAttribute const *references)
Creates a symbol reference attribute in the given context referencing a symbol identified by the give...
uint64_t mlirDenseUInt64ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
bool mlirAttributeIsASparseElements(MlirAttribute attr)
Checks whether the given attribute is a sparse elements attribute.
MlirTypeID mlirAffineMapAttrGetTypeID(void)
Returns the typeID of an AffineMap attribute.
bool mlirBoolAttrGetValue(MlirAttribute attr)
Returns the value stored in the given bool attribute.
MlirTypeID mlirDenseArrayAttrGetTypeID()
int16_t mlirDenseInt16ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
MlirAttribute mlirDenseElementsAttrBoolGet(MlirType shapedType, intptr_t numElements, const int *elements)
Creates a dense elements attribute with the given shaped type from elements of a specific type.
uint64_t mlirDenseElementsAttrGetUInt64SplatValue(MlirAttribute attr)
int64_t mlirIntegerAttrGetValueSInt(MlirAttribute attr)
Returns the value stored in the given integer attribute, assuming the value is of signed type and fit...
MlirAttribute mlirDenseI32ArrayGet(MlirContext ctx, intptr_t size, int32_t const *values)
MlirAttribute mlirSymbolRefAttrGetNestedReference(MlirAttribute attr, intptr_t pos)
Returns pos-th reference nested in the given symbol reference attribute.
MlirAttribute mlirDenseElementsAttrStringGet(MlirType shapedType, intptr_t numElements, MlirStringRef *strs)
Creates a dense elements attribute with the given shaped type from string elements.
MlirStringRef mlirUnitAttrGetName(void)
MlirTypeID mlirIntegerSetAttrGetTypeID(void)
Returns the typeID of an IntegerSet attribute.
MlirAttribute mlirUnmanagedDenseResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, void *data, size_t dataLength, size_t dataAlignment, bool dataIsMutable, void(*deleter)(void *userData, const void *data, size_t size, size_t align), void *userData)
Unlike the typed accessors below, constructs the attribute with a raw data buffer and no type/alignme...
MlirAttribute mlirUnmanagedDenseInt16ResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const int16_t *elements)
MlirStringRef mlirAffineMapAttrGetName(void)
MlirAttribute mlirDenseElementsAttrDoubleGet(MlirType shapedType, intptr_t numElements, const double *elements)
MlirAttribute mlirUnmanagedDenseUInt16ResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const uint16_t *elements)
intptr_t mlirSymbolRefAttrGetNumNestedReferences(MlirAttribute attr)
Returns the number of references nested in the given symbol reference attribute.
MlirStringRef mlirStridedLayoutAttrGetName(void)
bool mlirAttributeIsADenseI16Array(MlirAttribute attr)
MlirAttribute mlirDenseElementsAttrDoubleSplatGet(MlirType shapedType, double element)
intptr_t mlirDenseArrayGetNumElements(MlirAttribute attr)
Get the size of a dense array.
bool mlirAttributeIsADenseBoolArray(MlirAttribute attr)
Checks whether the given attribute is a dense array attribute.
MlirAttribute mlirUnmanagedDenseBoolResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const int *elements)
bool mlirAttributeIsADenseI64Array(MlirAttribute attr)
MlirStringRef mlirStringAttrGetValue(MlirAttribute attr)
Returns the attribute values as a string reference.
bool mlirAttributeIsAElements(MlirAttribute attr)
Checks whether the given attribute is an elements attribute.
MlirAttribute mlirStringAttrTypedGet(MlirType type, MlirStringRef str)
Creates a string attribute in the given context containing the given string.
uint8_t mlirDenseElementsAttrGetUInt8Value(MlirAttribute attr, intptr_t pos)
uint64_t mlirDenseElementsAttrGetUInt64Value(MlirAttribute attr, intptr_t pos)
MlirAttribute mlirDenseElementsAttrUInt8SplatGet(MlirType shapedType, uint8_t element)
MlirTypeID mlirTypeAttrGetTypeID(void)
Returns the typeID of a Type attribute.
MlirAttribute mlirDictionaryAttrGet(MlirContext ctx, intptr_t numElements, MlirNamedAttribute const *elements)
Creates a dictionary attribute containing the given list of elements in the provided context.
uint8_t mlirDenseUInt8ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
int8_t mlirDenseElementsAttrGetInt8SplatValue(MlirAttribute attr)
MlirStringRef mlirDenseResourceElementsAttrGetName(void)
MlirTypeID mlirDenseIntOrFPElementsAttrGetTypeID(void)
Returns the typeID of an DenseIntOrFPElements attribute.
MlirAttribute mlirDenseElementsAttrUInt16Get(MlirType shapedType, intptr_t numElements, const uint16_t *elements)
MlirNamedAttribute mlirDictionaryAttrGetElement(MlirAttribute attr, intptr_t pos)
Returns pos-th element of the given dictionary attribute.
MlirAttribute mlirDenseElementsAttrBFloat16Get(MlirType shapedType, intptr_t numElements, const uint16_t *elements)
int16_t mlirDenseI16ArrayGetElement(MlirAttribute attr, intptr_t pos)
int32_t mlirDenseI32ArrayGetElement(MlirAttribute attr, intptr_t pos)
MlirAttribute mlirStringAttrGet(MlirContext ctx, MlirStringRef str)
Creates a string attribute in the given context containing the given string.
bool mlirAttributeIsADenseFPElements(MlirAttribute attr)
bool mlirAttributeIsADenseI8Array(MlirAttribute attr)
MlirTypeID mlirOpaqueAttrGetTypeID(void)
Returns the typeID of an Opaque attribute.
MlirStringRef mlirSymbolRefAttrGetLeafReference(MlirAttribute attr)
Returns the string reference to the leaf referenced symbol.
bool mlirAttributeIsAType(MlirAttribute attr)
Checks whether the given attribute is a type attribute.
MlirAttribute mlirIntegerAttrGet(MlirType type, int64_t value)
Creates an integer attribute of the given type with the given integer value.
MlirType mlirTypeAttrGetValue(MlirAttribute attr)
Returns the type stored in the given type attribute.
MlirAttribute mlirArrayAttrGet(MlirContext ctx, intptr_t numElements, MlirAttribute const *elements)
Creates an array element containing the given list of elements in the given context.
double mlirDenseElementsAttrGetDoubleSplatValue(MlirAttribute attr)
MlirAttribute mlirUnmanagedDenseFloatResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const float *elements)
MlirAttribute mlirDenseElementsAttrInt64SplatGet(MlirType shapedType, int64_t element)
double mlirFloatAttrGetValueDouble(MlirAttribute attr)
Returns the value stored in the given floating point attribute, interpreting the value as double.
bool mlirAttributeIsAArray(MlirAttribute attr)
Checks whether the given attribute is an array attribute.
bool mlirAttributeIsAOpaque(MlirAttribute attr)
Checks whether the given attribute is an opaque attribute.
MlirAttribute mlirDenseElementsAttrFloatSplatGet(MlirType shapedType, float element)
MlirAttribute mlirDenseF64ArrayGet(MlirContext ctx, intptr_t size, double const *values)
bool mlirAttributeIsAAffineMap(MlirAttribute attr)
Checks whether the given attribute is an affine map attribute.
MlirStringRef mlirDictionaryAttrGetName(void)
MlirAttribute mlirDenseElementsAttrFloatGet(MlirType shapedType, intptr_t numElements, const float *elements)
MlirAttribute mlirSparseElementsAttrGetValues(MlirAttribute attr)
Returns the dense elements attribute containing the non-null elements in the given sparse elements at...
int64_t mlirStridedLayoutAttrGetStride(MlirAttribute attr, intptr_t pos)
MlirAttribute mlirArrayAttrGetElement(MlirAttribute attr, intptr_t pos)
Returns pos-th element stored in the given array attribute.
MlirStringRef mlirDenseElementsAttrGetStringSplatValue(MlirAttribute attr)
bool mlirDenseElementsAttrGetBoolValue(MlirAttribute attr, intptr_t pos)
Returns the pos-th value (flat contiguous indexing) of a specific type contained by the given dense e...
int32_t mlirDenseElementsAttrGetInt32Value(MlirAttribute attr, intptr_t pos)
intptr_t mlirStridedLayoutAttrGetNumStrides(MlirAttribute attr)
bool mlirAttributeIsADenseIntElements(MlirAttribute attr)
MlirTypeID mlirUnitAttrGetTypeID(void)
Returns the typeID of a Unit attribute.
bool mlirAttributeIsADenseF64Array(MlirAttribute attr)
MlirAttribute mlirDenseBoolArrayGet(MlirContext ctx, intptr_t size, int const *values)
Create a dense array attribute with the given elements.
MlirAttribute mlirDenseElementsAttrUInt32Get(MlirType shapedType, intptr_t numElements, const uint32_t *elements)
bool mlirAttributeIsABool(MlirAttribute attr)
Checks whether the given attribute is a bool attribute.
bool mlirAttributeIsADenseF32Array(MlirAttribute attr)
MlirAttribute mlirUnitAttrGet(MlirContext ctx)
Creates a unit attribute in the given context.
MlirAttribute mlirDenseI16ArrayGet(MlirContext ctx, intptr_t size, int16_t const *values)
MlirStringRef mlirSymbolRefAttrGetName(void)
int32_t mlirDenseElementsAttrGetInt32SplatValue(MlirAttribute attr)
int64_t mlirElementsAttrGetNumElements(MlirAttribute attr)
Gets the total number of elements in the given elements attribute.
MlirTypeID mlirStridedLayoutAttrGetTypeID(void)
Returns the typeID of a StridedLayout attribute.
double mlirDenseElementsAttrGetDoubleValue(MlirAttribute attr, intptr_t pos)
MlirStringRef mlirIntegerAttrGetName(void)
bool mlirElementsAttrIsValidIndex(MlirAttribute attr, intptr_t rank, uint64_t *idxs)
Checks whether the given rank-dimensional index is valid in the given elements attribute.
MlirAttribute mlirDenseElementsAttrRawBufferGet(MlirType shapedType, size_t rawBufferSize, const void *rawBuffer)
Creates a dense elements attribute with the given Shaped type and elements populated from a packed,...
bool mlirAttributeIsAFloat(MlirAttribute attr)
Checks whether the given attribute is a floating point attribute.
MlirAttribute mlirUnmanagedDenseInt32ResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const int32_t *elements)
MlirAttribute mlirFloatAttrDoubleGet(MlirContext ctx, MlirType type, double value)
Creates a floating point attribute in the given context with the given double value and double-precis...
MlirAttribute mlirUnmanagedDenseInt8ResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const int8_t *elements)
intptr_t mlirArrayAttrGetNumElements(MlirAttribute attr)
Returns the number of elements stored in the given array attribute.
uint64_t mlirDenseElementsAttrGetIndexValue(MlirAttribute attr, intptr_t pos)
MlirAttribute mlirDenseI64ArrayGet(MlirContext ctx, intptr_t size, int64_t const *values)
int64_t mlirDenseElementsAttrGetInt64Value(MlirAttribute attr, intptr_t pos)
bool mlirAttributeIsAStridedLayout(MlirAttribute attr)
bool mlirAttributeIsAIntegerSet(MlirAttribute attr)
Checks whether the given attribute is an integer set attribute.
int8_t mlirDenseInt8ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
MlirAttribute mlirDenseElementsAttrGetSplatValue(MlirAttribute attr)
Returns the single replicated value (splat) of a specific type contained by the given dense elements ...
MlirTypeID mlirStringAttrGetTypeID(void)
Returns the typeID of a String attribute.
static MlirAttribute getDenseResource(MlirType shapedType, MlirStringRef name, intptr_t numElements, const T *elements)
MlirStringRef mlirOpaqueAttrGetName(void)
MlirAttribute mlirDenseElementsAttrUInt8Get(MlirType shapedType, intptr_t numElements, const uint8_t *elements)
MlirStringRef mlirFlatSymbolRefAttrGetName(void)
static MlirAttribute getDenseAttribute(MlirType shapedType, intptr_t numElements, const T *elements)
Creates a dense attribute with elements of the type deduced by templates.
MlirAttribute mlirUnmanagedDenseInt64ResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const int64_t *elements)
bool mlirDenseElementsAttrIsSplat(MlirAttribute attr)
Checks whether the given dense elements attribute contains a single replicated value (splat).
MlirAttribute mlirElementsAttrGetValue(MlirAttribute attr, intptr_t rank, uint64_t *idxs)
Returns the element at the given rank-dimensional index.
MlirTypeID mlirSparseElementsAttrGetTypeID(void)
Returns the typeID of a SparseElements attribute.
MlirTypeID mlirIntegerAttrGetTypeID(void)
Returns the typeID of an Integer attribute.
MlirAttribute mlirDictionaryAttrGetElementByName(MlirAttribute attr, MlirStringRef name)
Returns the dictionary attribute element with the given name or NULL if the given name does not exist...
MlirAttribute mlirUnmanagedDenseUInt8ResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const uint8_t *elements)
double mlirDenseF64ArrayGetElement(MlirAttribute attr, intptr_t pos)
MlirAttribute mlirDenseElementsAttrInt8SplatGet(MlirType shapedType, int8_t element)
MlirAttribute mlirDenseElementsAttrInt32Get(MlirType shapedType, intptr_t numElements, const int32_t *elements)
MlirAttribute mlirDenseElementsAttrReshapeGet(MlirAttribute attr, MlirType shapedType)
Creates a dense elements attribute that has the same data as the given dense elements attribute and a...
MlirAttribute mlirDenseElementsAttrSplatGet(MlirType shapedType, MlirAttribute element)
Creates a dense elements attribute with the given Shaped type containing a single replicated element ...
MlirStringRef mlirOpaqueAttrGetDialectNamespace(MlirAttribute attr)
Returns the namespace of the dialect with which the given opaque attribute is associated.
MlirAttribute mlirOpaqueAttrGet(MlirContext ctx, MlirStringRef dialectNamespace, intptr_t dataLength, const char *data, MlirType type)
Creates an opaque attribute in the given context associated with the dialect identified by its namesp...
int64_t mlirDenseI64ArrayGetElement(MlirAttribute attr, intptr_t pos)
MlirAttribute mlirFloatAttrDoubleGetChecked(MlirLocation loc, MlirType type, double value)
Same as "mlirFloatAttrDoubleGet", but if the type is not valid for a construction of a FloatAttr,...
int64_t mlirDenseElementsAttrGetInt64SplatValue(MlirAttribute attr)
MlirAttribute mlirDenseElementsAttrInt8Get(MlirType shapedType, intptr_t numElements, const int8_t *elements)
MlirAttribute mlirDenseElementsAttrUInt64Get(MlirType shapedType, intptr_t numElements, const uint64_t *elements)
float mlirDenseElementsAttrGetFloatSplatValue(MlirAttribute attr)
MlirAttribute mlirDenseElementsAttrUInt32SplatGet(MlirType shapedType, uint32_t element)
MlirAttribute mlirUnmanagedDenseUInt64ResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const uint64_t *elements)
bool mlirAttributeIsAUnit(MlirAttribute attr)
Checks whether the given attribute is a unit attribute.
MlirAttribute mlirDenseElementsAttrUInt64SplatGet(MlirType shapedType, uint64_t element)
MlirTypeID mlirArrayAttrGetTypeID(void)
Returns the typeID of an Array attribute.
MlirAttribute mlirDenseElementsAttrBoolSplatGet(MlirType shapedType, bool element)
int8_t mlirDenseElementsAttrGetInt8Value(MlirAttribute attr, intptr_t pos)
MlirAttribute mlirDenseI8ArrayGet(MlirContext ctx, intptr_t size, int8_t const *values)
MlirAttribute mlirDenseElementsAttrInt32SplatGet(MlirType shapedType, int32_t element)
MlirTypeID mlirSymbolRefAttrGetTypeID(void)
Returns the typeID of an SymbolRef attribute.
uint32_t mlirDenseUInt32ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
bool mlirAttributeIsAInteger(MlirAttribute attr)
Checks whether the given attribute is an integer attribute.
MlirAttribute mlirDenseElementsAttrInt64Get(MlirType shapedType, intptr_t numElements, const int64_t *elements)
static T getDenseResourceVal(MlirAttribute attr, intptr_t pos)
bool mlirAttributeIsADenseResourceElements(MlirAttribute attr)
bool mlirAttributeIsASymbolRef(MlirAttribute attr)
Checks whether the given attribute is a symbol reference attribute.
MlirAttribute mlirUnmanagedDenseUInt32ResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const uint32_t *elements)
int64_t mlirStridedLayoutAttrGetOffset(MlirAttribute attr)
MlirStringRef mlirOpaqueAttrGetData(MlirAttribute attr)
Returns the raw data as a string reference.
MlirTypeID mlirDictionaryAttrGetTypeID(void)
Returns the typeID of a Dictionary attribute.
MlirAttribute mlirTypeAttrGet(MlirType type)
Creates a type attribute wrapping the given type in the same context as the type.
int32_t mlirDenseInt32ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
MlirAttribute mlirAttributeGetNull()
Returns an empty attribute.
static llvm::ArrayRef< CppTy > unwrapList(size_t size, CTy *first, llvm::SmallVectorImpl< CppTy > &storage)
This class represents a processed binary blob of data.
llvm::unique_function< void(void *data, size_t size, size_t align)> DeleterFn
A deleter function that frees a blob given the data, allocation size, and allocation aligment.
Attributes are known-constant values of operations.
static BoolAttr get(MLIRContext *context, bool value)
static DenseElementsAttr getFromRawBuffer(ShapedType type, ArrayRef< char > rawBuffer)
Construct a dense elements attribute from a raw buffer representing the data for this attribute.
static DenseElementsAttr get(ShapedType type, ArrayRef< Attribute > values)
Constructs a dense elements attribute from an array of element values.
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.
static DistinctAttr create(Attribute referencedAttr)
Creates a distinct attribute that associates a referenced attribute with a unique identifier.
static FlatSymbolRefAttr get(StringAttr value)
Construct a symbol reference for the given value name.
NamedAttribute represents a combination of a name and an Attribute value.
StringAttr getName() const
Return the name of the attribute.
Attribute getValue() const
Return the value of the attribute.
static AsmResourceBlob allocateInferAlign(ArrayRef< T > data, AsmResourceBlob::DeleterFn deleter={}, bool dataIsMutable=false)
static DenseArrayAttrImpl get(MLIRContext *context, ArrayRef< bool > content)
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
Include the generated interface declarations.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
A pointer to a sized fragment of a string, not necessarily null-terminated.