MLIR  17.0.0git
BuiltinAttributes.h
Go to the documentation of this file.
1 //===-- mlir-c/BuiltinAttributes.h - C API for Builtin Attributes -*- C -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM
4 // Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This header declares the C interface to MLIR Builtin attributes.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_C_BUILTINATTRIBUTES_H
15 #define MLIR_C_BUILTINATTRIBUTES_H
16 
17 #include "mlir-c/AffineMap.h"
18 #include "mlir-c/IR.h"
19 #include "mlir-c/Support.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 /// Returns an empty attribute.
26 MLIR_CAPI_EXPORTED MlirAttribute mlirAttributeGetNull(void);
27 
28 //===----------------------------------------------------------------------===//
29 // Location attribute.
30 //===----------------------------------------------------------------------===//
31 
32 MLIR_CAPI_EXPORTED bool mlirAttributeIsALocation(MlirAttribute attr);
33 
34 //===----------------------------------------------------------------------===//
35 // Affine map attribute.
36 //===----------------------------------------------------------------------===//
37 
38 /// Checks whether the given attribute is an affine map attribute.
39 MLIR_CAPI_EXPORTED bool mlirAttributeIsAAffineMap(MlirAttribute attr);
40 
41 /// Creates an affine map attribute wrapping the given map. The attribute
42 /// belongs to the same context as the affine map.
43 MLIR_CAPI_EXPORTED MlirAttribute mlirAffineMapAttrGet(MlirAffineMap map);
44 
45 /// Returns the affine map wrapped in the given affine map attribute.
46 MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapAttrGetValue(MlirAttribute attr);
47 
48 //===----------------------------------------------------------------------===//
49 // Array attribute.
50 //===----------------------------------------------------------------------===//
51 
52 /// Checks whether the given attribute is an array attribute.
53 MLIR_CAPI_EXPORTED bool mlirAttributeIsAArray(MlirAttribute attr);
54 
55 /// Creates an array element containing the given list of elements in the given
56 /// context.
58  MlirContext ctx, intptr_t numElements, MlirAttribute const *elements);
59 
60 /// Returns the number of elements stored in the given array attribute.
61 MLIR_CAPI_EXPORTED intptr_t mlirArrayAttrGetNumElements(MlirAttribute attr);
62 
63 /// Returns pos-th element stored in the given array attribute.
64 MLIR_CAPI_EXPORTED MlirAttribute mlirArrayAttrGetElement(MlirAttribute attr,
65  intptr_t pos);
66 
67 //===----------------------------------------------------------------------===//
68 // Dictionary attribute.
69 //===----------------------------------------------------------------------===//
70 
71 /// Checks whether the given attribute is a dictionary attribute.
72 MLIR_CAPI_EXPORTED bool mlirAttributeIsADictionary(MlirAttribute attr);
73 
74 /// Creates a dictionary attribute containing the given list of elements in the
75 /// provided context.
77  MlirContext ctx, intptr_t numElements, MlirNamedAttribute const *elements);
78 
79 /// Returns the number of attributes contained in a dictionary attribute.
80 MLIR_CAPI_EXPORTED intptr_t
81 mlirDictionaryAttrGetNumElements(MlirAttribute attr);
82 
83 /// Returns pos-th element of the given dictionary attribute.
85 mlirDictionaryAttrGetElement(MlirAttribute attr, intptr_t pos);
86 
87 /// Returns the dictionary attribute element with the given name or NULL if the
88 /// given name does not exist in the dictionary.
89 MLIR_CAPI_EXPORTED MlirAttribute
90 mlirDictionaryAttrGetElementByName(MlirAttribute attr, MlirStringRef name);
91 
92 //===----------------------------------------------------------------------===//
93 // Floating point attribute.
94 //===----------------------------------------------------------------------===//
95 
96 // TODO: add support for APFloat and APInt to LLVM IR C API, then expose the
97 // relevant functions here.
98 
99 /// Checks whether the given attribute is a floating point attribute.
100 MLIR_CAPI_EXPORTED bool mlirAttributeIsAFloat(MlirAttribute attr);
101 
102 /// Creates a floating point attribute in the given context with the given
103 /// double value and double-precision FP semantics.
104 MLIR_CAPI_EXPORTED MlirAttribute mlirFloatAttrDoubleGet(MlirContext ctx,
105  MlirType type,
106  double value);
107 
108 /// Same as "mlirFloatAttrDoubleGet", but if the type is not valid for a
109 /// construction of a FloatAttr, returns a null MlirAttribute.
110 MLIR_CAPI_EXPORTED MlirAttribute mlirFloatAttrDoubleGetChecked(MlirLocation loc,
111  MlirType type,
112  double value);
113 
114 /// Returns the value stored in the given floating point attribute, interpreting
115 /// the value as double.
116 MLIR_CAPI_EXPORTED double mlirFloatAttrGetValueDouble(MlirAttribute attr);
117 
118 //===----------------------------------------------------------------------===//
119 // Integer attribute.
120 //===----------------------------------------------------------------------===//
121 
122 // TODO: add support for APFloat and APInt to LLVM IR C API, then expose the
123 // relevant functions here.
124 
125 /// Checks whether the given attribute is an integer attribute.
126 MLIR_CAPI_EXPORTED bool mlirAttributeIsAInteger(MlirAttribute attr);
127 
128 /// Creates an integer attribute of the given type with the given integer
129 /// value.
130 MLIR_CAPI_EXPORTED MlirAttribute mlirIntegerAttrGet(MlirType type,
131  int64_t value);
132 
133 /// Returns the value stored in the given integer attribute, assuming the value
134 /// is of signless type and fits into a signed 64-bit integer.
135 MLIR_CAPI_EXPORTED int64_t mlirIntegerAttrGetValueInt(MlirAttribute attr);
136 
137 /// Returns the value stored in the given integer attribute, assuming the value
138 /// is of signed type and fits into a signed 64-bit integer.
139 MLIR_CAPI_EXPORTED int64_t mlirIntegerAttrGetValueSInt(MlirAttribute attr);
140 
141 /// Returns the value stored in the given integer attribute, assuming the value
142 /// is of unsigned type and fits into an unsigned 64-bit integer.
143 MLIR_CAPI_EXPORTED uint64_t mlirIntegerAttrGetValueUInt(MlirAttribute attr);
144 
145 //===----------------------------------------------------------------------===//
146 // Bool attribute.
147 //===----------------------------------------------------------------------===//
148 
149 /// Checks whether the given attribute is a bool attribute.
150 MLIR_CAPI_EXPORTED bool mlirAttributeIsABool(MlirAttribute attr);
151 
152 /// Creates a bool attribute in the given context with the given value.
153 MLIR_CAPI_EXPORTED MlirAttribute mlirBoolAttrGet(MlirContext ctx, int value);
154 
155 /// Returns the value stored in the given bool attribute.
156 MLIR_CAPI_EXPORTED bool mlirBoolAttrGetValue(MlirAttribute attr);
157 
158 //===----------------------------------------------------------------------===//
159 // Integer set attribute.
160 //===----------------------------------------------------------------------===//
161 
162 /// Checks whether the given attribute is an integer set attribute.
163 MLIR_CAPI_EXPORTED bool mlirAttributeIsAIntegerSet(MlirAttribute attr);
164 
165 //===----------------------------------------------------------------------===//
166 // Opaque attribute.
167 //===----------------------------------------------------------------------===//
168 
169 /// Checks whether the given attribute is an opaque attribute.
170 MLIR_CAPI_EXPORTED bool mlirAttributeIsAOpaque(MlirAttribute attr);
171 
172 /// Creates an opaque attribute in the given context associated with the dialect
173 /// identified by its namespace. The attribute contains opaque byte data of the
174 /// specified length (data need not be null-terminated).
175 MLIR_CAPI_EXPORTED MlirAttribute
176 mlirOpaqueAttrGet(MlirContext ctx, MlirStringRef dialectNamespace,
177  intptr_t dataLength, const char *data, MlirType type);
178 
179 /// Returns the namespace of the dialect with which the given opaque attribute
180 /// is associated. The namespace string is owned by the context.
182 mlirOpaqueAttrGetDialectNamespace(MlirAttribute attr);
183 
184 /// Returns the raw data as a string reference. The data remains live as long as
185 /// the context in which the attribute lives.
187 
188 //===----------------------------------------------------------------------===//
189 // String attribute.
190 //===----------------------------------------------------------------------===//
191 
192 /// Checks whether the given attribute is a string attribute.
193 MLIR_CAPI_EXPORTED bool mlirAttributeIsAString(MlirAttribute attr);
194 
195 /// Creates a string attribute in the given context containing the given string.
196 
197 MLIR_CAPI_EXPORTED MlirAttribute mlirStringAttrGet(MlirContext ctx,
198  MlirStringRef str);
199 
200 /// Creates a string attribute in the given context containing the given string.
201 /// Additionally, the attribute has the given type.
202 MLIR_CAPI_EXPORTED MlirAttribute mlirStringAttrTypedGet(MlirType type,
203  MlirStringRef str);
204 
205 /// Returns the attribute values as a string reference. The data remains live as
206 /// long as the context in which the attribute lives.
208 
209 //===----------------------------------------------------------------------===//
210 // SymbolRef attribute.
211 //===----------------------------------------------------------------------===//
212 
213 /// Checks whether the given attribute is a symbol reference attribute.
214 MLIR_CAPI_EXPORTED bool mlirAttributeIsASymbolRef(MlirAttribute attr);
215 
216 /// Creates a symbol reference attribute in the given context referencing a
217 /// symbol identified by the given string inside a list of nested references.
218 /// Each of the references in the list must not be nested.
219 MLIR_CAPI_EXPORTED MlirAttribute
220 mlirSymbolRefAttrGet(MlirContext ctx, MlirStringRef symbol,
221  intptr_t numReferences, MlirAttribute const *references);
222 
223 /// Returns the string reference to the root referenced symbol. The data remains
224 /// live as long as the context in which the attribute lives.
226 mlirSymbolRefAttrGetRootReference(MlirAttribute attr);
227 
228 /// Returns the string reference to the leaf referenced symbol. The data remains
229 /// live as long as the context in which the attribute lives.
231 mlirSymbolRefAttrGetLeafReference(MlirAttribute attr);
232 
233 /// Returns the number of references nested in the given symbol reference
234 /// attribute.
235 MLIR_CAPI_EXPORTED intptr_t
236 mlirSymbolRefAttrGetNumNestedReferences(MlirAttribute attr);
237 
238 /// Returns pos-th reference nested in the given symbol reference attribute.
239 MLIR_CAPI_EXPORTED MlirAttribute
240 mlirSymbolRefAttrGetNestedReference(MlirAttribute attr, intptr_t pos);
241 
242 //===----------------------------------------------------------------------===//
243 // Flat SymbolRef attribute.
244 //===----------------------------------------------------------------------===//
245 
246 /// Checks whether the given attribute is a flat symbol reference attribute.
247 MLIR_CAPI_EXPORTED bool mlirAttributeIsAFlatSymbolRef(MlirAttribute attr);
248 
249 /// Creates a flat symbol reference attribute in the given context referencing a
250 /// symbol identified by the given string.
251 MLIR_CAPI_EXPORTED MlirAttribute mlirFlatSymbolRefAttrGet(MlirContext ctx,
252  MlirStringRef symbol);
253 
254 /// Returns the referenced symbol as a string reference. The data remains live
255 /// as long as the context in which the attribute lives.
257 mlirFlatSymbolRefAttrGetValue(MlirAttribute attr);
258 
259 //===----------------------------------------------------------------------===//
260 // Type attribute.
261 //===----------------------------------------------------------------------===//
262 
263 /// Checks whether the given attribute is a type attribute.
264 MLIR_CAPI_EXPORTED bool mlirAttributeIsAType(MlirAttribute attr);
265 
266 /// Creates a type attribute wrapping the given type in the same context as the
267 /// type.
268 MLIR_CAPI_EXPORTED MlirAttribute mlirTypeAttrGet(MlirType type);
269 
270 /// Returns the type stored in the given type attribute.
271 MLIR_CAPI_EXPORTED MlirType mlirTypeAttrGetValue(MlirAttribute attr);
272 
273 //===----------------------------------------------------------------------===//
274 // Unit attribute.
275 //===----------------------------------------------------------------------===//
276 
277 /// Checks whether the given attribute is a unit attribute.
278 MLIR_CAPI_EXPORTED bool mlirAttributeIsAUnit(MlirAttribute attr);
279 
280 /// Creates a unit attribute in the given context.
281 MLIR_CAPI_EXPORTED MlirAttribute mlirUnitAttrGet(MlirContext ctx);
282 
283 //===----------------------------------------------------------------------===//
284 // Elements attributes.
285 //===----------------------------------------------------------------------===//
286 
287 /// Checks whether the given attribute is an elements attribute.
288 MLIR_CAPI_EXPORTED bool mlirAttributeIsAElements(MlirAttribute attr);
289 
290 /// Returns the element at the given rank-dimensional index.
291 MLIR_CAPI_EXPORTED MlirAttribute mlirElementsAttrGetValue(MlirAttribute attr,
292  intptr_t rank,
293  uint64_t *idxs);
294 
295 /// Checks whether the given rank-dimensional index is valid in the given
296 /// elements attribute.
298 mlirElementsAttrIsValidIndex(MlirAttribute attr, intptr_t rank, uint64_t *idxs);
299 
300 /// Gets the total number of elements in the given elements attribute. In order
301 /// to iterate over the attribute, obtain its type, which must be a statically
302 /// shaped type and use its sizes to build a multi-dimensional index.
303 MLIR_CAPI_EXPORTED int64_t mlirElementsAttrGetNumElements(MlirAttribute attr);
304 
305 //===----------------------------------------------------------------------===//
306 // Dense array attribute.
307 //===----------------------------------------------------------------------===//
308 
309 /// Checks whether the given attribute is a dense array attribute.
310 MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseBoolArray(MlirAttribute attr);
311 MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseI8Array(MlirAttribute attr);
312 MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseI16Array(MlirAttribute attr);
313 MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseI32Array(MlirAttribute attr);
314 MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseI64Array(MlirAttribute attr);
315 MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseF32Array(MlirAttribute attr);
316 MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseF64Array(MlirAttribute attr);
317 
318 /// Create a dense array attribute with the given elements.
319 MLIR_CAPI_EXPORTED MlirAttribute mlirDenseBoolArrayGet(MlirContext ctx,
320  intptr_t size,
321  int const *values);
322 MLIR_CAPI_EXPORTED MlirAttribute mlirDenseI8ArrayGet(MlirContext ctx,
323  intptr_t size,
324  int8_t const *values);
325 MLIR_CAPI_EXPORTED MlirAttribute mlirDenseI16ArrayGet(MlirContext ctx,
326  intptr_t size,
327  int16_t const *values);
328 MLIR_CAPI_EXPORTED MlirAttribute mlirDenseI32ArrayGet(MlirContext ctx,
329  intptr_t size,
330  int32_t const *values);
331 MLIR_CAPI_EXPORTED MlirAttribute mlirDenseI64ArrayGet(MlirContext ctx,
332  intptr_t size,
333  int64_t const *values);
334 MLIR_CAPI_EXPORTED MlirAttribute mlirDenseF32ArrayGet(MlirContext ctx,
335  intptr_t size,
336  float const *values);
337 MLIR_CAPI_EXPORTED MlirAttribute mlirDenseF64ArrayGet(MlirContext ctx,
338  intptr_t size,
339  double const *values);
340 
341 /// Get the size of a dense array.
342 MLIR_CAPI_EXPORTED intptr_t mlirDenseArrayGetNumElements(MlirAttribute attr);
343 
344 /// Get an element of a dense array.
345 MLIR_CAPI_EXPORTED bool mlirDenseBoolArrayGetElement(MlirAttribute attr,
346  intptr_t pos);
347 MLIR_CAPI_EXPORTED int8_t mlirDenseI8ArrayGetElement(MlirAttribute attr,
348  intptr_t pos);
349 MLIR_CAPI_EXPORTED int16_t mlirDenseI16ArrayGetElement(MlirAttribute attr,
350  intptr_t pos);
351 MLIR_CAPI_EXPORTED int32_t mlirDenseI32ArrayGetElement(MlirAttribute attr,
352  intptr_t pos);
353 MLIR_CAPI_EXPORTED int64_t mlirDenseI64ArrayGetElement(MlirAttribute attr,
354  intptr_t pos);
355 MLIR_CAPI_EXPORTED float mlirDenseF32ArrayGetElement(MlirAttribute attr,
356  intptr_t pos);
357 MLIR_CAPI_EXPORTED double mlirDenseF64ArrayGetElement(MlirAttribute attr,
358  intptr_t pos);
359 
360 //===----------------------------------------------------------------------===//
361 // Dense elements attribute.
362 //===----------------------------------------------------------------------===//
363 
364 // TODO: decide on the interface and add support for complex elements.
365 // TODO: add support for APFloat and APInt to LLVM IR C API, then expose the
366 // relevant functions here.
367 
368 /// Checks whether the given attribute is a dense elements attribute.
369 MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseElements(MlirAttribute attr);
371 MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseFPElements(MlirAttribute attr);
372 
373 /// Creates a dense elements attribute with the given Shaped type and elements
374 /// in the same context as the type.
376  MlirType shapedType, intptr_t numElements, MlirAttribute const *elements);
377 
378 /// Creates a dense elements attribute with the given Shaped type and elements
379 /// populated from a packed, row-major opaque buffer of contents.
380 ///
381 /// The format of the raw buffer is a densely packed array of values that
382 /// can be bitcast to the storage format of the element type specified.
383 /// Types that are not byte aligned will be:
384 /// - For bitwidth > 1: Rounded up to the next byte.
385 /// - For bitwidth = 1: Packed into 8bit bytes with bits corresponding to
386 /// the linear order of the shape type from MSB to LSB, padded to on the
387 /// right.
388 ///
389 /// A raw buffer of a single element (or for 1-bit, a byte of value 0 or 255)
390 /// will be interpreted as a splat. User code should be prepared for additional,
391 /// conformant patterns to be identified as splats in the future.
393  MlirType shapedType, size_t rawBufferSize, const void *rawBuffer);
394 
395 /// Creates a dense elements attribute with the given Shaped type containing a
396 /// single replicated element (splat).
397 MLIR_CAPI_EXPORTED MlirAttribute
398 mlirDenseElementsAttrSplatGet(MlirType shapedType, MlirAttribute element);
399 MLIR_CAPI_EXPORTED MlirAttribute
400 mlirDenseElementsAttrBoolSplatGet(MlirType shapedType, bool element);
401 MLIR_CAPI_EXPORTED MlirAttribute
402 mlirDenseElementsAttrUInt8SplatGet(MlirType shapedType, uint8_t element);
403 MLIR_CAPI_EXPORTED MlirAttribute
404 mlirDenseElementsAttrInt8SplatGet(MlirType shapedType, int8_t element);
405 MLIR_CAPI_EXPORTED MlirAttribute
406 mlirDenseElementsAttrUInt32SplatGet(MlirType shapedType, uint32_t element);
407 MLIR_CAPI_EXPORTED MlirAttribute
408 mlirDenseElementsAttrInt32SplatGet(MlirType shapedType, int32_t element);
409 MLIR_CAPI_EXPORTED MlirAttribute
410 mlirDenseElementsAttrUInt64SplatGet(MlirType shapedType, uint64_t element);
411 MLIR_CAPI_EXPORTED MlirAttribute
412 mlirDenseElementsAttrInt64SplatGet(MlirType shapedType, int64_t element);
413 MLIR_CAPI_EXPORTED MlirAttribute
414 mlirDenseElementsAttrFloatSplatGet(MlirType shapedType, float element);
415 MLIR_CAPI_EXPORTED MlirAttribute
416 mlirDenseElementsAttrDoubleSplatGet(MlirType shapedType, double element);
417 
418 /// Creates a dense elements attribute with the given shaped type from elements
419 /// of a specific type. Expects the element type of the shaped type to match the
420 /// data element type.
422  MlirType shapedType, intptr_t numElements, const int *elements);
424  MlirType shapedType, intptr_t numElements, const uint8_t *elements);
426  MlirType shapedType, intptr_t numElements, const int8_t *elements);
428  MlirType shapedType, intptr_t numElements, const uint16_t *elements);
430  MlirType shapedType, intptr_t numElements, const int16_t *elements);
432  MlirType shapedType, intptr_t numElements, const uint32_t *elements);
434  MlirType shapedType, intptr_t numElements, const int32_t *elements);
436  MlirType shapedType, intptr_t numElements, const uint64_t *elements);
438  MlirType shapedType, intptr_t numElements, const int64_t *elements);
440  MlirType shapedType, intptr_t numElements, const float *elements);
442  MlirType shapedType, intptr_t numElements, const double *elements);
444  MlirType shapedType, intptr_t numElements, const uint16_t *elements);
446  MlirType shapedType, intptr_t numElements, const uint16_t *elements);
447 
448 /// Creates a dense elements attribute with the given shaped type from string
449 /// elements.
451  MlirType shapedType, intptr_t numElements, MlirStringRef *strs);
452 
453 /// Creates a dense elements attribute that has the same data as the given dense
454 /// elements attribute and a different shaped type. The new type must have the
455 /// same total number of elements.
456 MLIR_CAPI_EXPORTED MlirAttribute
457 mlirDenseElementsAttrReshapeGet(MlirAttribute attr, MlirType shapedType);
458 
459 /// Checks whether the given dense elements attribute contains a single
460 /// replicated value (splat).
461 MLIR_CAPI_EXPORTED bool mlirDenseElementsAttrIsSplat(MlirAttribute attr);
462 
463 /// Returns the single replicated value (splat) of a specific type contained by
464 /// the given dense elements attribute.
465 MLIR_CAPI_EXPORTED MlirAttribute
466 mlirDenseElementsAttrGetSplatValue(MlirAttribute attr);
468 mlirDenseElementsAttrGetBoolSplatValue(MlirAttribute attr);
469 MLIR_CAPI_EXPORTED int8_t
470 mlirDenseElementsAttrGetInt8SplatValue(MlirAttribute attr);
471 MLIR_CAPI_EXPORTED uint8_t
472 mlirDenseElementsAttrGetUInt8SplatValue(MlirAttribute attr);
473 MLIR_CAPI_EXPORTED int32_t
474 mlirDenseElementsAttrGetInt32SplatValue(MlirAttribute attr);
475 MLIR_CAPI_EXPORTED uint32_t
476 mlirDenseElementsAttrGetUInt32SplatValue(MlirAttribute attr);
477 MLIR_CAPI_EXPORTED int64_t
478 mlirDenseElementsAttrGetInt64SplatValue(MlirAttribute attr);
479 MLIR_CAPI_EXPORTED uint64_t
480 mlirDenseElementsAttrGetUInt64SplatValue(MlirAttribute attr);
481 MLIR_CAPI_EXPORTED float
482 mlirDenseElementsAttrGetFloatSplatValue(MlirAttribute attr);
483 MLIR_CAPI_EXPORTED double
484 mlirDenseElementsAttrGetDoubleSplatValue(MlirAttribute attr);
486 mlirDenseElementsAttrGetStringSplatValue(MlirAttribute attr);
487 
488 /// Returns the pos-th value (flat contiguous indexing) of a specific type
489 /// contained by the given dense elements attribute.
491  intptr_t pos);
492 MLIR_CAPI_EXPORTED int8_t mlirDenseElementsAttrGetInt8Value(MlirAttribute attr,
493  intptr_t pos);
494 MLIR_CAPI_EXPORTED uint8_t
495 mlirDenseElementsAttrGetUInt8Value(MlirAttribute attr, intptr_t pos);
496 MLIR_CAPI_EXPORTED int16_t
497 mlirDenseElementsAttrGetInt16Value(MlirAttribute attr, intptr_t pos);
498 MLIR_CAPI_EXPORTED uint16_t
499 mlirDenseElementsAttrGetUInt16Value(MlirAttribute attr, intptr_t pos);
500 MLIR_CAPI_EXPORTED int32_t
501 mlirDenseElementsAttrGetInt32Value(MlirAttribute attr, intptr_t pos);
502 MLIR_CAPI_EXPORTED uint32_t
503 mlirDenseElementsAttrGetUInt32Value(MlirAttribute attr, intptr_t pos);
504 MLIR_CAPI_EXPORTED int64_t
505 mlirDenseElementsAttrGetInt64Value(MlirAttribute attr, intptr_t pos);
506 MLIR_CAPI_EXPORTED uint64_t
507 mlirDenseElementsAttrGetUInt64Value(MlirAttribute attr, intptr_t pos);
509  intptr_t pos);
510 MLIR_CAPI_EXPORTED double
511 mlirDenseElementsAttrGetDoubleValue(MlirAttribute attr, intptr_t pos);
513 mlirDenseElementsAttrGetStringValue(MlirAttribute attr, intptr_t pos);
514 
515 /// Returns the raw data of the given dense elements attribute.
516 MLIR_CAPI_EXPORTED const void *
517 mlirDenseElementsAttrGetRawData(MlirAttribute attr);
518 
519 //===----------------------------------------------------------------------===//
520 // Resource blob attributes.
521 //===----------------------------------------------------------------------===//
522 
524  MlirType shapedType, MlirStringRef name, intptr_t numElements,
525  const int *elements);
527  MlirType shapedType, MlirStringRef name, intptr_t numElements,
528  const uint8_t *elements);
530  MlirType shapedType, MlirStringRef name, intptr_t numElements,
531  const int8_t *elements);
532 MLIR_CAPI_EXPORTED MlirAttribute
534  MlirStringRef name,
535  intptr_t numElements,
536  const uint16_t *elements);
538  MlirType shapedType, MlirStringRef name, intptr_t numElements,
539  const int16_t *elements);
540 MLIR_CAPI_EXPORTED MlirAttribute
542  MlirStringRef name,
543  intptr_t numElements,
544  const uint32_t *elements);
546  MlirType shapedType, MlirStringRef name, intptr_t numElements,
547  const int32_t *elements);
548 MLIR_CAPI_EXPORTED MlirAttribute
550  MlirStringRef name,
551  intptr_t numElements,
552  const uint64_t *elements);
554  MlirType shapedType, MlirStringRef name, intptr_t numElements,
555  const int64_t *elements);
557  MlirType shapedType, MlirStringRef name, intptr_t numElements,
558  const float *elements);
559 MLIR_CAPI_EXPORTED MlirAttribute
561  MlirStringRef name,
562  intptr_t numElements,
563  const double *elements);
564 
565 /// Returns the pos-th value (flat contiguous indexing) of a specific type
566 /// contained by the given dense resource elements attribute.
568 mlirDenseBoolResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos);
569 MLIR_CAPI_EXPORTED int8_t
570 mlirDenseInt8ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos);
571 MLIR_CAPI_EXPORTED uint8_t
572 mlirDenseUInt8ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos);
573 MLIR_CAPI_EXPORTED int16_t
574 mlirDenseInt16ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos);
575 MLIR_CAPI_EXPORTED uint16_t
576 mlirDenseUInt16ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos);
577 MLIR_CAPI_EXPORTED int32_t
578 mlirDenseInt32ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos);
579 MLIR_CAPI_EXPORTED uint32_t
580 mlirDenseUInt32ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos);
581 MLIR_CAPI_EXPORTED int64_t
582 mlirDenseInt64ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos);
583 MLIR_CAPI_EXPORTED uint64_t
584 mlirDenseUInt64ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos);
585 MLIR_CAPI_EXPORTED float
586 mlirDenseFloatResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos);
587 MLIR_CAPI_EXPORTED double
588 mlirDenseDoubleResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos);
589 
590 //===----------------------------------------------------------------------===//
591 // Sparse elements attribute.
592 //===----------------------------------------------------------------------===//
593 
594 /// Checks whether the given attribute is a sparse elements attribute.
595 MLIR_CAPI_EXPORTED bool mlirAttributeIsASparseElements(MlirAttribute attr);
596 
597 /// Creates a sparse elements attribute of the given shape from a list of
598 /// indices and a list of associated values. Both lists are expected to be dense
599 /// elements attributes with the same number of elements. The list of indices is
600 /// expected to contain 64-bit integers. The attribute is created in the same
601 /// context as the type.
603  MlirType shapedType, MlirAttribute denseIndices, MlirAttribute denseValues);
604 
605 /// Returns the dense elements attribute containing 64-bit integer indices of
606 /// non-null elements in the given sparse elements attribute.
607 MLIR_CAPI_EXPORTED MlirAttribute
608 mlirSparseElementsAttrGetIndices(MlirAttribute attr);
609 
610 /// Returns the dense elements attribute containing the non-null elements in the
611 /// given sparse elements attribute.
612 MLIR_CAPI_EXPORTED MlirAttribute
613 mlirSparseElementsAttrGetValues(MlirAttribute attr);
614 
615 //===----------------------------------------------------------------------===//
616 // Strided layout attribute.
617 //===----------------------------------------------------------------------===//
618 
619 // Checks wheather the given attribute is a strided layout attribute.
620 MLIR_CAPI_EXPORTED bool mlirAttributeIsAStridedLayout(MlirAttribute attr);
621 
622 // Creates a strided layout attribute from given strides and offset.
623 MLIR_CAPI_EXPORTED MlirAttribute
624 mlirStridedLayoutAttrGet(MlirContext ctx, int64_t offset, intptr_t numStrides,
625  const int64_t *strides);
626 
627 // Returns the offset in the given strided layout layout attribute.
628 MLIR_CAPI_EXPORTED int64_t mlirStridedLayoutAttrGetOffset(MlirAttribute attr);
629 
630 // Returns the number of strides in the given strided layout attribute.
631 MLIR_CAPI_EXPORTED intptr_t
632 mlirStridedLayoutAttrGetNumStrides(MlirAttribute attr);
633 
634 // Returns the pos-th stride stored in the given strided layout attribute.
635 MLIR_CAPI_EXPORTED int64_t mlirStridedLayoutAttrGetStride(MlirAttribute attr,
636  intptr_t pos);
637 
638 #ifdef __cplusplus
639 }
640 #endif
641 
642 #endif // MLIR_C_BUILTINATTRIBUTES_H
MLIR_CAPI_EXPORTED MlirAttribute mlirAffineMapAttrGet(MlirAffineMap map)
Creates an affine map attribute wrapping the given map.
MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseFPElements(MlirAttribute attr)
MLIR_CAPI_EXPORTED 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...
MLIR_CAPI_EXPORTED MlirAttribute mlirFloatAttrDoubleGetChecked(MlirLocation loc, MlirType type, double value)
Same as "mlirFloatAttrDoubleGet", but if the type is not valid for a construction of a FloatAttr,...
MLIR_CAPI_EXPORTED int16_t mlirDenseI16ArrayGetElement(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED bool mlirAttributeIsAStridedLayout(MlirAttribute attr)
MLIR_CAPI_EXPORTED uint8_t mlirDenseElementsAttrGetUInt8Value(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED int64_t mlirStridedLayoutAttrGetOffset(MlirAttribute attr)
MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseI64Array(MlirAttribute attr)
MLIR_CAPI_EXPORTED uint64_t mlirDenseElementsAttrGetUInt64SplatValue(MlirAttribute attr)
MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapAttrGetValue(MlirAttribute attr)
Returns the affine map wrapped in the given affine map attribute.
MLIR_CAPI_EXPORTED int64_t mlirStridedLayoutAttrGetStride(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED MlirAttribute mlirSparseElementsAttrGetValues(MlirAttribute attr)
Returns the dense elements attribute containing the non-null elements in the given sparse elements at...
MLIR_CAPI_EXPORTED int8_t mlirDenseElementsAttrGetInt8Value(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED MlirAttribute mlirStridedLayoutAttrGet(MlirContext ctx, int64_t offset, intptr_t numStrides, const int64_t *strides)
MLIR_CAPI_EXPORTED int32_t mlirDenseInt32ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseInt8ResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const int8_t *elements)
MLIR_CAPI_EXPORTED 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...
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrStringGet(MlirType shapedType, intptr_t numElements, MlirStringRef *strs)
Creates a dense elements attribute with the given shaped type from string elements.
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrInt64SplatGet(MlirType shapedType, int64_t element)
MLIR_CAPI_EXPORTED bool mlirAttributeIsAUnit(MlirAttribute attr)
Checks whether the given attribute is a unit attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseElements(MlirAttribute attr)
Checks whether the given attribute is a dense elements attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsAIntegerSet(MlirAttribute attr)
Checks whether the given attribute is an integer set attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsAAffineMap(MlirAttribute attr)
Checks whether the given attribute is an affine map attribute.
MLIR_CAPI_EXPORTED int32_t mlirDenseI32ArrayGetElement(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED double mlirDenseF64ArrayGetElement(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED MlirAttribute mlirFlatSymbolRefAttrGet(MlirContext ctx, MlirStringRef symbol)
Creates a flat symbol reference attribute in the given context referencing a symbol identified by the...
MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseUInt8ResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const uint8_t *elements)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrUInt8SplatGet(MlirType shapedType, uint8_t element)
MLIR_CAPI_EXPORTED int16_t mlirDenseElementsAttrGetInt16Value(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrFloatSplatGet(MlirType shapedType, float element)
MLIR_CAPI_EXPORTED MlirStringRef mlirSymbolRefAttrGetRootReference(MlirAttribute attr)
Returns the string reference to the root referenced symbol.
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrReshapeGet(MlirAttribute attr, MlirType shapedType)
Creates a dense elements attribute that has the same data as the given dense elements attribute and a...
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrInt8SplatGet(MlirType shapedType, int8_t element)
MLIR_CAPI_EXPORTED bool mlirAttributeIsAType(MlirAttribute attr)
Checks whether the given attribute is a type attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseIntElements(MlirAttribute attr)
MLIR_CAPI_EXPORTED bool mlirAttributeIsAArray(MlirAttribute attr)
Checks whether the given attribute is an array attribute.
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrInt32Get(MlirType shapedType, intptr_t numElements, const int32_t *elements)
MLIR_CAPI_EXPORTED bool mlirAttributeIsAInteger(MlirAttribute attr)
Checks whether the given attribute is an integer attribute.
MLIR_CAPI_EXPORTED MlirAttribute mlirElementsAttrGetValue(MlirAttribute attr, intptr_t rank, uint64_t *idxs)
Returns the element at the given rank-dimensional index.
MLIR_CAPI_EXPORTED intptr_t mlirDictionaryAttrGetNumElements(MlirAttribute attr)
Returns the number of attributes contained in a dictionary attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsALocation(MlirAttribute attr)
MLIR_CAPI_EXPORTED int8_t mlirDenseInt8ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED uint16_t mlirDenseElementsAttrGetUInt16Value(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrInt16Get(MlirType shapedType, intptr_t numElements, const int16_t *elements)
MLIR_CAPI_EXPORTED uint64_t mlirDenseElementsAttrGetUInt64Value(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED bool mlirBoolAttrGetValue(MlirAttribute attr)
Returns the value stored in the given bool attribute.
MLIR_CAPI_EXPORTED double mlirDenseDoubleResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrUInt16Get(MlirType shapedType, intptr_t numElements, const uint16_t *elements)
MLIR_CAPI_EXPORTED int64_t mlirDenseI64ArrayGetElement(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED MlirAttribute mlirIntegerAttrGet(MlirType type, int64_t value)
Creates an integer attribute of the given type with the given integer value.
MLIR_CAPI_EXPORTED 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...
MLIR_CAPI_EXPORTED MlirStringRef mlirDenseElementsAttrGetStringValue(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED MlirAttribute mlirDictionaryAttrGet(MlirContext ctx, intptr_t numElements, MlirNamedAttribute const *elements)
Creates a dictionary attribute containing the given list of elements in the provided context.
MLIR_CAPI_EXPORTED uint64_t mlirDenseUInt64ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED int8_t mlirDenseElementsAttrGetInt8SplatValue(MlirAttribute attr)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrUInt32Get(MlirType shapedType, intptr_t numElements, const uint32_t *elements)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrFloat16Get(MlirType shapedType, intptr_t numElements, const uint16_t *elements)
MLIR_CAPI_EXPORTED bool mlirAttributeIsABool(MlirAttribute attr)
Checks whether the given attribute is a bool attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsASparseElements(MlirAttribute attr)
Checks whether the given attribute is a sparse elements attribute.
MLIR_CAPI_EXPORTED bool mlirDenseBoolArrayGetElement(MlirAttribute attr, intptr_t pos)
Get an element of a dense array.
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseI64ArrayGet(MlirContext ctx, intptr_t size, int64_t const *values)
MLIR_CAPI_EXPORTED MlirAttribute mlirSymbolRefAttrGetNestedReference(MlirAttribute attr, intptr_t pos)
Returns pos-th reference nested in the given symbol reference attribute.
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrBFloat16Get(MlirType shapedType, intptr_t numElements, const uint16_t *elements)
MLIR_CAPI_EXPORTED float mlirDenseF32ArrayGetElement(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseF64ArrayGet(MlirContext ctx, intptr_t size, double const *values)
MLIR_CAPI_EXPORTED 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...
MLIR_CAPI_EXPORTED int64_t mlirIntegerAttrGetValueInt(MlirAttribute attr)
Returns the value stored in the given integer attribute, assuming the value is of signless type and f...
MLIR_CAPI_EXPORTED intptr_t mlirSymbolRefAttrGetNumNestedReferences(MlirAttribute attr)
Returns the number of references nested in the given symbol reference attribute.
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrInt64Get(MlirType shapedType, intptr_t numElements, const int64_t *elements)
MLIR_CAPI_EXPORTED MlirType mlirTypeAttrGetValue(MlirAttribute attr)
Returns the type stored in the given type attribute.
MLIR_CAPI_EXPORTED bool mlirDenseElementsAttrIsSplat(MlirAttribute attr)
Checks whether the given dense elements attribute contains a single replicated value (splat).
MLIR_CAPI_EXPORTED 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...
MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseBoolArray(MlirAttribute attr)
Checks whether the given attribute is a dense array attribute.
MLIR_CAPI_EXPORTED MlirStringRef mlirOpaqueAttrGetData(MlirAttribute attr)
Returns the raw data as a string reference.
MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseUInt16ResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const uint16_t *elements)
MLIR_CAPI_EXPORTED uint8_t mlirDenseElementsAttrGetUInt8SplatValue(MlirAttribute attr)
MLIR_CAPI_EXPORTED double mlirDenseElementsAttrGetDoubleSplatValue(MlirAttribute attr)
MLIR_CAPI_EXPORTED MlirAttribute mlirAttributeGetNull(void)
Returns an empty attribute.
MLIR_CAPI_EXPORTED MlirAttribute mlirBoolAttrGet(MlirContext ctx, int value)
Creates a bool attribute in the given context with the given value.
MLIR_CAPI_EXPORTED int64_t mlirIntegerAttrGetValueSInt(MlirAttribute attr)
Returns the value stored in the given integer attribute, assuming the value is of signed type and fit...
MLIR_CAPI_EXPORTED int8_t mlirDenseI8ArrayGetElement(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrUInt32SplatGet(MlirType shapedType, uint32_t element)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseI32ArrayGet(MlirContext ctx, intptr_t size, int32_t const *values)
MLIR_CAPI_EXPORTED int64_t mlirDenseElementsAttrGetInt64Value(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED MlirNamedAttribute mlirDictionaryAttrGetElement(MlirAttribute attr, intptr_t pos)
Returns pos-th element of the given dictionary attribute.
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseF32ArrayGet(MlirContext ctx, intptr_t size, float const *values)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseBoolArrayGet(MlirContext ctx, intptr_t size, int const *values)
Create a dense array attribute with the given elements.
MLIR_CAPI_EXPORTED MlirAttribute mlirSparseElementsAttrGetIndices(MlirAttribute attr)
Returns the dense elements attribute containing 64-bit integer indices of non-null elements in the gi...
MLIR_CAPI_EXPORTED bool mlirAttributeIsAOpaque(MlirAttribute attr)
Checks whether the given attribute is an opaque attribute.
MLIR_CAPI_EXPORTED MlirAttribute mlirArrayAttrGetElement(MlirAttribute attr, intptr_t pos)
Returns pos-th element stored in the given array attribute.
MLIR_CAPI_EXPORTED MlirAttribute mlirDictionaryAttrGetElementByName(MlirAttribute attr, MlirStringRef name)
Returns the dictionary attribute element with the given name or NULL if the given name does not exist...
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrDoubleSplatGet(MlirType shapedType, double element)
MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseUInt64ResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const uint64_t *elements)
MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseF32Array(MlirAttribute attr)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrGetSplatValue(MlirAttribute attr)
Returns the single replicated value (splat) of a specific type contained by the given dense elements ...
MLIR_CAPI_EXPORTED bool mlirAttributeIsASymbolRef(MlirAttribute attr)
Checks whether the given attribute is a symbol reference attribute.
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrUInt8Get(MlirType shapedType, intptr_t numElements, const uint8_t *elements)
MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseInt16ResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const int16_t *elements)
MLIR_CAPI_EXPORTED float mlirDenseElementsAttrGetFloatValue(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED bool mlirAttributeIsAString(MlirAttribute attr)
Checks whether the given attribute is a string attribute.
MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseInt32ResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const int32_t *elements)
MLIR_CAPI_EXPORTED int64_t mlirElementsAttrGetNumElements(MlirAttribute attr)
Gets the total number of elements in the given elements attribute.
MLIR_CAPI_EXPORTED int16_t mlirDenseInt16ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrInt8Get(MlirType shapedType, intptr_t numElements, const int8_t *elements)
MLIR_CAPI_EXPORTED MlirStringRef mlirOpaqueAttrGetDialectNamespace(MlirAttribute attr)
Returns the namespace of the dialect with which the given opaque attribute is associated.
MLIR_CAPI_EXPORTED bool mlirAttributeIsADictionary(MlirAttribute attr)
Checks whether the given attribute is a dictionary attribute.
MLIR_CAPI_EXPORTED int32_t mlirDenseElementsAttrGetInt32Value(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED MlirStringRef mlirStringAttrGetValue(MlirAttribute attr)
Returns the attribute values as a string reference.
MLIR_CAPI_EXPORTED uint32_t mlirDenseUInt32ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED uint16_t mlirDenseUInt16ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED 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.
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseI16ArrayGet(MlirContext ctx, intptr_t size, int16_t const *values)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrInt32SplatGet(MlirType shapedType, int32_t element)
MLIR_CAPI_EXPORTED uint32_t mlirDenseElementsAttrGetUInt32SplatValue(MlirAttribute attr)
MLIR_CAPI_EXPORTED MlirStringRef mlirDenseElementsAttrGetStringSplatValue(MlirAttribute attr)
MLIR_CAPI_EXPORTED int64_t mlirDenseInt64ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED double mlirFloatAttrGetValueDouble(MlirAttribute attr)
Returns the value stored in the given floating point attribute, interpreting the value as double.
MLIR_CAPI_EXPORTED uint64_t mlirIntegerAttrGetValueUInt(MlirAttribute attr)
Returns the value stored in the given integer attribute, assuming the value is of unsigned type and f...
MLIR_CAPI_EXPORTED uint8_t mlirDenseUInt8ResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrFloatGet(MlirType shapedType, intptr_t numElements, const float *elements)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrUInt64Get(MlirType shapedType, intptr_t numElements, const uint64_t *elements)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseI8ArrayGet(MlirContext ctx, intptr_t size, int8_t const *values)
MLIR_CAPI_EXPORTED MlirAttribute mlirUnitAttrGet(MlirContext ctx)
Creates a unit attribute in the given context.
MLIR_CAPI_EXPORTED double mlirDenseElementsAttrGetDoubleValue(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseFloatResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const float *elements)
MLIR_CAPI_EXPORTED intptr_t mlirStridedLayoutAttrGetNumStrides(MlirAttribute attr)
MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseBoolResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const int *elements)
MLIR_CAPI_EXPORTED 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...
MLIR_CAPI_EXPORTED int64_t mlirDenseElementsAttrGetInt64SplatValue(MlirAttribute attr)
MLIR_CAPI_EXPORTED MlirAttribute mlirArrayAttrGet(MlirContext ctx, intptr_t numElements, MlirAttribute const *elements)
Creates an array element containing the given list of elements in the given context.
MLIR_CAPI_EXPORTED const void * mlirDenseElementsAttrGetRawData(MlirAttribute attr)
Returns the raw data of the given dense elements attribute.
MLIR_CAPI_EXPORTED intptr_t mlirDenseArrayGetNumElements(MlirAttribute attr)
Get the size of a dense array.
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrBoolSplatGet(MlirType shapedType, bool element)
MLIR_CAPI_EXPORTED bool mlirElementsAttrIsValidIndex(MlirAttribute attr, intptr_t rank, uint64_t *idxs)
Checks whether the given rank-dimensional index is valid in the given elements attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsAFloat(MlirAttribute attr)
Checks whether the given attribute is a floating point attribute.
MLIR_CAPI_EXPORTED 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...
MLIR_CAPI_EXPORTED int32_t mlirDenseElementsAttrGetInt32SplatValue(MlirAttribute attr)
MLIR_CAPI_EXPORTED float mlirDenseFloatResourceElementsAttrGetValue(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrSplatGet(MlirType shapedType, MlirAttribute element)
Creates a dense elements attribute with the given Shaped type containing a single replicated element ...
MLIR_CAPI_EXPORTED bool mlirAttributeIsAElements(MlirAttribute attr)
Checks whether the given attribute is an elements attribute.
MLIR_CAPI_EXPORTED MlirAttribute mlirStringAttrGet(MlirContext ctx, MlirStringRef str)
Creates a string attribute in the given context containing the given string.
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrUInt64SplatGet(MlirType shapedType, uint64_t element)
MLIR_CAPI_EXPORTED MlirAttribute mlirTypeAttrGet(MlirType type)
Creates a type attribute wrapping the given type in the same context as the type.
MLIR_CAPI_EXPORTED intptr_t mlirArrayAttrGetNumElements(MlirAttribute attr)
Returns the number of elements stored in the given array attribute.
MLIR_CAPI_EXPORTED 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,...
MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseInt64ResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const int64_t *elements)
MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseI32Array(MlirAttribute attr)
MLIR_CAPI_EXPORTED int mlirDenseElementsAttrGetBoolSplatValue(MlirAttribute attr)
MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseDoubleResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const double *elements)
MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseI8Array(MlirAttribute attr)
MLIR_CAPI_EXPORTED MlirAttribute mlirStringAttrTypedGet(MlirType type, MlirStringRef str)
Creates a string attribute in the given context containing the given string.
MLIR_CAPI_EXPORTED bool mlirAttributeIsAFlatSymbolRef(MlirAttribute attr)
Checks whether the given attribute is a flat symbol reference attribute.
MLIR_CAPI_EXPORTED MlirStringRef mlirFlatSymbolRefAttrGetValue(MlirAttribute attr)
Returns the referenced symbol as a string reference.
MLIR_CAPI_EXPORTED MlirAttribute mlirUnmanagedDenseUInt32ResourceElementsAttrGet(MlirType shapedType, MlirStringRef name, intptr_t numElements, const uint32_t *elements)
MLIR_CAPI_EXPORTED MlirStringRef mlirSymbolRefAttrGetLeafReference(MlirAttribute attr)
Returns the string reference to the leaf referenced symbol.
MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseI16Array(MlirAttribute attr)
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrDoubleGet(MlirType shapedType, intptr_t numElements, const double *elements)
MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseF64Array(MlirAttribute attr)
MLIR_CAPI_EXPORTED uint32_t mlirDenseElementsAttrGetUInt32Value(MlirAttribute attr, intptr_t pos)
MLIR_CAPI_EXPORTED float mlirDenseElementsAttrGetFloatSplatValue(MlirAttribute attr)
#define MLIR_CAPI_EXPORTED
Definition: Support.h:46
Named MLIR attribute.
Definition: IR.h:76
A pointer to a sized fragment of a string, not necessarily null-terminated.
Definition: Support.h:71