MLIR 23.0.0git
IRTypes.cpp
Go to the documentation of this file.
1//===- IRTypes.cpp - Exports builtin and standard 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// clang-format off
12// clang-format on
13
14#include <optional>
15#include <vector>
16
18#include "mlir-c/BuiltinTypes.h"
19#include "mlir-c/Support.h"
21
22namespace nb = nanobind;
23using namespace mlir;
25
26namespace mlir {
27namespace python {
29
30int mlirTypeIsAIntegerOrFloat(MlirType type) {
31 return mlirTypeIsAInteger(type) || mlirTypeIsABF16(type) ||
32 mlirTypeIsAF16(type) || mlirTypeIsAF32(type) || mlirTypeIsAF64(type);
33}
34
36 nb::enum_<Signedness>(c, "Signedness")
37 .value("SIGNLESS", Signless)
38 .value("SIGNED", Signed)
39 .value("UNSIGNED", Unsigned)
40 .export_values();
41
42 c.def_static(
43 "get_signless",
44 [](unsigned width, DefaultingPyMlirContext context) {
45 MlirType t = mlirIntegerTypeGet(context->get(), width);
46 return PyIntegerType(context->getRef(), t);
47 },
48 nb::arg("width"), nb::arg("context") = nb::none(),
49 "Create a signless integer type");
50 c.def_static(
51 "get_signed",
52 [](unsigned width, DefaultingPyMlirContext context) {
53 MlirType t = mlirIntegerTypeSignedGet(context->get(), width);
54 return PyIntegerType(context->getRef(), t);
55 },
56 nb::arg("width"), nb::arg("context") = nb::none(),
57 "Create a signed integer type");
58 c.def_static(
59 "get_unsigned",
60 [](unsigned width, DefaultingPyMlirContext context) {
61 MlirType t = mlirIntegerTypeUnsignedGet(context->get(), width);
62 return PyIntegerType(context->getRef(), t);
63 },
64 nb::arg("width"), nb::arg("context") = nb::none(),
65 "Create an unsigned integer type");
66 c.def_static(
67 "get",
68 [](unsigned width, Signedness signedness,
70 MlirType t;
71 switch (signedness) {
72 case Signless:
73 t = mlirIntegerTypeGet(context->get(), width);
74 break;
75 case Signed:
76 t = mlirIntegerTypeSignedGet(context->get(), width);
77 break;
78 case Unsigned:
79 t = mlirIntegerTypeUnsignedGet(context->get(), width);
80 break;
81 }
82 return PyIntegerType(context->getRef(), t);
83 },
84 nb::arg("width"), nb::arg("signedness") = Signless,
85 nb::arg("context") = nb::none(), "Create an integer type");
86 c.def_prop_ro("signedness", [](PyIntegerType &self) -> Signedness {
88 return Signless;
90 return Signed;
91 return Unsigned;
92 });
93 c.def_prop_ro(
94 "width",
95 [](PyIntegerType &self) { return mlirIntegerTypeGetWidth(self); },
96 "Returns the width of the integer type");
97 c.def_prop_ro(
98 "is_signless",
99 [](PyIntegerType &self) -> bool {
100 return mlirIntegerTypeIsSignless(self);
101 },
102 "Returns whether this is a signless integer");
103 c.def_prop_ro(
104 "is_signed",
105 [](PyIntegerType &self) -> bool { return mlirIntegerTypeIsSigned(self); },
106 "Returns whether this is a signed integer");
107 c.def_prop_ro(
108 "is_unsigned",
109 [](PyIntegerType &self) -> bool {
110 return mlirIntegerTypeIsUnsigned(self);
111 },
112 "Returns whether this is an unsigned integer");
113}
114
116 c.def_static(
117 "get",
118 [](DefaultingPyMlirContext context) {
119 MlirType t = mlirIndexTypeGet(context->get());
120 return PyIndexType(context->getRef(), t);
121 },
122 nb::arg("context") = nb::none(), "Create a index type.");
123}
124
126 c.def_prop_ro(
127 "width", [](PyFloatType &self) { return mlirFloatTypeGetWidth(self); },
128 "Returns the width of the floating-point type");
129}
130
132 c.def_static(
133 "get",
134 [](DefaultingPyMlirContext context) {
135 MlirType t = mlirFloat4E2M1FNTypeGet(context->get());
136 return PyFloat4E2M1FNType(context->getRef(), t);
137 },
138 nb::arg("context") = nb::none(), "Create a float4_e2m1fn type.");
139}
140
142 c.def_static(
143 "get",
144 [](DefaultingPyMlirContext context) {
145 MlirType t = mlirFloat6E2M3FNTypeGet(context->get());
146 return PyFloat6E2M3FNType(context->getRef(), t);
147 },
148 nb::arg("context") = nb::none(), "Create a float6_e2m3fn type.");
149}
150
152 c.def_static(
153 "get",
154 [](DefaultingPyMlirContext context) {
155 MlirType t = mlirFloat6E3M2FNTypeGet(context->get());
156 return PyFloat6E3M2FNType(context->getRef(), t);
157 },
158 nb::arg("context") = nb::none(), "Create a float6_e3m2fn type.");
159}
160
162 c.def_static(
163 "get",
164 [](DefaultingPyMlirContext context) {
165 MlirType t = mlirFloat8E4M3FNTypeGet(context->get());
166 return PyFloat8E4M3FNType(context->getRef(), t);
167 },
168 nb::arg("context") = nb::none(), "Create a float8_e4m3fn type.");
169}
170
172 c.def_static(
173 "get",
174 [](DefaultingPyMlirContext context) {
175 MlirType t = mlirFloat8E5M2TypeGet(context->get());
176 return PyFloat8E5M2Type(context->getRef(), t);
177 },
178 nb::arg("context") = nb::none(), "Create a float8_e5m2 type.");
179}
180
182 c.def_static(
183 "get",
184 [](DefaultingPyMlirContext context) {
185 MlirType t = mlirFloat8E4M3TypeGet(context->get());
186 return PyFloat8E4M3Type(context->getRef(), t);
187 },
188 nb::arg("context") = nb::none(), "Create a float8_e4m3 type.");
189}
190
192 c.def_static(
193 "get",
194 [](DefaultingPyMlirContext context) {
195 MlirType t = mlirFloat8E4M3FNUZTypeGet(context->get());
196 return PyFloat8E4M3FNUZType(context->getRef(), t);
197 },
198 nb::arg("context") = nb::none(), "Create a float8_e4m3fnuz type.");
199}
200
202 c.def_static(
203 "get",
204 [](DefaultingPyMlirContext context) {
205 MlirType t = mlirFloat8E4M3B11FNUZTypeGet(context->get());
206 return PyFloat8E4M3B11FNUZType(context->getRef(), t);
207 },
208 nb::arg("context") = nb::none(), "Create a float8_e4m3b11fnuz type.");
209}
210
212 c.def_static(
213 "get",
214 [](DefaultingPyMlirContext context) {
215 MlirType t = mlirFloat8E5M2FNUZTypeGet(context->get());
216 return PyFloat8E5M2FNUZType(context->getRef(), t);
217 },
218 nb::arg("context") = nb::none(), "Create a float8_e5m2fnuz type.");
219}
220
222 c.def_static(
223 "get",
224 [](DefaultingPyMlirContext context) {
225 MlirType t = mlirFloat8E3M4TypeGet(context->get());
226 return PyFloat8E3M4Type(context->getRef(), t);
227 },
228 nb::arg("context") = nb::none(), "Create a float8_e3m4 type.");
229}
230
232 c.def_static(
233 "get",
234 [](DefaultingPyMlirContext context) {
235 MlirType t = mlirFloat8E8M0FNUTypeGet(context->get());
236 return PyFloat8E8M0FNUType(context->getRef(), t);
237 },
238 nb::arg("context") = nb::none(), "Create a float8_e8m0fnu type.");
239}
240
242 c.def_static(
243 "get",
244 [](DefaultingPyMlirContext context) {
245 MlirType t = mlirBF16TypeGet(context->get());
246 return PyBF16Type(context->getRef(), t);
247 },
248 nb::arg("context") = nb::none(), "Create a bf16 type.");
249}
250
252 c.def_static(
253 "get",
254 [](DefaultingPyMlirContext context) {
255 MlirType t = mlirF16TypeGet(context->get());
256 return PyF16Type(context->getRef(), t);
257 },
258 nb::arg("context") = nb::none(), "Create a f16 type.");
259}
260
262 c.def_static(
263 "get",
264 [](DefaultingPyMlirContext context) {
265 MlirType t = mlirTF32TypeGet(context->get());
266 return PyTF32Type(context->getRef(), t);
267 },
268 nb::arg("context") = nb::none(), "Create a tf32 type.");
269}
270
272 c.def_static(
273 "get",
274 [](DefaultingPyMlirContext context) {
275 MlirType t = mlirF32TypeGet(context->get());
276 return PyF32Type(context->getRef(), t);
277 },
278 nb::arg("context") = nb::none(), "Create a f32 type.");
279}
280
282 c.def_static(
283 "get",
284 [](DefaultingPyMlirContext context) {
285 MlirType t = mlirF64TypeGet(context->get());
286 return PyF64Type(context->getRef(), t);
287 },
288 nb::arg("context") = nb::none(), "Create a f64 type.");
289}
290
292 c.def_static(
293 "get",
294 [](DefaultingPyMlirContext context) {
295 MlirType t = mlirNoneTypeGet(context->get());
296 return PyNoneType(context->getRef(), t);
297 },
298 nb::arg("context") = nb::none(), "Create a none type.");
299}
300
302 c.def_static(
303 "get",
304 [](PyType &elementType) {
305 // The element must be a floating point or integer scalar type.
306 if (mlirTypeIsAIntegerOrFloat(elementType)) {
307 MlirType t = mlirComplexTypeGet(elementType);
308 return PyComplexType(elementType.getContext(), t);
309 }
310 throw nb::value_error(
312 "invalid '",
313 nb::cast<std::string>(nb::repr(nb::cast(elementType))),
314 "' and expected floating point or integer type.")
315 .c_str());
316 },
317 "Create a complex type");
318 c.def_prop_ro(
319 "element_type",
320 [](PyComplexType &self) -> nb::typed<nb::object, PyType> {
322 .maybeDownCast();
323 },
324 "Returns element type.");
325}
326
327// Shaped Type Interface - ShapedType
329 c.def_prop_ro(
330 "element_type",
331 [](PyShapedType &self) -> nb::typed<nb::object, PyType> {
333 .maybeDownCast();
334 },
335 "Returns the element type of the shaped type.");
336 c.def_prop_ro(
337 "has_rank",
338 [](PyShapedType &self) -> bool { return mlirShapedTypeHasRank(self); },
339 "Returns whether the given shaped type is ranked.");
340 c.def_prop_ro(
341 "rank",
342 [](PyShapedType &self) {
343 self.requireHasRank();
344 return mlirShapedTypeGetRank(self);
345 },
346 "Returns the rank of the given ranked shaped type.");
347 c.def_prop_ro(
348 "has_static_shape",
349 [](PyShapedType &self) -> bool {
350 return mlirShapedTypeHasStaticShape(self);
351 },
352 "Returns whether the given shaped type has a static shape.");
353 c.def(
354 "is_dynamic_dim",
355 [](PyShapedType &self, intptr_t dim) -> bool {
356 self.requireHasRank();
357 return mlirShapedTypeIsDynamicDim(self, dim);
358 },
359 nb::arg("dim"),
360 "Returns whether the dim-th dimension of the given shaped type is "
361 "dynamic.");
362 c.def(
363 "is_static_dim",
364 [](PyShapedType &self, intptr_t dim) -> bool {
365 self.requireHasRank();
366 return mlirShapedTypeIsStaticDim(self, dim);
367 },
368 nb::arg("dim"),
369 "Returns whether the dim-th dimension of the given shaped type is "
370 "static.");
371 c.def(
372 "get_dim_size",
373 [](PyShapedType &self, intptr_t dim) {
374 self.requireHasRank();
375 return mlirShapedTypeGetDimSize(self, dim);
376 },
377 nb::arg("dim"),
378 "Returns the dim-th dimension of the given ranked shaped type.");
379 c.def_static(
380 "is_dynamic_size",
381 [](int64_t size) -> bool { return mlirShapedTypeIsDynamicSize(size); },
382 nb::arg("dim_size"),
383 "Returns whether the given dimension size indicates a dynamic "
384 "dimension.");
385 c.def_static(
386 "is_static_size",
387 [](int64_t size) -> bool { return mlirShapedTypeIsStaticSize(size); },
388 nb::arg("dim_size"),
389 "Returns whether the given dimension size indicates a static "
390 "dimension.");
391 c.def(
392 "is_dynamic_stride_or_offset",
393 [](PyShapedType &self, int64_t val) -> bool {
394 self.requireHasRank();
396 },
397 nb::arg("dim_size"),
398 "Returns whether the given value is used as a placeholder for dynamic "
399 "strides and offsets in shaped types.");
400 c.def(
401 "is_static_stride_or_offset",
402 [](PyShapedType &self, int64_t val) -> bool {
403 self.requireHasRank();
405 },
406 nb::arg("dim_size"),
407 "Returns whether the given shaped type stride or offset value is "
408 "statically-sized.");
409 c.def_prop_ro(
410 "shape",
411 [](PyShapedType &self) {
412 self.requireHasRank();
413
414 std::vector<int64_t> shape;
415 int64_t rank = mlirShapedTypeGetRank(self);
416 shape.reserve(rank);
417 for (int64_t i = 0; i < rank; ++i)
418 shape.push_back(mlirShapedTypeGetDimSize(self, i));
419 return shape;
420 },
421 "Returns the shape of the ranked shaped type as a list of integers.");
422 c.def_static(
423 "get_dynamic_size", []() { return mlirShapedTypeGetDynamicSize(); },
424 "Returns the value used to indicate dynamic dimensions in shaped "
425 "types.");
426 c.def_static(
427 "get_dynamic_stride_or_offset",
429 "Returns the value used to indicate dynamic strides or offsets in "
430 "shaped types.");
431}
432
433void PyShapedType::requireHasRank() {
434 if (!mlirShapedTypeHasRank(*this)) {
435 throw nb::value_error(
436 "calling this method requires that the type has a rank.");
437 }
438}
439
441
443 c.def_static("get", &PyVectorType::getChecked, nb::arg("shape"),
444 nb::arg("element_type"), nb::kw_only(),
445 nb::arg("scalable") = nb::none(),
446 nb::arg("scalable_dims") = nb::none(),
447 nb::arg("loc") = nb::none(), "Create a vector type")
448 .def_static("get_unchecked", &PyVectorType::get, nb::arg("shape"),
449 nb::arg("element_type"), nb::kw_only(),
450 nb::arg("scalable") = nb::none(),
451 nb::arg("scalable_dims") = nb::none(),
452 nb::arg("context") = nb::none(), "Create a vector type")
453 .def_prop_ro("scalable",
454 [](PyType self) { return mlirVectorTypeIsScalable(self); })
455 .def_prop_ro("scalable_dims", [](PyType self) {
456 std::vector<bool> scalableDims;
457 size_t rank = static_cast<size_t>(mlirShapedTypeGetRank(self));
458 scalableDims.reserve(rank);
459 for (size_t i = 0; i < rank; ++i)
460 scalableDims.push_back(mlirVectorTypeIsDimScalable(self, i));
461 return scalableDims;
462 });
463}
464
466PyVectorType::getChecked(std::vector<int64_t> shape, PyType &elementType,
467 std::optional<nb::list> scalable,
468 std::optional<std::vector<int64_t>> scalableDims,
470 if (scalable && scalableDims) {
471 throw nb::value_error("'scalable' and 'scalable_dims' kwargs "
472 "are mutually exclusive.");
473 }
474
475 PyMlirContext::ErrorCapture errors(loc->getContext());
476 MlirType type;
477 if (scalable) {
478 if (scalable->size() != shape.size())
479 throw nb::value_error("Expected len(scalable) == len(shape).");
480
481 std::vector<char> scalableDimFlags;
482 scalableDimFlags.reserve(scalable->size());
483 for (const nb::handle &h : *scalable) {
484 scalableDimFlags.push_back(nb::cast<bool>(h) ? 1 : 0);
485 }
487 loc, shape.size(), shape.data(),
488 reinterpret_cast<const bool *>(scalableDimFlags.data()), elementType);
489 } else if (scalableDims) {
490 std::vector<char> scalableDimFlags(shape.size(), 0);
491 for (int64_t dim : *scalableDims) {
492 if (static_cast<size_t>(dim) >= scalableDimFlags.size() || dim < 0)
493 throw nb::value_error("Scalable dimension index out of bounds.");
494 scalableDimFlags[dim] = 1;
495 }
497 loc, shape.size(), shape.data(),
498 reinterpret_cast<const bool *>(scalableDimFlags.data()), elementType);
499 } else {
500 type =
501 mlirVectorTypeGetChecked(loc, shape.size(), shape.data(), elementType);
502 }
503 if (mlirTypeIsNull(type))
504 throw MLIRError("Invalid type", errors.take());
505 return PyVectorType(elementType.getContext(), type);
506}
507
508PyVectorType PyVectorType::get(std::vector<int64_t> shape, PyType &elementType,
509 std::optional<nb::list> scalable,
510 std::optional<std::vector<int64_t>> scalableDims,
511 DefaultingPyMlirContext context) {
512 if (scalable && scalableDims) {
513 throw nb::value_error("'scalable' and 'scalable_dims' kwargs "
514 "are mutually exclusive.");
515 }
516
517 PyMlirContext::ErrorCapture errors(context->getRef());
518 MlirType type;
519 if (scalable) {
520 if (scalable->size() != shape.size())
521 throw nb::value_error("Expected len(scalable) == len(shape).");
522
523 std::vector<char> scalableDimFlags;
524 scalableDimFlags.reserve(scalable->size());
525 for (const nb::handle &h : *scalable) {
526 scalableDimFlags.push_back(nb::cast<bool>(h) ? 1 : 0);
527 }
529 shape.size(), shape.data(),
530 reinterpret_cast<const bool *>(scalableDimFlags.data()), elementType);
531 } else if (scalableDims) {
532 std::vector<char> scalableDimFlags(shape.size(), 0);
533 for (int64_t dim : *scalableDims) {
534 if (static_cast<size_t>(dim) >= scalableDimFlags.size() || dim < 0)
535 throw nb::value_error("Scalable dimension index out of bounds.");
536 scalableDimFlags[dim] = 1;
537 }
539 shape.size(), shape.data(),
540 reinterpret_cast<const bool *>(scalableDimFlags.data()), elementType);
541 } else {
542 type = mlirVectorTypeGet(shape.size(), shape.data(), elementType);
543 }
544 if (mlirTypeIsNull(type))
545 throw MLIRError("Invalid type", errors.take());
546 return PyVectorType(elementType.getContext(), type);
547}
548
550 c.def_static(
551 "get",
552 [](std::vector<int64_t> shape, PyType &elementType,
553 std::optional<PyAttribute> &encodingAttr, DefaultingPyLocation loc) {
554 PyMlirContext::ErrorCapture errors(loc->getContext());
556 loc, shape.size(), shape.data(), elementType,
557 encodingAttr ? encodingAttr->get() : mlirAttributeGetNull());
558 if (mlirTypeIsNull(t))
559 throw MLIRError("Invalid type", errors.take());
560 return PyRankedTensorType(elementType.getContext(), t);
561 },
562 nb::arg("shape"), nb::arg("element_type"),
563 nb::arg("encoding") = nb::none(), nb::arg("loc") = nb::none(),
564 "Create a ranked tensor type");
565 c.def_static(
566 "get_unchecked",
567 [](std::vector<int64_t> shape, PyType &elementType,
568 std::optional<PyAttribute> &encodingAttr,
569 DefaultingPyMlirContext context) {
570 PyMlirContext::ErrorCapture errors(context->getRef());
571 MlirType t = mlirRankedTensorTypeGet(
572 shape.size(), shape.data(), elementType,
573 encodingAttr ? encodingAttr->get() : mlirAttributeGetNull());
574 if (mlirTypeIsNull(t))
575 throw MLIRError("Invalid type", errors.take());
576 return PyRankedTensorType(elementType.getContext(), t);
577 },
578 nb::arg("shape"), nb::arg("element_type"),
579 nb::arg("encoding") = nb::none(), nb::arg("context") = nb::none(),
580 "Create a ranked tensor type");
581 c.def_prop_ro(
582 "encoding",
583 [](PyRankedTensorType &self)
584 -> std::optional<nb::typed<nb::object, PyAttribute>> {
585 MlirAttribute encoding = mlirRankedTensorTypeGetEncoding(self.get());
586 if (mlirAttributeIsNull(encoding))
587 return std::nullopt;
588 return PyAttribute(self.getContext(), encoding).maybeDownCast();
589 });
590}
591
593 c.def_static(
594 "get",
595 [](PyType &elementType, DefaultingPyLocation loc) {
596 PyMlirContext::ErrorCapture errors(loc->getContext());
597 MlirType t = mlirUnrankedTensorTypeGetChecked(loc, elementType);
598 if (mlirTypeIsNull(t))
599 throw MLIRError("Invalid type", errors.take());
600 return PyUnrankedTensorType(elementType.getContext(), t);
601 },
602 nb::arg("element_type"), nb::arg("loc") = nb::none(),
603 "Create a unranked tensor type");
604 c.def_static(
605 "get_unchecked",
606 [](PyType &elementType, DefaultingPyMlirContext context) {
607 PyMlirContext::ErrorCapture errors(context->getRef());
608 MlirType t = mlirUnrankedTensorTypeGet(elementType);
609 if (mlirTypeIsNull(t))
610 throw MLIRError("Invalid type", errors.take());
611 return PyUnrankedTensorType(elementType.getContext(), t);
612 },
613 nb::arg("element_type"), nb::arg("context") = nb::none(),
614 "Create a unranked tensor type");
615}
616
618 c.def_static(
619 "get",
620 [](std::vector<int64_t> shape, PyType &elementType, PyAttribute *layout,
621 PyAttribute *memorySpace, DefaultingPyLocation loc) {
622 PyMlirContext::ErrorCapture errors(loc->getContext());
623 MlirAttribute layoutAttr = layout ? *layout : mlirAttributeGetNull();
624 MlirAttribute memSpaceAttr =
625 memorySpace ? *memorySpace : mlirAttributeGetNull();
626 MlirType t =
627 mlirMemRefTypeGetChecked(loc, elementType, shape.size(),
628 shape.data(), layoutAttr, memSpaceAttr);
629 if (mlirTypeIsNull(t))
630 throw MLIRError("Invalid type", errors.take());
631 return PyMemRefType(elementType.getContext(), t);
632 },
633 nb::arg("shape"), nb::arg("element_type"),
634 nb::arg("layout") = nb::none(), nb::arg("memory_space") = nb::none(),
635 nb::arg("loc") = nb::none(), "Create a memref type")
636 .def_static(
637 "get_unchecked",
638 [](std::vector<int64_t> shape, PyType &elementType,
639 PyAttribute *layout, PyAttribute *memorySpace,
640 DefaultingPyMlirContext context) {
641 PyMlirContext::ErrorCapture errors(context->getRef());
642 MlirAttribute layoutAttr =
643 layout ? *layout : mlirAttributeGetNull();
644 MlirAttribute memSpaceAttr =
645 memorySpace ? *memorySpace : mlirAttributeGetNull();
646 MlirType t =
647 mlirMemRefTypeGet(elementType, shape.size(), shape.data(),
648 layoutAttr, memSpaceAttr);
649 if (mlirTypeIsNull(t))
650 throw MLIRError("Invalid type", errors.take());
651 return PyMemRefType(elementType.getContext(), t);
652 },
653 nb::arg("shape"), nb::arg("element_type"),
654 nb::arg("layout") = nb::none(), nb::arg("memory_space") = nb::none(),
655 nb::arg("context") = nb::none(), "Create a memref type")
656 .def_prop_ro(
657 "layout",
658 [](PyMemRefType &self) -> nb::typed<nb::object, PyAttribute> {
660 .maybeDownCast();
661 },
662 "The layout of the MemRef type.")
663 .def(
664 "get_strides_and_offset",
665 [](PyMemRefType &self) -> std::pair<std::vector<int64_t>, int64_t> {
666 std::vector<int64_t> strides(mlirShapedTypeGetRank(self));
667 int64_t offset;
669 self, strides.data(), &offset)))
670 throw std::runtime_error(
671 "Failed to extract strides and offset from memref.");
672 return {strides, offset};
673 },
674 "The strides and offset of the MemRef type.")
675 .def_prop_ro(
676 "affine_map",
677 [](PyMemRefType &self) -> PyAffineMap {
678 MlirAffineMap map = mlirMemRefTypeGetAffineMap(self);
679 return PyAffineMap(self.getContext(), map);
680 },
681 "The layout of the MemRef type as an affine map.")
682 .def_prop_ro(
683 "memory_space",
684 [](PyMemRefType &self)
685 -> std::optional<nb::typed<nb::object, PyAttribute>> {
686 MlirAttribute a = mlirMemRefTypeGetMemorySpace(self);
687 if (mlirAttributeIsNull(a))
688 return std::nullopt;
689 return PyAttribute(self.getContext(), a).maybeDownCast();
690 },
691 "Returns the memory space of the given MemRef type.");
692}
693
695 c.def_static(
696 "get",
697 [](PyType &elementType, PyAttribute *memorySpace,
699 PyMlirContext::ErrorCapture errors(loc->getContext());
700 MlirAttribute memSpaceAttr = {};
701 if (memorySpace)
702 memSpaceAttr = *memorySpace;
703
704 MlirType t =
705 mlirUnrankedMemRefTypeGetChecked(loc, elementType, memSpaceAttr);
706 if (mlirTypeIsNull(t))
707 throw MLIRError("Invalid type", errors.take());
708 return PyUnrankedMemRefType(elementType.getContext(), t);
709 },
710 nb::arg("element_type"), nb::arg("memory_space").none(),
711 nb::arg("loc") = nb::none(), "Create a unranked memref type")
712 .def_static(
713 "get_unchecked",
714 [](PyType &elementType, PyAttribute *memorySpace,
715 DefaultingPyMlirContext context) {
716 PyMlirContext::ErrorCapture errors(context->getRef());
717 MlirAttribute memSpaceAttr = {};
718 if (memorySpace)
719 memSpaceAttr = *memorySpace;
720
721 MlirType t = mlirUnrankedMemRefTypeGet(elementType, memSpaceAttr);
722 if (mlirTypeIsNull(t))
723 throw MLIRError("Invalid type", errors.take());
724 return PyUnrankedMemRefType(elementType.getContext(), t);
725 },
726 nb::arg("element_type"), nb::arg("memory_space").none(),
727 nb::arg("context") = nb::none(), "Create a unranked memref type")
728 .def_prop_ro(
729 "memory_space",
730 [](PyUnrankedMemRefType &self)
731 -> std::optional<nb::typed<nb::object, PyAttribute>> {
732 MlirAttribute a = mlirUnrankedMemrefGetMemorySpace(self);
733 if (mlirAttributeIsNull(a))
734 return std::nullopt;
735 return PyAttribute(self.getContext(), a).maybeDownCast();
736 },
737 "Returns the memory space of the given Unranked MemRef type.");
738}
739
741 c.def_static(
742 "get_tuple",
743 [](const std::vector<PyType> &elements, DefaultingPyMlirContext context) {
744 std::vector<MlirType> mlirElements;
745 mlirElements.reserve(elements.size());
746 for (const auto &element : elements)
747 mlirElements.push_back(element.get());
748 MlirType t = mlirTupleTypeGet(context->get(), elements.size(),
749 mlirElements.data());
750 return PyTupleType(context->getRef(), t);
751 },
752 nb::arg("elements"), nb::arg("context") = nb::none(),
753 "Create a tuple type");
754 c.def_static(
755 "get_tuple",
756 [](std::vector<PyType> elements, DefaultingPyMlirContext context) {
757 std::vector<MlirType> elements_(elements.size());
758 std::copy(elements.begin(), elements.end(), elements_.begin());
759 MlirType t = mlirTupleTypeGet(context->get(), elements_.size(),
760 elements_.data());
761 return PyTupleType(context->getRef(), t);
762 },
763 nb::arg("elements"), nb::arg("context") = nb::none(),
764 // clang-format off
765 nb::sig("def get_tuple(elements: Sequence[Type], context: Context | None = None) -> TupleType"),
766 // clang-format on
767 "Create a tuple type");
768 c.def(
769 "get_type",
770 [](PyTupleType &self, intptr_t pos) -> nb::typed<nb::object, PyType> {
771 return PyType(self.getContext(), mlirTupleTypeGetType(self, pos))
772 .maybeDownCast();
773 },
774 nb::arg("pos"), "Returns the pos-th type in the tuple type.");
775 c.def_prop_ro(
776 "num_types",
777 [](PyTupleType &self) -> intptr_t {
778 return mlirTupleTypeGetNumTypes(self);
779 },
780 "Returns the number of types contained in a tuple.");
781}
782
784 c.def_static(
785 "get",
786 [](std::vector<PyType> inputs, std::vector<PyType> results,
787 DefaultingPyMlirContext context) {
788 std::vector<MlirType> mlirInputs;
789 mlirInputs.reserve(inputs.size());
790 for (const auto &input : inputs)
791 mlirInputs.push_back(input.get());
792 std::vector<MlirType> mlirResults;
793 mlirResults.reserve(results.size());
794 for (const auto &result : results)
795 mlirResults.push_back(result.get());
796
797 MlirType t = mlirFunctionTypeGet(context->get(), inputs.size(),
798 mlirInputs.data(), results.size(),
799 mlirResults.data());
800 return PyFunctionType(context->getRef(), t);
801 },
802 nb::arg("inputs"), nb::arg("results"), nb::arg("context") = nb::none(),
803 "Gets a FunctionType from a list of input and result types");
804 c.def_static(
805 "get",
806 [](std::vector<PyType> inputs, std::vector<PyType> results,
807 DefaultingPyMlirContext context) {
808 std::vector<MlirType> inputs_(inputs.size());
809 std::copy(inputs.begin(), inputs.end(), inputs_.begin());
810 std::vector<MlirType> results_(results.size());
811 std::copy(results.begin(), results.end(), results_.begin());
812 MlirType t =
813 mlirFunctionTypeGet(context->get(), inputs_.size(), inputs_.data(),
814 results_.size(), results_.data());
815 return PyFunctionType(context->getRef(), t);
816 },
817 nb::arg("inputs"), nb::arg("results"), nb::arg("context") = nb::none(),
818 // clang-format off
819 nb::sig("def get(inputs: Sequence[Type], results: Sequence[Type], context: Context | None = None) -> FunctionType"),
820 // clang-format on
821 "Gets a FunctionType from a list of input and result types");
822 c.def_prop_ro(
823 "inputs",
824 [](PyFunctionType &self) {
825 MlirType t = self;
826 nb::list types;
827 for (intptr_t i = 0, e = mlirFunctionTypeGetNumInputs(self); i < e;
828 ++i) {
829 types.append(mlirFunctionTypeGetInput(t, i));
830 }
831 return types;
832 },
833 "Returns the list of input types in the FunctionType.");
834 c.def_prop_ro(
835 "results",
836 [](PyFunctionType &self) {
837 nb::list types;
838 for (intptr_t i = 0, e = mlirFunctionTypeGetNumResults(self); i < e;
839 ++i) {
840 types.append(mlirFunctionTypeGetResult(self, i));
841 }
842 return types;
843 },
844 "Returns the list of result types in the FunctionType.");
845}
846
848 c.def_static(
849 "get",
850 [](const std::string &dialectNamespace, const std::string &typeData,
851 DefaultingPyMlirContext context) {
852 MlirType type =
853 mlirOpaqueTypeGet(context->get(), toMlirStringRef(dialectNamespace),
854 toMlirStringRef(typeData));
855 return PyOpaqueType(context->getRef(), type);
856 },
857 nb::arg("dialect_namespace"), nb::arg("buffer"),
858 nb::arg("context") = nb::none(),
859 "Create an unregistered (opaque) dialect type.");
860 c.def_prop_ro(
861 "dialect_namespace",
862 [](PyOpaqueType &self) {
864 return nb::str(stringRef.data, stringRef.length);
865 },
866 "Returns the dialect namespace for the Opaque type as a string.");
867 c.def_prop_ro(
868 "data",
869 [](PyOpaqueType &self) {
870 MlirStringRef stringRef = mlirOpaqueTypeGetData(self);
871 return nb::str(stringRef.data, stringRef.length);
872 },
873 "Returns the data for the Opaque type as a string.");
874}
875
908} // namespace MLIR_BINDINGS_PYTHON_DOMAIN
909} // namespace python
910} // namespace mlir
ReferrentTy * get() const
PyMlirContextRef & getContext()
Accesses the context reference.
Definition IRCore.h:298
Used in function arguments when None should resolve to the current context manager set instance.
Definition IRCore.h:525
Used in function arguments when None should resolve to the current context manager set instance.
Definition IRCore.h:279
Wrapper around the generic MlirAttribute.
Definition IRCore.h:1006
nanobind::typed< nanobind::object, PyAttribute > maybeDownCast()
Definition IRCore.cpp:1896
Floating Point Type subclass - BF16Type.
Definition IRTypes.h:216
Complex Type subclass - ComplexType.
Definition IRTypes.h:299
Floating Point Type subclass - F16Type.
Definition IRTypes.h:230
Floating Point Type subclass - F32Type.
Definition IRTypes.h:258
Floating Point Type subclass - F64Type.
Definition IRTypes.h:272
Floating Point Type subclass - Float4E2M1FNType.
Definition IRTypes.h:62
Floating Point Type subclass - Float6E2M3FNType.
Definition IRTypes.h:76
Floating Point Type subclass - Float6E3M2FNType.
Definition IRTypes.h:90
Floating Point Type subclass - Float8E3M4Type.
Definition IRTypes.h:188
Floating Point Type subclass - Float8E4M3B11FNUZ.
Definition IRTypes.h:160
Floating Point Type subclass - Float8E4M3FNType.
Definition IRTypes.h:104
Floating Point Type subclass - Float8E4M3FNUZ.
Definition IRTypes.h:146
Floating Point Type subclass - Float8E4M3Type.
Definition IRTypes.h:132
Floating Point Type subclass - Float8E5M2FNUZ.
Definition IRTypes.h:174
Floating Point Type subclass - Float8E5M2Type.
Definition IRTypes.h:118
Floating Point Type subclass - Float8E8M0FNUType.
Definition IRTypes.h:202
Ranked MemRef Type subclass - MemRefType.
Definition IRTypes.h:381
Ranked Tensor Type subclass - RankedTensorType.
Definition IRTypes.h:353
Shaped Type Interface - ShapedType.
Definition IRTypes.h:313
Floating Point Type subclass - TF32Type.
Definition IRTypes.h:244
Wrapper around the generic MlirType.
Definition IRCore.h:875
PyType(PyMlirContextRef contextRef, MlirType type)
Definition IRCore.h:877
Unranked MemRef Type subclass - UnrankedMemRefType.
Definition IRTypes.h:395
Unranked Tensor Type subclass - UnrankedTensorType.
Definition IRTypes.h:367
MLIR_CAPI_EXPORTED MlirAttribute mlirAttributeGetNull(void)
Returns an empty attribute.
MLIR_CAPI_EXPORTED 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...
MLIR_CAPI_EXPORTED bool mlirIntegerTypeIsSignless(MlirType type)
Checks whether the given integer type is signless.
MLIR_CAPI_EXPORTED MlirAttribute mlirRankedTensorTypeGetEncoding(MlirType type)
Gets the 'encoding' attribute from the ranked tensor type, returning a null attribute if none.
MLIR_CAPI_EXPORTED bool mlirTypeIsAInteger(MlirType type)
Checks whether the given type is an integer type.
MLIR_CAPI_EXPORTED MlirAffineMap mlirMemRefTypeGetAffineMap(MlirType type)
Returns the affine map of the given MemRef type.
MLIR_CAPI_EXPORTED unsigned mlirFloatTypeGetWidth(MlirType type)
Returns the bitwidth of a floating-point type.
MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDimSize(MlirType type, intptr_t dim)
Returns the dim-th dimension of the given ranked shaped type.
MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeGet(MlirContext ctx, unsigned bitwidth)
Creates a signless integer type of the given bitwidth in the context.
MLIR_CAPI_EXPORTED MlirStringRef mlirOpaqueTypeGetData(MlirType type)
Returns the raw data as a string reference.
MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGetInput(MlirType type, intptr_t pos)
Returns the pos-th input type.
MLIR_CAPI_EXPORTED MlirType mlirIndexTypeGet(MlirContext ctx)
Creates an index type in the given context.
MLIR_CAPI_EXPORTED bool mlirShapedTypeIsStaticDim(MlirType type, intptr_t dim)
Checks whether the dim-th dimension of the given shaped type is static.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E3M4TypeGet(MlirContext ctx)
Creates an f8E3M4 type in the given context.
MLIR_CAPI_EXPORTED bool mlirShapedTypeIsStaticStrideOrOffset(int64_t val)
Checks whether the given dimension value of a stride or an offset is statically-sized.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E5M2FNUZTypeGet(MlirContext ctx)
Creates an f8E5M2FNUZ type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E8M0FNUTypeGet(MlirContext ctx)
Creates an f8E8M0FNU type in the given context.
MLIR_CAPI_EXPORTED bool mlirIntegerTypeIsUnsigned(MlirType type)
Checks whether the given integer type is unsigned.
MLIR_CAPI_EXPORTED unsigned mlirIntegerTypeGetWidth(MlirType type)
Returns the bitwidth of an integer type.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E5M2TypeGet(MlirContext ctx)
Creates an f8E5M2 type in the given context.
MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetRank(MlirType type)
Returns the rank of the given ranked shaped type.
MLIR_CAPI_EXPORTED MlirType mlirF64TypeGet(MlirContext ctx)
Creates a f64 type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeSignedGet(MlirContext ctx, unsigned bitwidth)
Creates a signed integer type of the given bitwidth in the context.
MLIR_CAPI_EXPORTED MlirType mlirUnrankedTensorTypeGetChecked(MlirLocation loc, MlirType elementType)
Same as "mlirUnrankedTensorTypeGet" but returns a nullptr wrapping MlirType on illegal arguments,...
MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGetScalableChecked(MlirLocation loc, intptr_t rank, const int64_t *shape, const bool *scalable, MlirType elementType)
Same as "mlirVectorTypeGetScalable" but returns a nullptr wrapping MlirType on illegal arguments,...
MLIR_CAPI_EXPORTED MlirType mlirF16TypeGet(MlirContext ctx)
Creates an f16 type in the given context.
MLIR_CAPI_EXPORTED MlirAttribute mlirMemRefTypeGetMemorySpace(MlirType type)
Returns the memory space of the given MemRef type.
MLIR_CAPI_EXPORTED bool mlirTypeIsAF64(MlirType type)
Checks whether the given type is an f64 type.
MLIR_CAPI_EXPORTED MlirType mlirFloat6E2M3FNTypeGet(MlirContext ctx)
Creates an f6E2M3FN type in the given context.
MLIR_CAPI_EXPORTED bool mlirTypeIsAF16(MlirType type)
Checks whether the given type is an f16 type.
MLIR_CAPI_EXPORTED bool mlirIntegerTypeIsSigned(MlirType type)
Checks whether the given integer type is signed.
MLIR_CAPI_EXPORTED 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,...
MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGetScalable(intptr_t rank, const int64_t *shape, const bool *scalable, MlirType elementType)
Creates a scalable vector type with the shape identified by its rank and dimensions.
MLIR_CAPI_EXPORTED MlirType mlirShapedTypeGetElementType(MlirType type)
Returns the element type of the shaped type.
MLIR_CAPI_EXPORTED intptr_t mlirFunctionTypeGetNumInputs(MlirType type)
Returns the number of input types.
MLIR_CAPI_EXPORTED 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,...
MLIR_CAPI_EXPORTED MlirType mlirNoneTypeGet(MlirContext ctx)
Creates a None type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirComplexTypeGet(MlirType elementType)
Creates a complex type with the given element type in the same context as the element type.
MLIR_CAPI_EXPORTED MlirStringRef mlirOpaqueTypeGetDialectNamespace(MlirType type)
Returns the namespace of the dialect with which the given opaque type is associated.
MLIR_CAPI_EXPORTED bool mlirShapedTypeHasStaticShape(MlirType type)
Checks whether the given shaped type has a static shape.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3TypeGet(MlirContext ctx)
Creates an f8E4M3 type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirBF16TypeGet(MlirContext ctx)
Creates a bf16 type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirF32TypeGet(MlirContext ctx)
Creates an f32 type in the given context.
MLIR_CAPI_EXPORTED bool mlirShapedTypeHasRank(MlirType type)
Checks whether the given shaped type is ranked.
MLIR_CAPI_EXPORTED MlirLogicalResult mlirMemRefTypeGetStridesAndOffset(MlirType type, int64_t *strides, int64_t *offset)
Returns the strides of the MemRef if the layout map is in strided form.
MLIR_CAPI_EXPORTED bool mlirTypeIsAShaped(MlirType type)
Checks whether the given type is a Shaped type.
MLIR_CAPI_EXPORTED intptr_t mlirTupleTypeGetNumTypes(MlirType type)
Returns the number of types contained in a tuple.
MLIR_CAPI_EXPORTED 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...
MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeUnsignedGet(MlirContext ctx, unsigned bitwidth)
Creates an unsigned integer type of the given bitwidth in the context.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3FNTypeGet(MlirContext ctx)
Creates an f8E4M3FN type in the given context.
MLIR_CAPI_EXPORTED bool mlirTypeIsAF32(MlirType type)
Checks whether the given type is an f32 type.
MLIR_CAPI_EXPORTED 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.
MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicStrideOrOffset(int64_t val)
Checks whether the given value is used as a placeholder for dynamic strides and offsets in shaped typ...
MLIR_CAPI_EXPORTED MlirType mlirTupleTypeGetType(MlirType type, intptr_t pos)
Returns the pos-th type in the tuple type.
MLIR_CAPI_EXPORTED bool mlirVectorTypeIsDimScalable(MlirType type, intptr_t dim)
Checks whether the "dim"-th dimension of the given vector is scalable.
MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicDim(MlirType type, intptr_t dim)
Checks whether the dim-th dimension of the given shaped type is dynamic.
MLIR_CAPI_EXPORTED MlirType mlirFloat6E3M2FNTypeGet(MlirContext ctx)
Creates an f6E3M2FN type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirUnrankedMemRefTypeGet(MlirType elementType, MlirAttribute memorySpace)
Creates an Unranked MemRef type with the given element type and in the given memory space.
MLIR_CAPI_EXPORTED 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,...
MLIR_CAPI_EXPORTED bool mlirTypeIsABF16(MlirType type)
Checks whether the given type is a bf16 type.
MLIR_CAPI_EXPORTED MlirType mlirOpaqueTypeGet(MlirContext ctx, MlirStringRef dialectNamespace, MlirStringRef typeData)
Creates an opaque type in the given context associated with the dialect identified by its namespace.
MLIR_CAPI_EXPORTED intptr_t mlirFunctionTypeGetNumResults(MlirType type)
Returns the number of result types.
MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicSize(int64_t size)
Checks whether the given value is used as a placeholder for dynamic sizes in shaped types.
MLIR_CAPI_EXPORTED MlirType mlirUnrankedMemRefTypeGetChecked(MlirLocation loc, MlirType elementType, MlirAttribute memorySpace)
Same as "mlirUnrankedMemRefTypeGet" but returns a nullptr wrapping MlirType on illegal arguments,...
MLIR_CAPI_EXPORTED bool mlirShapedTypeIsStaticSize(int64_t size)
Checks whether the given shaped type dimension value is statically-sized.
MLIR_CAPI_EXPORTED 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,...
MLIR_CAPI_EXPORTED MlirType mlirUnrankedTensorTypeGet(MlirType elementType)
Creates an unranked tensor type with the given element type in the same context as the element type.
MLIR_CAPI_EXPORTED bool mlirVectorTypeIsScalable(MlirType type)
Checks whether the given vector type is scalable, i.e., has at least one scalable dimension.
MLIR_CAPI_EXPORTED MlirType mlirComplexTypeGetElementType(MlirType type)
Returns the element type of the given complex type.
MLIR_CAPI_EXPORTED MlirAttribute mlirUnrankedMemrefGetMemorySpace(MlirType type)
Returns the memory spcae of the given Unranked MemRef type.
MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDynamicStrideOrOffset(void)
Returns the value indicating a dynamic stride or offset in a shaped type.
MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDynamicSize(void)
Returns the value indicating a dynamic size in a shaped type.
MLIR_CAPI_EXPORTED MlirAttribute mlirMemRefTypeGetLayout(MlirType type)
Returns the layout of the given MemRef type.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3B11FNUZTypeGet(MlirContext ctx)
Creates an f8E4M3B11FNUZ type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirTupleTypeGet(MlirContext ctx, intptr_t numElements, MlirType const *elements)
Creates a tuple type that consists of the given list of elemental types.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3FNUZTypeGet(MlirContext ctx)
Creates an f8E4M3FNUZ type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGetResult(MlirType type, intptr_t pos)
Returns the pos-th result type.
MLIR_CAPI_EXPORTED MlirType mlirTF32TypeGet(MlirContext ctx)
Creates a TF32 type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirFloat4E2M1FNTypeGet(MlirContext ctx)
Creates an f4E2M1FN type in the given context.
static bool mlirTypeIsNull(MlirType type)
Checks whether a type is null.
Definition IR.h:1160
static bool mlirLogicalResultIsFailure(MlirLogicalResult res)
Checks if the given logical result represents a failure.
Definition Support.h:132
MLIR_PYTHON_API_EXPORTED void populateIRTypes(nanobind::module_ &m)
MLIR_PYTHON_API_EXPORTED int mlirTypeIsAIntegerOrFloat(MlirType type)
Definition IRTypes.cpp:30
MlirStringRef toMlirStringRef(const std::string &s)
Definition IRCore.h:1339
Include the generated interface declarations.
std::string join(const Ts &...args)
Helper function to concatenate arguments into a std::string.
A pointer to a sized fragment of a string, not necessarily null-terminated.
Definition Support.h:78
const char * data
Pointer to the first symbol.
Definition Support.h:79
size_t length
Length of the fragment.
Definition Support.h:80
Custom exception that allows access to error diagnostic information.
Definition IRCore.h:1326
RAII object that captures any error diagnostics emitted to the provided context.
Definition IRCore.h:434
std::vector< PyDiagnostic::DiagnosticInfo > take()
Definition IRCore.h:444