MLIR  17.0.0git
BuiltinTypes.cpp
Go to the documentation of this file.
1 //===- BuiltinTypes.cpp - C Interface to MLIR Builtin Types ---------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "mlir-c/BuiltinTypes.h"
10 #include "mlir-c/AffineMap.h"
11 #include "mlir-c/IR.h"
12 #include "mlir/CAPI/AffineMap.h"
13 #include "mlir/CAPI/IR.h"
14 #include "mlir/CAPI/Support.h"
15 #include "mlir/IR/AffineMap.h"
16 #include "mlir/IR/BuiltinTypes.h"
17 #include "mlir/IR/Types.h"
18 
19 using namespace mlir;
20 
21 //===----------------------------------------------------------------------===//
22 // Integer types.
23 //===----------------------------------------------------------------------===//
24 
25 bool mlirTypeIsAInteger(MlirType type) {
26  return unwrap(type).isa<IntegerType>();
27 }
28 
29 MlirType mlirIntegerTypeGet(MlirContext ctx, unsigned bitwidth) {
30  return wrap(IntegerType::get(unwrap(ctx), bitwidth));
31 }
32 
33 MlirType mlirIntegerTypeSignedGet(MlirContext ctx, unsigned bitwidth) {
34  return wrap(IntegerType::get(unwrap(ctx), bitwidth, IntegerType::Signed));
35 }
36 
37 MlirType mlirIntegerTypeUnsignedGet(MlirContext ctx, unsigned bitwidth) {
38  return wrap(IntegerType::get(unwrap(ctx), bitwidth, IntegerType::Unsigned));
39 }
40 
41 unsigned mlirIntegerTypeGetWidth(MlirType type) {
42  return unwrap(type).cast<IntegerType>().getWidth();
43 }
44 
45 bool mlirIntegerTypeIsSignless(MlirType type) {
46  return unwrap(type).cast<IntegerType>().isSignless();
47 }
48 
49 bool mlirIntegerTypeIsSigned(MlirType type) {
50  return unwrap(type).cast<IntegerType>().isSigned();
51 }
52 
53 bool mlirIntegerTypeIsUnsigned(MlirType type) {
54  return unwrap(type).cast<IntegerType>().isUnsigned();
55 }
56 
57 //===----------------------------------------------------------------------===//
58 // Index type.
59 //===----------------------------------------------------------------------===//
60 
61 bool mlirTypeIsAIndex(MlirType type) { return unwrap(type).isa<IndexType>(); }
62 
63 MlirType mlirIndexTypeGet(MlirContext ctx) {
64  return wrap(IndexType::get(unwrap(ctx)));
65 }
66 
67 //===----------------------------------------------------------------------===//
68 // Floating-point types.
69 //===----------------------------------------------------------------------===//
70 
71 bool mlirTypeIsAFloat8E5M2(MlirType type) {
72  return unwrap(type).isFloat8E5M2();
73 }
74 
75 MlirType mlirFloat8E5M2TypeGet(MlirContext ctx) {
76  return wrap(FloatType::getFloat8E5M2(unwrap(ctx)));
77 }
78 
79 bool mlirTypeIsAFloat8E4M3FN(MlirType type) {
80  return unwrap(type).isFloat8E4M3FN();
81 }
82 
83 MlirType mlirFloat8E4M3FNTypeGet(MlirContext ctx) {
85 }
86 
87 bool mlirTypeIsAFloat8E5M2FNUZ(MlirType type) {
88  return unwrap(type).isFloat8E5M2FNUZ();
89 }
90 
91 MlirType mlirFloat8E5M2FNUZTypeGet(MlirContext ctx) {
93 }
94 
95 bool mlirTypeIsAFloat8E4M3FNUZ(MlirType type) {
96  return unwrap(type).isFloat8E4M3FNUZ();
97 }
98 
99 MlirType mlirFloat8E4M3FNUZTypeGet(MlirContext ctx) {
101 }
102 
103 bool mlirTypeIsAFloat8E4M3B11FNUZ(MlirType type) {
104  return unwrap(type).isFloat8E4M3B11FNUZ();
105 }
106 
107 MlirType mlirFloat8E4M3B11FNUZTypeGet(MlirContext ctx) {
109 }
110 
111 bool mlirTypeIsABF16(MlirType type) { return unwrap(type).isBF16(); }
112 
113 MlirType mlirBF16TypeGet(MlirContext ctx) {
114  return wrap(FloatType::getBF16(unwrap(ctx)));
115 }
116 
117 bool mlirTypeIsAF16(MlirType type) { return unwrap(type).isF16(); }
118 
119 MlirType mlirF16TypeGet(MlirContext ctx) {
120  return wrap(FloatType::getF16(unwrap(ctx)));
121 }
122 
123 bool mlirTypeIsAF32(MlirType type) { return unwrap(type).isF32(); }
124 
125 MlirType mlirF32TypeGet(MlirContext ctx) {
126  return wrap(FloatType::getF32(unwrap(ctx)));
127 }
128 
129 bool mlirTypeIsAF64(MlirType type) { return unwrap(type).isF64(); }
130 
131 MlirType mlirF64TypeGet(MlirContext ctx) {
132  return wrap(FloatType::getF64(unwrap(ctx)));
133 }
134 
135 //===----------------------------------------------------------------------===//
136 // None type.
137 //===----------------------------------------------------------------------===//
138 
139 bool mlirTypeIsANone(MlirType type) { return unwrap(type).isa<NoneType>(); }
140 
141 MlirType mlirNoneTypeGet(MlirContext ctx) {
142  return wrap(NoneType::get(unwrap(ctx)));
143 }
144 
145 //===----------------------------------------------------------------------===//
146 // Complex type.
147 //===----------------------------------------------------------------------===//
148 
149 bool mlirTypeIsAComplex(MlirType type) {
150  return unwrap(type).isa<ComplexType>();
151 }
152 
153 MlirType mlirComplexTypeGet(MlirType elementType) {
154  return wrap(ComplexType::get(unwrap(elementType)));
155 }
156 
157 MlirType mlirComplexTypeGetElementType(MlirType type) {
158  return wrap(unwrap(type).cast<ComplexType>().getElementType());
159 }
160 
161 //===----------------------------------------------------------------------===//
162 // Shaped type.
163 //===----------------------------------------------------------------------===//
164 
165 bool mlirTypeIsAShaped(MlirType type) { return unwrap(type).isa<ShapedType>(); }
166 
167 MlirType mlirShapedTypeGetElementType(MlirType type) {
168  return wrap(unwrap(type).cast<ShapedType>().getElementType());
169 }
170 
171 bool mlirShapedTypeHasRank(MlirType type) {
172  return unwrap(type).cast<ShapedType>().hasRank();
173 }
174 
175 int64_t mlirShapedTypeGetRank(MlirType type) {
176  return unwrap(type).cast<ShapedType>().getRank();
177 }
178 
179 bool mlirShapedTypeHasStaticShape(MlirType type) {
180  return unwrap(type).cast<ShapedType>().hasStaticShape();
181 }
182 
183 bool mlirShapedTypeIsDynamicDim(MlirType type, intptr_t dim) {
184  return unwrap(type).cast<ShapedType>().isDynamicDim(
185  static_cast<unsigned>(dim));
186 }
187 
188 int64_t mlirShapedTypeGetDimSize(MlirType type, intptr_t dim) {
189  return unwrap(type).cast<ShapedType>().getDimSize(static_cast<unsigned>(dim));
190 }
191 
192 int64_t mlirShapedTypeGetDynamicSize() { return ShapedType::kDynamic; }
193 
194 bool mlirShapedTypeIsDynamicSize(int64_t size) {
195  return ShapedType::isDynamic(size);
196 }
197 
199  return ShapedType::isDynamic(val);
200 }
201 
203  return ShapedType::kDynamic;
204 }
205 
206 //===----------------------------------------------------------------------===//
207 // Vector type.
208 //===----------------------------------------------------------------------===//
209 
210 bool mlirTypeIsAVector(MlirType type) { return unwrap(type).isa<VectorType>(); }
211 
212 MlirType mlirVectorTypeGet(intptr_t rank, const int64_t *shape,
213  MlirType elementType) {
214  return wrap(VectorType::get(llvm::ArrayRef(shape, static_cast<size_t>(rank)),
215  unwrap(elementType)));
216 }
217 
218 MlirType mlirVectorTypeGetChecked(MlirLocation loc, intptr_t rank,
219  const int64_t *shape, MlirType elementType) {
220  return wrap(VectorType::getChecked(
221  unwrap(loc), llvm::ArrayRef(shape, static_cast<size_t>(rank)),
222  unwrap(elementType)));
223 }
224 
225 //===----------------------------------------------------------------------===//
226 // Ranked / Unranked tensor type.
227 //===----------------------------------------------------------------------===//
228 
229 bool mlirTypeIsATensor(MlirType type) { return unwrap(type).isa<TensorType>(); }
230 
231 bool mlirTypeIsARankedTensor(MlirType type) {
232  return unwrap(type).isa<RankedTensorType>();
233 }
234 
235 bool mlirTypeIsAUnrankedTensor(MlirType type) {
236  return unwrap(type).isa<UnrankedTensorType>();
237 }
238 
239 MlirType mlirRankedTensorTypeGet(intptr_t rank, const int64_t *shape,
240  MlirType elementType, MlirAttribute encoding) {
241  return wrap(
242  RankedTensorType::get(llvm::ArrayRef(shape, static_cast<size_t>(rank)),
243  unwrap(elementType), unwrap(encoding)));
244 }
245 
246 MlirType mlirRankedTensorTypeGetChecked(MlirLocation loc, intptr_t rank,
247  const int64_t *shape,
248  MlirType elementType,
249  MlirAttribute encoding) {
250  return wrap(RankedTensorType::getChecked(
251  unwrap(loc), llvm::ArrayRef(shape, static_cast<size_t>(rank)),
252  unwrap(elementType), unwrap(encoding)));
253 }
254 
255 MlirAttribute mlirRankedTensorTypeGetEncoding(MlirType type) {
256  return wrap(unwrap(type).cast<RankedTensorType>().getEncoding());
257 }
258 
259 MlirType mlirUnrankedTensorTypeGet(MlirType elementType) {
260  return wrap(UnrankedTensorType::get(unwrap(elementType)));
261 }
262 
263 MlirType mlirUnrankedTensorTypeGetChecked(MlirLocation loc,
264  MlirType elementType) {
265  return wrap(UnrankedTensorType::getChecked(unwrap(loc), unwrap(elementType)));
266 }
267 
268 //===----------------------------------------------------------------------===//
269 // Ranked / Unranked MemRef type.
270 //===----------------------------------------------------------------------===//
271 
272 bool mlirTypeIsAMemRef(MlirType type) { return unwrap(type).isa<MemRefType>(); }
273 
274 MlirType mlirMemRefTypeGet(MlirType elementType, intptr_t rank,
275  const int64_t *shape, MlirAttribute layout,
276  MlirAttribute memorySpace) {
277  return wrap(MemRefType::get(
278  llvm::ArrayRef(shape, static_cast<size_t>(rank)), unwrap(elementType),
279  mlirAttributeIsNull(layout)
280  ? MemRefLayoutAttrInterface()
281  : unwrap(layout).cast<MemRefLayoutAttrInterface>(),
282  unwrap(memorySpace)));
283 }
284 
285 MlirType mlirMemRefTypeGetChecked(MlirLocation loc, MlirType elementType,
286  intptr_t rank, const int64_t *shape,
287  MlirAttribute layout,
288  MlirAttribute memorySpace) {
289  return wrap(MemRefType::getChecked(
290  unwrap(loc), llvm::ArrayRef(shape, static_cast<size_t>(rank)),
291  unwrap(elementType),
292  mlirAttributeIsNull(layout)
293  ? MemRefLayoutAttrInterface()
294  : unwrap(layout).cast<MemRefLayoutAttrInterface>(),
295  unwrap(memorySpace)));
296 }
297 
298 MlirType mlirMemRefTypeContiguousGet(MlirType elementType, intptr_t rank,
299  const int64_t *shape,
300  MlirAttribute memorySpace) {
301  return wrap(MemRefType::get(llvm::ArrayRef(shape, static_cast<size_t>(rank)),
302  unwrap(elementType), MemRefLayoutAttrInterface(),
303  unwrap(memorySpace)));
304 }
305 
306 MlirType mlirMemRefTypeContiguousGetChecked(MlirLocation loc,
307  MlirType elementType, intptr_t rank,
308  const int64_t *shape,
309  MlirAttribute memorySpace) {
310  return wrap(MemRefType::getChecked(
311  unwrap(loc), llvm::ArrayRef(shape, static_cast<size_t>(rank)),
312  unwrap(elementType), MemRefLayoutAttrInterface(), unwrap(memorySpace)));
313 }
314 
315 MlirAttribute mlirMemRefTypeGetLayout(MlirType type) {
316  return wrap(unwrap(type).cast<MemRefType>().getLayout());
317 }
318 
319 MlirAffineMap mlirMemRefTypeGetAffineMap(MlirType type) {
320  return wrap(unwrap(type).cast<MemRefType>().getLayout().getAffineMap());
321 }
322 
323 MlirAttribute mlirMemRefTypeGetMemorySpace(MlirType type) {
324  return wrap(unwrap(type).cast<MemRefType>().getMemorySpace());
325 }
326 
327 bool mlirTypeIsAUnrankedMemRef(MlirType type) {
328  return unwrap(type).isa<UnrankedMemRefType>();
329 }
330 
331 MlirType mlirUnrankedMemRefTypeGet(MlirType elementType,
332  MlirAttribute memorySpace) {
333  return wrap(
334  UnrankedMemRefType::get(unwrap(elementType), unwrap(memorySpace)));
335 }
336 
337 MlirType mlirUnrankedMemRefTypeGetChecked(MlirLocation loc,
338  MlirType elementType,
339  MlirAttribute memorySpace) {
340  return wrap(UnrankedMemRefType::getChecked(unwrap(loc), unwrap(elementType),
341  unwrap(memorySpace)));
342 }
343 
344 MlirAttribute mlirUnrankedMemrefGetMemorySpace(MlirType type) {
345  return wrap(unwrap(type).cast<UnrankedMemRefType>().getMemorySpace());
346 }
347 
348 //===----------------------------------------------------------------------===//
349 // Tuple type.
350 //===----------------------------------------------------------------------===//
351 
352 bool mlirTypeIsATuple(MlirType type) { return unwrap(type).isa<TupleType>(); }
353 
354 MlirType mlirTupleTypeGet(MlirContext ctx, intptr_t numElements,
355  MlirType const *elements) {
356  SmallVector<Type, 4> types;
357  ArrayRef<Type> typeRef = unwrapList(numElements, elements, types);
358  return wrap(TupleType::get(unwrap(ctx), typeRef));
359 }
360 
361 intptr_t mlirTupleTypeGetNumTypes(MlirType type) {
362  return unwrap(type).cast<TupleType>().size();
363 }
364 
365 MlirType mlirTupleTypeGetType(MlirType type, intptr_t pos) {
366  return wrap(unwrap(type).cast<TupleType>().getType(static_cast<size_t>(pos)));
367 }
368 
369 //===----------------------------------------------------------------------===//
370 // Function type.
371 //===----------------------------------------------------------------------===//
372 
373 bool mlirTypeIsAFunction(MlirType type) {
374  return unwrap(type).isa<FunctionType>();
375 }
376 
377 MlirType mlirFunctionTypeGet(MlirContext ctx, intptr_t numInputs,
378  MlirType const *inputs, intptr_t numResults,
379  MlirType const *results) {
380  SmallVector<Type, 4> inputsList;
381  SmallVector<Type, 4> resultsList;
382  (void)unwrapList(numInputs, inputs, inputsList);
383  (void)unwrapList(numResults, results, resultsList);
384  return wrap(FunctionType::get(unwrap(ctx), inputsList, resultsList));
385 }
386 
387 intptr_t mlirFunctionTypeGetNumInputs(MlirType type) {
388  return unwrap(type).cast<FunctionType>().getNumInputs();
389 }
390 
391 intptr_t mlirFunctionTypeGetNumResults(MlirType type) {
392  return unwrap(type).cast<FunctionType>().getNumResults();
393 }
394 
395 MlirType mlirFunctionTypeGetInput(MlirType type, intptr_t pos) {
396  assert(pos >= 0 && "pos in array must be positive");
397  return wrap(
398  unwrap(type).cast<FunctionType>().getInput(static_cast<unsigned>(pos)));
399 }
400 
401 MlirType mlirFunctionTypeGetResult(MlirType type, intptr_t pos) {
402  assert(pos >= 0 && "pos in array must be positive");
403  return wrap(
404  unwrap(type).cast<FunctionType>().getResult(static_cast<unsigned>(pos)));
405 }
406 
407 //===----------------------------------------------------------------------===//
408 // Opaque type.
409 //===----------------------------------------------------------------------===//
410 
411 bool mlirTypeIsAOpaque(MlirType type) { return unwrap(type).isa<OpaqueType>(); }
412 
413 MlirType mlirOpaqueTypeGet(MlirContext ctx, MlirStringRef dialectNamespace,
414  MlirStringRef typeData) {
415  return wrap(
416  OpaqueType::get(StringAttr::get(unwrap(ctx), unwrap(dialectNamespace)),
417  unwrap(typeData)));
418 }
419 
421  return wrap(unwrap(type).cast<OpaqueType>().getDialectNamespace().strref());
422 }
423 
425  return wrap(unwrap(type).cast<OpaqueType>().getTypeData());
426 }
bool mlirTypeIsAF16(MlirType type)
Checks whether the given type is an f16 type.
bool mlirTypeIsAF64(MlirType type)
Checks whether the given type is an f64 type.
bool mlirTypeIsAFloat8E4M3FNUZ(MlirType type)
Checks whether the given type is an f8E4M3FNUZ type.
bool mlirIntegerTypeIsUnsigned(MlirType type)
Checks whether the given integer type is unsigned.
MlirType mlirF32TypeGet(MlirContext ctx)
Creates an f32 type in the given context.
MlirType mlirVectorTypeGetChecked(MlirLocation loc, intptr_t rank, const int64_t *shape, MlirType elementType)
Same as "mlirVectorTypeGet" but returns a nullptr wrapping MlirType on illegal arguments,...
MlirType mlirIntegerTypeGet(MlirContext ctx, unsigned bitwidth)
Creates a signless integer type of the given bitwidth in the context.
intptr_t mlirFunctionTypeGetNumResults(MlirType type)
Returns the number of result types.
unsigned mlirIntegerTypeGetWidth(MlirType type)
Returns the bitwidth of an integer type.
bool mlirTypeIsAUnrankedTensor(MlirType type)
Checks whether the given type is an unranked tensor type.
int64_t mlirShapedTypeGetDynamicStrideOrOffset()
Returns the value indicating a dynamic stride or offset in a shaped type.
MlirType mlirF64TypeGet(MlirContext ctx)
Creates a f64 type in the given context.
MlirAttribute mlirUnrankedMemrefGetMemorySpace(MlirType type)
Returns the memory spcae of the given Unranked MemRef type.
bool mlirTypeIsAFloat8E4M3B11FNUZ(MlirType type)
Checks whether the given type is an f8E4M3B11FNUZ type.
bool mlirTypeIsAFloat8E5M2(MlirType type)
Checks whether the given type is an f8E5M2 type.
MlirType mlirIntegerTypeSignedGet(MlirContext ctx, unsigned bitwidth)
Creates a signed integer type of the given bitwidth in the context.
int64_t mlirShapedTypeGetDimSize(MlirType type, intptr_t dim)
Returns the dim-th dimension of the given ranked shaped type.
MlirType mlirMemRefTypeGetChecked(MlirLocation loc, MlirType elementType, intptr_t rank, const int64_t *shape, MlirAttribute layout, MlirAttribute memorySpace)
Same as "mlirMemRefTypeGet" but returns a nullptr-wrapping MlirType o illegal arguments,...
MlirType mlirUnrankedTensorTypeGet(MlirType elementType)
Creates an unranked tensor type with the given element type in the same context as the element type.
MlirStringRef mlirOpaqueTypeGetData(MlirType type)
Returns the raw data as a string reference.
bool mlirTypeIsAF32(MlirType type)
Checks whether the given type is an f32 type.
bool mlirTypeIsAFunction(MlirType type)
Checks whether the given type is a function type.
MlirAffineMap mlirMemRefTypeGetAffineMap(MlirType type)
Returns the affine map of the given MemRef type.
MlirType mlirUnrankedMemRefTypeGetChecked(MlirLocation loc, MlirType elementType, MlirAttribute memorySpace)
Same as "mlirUnrankedMemRefTypeGet" but returns a nullptr wrapping MlirType on illegal arguments,...
bool mlirTypeIsAMemRef(MlirType type)
Checks whether the given type is a MemRef type.
MlirType mlirFunctionTypeGetResult(MlirType type, intptr_t pos)
Returns the pos-th result type.
MlirType mlirF16TypeGet(MlirContext ctx)
Creates an f16 type in the given context.
bool mlirTypeIsAComplex(MlirType type)
Checks whether the given type is a Complex type.
MlirType mlirNoneTypeGet(MlirContext ctx)
Creates a None type in the given context.
bool mlirShapedTypeHasRank(MlirType type)
Checks whether the given shaped type is ranked.
bool mlirTypeIsAShaped(MlirType type)
Checks whether the given type is a Shaped type.
MlirType mlirUnrankedTensorTypeGetChecked(MlirLocation loc, MlirType elementType)
Same as "mlirUnrankedTensorTypeGet" but returns a nullptr wrapping MlirType on illegal arguments,...
bool mlirIntegerTypeIsSignless(MlirType type)
Checks whether the given integer type is signless.
MlirType mlirRankedTensorTypeGet(intptr_t rank, const int64_t *shape, MlirType elementType, MlirAttribute encoding)
Creates a tensor type of a fixed rank with the given shape, element type, and optional encoding in th...
bool mlirShapedTypeIsDynamicDim(MlirType type, intptr_t dim)
Checks wither the dim-th dimension of the given shaped type is dynamic.
MlirType mlirFloat8E4M3B11FNUZTypeGet(MlirContext ctx)
Creates an f8E4M3B11FNUZ type in the given context.
MlirType mlirFunctionTypeGet(MlirContext ctx, intptr_t numInputs, MlirType const *inputs, intptr_t numResults, MlirType const *results)
Creates a function type, mapping a list of input types to result types.
bool mlirTypeIsAUnrankedMemRef(MlirType type)
Checks whether the given type is an UnrankedMemRef type.
MlirType mlirIntegerTypeUnsignedGet(MlirContext ctx, unsigned bitwidth)
Creates an unsigned integer type of the given bitwidth in the context.
MlirType mlirShapedTypeGetElementType(MlirType type)
Returns the element type of the shaped type.
int64_t mlirShapedTypeGetDynamicSize()
Returns the value indicating a dynamic size in a shaped type.
bool mlirTypeIsAVector(MlirType type)
Checks whether the given type is a Vector type.
MlirType mlirFloat8E4M3FNUZTypeGet(MlirContext ctx)
Creates an f8E4M3FNUZ type in the given context.
MlirAttribute mlirMemRefTypeGetLayout(MlirType type)
Returns the layout of the given MemRef type.
MlirType mlirFloat8E5M2FNUZTypeGet(MlirContext ctx)
Creates an f8E5M2FNUZ type in the given context.
bool mlirShapedTypeIsDynamicStrideOrOffset(int64_t val)
Checks whether the given value is used as a placeholder for dynamic strides and offsets in shaped typ...
MlirType mlirMemRefTypeGet(MlirType elementType, intptr_t rank, const int64_t *shape, MlirAttribute layout, MlirAttribute memorySpace)
Creates a MemRef type with the given rank and shape, a potentially empty list of affine layout maps,...
bool mlirTypeIsABF16(MlirType type)
Checks whether the given type is a bf16 type.
intptr_t mlirTupleTypeGetNumTypes(MlirType type)
Returns the number of types contained in a tuple.
MlirStringRef mlirOpaqueTypeGetDialectNamespace(MlirType type)
Returns the namespace of the dialect with which the given opaque type is associated.
MlirType mlirFunctionTypeGetInput(MlirType type, intptr_t pos)
Returns the pos-th input type.
MlirType mlirMemRefTypeContiguousGetChecked(MlirLocation loc, MlirType elementType, intptr_t rank, const int64_t *shape, MlirAttribute memorySpace)
Same as "mlirMemRefTypeContiguousGet" but returns a nullptr wrapping MlirType on illegal arguments,...
bool mlirTypeIsAInteger(MlirType type)
Checks whether the given type is an integer type.
MlirAttribute mlirRankedTensorTypeGetEncoding(MlirType type)
Gets the 'encoding' attribute from the ranked tensor type, returning a null attribute if none.
intptr_t mlirFunctionTypeGetNumInputs(MlirType type)
Returns the number of input types.
bool mlirTypeIsATuple(MlirType type)
Checks whether the given type is a tuple type.
MlirType mlirTupleTypeGet(MlirContext ctx, intptr_t numElements, MlirType const *elements)
Creates a tuple type that consists of the given list of elemental types.
MlirType mlirComplexTypeGet(MlirType elementType)
Creates a complex type with the given element type in the same context as the element type.
int64_t mlirShapedTypeGetRank(MlirType type)
Returns the rank of the given ranked shaped type.
bool mlirTypeIsAFloat8E4M3FN(MlirType type)
Checks whether the given type is an f8E4M3FN type.
bool mlirTypeIsAOpaque(MlirType type)
Checks whether the given type is an opaque type.
MlirType mlirTupleTypeGetType(MlirType type, intptr_t pos)
Returns the pos-th type in the tuple type.
bool mlirTypeIsATensor(MlirType type)
Checks whether the given type is a Tensor type.
bool mlirIntegerTypeIsSigned(MlirType type)
Checks whether the given integer type is signed.
bool mlirShapedTypeHasStaticShape(MlirType type)
Checks whether the given shaped type has a static shape.
MlirType mlirBF16TypeGet(MlirContext ctx)
Creates a bf16 type in the given context.
MlirType mlirComplexTypeGetElementType(MlirType type)
Returns the element type of the given complex type.
bool mlirTypeIsAIndex(MlirType type)
Checks whether the given type is an index type.
bool mlirTypeIsAFloat8E5M2FNUZ(MlirType type)
Checks whether the given type is an f8E5M2FNUZ type.
MlirType mlirOpaqueTypeGet(MlirContext ctx, MlirStringRef dialectNamespace, MlirStringRef typeData)
Creates an opaque type in the given context associated with the dialect identified by its namespace.
MlirAttribute mlirMemRefTypeGetMemorySpace(MlirType type)
Returns the memory space of the given MemRef type.
MlirType mlirRankedTensorTypeGetChecked(MlirLocation loc, intptr_t rank, const int64_t *shape, MlirType elementType, MlirAttribute encoding)
Same as "mlirRankedTensorTypeGet" but returns a nullptr wrapping MlirType on illegal arguments,...
MlirType mlirVectorTypeGet(intptr_t rank, const int64_t *shape, MlirType elementType)
Creates a vector type of the shape identified by its rank and dimensions, with the given element type...
MlirType mlirMemRefTypeContiguousGet(MlirType elementType, intptr_t rank, const int64_t *shape, MlirAttribute memorySpace)
Creates a MemRef type with the given rank, shape, memory space and element type in the same context a...
MlirType mlirFloat8E4M3FNTypeGet(MlirContext ctx)
Creates an f8E4M3FN type in the given context.
MlirType mlirIndexTypeGet(MlirContext ctx)
Creates an index type in the given context.
bool mlirTypeIsARankedTensor(MlirType type)
Checks whether the given type is a ranked tensor type.
bool mlirShapedTypeIsDynamicSize(int64_t size)
Checks whether the given value is used as a placeholder for dynamic sizes in shaped types.
bool mlirTypeIsANone(MlirType type)
Checks whether the given type is a None type.
MlirType mlirFloat8E5M2TypeGet(MlirContext ctx)
Creates an f8E5M2 type in the given context.
MlirType mlirUnrankedMemRefTypeGet(MlirType elementType, MlirAttribute memorySpace)
Creates an Unranked MemRef type with the given element type and in the given memory space.
static Type getElementType(Type type, ArrayRef< int32_t > indices, function_ref< InFlightDiagnostic(StringRef)> emitErrorFn)
Walks the given type hierarchy with the given indices, potentially down to component granularity,...
Definition: SPIRVOps.cpp:698
static llvm::ArrayRef< CppTy > unwrapList(size_t size, CTy *first, llvm::SmallVectorImpl< CppTy > &storage)
Definition: Wrap.h:40
static FloatType getF64(MLIRContext *ctx)
Definition: BuiltinTypes.h:418
static FloatType getFloat8E5M2(MLIRContext *ctx)
Definition: BuiltinTypes.h:386
static FloatType getFloat8E4M3FN(MLIRContext *ctx)
Definition: BuiltinTypes.h:390
static FloatType getF16(MLIRContext *ctx)
Definition: BuiltinTypes.h:410
static FloatType getBF16(MLIRContext *ctx)
Definition: BuiltinTypes.h:406
static FloatType getFloat8E4M3FNUZ(MLIRContext *ctx)
Definition: BuiltinTypes.h:398
static FloatType getFloat8E4M3B11FNUZ(MLIRContext *ctx)
Definition: BuiltinTypes.h:402
static FloatType getFloat8E5M2FNUZ(MLIRContext *ctx)
Definition: BuiltinTypes.h:394
static FloatType getF32(MLIRContext *ctx)
Definition: BuiltinTypes.h:414
Tensor types represent multi-dimensional arrays, and have two variants: RankedTensorType and Unranked...
Definition: BuiltinTypes.h:80
static bool mlirAttributeIsNull(MlirAttribute attr)
Checks whether an attribute is null.
Definition: IR.h:824
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
Definition: Diagnostics.h:19
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
Definition: Diagnostics.h:24
This header declares functions that assit transformations in the MemRef dialect.
A pointer to a sized fragment of a string, not necessarily null-terminated.
Definition: Support.h:71