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