32static int mlirTypeIsAIntegerOrFloat(MlirType type) {
37class PyIntegerType :
public PyConcreteType<PyIntegerType> {
40 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
42 static constexpr const char *pyClassName =
"IntegerType";
45 static void bindDerived(ClassTy &c) {
48 [](
unsigned width, DefaultingPyMlirContext context) {
50 return PyIntegerType(context->getRef(), t);
52 nb::arg(
"width"), nb::arg(
"context") = nb::none(),
53 "Create a signless integer type");
56 [](
unsigned width, DefaultingPyMlirContext context) {
58 return PyIntegerType(context->getRef(), t);
60 nb::arg(
"width"), nb::arg(
"context") = nb::none(),
61 "Create a signed integer type");
64 [](
unsigned width, DefaultingPyMlirContext context) {
66 return PyIntegerType(context->getRef(), t);
68 nb::arg(
"width"), nb::arg(
"context") = nb::none(),
69 "Create an unsigned integer type");
73 "Returns the width of the integer type");
76 [](PyIntegerType &self) ->
bool {
79 "Returns whether this is a signless integer");
82 [](PyIntegerType &self) ->
bool {
85 "Returns whether this is a signed integer");
88 [](PyIntegerType &self) ->
bool {
91 "Returns whether this is an unsigned integer");
96class PyIndexType :
public PyConcreteType<PyIndexType> {
99 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
101 static constexpr const char *pyClassName =
"IndexType";
104 static void bindDerived(ClassTy &c) {
107 [](DefaultingPyMlirContext context) {
109 return PyIndexType(context->getRef(), t);
111 nb::arg(
"context") = nb::none(),
"Create a index type.");
115class PyFloatType :
public PyConcreteType<PyFloatType> {
118 static constexpr const char *pyClassName =
"FloatType";
121 static void bindDerived(ClassTy &c) {
124 "Returns the width of the floating-point type");
129class PyFloat4E2M1FNType
130 :
public PyConcreteType<PyFloat4E2M1FNType, PyFloatType> {
133 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
135 static constexpr const char *pyClassName =
"Float4E2M1FNType";
138 static void bindDerived(ClassTy &c) {
141 [](DefaultingPyMlirContext context) {
143 return PyFloat4E2M1FNType(context->getRef(), t);
145 nb::arg(
"context") = nb::none(),
"Create a float4_e2m1fn type.");
150class PyFloat6E2M3FNType
151 :
public PyConcreteType<PyFloat6E2M3FNType, PyFloatType> {
154 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
156 static constexpr const char *pyClassName =
"Float6E2M3FNType";
159 static void bindDerived(ClassTy &c) {
162 [](DefaultingPyMlirContext context) {
164 return PyFloat6E2M3FNType(context->getRef(), t);
166 nb::arg(
"context") = nb::none(),
"Create a float6_e2m3fn type.");
171class PyFloat6E3M2FNType
172 :
public PyConcreteType<PyFloat6E3M2FNType, PyFloatType> {
175 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
177 static constexpr const char *pyClassName =
"Float6E3M2FNType";
180 static void bindDerived(ClassTy &c) {
183 [](DefaultingPyMlirContext context) {
185 return PyFloat6E3M2FNType(context->getRef(), t);
187 nb::arg(
"context") = nb::none(),
"Create a float6_e3m2fn type.");
192class PyFloat8E4M3FNType
193 :
public PyConcreteType<PyFloat8E4M3FNType, PyFloatType> {
196 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
198 static constexpr const char *pyClassName =
"Float8E4M3FNType";
201 static void bindDerived(ClassTy &c) {
204 [](DefaultingPyMlirContext context) {
206 return PyFloat8E4M3FNType(context->getRef(), t);
208 nb::arg(
"context") = nb::none(),
"Create a float8_e4m3fn type.");
213class PyFloat8E5M2Type :
public PyConcreteType<PyFloat8E5M2Type, PyFloatType> {
216 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
218 static constexpr const char *pyClassName =
"Float8E5M2Type";
221 static void bindDerived(ClassTy &c) {
224 [](DefaultingPyMlirContext context) {
226 return PyFloat8E5M2Type(context->getRef(), t);
228 nb::arg(
"context") = nb::none(),
"Create a float8_e5m2 type.");
233class PyFloat8E4M3Type :
public PyConcreteType<PyFloat8E4M3Type, PyFloatType> {
236 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
238 static constexpr const char *pyClassName =
"Float8E4M3Type";
241 static void bindDerived(ClassTy &c) {
244 [](DefaultingPyMlirContext context) {
246 return PyFloat8E4M3Type(context->getRef(), t);
248 nb::arg(
"context") = nb::none(),
"Create a float8_e4m3 type.");
253class PyFloat8E4M3FNUZType
254 :
public PyConcreteType<PyFloat8E4M3FNUZType, PyFloatType> {
257 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
259 static constexpr const char *pyClassName =
"Float8E4M3FNUZType";
262 static void bindDerived(ClassTy &c) {
265 [](DefaultingPyMlirContext context) {
267 return PyFloat8E4M3FNUZType(context->getRef(), t);
269 nb::arg(
"context") = nb::none(),
"Create a float8_e4m3fnuz type.");
274class PyFloat8E4M3B11FNUZType
275 :
public PyConcreteType<PyFloat8E4M3B11FNUZType, PyFloatType> {
278 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
280 static constexpr const char *pyClassName =
"Float8E4M3B11FNUZType";
283 static void bindDerived(ClassTy &c) {
286 [](DefaultingPyMlirContext context) {
288 return PyFloat8E4M3B11FNUZType(context->getRef(), t);
290 nb::arg(
"context") = nb::none(),
"Create a float8_e4m3b11fnuz type.");
295class PyFloat8E5M2FNUZType
296 :
public PyConcreteType<PyFloat8E5M2FNUZType, PyFloatType> {
299 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
301 static constexpr const char *pyClassName =
"Float8E5M2FNUZType";
304 static void bindDerived(ClassTy &c) {
307 [](DefaultingPyMlirContext context) {
309 return PyFloat8E5M2FNUZType(context->getRef(), t);
311 nb::arg(
"context") = nb::none(),
"Create a float8_e5m2fnuz type.");
316class PyFloat8E3M4Type :
public PyConcreteType<PyFloat8E3M4Type, PyFloatType> {
319 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
321 static constexpr const char *pyClassName =
"Float8E3M4Type";
324 static void bindDerived(ClassTy &c) {
327 [](DefaultingPyMlirContext context) {
329 return PyFloat8E3M4Type(context->getRef(), t);
331 nb::arg(
"context") = nb::none(),
"Create a float8_e3m4 type.");
336class PyFloat8E8M0FNUType
337 :
public PyConcreteType<PyFloat8E8M0FNUType, PyFloatType> {
340 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
342 static constexpr const char *pyClassName =
"Float8E8M0FNUType";
345 static void bindDerived(ClassTy &c) {
348 [](DefaultingPyMlirContext context) {
350 return PyFloat8E8M0FNUType(context->getRef(), t);
352 nb::arg(
"context") = nb::none(),
"Create a float8_e8m0fnu type.");
357class PyBF16Type :
public PyConcreteType<PyBF16Type, PyFloatType> {
360 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
362 static constexpr const char *pyClassName =
"BF16Type";
365 static void bindDerived(ClassTy &c) {
368 [](DefaultingPyMlirContext context) {
370 return PyBF16Type(context->getRef(), t);
372 nb::arg(
"context") = nb::none(),
"Create a bf16 type.");
377class PyF16Type :
public PyConcreteType<PyF16Type, PyFloatType> {
380 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
382 static constexpr const char *pyClassName =
"F16Type";
385 static void bindDerived(ClassTy &c) {
388 [](DefaultingPyMlirContext context) {
390 return PyF16Type(context->getRef(), t);
392 nb::arg(
"context") = nb::none(),
"Create a f16 type.");
397class PyTF32Type :
public PyConcreteType<PyTF32Type, PyFloatType> {
400 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
402 static constexpr const char *pyClassName =
"FloatTF32Type";
405 static void bindDerived(ClassTy &c) {
408 [](DefaultingPyMlirContext context) {
410 return PyTF32Type(context->getRef(), t);
412 nb::arg(
"context") = nb::none(),
"Create a tf32 type.");
417class PyF32Type :
public PyConcreteType<PyF32Type, PyFloatType> {
420 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
422 static constexpr const char *pyClassName =
"F32Type";
425 static void bindDerived(ClassTy &c) {
428 [](DefaultingPyMlirContext context) {
430 return PyF32Type(context->getRef(), t);
432 nb::arg(
"context") = nb::none(),
"Create a f32 type.");
437class PyF64Type :
public PyConcreteType<PyF64Type, PyFloatType> {
440 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
442 static constexpr const char *pyClassName =
"F64Type";
445 static void bindDerived(ClassTy &c) {
448 [](DefaultingPyMlirContext context) {
450 return PyF64Type(context->getRef(), t);
452 nb::arg(
"context") = nb::none(),
"Create a f64 type.");
457class PyNoneType :
public PyConcreteType<PyNoneType> {
460 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
462 static constexpr const char *pyClassName =
"NoneType";
465 static void bindDerived(ClassTy &c) {
468 [](DefaultingPyMlirContext context) {
470 return PyNoneType(context->getRef(), t);
472 nb::arg(
"context") = nb::none(),
"Create a none type.");
477class PyComplexType :
public PyConcreteType<PyComplexType> {
480 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
482 static constexpr const char *pyClassName =
"ComplexType";
485 static void bindDerived(ClassTy &c) {
488 [](PyType &elementType) {
490 if (mlirTypeIsAIntegerOrFloat(elementType)) {
492 return PyComplexType(elementType.
getContext(), t);
494 throw nb::value_error(
495 (Twine(
"invalid '") +
496 nb::cast<std::string>(nb::repr(nb::cast(elementType))) +
497 "' and expected floating point or integer type.")
501 "Create a complex type");
504 [](PyComplexType &self) -> nb::typed<nb::object, PyType> {
508 "Returns element type.");
518 [](
PyShapedType &self) -> nb::typed<nb::object, PyType> {
522 "Returns the element type of the shaped type.");
526 "Returns whether the given shaped type is ranked.");
530 self.requireHasRank();
533 "Returns the rank of the given ranked shaped type.");
539 "Returns whether the given shaped type has a static shape.");
543 self.requireHasRank();
547 "Returns whether the dim-th dimension of the given shaped type is "
552 self.requireHasRank();
556 "Returns whether the dim-th dimension of the given shaped type is "
561 self.requireHasRank();
565 "Returns the dim-th dimension of the given ranked shaped type.");
570 "Returns whether the given dimension size indicates a dynamic "
576 "Returns whether the given dimension size indicates a static "
579 "is_dynamic_stride_or_offset",
581 self.requireHasRank();
585 "Returns whether the given value is used as a placeholder for dynamic "
586 "strides and offsets in shaped types.");
588 "is_static_stride_or_offset",
590 self.requireHasRank();
594 "Returns whether the given shaped type stride or offset value is "
595 "statically-sized.");
599 self.requireHasRank();
601 std::vector<int64_t>
shape;
604 for (
int64_t i = 0; i < rank; ++i)
608 "Returns the shape of the ranked shaped type as a list of integers.");
611 "Returns the value used to indicate dynamic dimensions in shaped "
614 "get_dynamic_stride_or_offset",
616 "Returns the value used to indicate dynamic strides or offsets in "
620void mlir::PyShapedType::requireHasRank() {
622 throw nb::value_error(
623 "calling this method requires that the type has a rank.");
633class PyVectorType :
public PyConcreteType<PyVectorType, PyShapedType> {
636 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
638 static constexpr const char *pyClassName =
"VectorType";
641 static void bindDerived(ClassTy &c) {
642 c.def_static(
"get", &PyVectorType::getChecked, nb::arg(
"shape"),
643 nb::arg(
"element_type"), nb::kw_only(),
644 nb::arg(
"scalable") = nb::none(),
645 nb::arg(
"scalable_dims") = nb::none(),
646 nb::arg(
"loc") = nb::none(),
"Create a vector type")
647 .def_static(
"get_unchecked", &PyVectorType::get, nb::arg(
"shape"),
648 nb::arg(
"element_type"), nb::kw_only(),
649 nb::arg(
"scalable") = nb::none(),
650 nb::arg(
"scalable_dims") = nb::none(),
651 nb::arg(
"context") = nb::none(),
"Create a vector type")
655 .def_prop_ro(
"scalable_dims", [](MlirType self) {
656 std::vector<bool> scalableDims;
658 scalableDims.reserve(rank);
659 for (
size_t i = 0; i < rank; ++i)
667 getChecked(std::vector<int64_t> shape, PyType &elementType,
668 std::optional<nb::list> scalable,
669 std::optional<std::vector<int64_t>> scalableDims,
670 DefaultingPyLocation loc) {
671 if (scalable && scalableDims) {
672 throw nb::value_error(
"'scalable' and 'scalable_dims' kwargs "
673 "are mutually exclusive.");
676 PyMlirContext::ErrorCapture errors(loc->getContext());
679 if (scalable->size() != shape.size())
680 throw nb::value_error(
"Expected len(scalable) == len(shape).");
682 SmallVector<bool> scalableDimFlags = llvm::to_vector(llvm::map_range(
683 *scalable, [](
const nb::handle &h) {
return nb::cast<bool>(h); }));
685 scalableDimFlags.data(),
687 }
else if (scalableDims) {
688 SmallVector<bool> scalableDimFlags(shape.size(),
false);
689 for (int64_t dim : *scalableDims) {
690 if (
static_cast<size_t>(dim) >= scalableDimFlags.size() || dim < 0)
691 throw nb::value_error(
"Scalable dimension index out of bounds.");
692 scalableDimFlags[dim] =
true;
695 scalableDimFlags.data(),
702 throw MLIRError(
"Invalid type", errors.take());
703 return PyVectorType(elementType.
getContext(), type);
706 static PyVectorType
get(std::vector<int64_t> shape, PyType &elementType,
707 std::optional<nb::list> scalable,
708 std::optional<std::vector<int64_t>> scalableDims,
709 DefaultingPyMlirContext context) {
710 if (scalable && scalableDims) {
711 throw nb::value_error(
"'scalable' and 'scalable_dims' kwargs "
712 "are mutually exclusive.");
715 PyMlirContext::ErrorCapture errors(context->getRef());
718 if (scalable->size() != shape.size())
719 throw nb::value_error(
"Expected len(scalable) == len(shape).");
721 SmallVector<bool> scalableDimFlags = llvm::to_vector(llvm::map_range(
722 *scalable, [](
const nb::handle &h) {
return nb::cast<bool>(h); }));
724 scalableDimFlags.data(), elementType);
725 }
else if (scalableDims) {
726 SmallVector<bool> scalableDimFlags(shape.size(),
false);
727 for (int64_t dim : *scalableDims) {
728 if (
static_cast<size_t>(dim) >= scalableDimFlags.size() || dim < 0)
729 throw nb::value_error(
"Scalable dimension index out of bounds.");
730 scalableDimFlags[dim] =
true;
733 scalableDimFlags.data(), elementType);
738 throw MLIRError(
"Invalid type", errors.take());
739 return PyVectorType(elementType.
getContext(), type);
744class PyRankedTensorType
745 :
public PyConcreteType<PyRankedTensorType, PyShapedType> {
748 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
750 static constexpr const char *pyClassName =
"RankedTensorType";
753 static void bindDerived(ClassTy &c) {
756 [](std::vector<int64_t> shape, PyType &elementType,
757 std::optional<PyAttribute> &encodingAttr, DefaultingPyLocation loc) {
758 PyMlirContext::ErrorCapture errors(loc->getContext());
760 loc, shape.size(), shape.data(), elementType,
763 throw MLIRError(
"Invalid type", errors.take());
764 return PyRankedTensorType(elementType.
getContext(), t);
766 nb::arg(
"shape"), nb::arg(
"element_type"),
767 nb::arg(
"encoding") = nb::none(), nb::arg(
"loc") = nb::none(),
768 "Create a ranked tensor type");
771 [](std::vector<int64_t> shape, PyType &elementType,
772 std::optional<PyAttribute> &encodingAttr,
773 DefaultingPyMlirContext context) {
774 PyMlirContext::ErrorCapture errors(context->getRef());
776 shape.size(), shape.data(), elementType,
779 throw MLIRError(
"Invalid type", errors.take());
780 return PyRankedTensorType(elementType.
getContext(), t);
782 nb::arg(
"shape"), nb::arg(
"element_type"),
783 nb::arg(
"encoding") = nb::none(), nb::arg(
"context") = nb::none(),
784 "Create a ranked tensor type");
787 [](PyRankedTensorType &self)
788 -> std::optional<nb::typed<nb::object, PyAttribute>> {
790 if (mlirAttributeIsNull(encoding))
792 return PyAttribute(self.getContext(), encoding).maybeDownCast();
798class PyUnrankedTensorType
799 :
public PyConcreteType<PyUnrankedTensorType, PyShapedType> {
802 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
804 static constexpr const char *pyClassName =
"UnrankedTensorType";
807 static void bindDerived(ClassTy &c) {
810 [](PyType &elementType, DefaultingPyLocation loc) {
811 PyMlirContext::ErrorCapture errors(loc->getContext());
814 throw MLIRError(
"Invalid type", errors.take());
815 return PyUnrankedTensorType(elementType.
getContext(), t);
817 nb::arg(
"element_type"), nb::arg(
"loc") = nb::none(),
818 "Create a unranked tensor type");
821 [](PyType &elementType, DefaultingPyMlirContext context) {
822 PyMlirContext::ErrorCapture errors(context->getRef());
825 throw MLIRError(
"Invalid type", errors.take());
826 return PyUnrankedTensorType(elementType.
getContext(), t);
828 nb::arg(
"element_type"), nb::arg(
"context") = nb::none(),
829 "Create a unranked tensor type");
834class PyMemRefType :
public PyConcreteType<PyMemRefType, PyShapedType> {
837 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
839 static constexpr const char *pyClassName =
"MemRefType";
842 static void bindDerived(ClassTy &c) {
845 [](std::vector<int64_t> shape, PyType &elementType,
846 PyAttribute *layout, PyAttribute *memorySpace,
847 DefaultingPyLocation loc) {
848 PyMlirContext::ErrorCapture errors(loc->getContext());
850 MlirAttribute memSpaceAttr =
854 shape.data(), layoutAttr, memSpaceAttr);
856 throw MLIRError(
"Invalid type", errors.take());
857 return PyMemRefType(elementType.
getContext(), t);
859 nb::arg(
"shape"), nb::arg(
"element_type"),
860 nb::arg(
"layout") = nb::none(), nb::arg(
"memory_space") = nb::none(),
861 nb::arg(
"loc") = nb::none(),
"Create a memref type")
864 [](std::vector<int64_t> shape, PyType &elementType,
865 PyAttribute *layout, PyAttribute *memorySpace,
866 DefaultingPyMlirContext context) {
867 PyMlirContext::ErrorCapture errors(context->getRef());
868 MlirAttribute layoutAttr =
870 MlirAttribute memSpaceAttr =
874 layoutAttr, memSpaceAttr);
876 throw MLIRError(
"Invalid type", errors.take());
877 return PyMemRefType(elementType.
getContext(), t);
879 nb::arg(
"shape"), nb::arg(
"element_type"),
880 nb::arg(
"layout") = nb::none(),
881 nb::arg(
"memory_space") = nb::none(),
882 nb::arg(
"context") = nb::none(),
"Create a memref type")
885 [](PyMemRefType &self) -> nb::typed<nb::object, PyAttribute> {
886 return PyAttribute(self.getContext(),
890 "The layout of the MemRef type.")
892 "get_strides_and_offset",
893 [](PyMemRefType &self) -> std::pair<std::vector<int64_t>, int64_t> {
897 self, strides.data(), &offset)))
898 throw std::runtime_error(
899 "Failed to extract strides and offset from memref.");
900 return {strides, offset};
902 "The strides and offset of the MemRef type.")
905 [](PyMemRefType &self) -> PyAffineMap {
907 return PyAffineMap(self.getContext(), map);
909 "The layout of the MemRef type as an affine map.")
912 [](PyMemRefType &self)
913 -> std::optional<nb::typed<nb::object, PyAttribute>> {
915 if (mlirAttributeIsNull(a))
917 return PyAttribute(self.getContext(), a).maybeDownCast();
919 "Returns the memory space of the given MemRef type.");
924class PyUnrankedMemRefType
925 :
public PyConcreteType<PyUnrankedMemRefType, PyShapedType> {
928 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
930 static constexpr const char *pyClassName =
"UnrankedMemRefType";
933 static void bindDerived(ClassTy &c) {
936 [](PyType &elementType, PyAttribute *memorySpace,
937 DefaultingPyLocation loc) {
938 PyMlirContext::ErrorCapture errors(loc->getContext());
939 MlirAttribute memSpaceAttr = {};
941 memSpaceAttr = *memorySpace;
946 throw MLIRError(
"Invalid type", errors.take());
947 return PyUnrankedMemRefType(elementType.
getContext(), t);
949 nb::arg(
"element_type"), nb::arg(
"memory_space").none(),
950 nb::arg(
"loc") = nb::none(),
"Create a unranked memref type")
953 [](PyType &elementType, PyAttribute *memorySpace,
954 DefaultingPyMlirContext context) {
955 PyMlirContext::ErrorCapture errors(context->getRef());
956 MlirAttribute memSpaceAttr = {};
958 memSpaceAttr = *memorySpace;
962 throw MLIRError(
"Invalid type", errors.take());
963 return PyUnrankedMemRefType(elementType.
getContext(), t);
965 nb::arg(
"element_type"), nb::arg(
"memory_space").none(),
966 nb::arg(
"context") = nb::none(),
"Create a unranked memref type")
969 [](PyUnrankedMemRefType &self)
970 -> std::optional<nb::typed<nb::object, PyAttribute>> {
972 if (mlirAttributeIsNull(a))
974 return PyAttribute(self.getContext(), a).maybeDownCast();
976 "Returns the memory space of the given Unranked MemRef type.");
981class PyTupleType :
public PyConcreteType<PyTupleType> {
984 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
986 static constexpr const char *pyClassName =
"TupleType";
989 static void bindDerived(ClassTy &c) {
992 [](
const std::vector<PyType> &elements,
993 DefaultingPyMlirContext context) {
994 std::vector<MlirType> mlirElements;
995 mlirElements.reserve(elements.size());
996 for (
const auto &element : elements)
997 mlirElements.push_back(element.get());
999 mlirElements.data());
1000 return PyTupleType(context->getRef(), t);
1002 nb::arg(
"elements"), nb::arg(
"context") = nb::none(),
1003 "Create a tuple type");
1006 [](std::vector<MlirType> elements, DefaultingPyMlirContext context) {
1009 return PyTupleType(context->getRef(), t);
1011 nb::arg(
"elements"), nb::arg(
"context") = nb::none(),
1013 nb::sig(
"def get_tuple(elements: Sequence[Type], context: Context | None = None) -> TupleType"),
1015 "Create a tuple type");
1018 [](PyTupleType &self, intptr_t pos) -> nb::typed<nb::object, PyType> {
1022 nb::arg(
"pos"),
"Returns the pos-th type in the tuple type.");
1025 [](PyTupleType &self) -> intptr_t {
1028 "Returns the number of types contained in a tuple.");
1033class PyFunctionType :
public PyConcreteType<PyFunctionType> {
1036 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
1038 static constexpr const char *pyClassName =
"FunctionType";
1041 static void bindDerived(ClassTy &c) {
1044 [](std::vector<PyType> inputs, std::vector<PyType> results,
1045 DefaultingPyMlirContext context) {
1046 std::vector<MlirType> mlirInputs;
1047 mlirInputs.reserve(inputs.size());
1048 for (
const auto &input : inputs)
1049 mlirInputs.push_back(input.get());
1050 std::vector<MlirType> mlirResults;
1051 mlirResults.reserve(results.size());
1052 for (
const auto &
result : results)
1053 mlirResults.push_back(
result.get());
1056 mlirInputs.data(), results.size(),
1057 mlirResults.data());
1058 return PyFunctionType(context->getRef(), t);
1060 nb::arg(
"inputs"), nb::arg(
"results"), nb::arg(
"context") = nb::none(),
1061 "Gets a FunctionType from a list of input and result types");
1064 [](std::vector<MlirType> inputs, std::vector<MlirType> results,
1065 DefaultingPyMlirContext context) {
1068 results.size(), results.data());
1069 return PyFunctionType(context->getRef(), t);
1071 nb::arg(
"inputs"), nb::arg(
"results"), nb::arg(
"context") = nb::none(),
1073 nb::sig(
"def get(inputs: Sequence[Type], results: Sequence[Type], context: Context | None = None) -> FunctionType"),
1075 "Gets a FunctionType from a list of input and result types");
1078 [](PyFunctionType &self) {
1087 "Returns the list of input types in the FunctionType.");
1090 [](PyFunctionType &self) {
1098 "Returns the list of result types in the FunctionType.");
1107class PyOpaqueType :
public PyConcreteType<PyOpaqueType> {
1110 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
1112 static constexpr const char *pyClassName =
"OpaqueType";
1115 static void bindDerived(ClassTy &c) {
1118 [](
const std::string &dialectNamespace,
const std::string &typeData,
1119 DefaultingPyMlirContext context) {
1123 return PyOpaqueType(context->getRef(), type);
1125 nb::arg(
"dialect_namespace"), nb::arg(
"buffer"),
1126 nb::arg(
"context") = nb::none(),
1127 "Create an unregistered (opaque) dialect type.");
1129 "dialect_namespace",
1130 [](PyOpaqueType &self) {
1132 return nb::str(stringRef.
data, stringRef.
length);
1134 "Returns the dialect namespace for the Opaque type as a string.");
1137 [](PyOpaqueType &self) {
1139 return nb::str(stringRef.
data, stringRef.
length);
1141 "Returns the data for the Opaque type as a string.");
1148 PyIntegerType::bind(m);
1149 PyFloatType::bind(m);
1150 PyIndexType::bind(m);
1151 PyFloat4E2M1FNType::bind(m);
1152 PyFloat6E2M3FNType::bind(m);
1153 PyFloat6E3M2FNType::bind(m);
1154 PyFloat8E4M3FNType::bind(m);
1155 PyFloat8E5M2Type::bind(m);
1156 PyFloat8E4M3Type::bind(m);
1157 PyFloat8E4M3FNUZType::bind(m);
1158 PyFloat8E4M3B11FNUZType::bind(m);
1159 PyFloat8E5M2FNUZType::bind(m);
1160 PyFloat8E3M4Type::bind(m);
1161 PyFloat8E8M0FNUType::bind(m);
1162 PyBF16Type::bind(m);
1164 PyTF32Type::bind(m);
1167 PyNoneType::bind(m);
1168 PyComplexType::bind(m);
1170 PyVectorType::bind(m);
1171 PyRankedTensorType::bind(m);
1172 PyUnrankedTensorType::bind(m);
1173 PyMemRefType::bind(m);
1174 PyUnrankedMemRefType::bind(m);
1175 PyTupleType::bind(m);
1176 PyFunctionType::bind(m);
1177 PyOpaqueType::bind(m);
static MlirStringRef toMlirStringRef(const std::string &s)
Shaped Type Interface - ShapedType.
static const IsAFunctionTy isaFunction
static void bindDerived(ClassTy &c)
PyMlirContextRef & getContext()
Accesses the context reference.
ReferrentTy * get() const
nanobind::class_< PyShapedType, PyType > ClassTy
static void bind(nanobind::module_ &m)
bool(*)(MlirType) IsAFunctionTy
PyType(PyMlirContextRef contextRef, MlirType type)
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 MlirTypeID mlirFloat8E8M0FNUTypeGetTypeID(void)
Returns the typeID of an Float8E8M0FNU type.
MLIR_CAPI_EXPORTED bool mlirIntegerTypeIsSignless(MlirType type)
Checks whether the given integer type is signless.
MLIR_CAPI_EXPORTED bool mlirTypeIsAMemRef(MlirType type)
Checks whether the given type is a MemRef type.
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 MlirTypeID mlirFloat16TypeGetTypeID(void)
Returns the typeID of an Float16 type.
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 MlirTypeID mlirFloat4E2M1FNTypeGetTypeID(void)
Returns the typeID of an Float4E2M1FN type.
MLIR_CAPI_EXPORTED MlirTypeID mlirFloatTF32TypeGetTypeID(void)
Returns the typeID of a TF32 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 bool mlirTypeIsAFloat8E8M0FNU(MlirType type)
Checks whether the given type is an f8E8M0FNU type.
MLIR_CAPI_EXPORTED MlirTypeID mlirNoneTypeGetTypeID(void)
Returns the typeID of an None type.
MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E4M3FNUZTypeGetTypeID(void)
Returns the typeID of an Float8E4M3FNUZ 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 bool mlirTypeIsAVector(MlirType type)
Checks whether the given type is a Vector type.
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 MlirTypeID mlirVectorTypeGetTypeID(void)
Returns the typeID of an Vector type.
MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat6E3M2FN(MlirType type)
Checks whether the given type is an f6E3M2FN type.
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 bool mlirTypeIsAFunction(MlirType type)
Checks whether the given type is a function type.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E3M4TypeGet(MlirContext ctx)
Creates an f8E3M4 type in the given context.
MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E3M4(MlirType type)
Checks whether the given type is an f8E3M4 type.
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 MlirTypeID mlirUnrankedTensorTypeGetTypeID(void)
Returns the typeID of an UnrankedTensor type.
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 MlirTypeID mlirMemRefTypeGetTypeID(void)
Returns the typeID of an MemRef type.
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 bool mlirTypeIsAFloat8E4M3(MlirType type)
Checks whether the given type is an f8E4M3 type.
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 bool mlirTypeIsAFloat8E5M2(MlirType type)
Checks whether the given type is an f8E5M2 type.
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 MlirTypeID mlirFloat8E5M2FNUZTypeGetTypeID(void)
Returns the typeID of an Float8E5M2FNUZ type.
MLIR_CAPI_EXPORTED MlirType mlirShapedTypeGetElementType(MlirType type)
Returns the element type of the shaped type.
MLIR_CAPI_EXPORTED MlirTypeID mlirFloat64TypeGetTypeID(void)
Returns the typeID of an Float64 type.
MLIR_CAPI_EXPORTED bool mlirTypeIsATuple(MlirType type)
Checks whether the given type is a tuple type.
MLIR_CAPI_EXPORTED intptr_t mlirFunctionTypeGetNumInputs(MlirType type)
Returns the number of input types.
MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E5M2TypeGetTypeID(void)
Returns the typeID of an Float8E5M2 type.
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 MlirTypeID mlirTupleTypeGetTypeID(void)
Returns the typeID of an Tuple type.
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 bool mlirTypeIsAFloat8E4M3FN(MlirType type)
Checks whether the given type is an f8E4M3FN type.
MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E4M3FNTypeGetTypeID(void)
Returns the typeID of an Float8E4M3FN type.
MLIR_CAPI_EXPORTED bool mlirTypeIsAOpaque(MlirType type)
Checks whether the given type is an opaque type.
MLIR_CAPI_EXPORTED MlirTypeID mlirFloat6E2M3FNTypeGetTypeID(void)
Returns the typeID of an Float6E2M3FN type.
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 bool mlirTypeIsAFloat6E2M3FN(MlirType type)
Checks whether the given type is an f6E2M3FN type.
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 MlirTypeID mlirFloat8E3M4TypeGetTypeID(void)
Returns the typeID of an Float8E3M4 type.
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 bool mlirTypeIsAFloat(MlirType type)
Checks whether the given type is a floating-point 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 bool mlirTypeIsAFloat8E4M3FNUZ(MlirType type)
Checks whether the given type is an f8E4M3FNUZ type.
MLIR_CAPI_EXPORTED MlirTypeID mlirBFloat16TypeGetTypeID(void)
Returns the typeID of an BFloat16 type.
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 MlirTypeID mlirRankedTensorTypeGetTypeID(void)
Returns the typeID of an RankedTensor 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 mlirTypeIsARankedTensor(MlirType type)
Checks whether the given type is a ranked tensor 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 bool mlirTypeIsATF32(MlirType type)
Checks whether the given type is an TF32 type.
MLIR_CAPI_EXPORTED MlirTypeID mlirComplexTypeGetTypeID(void)
Returns the typeID of an Complex type.
MLIR_CAPI_EXPORTED MlirTypeID mlirIntegerTypeGetTypeID(void)
Returns the typeID of an Integer type.
MLIR_CAPI_EXPORTED MlirType mlirFloat6E3M2FNTypeGet(MlirContext ctx)
Creates an f6E3M2FN type in the given context.
MLIR_CAPI_EXPORTED MlirTypeID mlirOpaqueTypeGetTypeID(void)
Returns the typeID of an Opaque type.
MLIR_CAPI_EXPORTED MlirTypeID mlirIndexTypeGetTypeID(void)
Returns the typeID of an Index type.
MLIR_CAPI_EXPORTED bool mlirTypeIsAComplex(MlirType type)
Checks whether the given type is a Complex type.
MLIR_CAPI_EXPORTED MlirTypeID mlirUnrankedMemRefTypeGetTypeID(void)
Returns the typeID of an UnrankedMemRef type.
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 bool mlirTypeIsAIndex(MlirType type)
Checks whether the given type is an index type.
MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E4M3B11FNUZ(MlirType type)
Checks whether the given type is an f8E4M3B11FNUZ 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 bool mlirTypeIsAUnrankedMemRef(MlirType type)
Checks whether the given type is an UnrankedMemRef type.
MLIR_CAPI_EXPORTED bool mlirTypeIsAFloat8E5M2FNUZ(MlirType type)
Checks whether the given type is an f8E5M2FNUZ type.
MLIR_CAPI_EXPORTED bool mlirTypeIsAUnrankedTensor(MlirType type)
Checks whether the given type is an unranked tensor type.
MLIR_CAPI_EXPORTED MlirTypeID mlirFloat32TypeGetTypeID(void)
Returns the typeID of an Float32 type.
MLIR_CAPI_EXPORTED MlirTypeID mlirFloat8E4M3TypeGetTypeID(void)
Returns the typeID of an Float8E4M3 type.
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 bool mlirTypeIsAFloat4E2M1FN(MlirType type)
Checks whether the given type is an f4E2M1FN type.
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 bool mlirTypeIsANone(MlirType type)
Checks whether the given type is a None type.
MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDynamicStrideOrOffset(void)
Returns the value indicating a dynamic stride or offset in a shaped type.
MLIR_CAPI_EXPORTED MlirTypeID mlirFunctionTypeGetTypeID(void)
Returns the typeID of an Function 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 MlirTypeID mlirFloat6E3M2FNTypeGetTypeID(void)
Returns the typeID of an Float6E3M2FN type.
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 MlirTypeID mlirFloat8E4M3B11FNUZTypeGetTypeID(void)
Returns the typeID of an Float8E4M3B11FNUZ type.
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.
static MlirStringRef mlirStringRefCreate(const char *str, size_t length)
Constructs a string reference from the pointer and length.
struct MlirStringRef MlirStringRef
static bool mlirLogicalResultIsFailure(MlirLogicalResult res)
Checks if the given logical result represents a failure.
void populateIRTypes(nanobind::module_ &m)
Include the generated interface declarations.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
const char * data
Pointer to the first symbol.
size_t length
Length of the fragment.