32 static int mlirTypeIsAIntegerOrFloat(MlirType type) {
40 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
42 static constexpr
const char *pyClassName =
"IntegerType";
45 static void bindDerived(ClassTy &c) {
50 return PyIntegerType(context->getRef(), t);
52 nb::arg(
"width"), nb::arg(
"context").none() = nb::none(),
53 "Create a signless integer type");
58 return PyIntegerType(context->getRef(), t);
60 nb::arg(
"width"), nb::arg(
"context").none() = nb::none(),
61 "Create a signed integer type");
66 return PyIntegerType(context->getRef(), t);
68 nb::arg(
"width"), nb::arg(
"context").none() = 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");
99 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
101 static constexpr
const char *pyClassName =
"IndexType";
104 static void bindDerived(ClassTy &c) {
109 return PyIndexType(context->getRef(), t);
111 nb::arg(
"context").none() = nb::none(),
"Create a index type.");
118 static constexpr
const char *pyClassName =
"FloatType";
121 static void bindDerived(ClassTy &c) {
124 "Returns the width of the floating-point type");
129 class PyFloat4E2M1FNType
133 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
135 static constexpr
const char *pyClassName =
"Float4E2M1FNType";
138 static void bindDerived(ClassTy &c) {
143 return PyFloat4E2M1FNType(context->getRef(), t);
145 nb::arg(
"context").none() = nb::none(),
"Create a float4_e2m1fn type.");
150 class PyFloat6E2M3FNType
154 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
156 static constexpr
const char *pyClassName =
"Float6E2M3FNType";
159 static void bindDerived(ClassTy &c) {
164 return PyFloat6E2M3FNType(context->getRef(), t);
166 nb::arg(
"context").none() = nb::none(),
"Create a float6_e2m3fn type.");
171 class PyFloat6E3M2FNType
175 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
177 static constexpr
const char *pyClassName =
"Float6E3M2FNType";
180 static void bindDerived(ClassTy &c) {
185 return PyFloat6E3M2FNType(context->getRef(), t);
187 nb::arg(
"context").none() = nb::none(),
"Create a float6_e3m2fn type.");
192 class PyFloat8E4M3FNType
196 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
198 static constexpr
const char *pyClassName =
"Float8E4M3FNType";
201 static void bindDerived(ClassTy &c) {
206 return PyFloat8E4M3FNType(context->getRef(), t);
208 nb::arg(
"context").none() = nb::none(),
"Create a float8_e4m3fn type.");
213 class PyFloat8E5M2Type :
public PyConcreteType<PyFloat8E5M2Type, PyFloatType> {
216 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
218 static constexpr
const char *pyClassName =
"Float8E5M2Type";
221 static void bindDerived(ClassTy &c) {
226 return PyFloat8E5M2Type(context->getRef(), t);
228 nb::arg(
"context").none() = nb::none(),
"Create a float8_e5m2 type.");
233 class PyFloat8E4M3Type :
public PyConcreteType<PyFloat8E4M3Type, PyFloatType> {
236 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
238 static constexpr
const char *pyClassName =
"Float8E4M3Type";
241 static void bindDerived(ClassTy &c) {
246 return PyFloat8E4M3Type(context->getRef(), t);
248 nb::arg(
"context").none() = nb::none(),
"Create a float8_e4m3 type.");
253 class PyFloat8E4M3FNUZType
257 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
259 static constexpr
const char *pyClassName =
"Float8E4M3FNUZType";
262 static void bindDerived(ClassTy &c) {
267 return PyFloat8E4M3FNUZType(context->getRef(), t);
269 nb::arg(
"context").none() = nb::none(),
270 "Create a float8_e4m3fnuz type.");
275 class PyFloat8E4M3B11FNUZType
279 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
281 static constexpr
const char *pyClassName =
"Float8E4M3B11FNUZType";
284 static void bindDerived(ClassTy &c) {
289 return PyFloat8E4M3B11FNUZType(context->getRef(), t);
291 nb::arg(
"context").none() = nb::none(),
292 "Create a float8_e4m3b11fnuz type.");
297 class PyFloat8E5M2FNUZType
301 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
303 static constexpr
const char *pyClassName =
"Float8E5M2FNUZType";
306 static void bindDerived(ClassTy &c) {
311 return PyFloat8E5M2FNUZType(context->getRef(), t);
313 nb::arg(
"context").none() = nb::none(),
314 "Create a float8_e5m2fnuz type.");
319 class PyFloat8E3M4Type :
public PyConcreteType<PyFloat8E3M4Type, PyFloatType> {
322 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
324 static constexpr
const char *pyClassName =
"Float8E3M4Type";
327 static void bindDerived(ClassTy &c) {
332 return PyFloat8E3M4Type(context->getRef(), t);
334 nb::arg(
"context").none() = nb::none(),
"Create a float8_e3m4 type.");
339 class PyFloat8E8M0FNUType
343 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
345 static constexpr
const char *pyClassName =
"Float8E8M0FNUType";
348 static void bindDerived(ClassTy &c) {
353 return PyFloat8E8M0FNUType(context->getRef(), t);
355 nb::arg(
"context").none() = nb::none(),
356 "Create a float8_e8m0fnu type.");
361 class PyBF16Type :
public PyConcreteType<PyBF16Type, PyFloatType> {
364 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
366 static constexpr
const char *pyClassName =
"BF16Type";
369 static void bindDerived(ClassTy &c) {
374 return PyBF16Type(context->getRef(), t);
376 nb::arg(
"context").none() = nb::none(),
"Create a bf16 type.");
384 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
386 static constexpr
const char *pyClassName =
"F16Type";
389 static void bindDerived(ClassTy &c) {
394 return PyF16Type(context->getRef(), t);
396 nb::arg(
"context").none() = nb::none(),
"Create a f16 type.");
401 class PyTF32Type :
public PyConcreteType<PyTF32Type, PyFloatType> {
404 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
406 static constexpr
const char *pyClassName =
"FloatTF32Type";
409 static void bindDerived(ClassTy &c) {
414 return PyTF32Type(context->getRef(), t);
416 nb::arg(
"context").none() = nb::none(),
"Create a tf32 type.");
424 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
426 static constexpr
const char *pyClassName =
"F32Type";
429 static void bindDerived(ClassTy &c) {
434 return PyF32Type(context->getRef(), t);
436 nb::arg(
"context").none() = nb::none(),
"Create a f32 type.");
444 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
446 static constexpr
const char *pyClassName =
"F64Type";
449 static void bindDerived(ClassTy &c) {
454 return PyF64Type(context->getRef(), t);
456 nb::arg(
"context").none() = nb::none(),
"Create a f64 type.");
464 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
466 static constexpr
const char *pyClassName =
"NoneType";
469 static void bindDerived(ClassTy &c) {
474 return PyNoneType(context->getRef(), t);
476 nb::arg(
"context").none() = nb::none(),
"Create a none type.");
484 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
486 static constexpr
const char *pyClassName =
"ComplexType";
489 static void bindDerived(ClassTy &c) {
494 if (mlirTypeIsAIntegerOrFloat(elementType)) {
496 return PyComplexType(elementType.
getContext(), t);
498 throw nb::value_error(
499 (Twine(
"invalid '") +
500 nb::cast<std::string>(nb::repr(nb::cast(elementType))) +
501 "' and expected floating point or integer type.")
505 "Create a complex type");
509 "Returns element type.");
520 "Returns the element type of the shaped type.");
524 "Returns whether the given shaped type is ranked.");
528 self.requireHasRank();
531 "Returns the rank of the given ranked shaped type.");
537 "Returns whether the given shaped type has a static shape.");
541 self.requireHasRank();
545 "Returns whether the dim-th dimension of the given shaped type is "
550 self.requireHasRank();
554 "Returns the dim-th dimension of the given ranked shaped type.");
559 "Returns whether the given dimension size indicates a dynamic "
562 "is_dynamic_stride_or_offset",
564 self.requireHasRank();
568 "Returns whether the given value is used as a placeholder for dynamic "
569 "strides and offsets in shaped types.");
573 self.requireHasRank();
575 std::vector<int64_t> shape;
578 for (int64_t i = 0; i < rank; ++i)
582 "Returns the shape of the ranked shaped type as a list of integers.");
585 "Returns the value used to indicate dynamic dimensions in shaped "
588 "get_dynamic_stride_or_offset",
590 "Returns the value used to indicate dynamic strides or offsets in "
594 void mlir::PyShapedType::requireHasRank() {
596 throw nb::value_error(
597 "calling this method requires that the type has a rank.");
607 class PyVectorType :
public PyConcreteType<PyVectorType, PyShapedType> {
610 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
612 static constexpr
const char *pyClassName =
"VectorType";
615 static void bindDerived(ClassTy &c) {
617 nb::arg(
"element_type"), nb::kw_only(),
618 nb::arg(
"scalable").none() = nb::none(),
619 nb::arg(
"scalable_dims").none() = nb::none(),
620 nb::arg(
"loc").none() = nb::none(),
"Create a vector type")
624 .def_prop_ro(
"scalable_dims", [](MlirType
self) {
625 std::vector<bool> scalableDims;
627 scalableDims.reserve(rank);
628 for (
size_t i = 0; i < rank; ++i)
635 static PyVectorType
get(std::vector<int64_t> shape,
PyType &elementType,
636 std::optional<nb::list> scalable,
637 std::optional<std::vector<int64_t>> scalableDims,
639 if (scalable && scalableDims) {
640 throw nb::value_error(
"'scalable' and 'scalable_dims' kwargs "
641 "are mutually exclusive.");
647 if (scalable->size() != shape.size())
648 throw nb::value_error(
"Expected len(scalable) == len(shape).");
651 *scalable, [](
const nb::handle &h) {
return nb::cast<bool>(h); }));
653 scalableDimFlags.data(),
655 }
else if (scalableDims) {
657 for (int64_t dim : *scalableDims) {
658 if (
static_cast<size_t>(dim) >= scalableDimFlags.size() || dim < 0)
659 throw nb::value_error(
"Scalable dimension index out of bounds.");
660 scalableDimFlags[dim] =
true;
663 scalableDimFlags.data(),
670 throw MLIRError(
"Invalid type", errors.take());
671 return PyVectorType(elementType.
getContext(), type);
676 class PyRankedTensorType
680 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
682 static constexpr
const char *pyClassName =
"RankedTensorType";
685 static void bindDerived(ClassTy &c) {
688 [](std::vector<int64_t> shape,
PyType &elementType,
692 loc, shape.size(), shape.data(), elementType,
695 throw MLIRError(
"Invalid type", errors.take());
696 return PyRankedTensorType(elementType.
getContext(), t);
698 nb::arg(
"shape"), nb::arg(
"element_type"),
699 nb::arg(
"encoding").none() = nb::none(),
700 nb::arg(
"loc").none() = nb::none(),
"Create a ranked tensor type");
701 c.def_prop_ro(
"encoding",
702 [](PyRankedTensorType &
self) -> std::optional<MlirAttribute> {
703 MlirAttribute encoding =
713 class PyUnrankedTensorType
717 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
719 static constexpr
const char *pyClassName =
"UnrankedTensorType";
722 static void bindDerived(ClassTy &c) {
729 throw MLIRError(
"Invalid type", errors.take());
730 return PyUnrankedTensorType(elementType.
getContext(), t);
732 nb::arg(
"element_type"), nb::arg(
"loc").none() = nb::none(),
733 "Create a unranked tensor type");
738 class PyMemRefType :
public PyConcreteType<PyMemRefType, PyShapedType> {
741 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
743 static constexpr
const char *pyClassName =
"MemRefType";
746 static void bindDerived(ClassTy &c) {
749 [](std::vector<int64_t> shape,
PyType &elementType,
754 MlirAttribute memSpaceAttr =
758 shape.data(), layoutAttr, memSpaceAttr);
760 throw MLIRError(
"Invalid type", errors.take());
761 return PyMemRefType(elementType.
getContext(), t);
763 nb::arg(
"shape"), nb::arg(
"element_type"),
764 nb::arg(
"layout").none() = nb::none(),
765 nb::arg(
"memory_space").none() = nb::none(),
766 nb::arg(
"loc").none() = nb::none(),
"Create a memref type")
769 [](PyMemRefType &
self) -> MlirAttribute {
772 "The layout of the MemRef type.")
774 "get_strides_and_offset",
775 [](PyMemRefType &
self) -> std::pair<std::vector<int64_t>, int64_t> {
779 self, strides.data(), &offset)))
780 throw std::runtime_error(
781 "Failed to extract strides and offset from memref.");
782 return {strides, offset};
784 "The strides and offset of the MemRef type.")
791 "The layout of the MemRef type as an affine map.")
794 [](PyMemRefType &
self) -> std::optional<MlirAttribute> {
800 "Returns the memory space of the given MemRef type.");
805 class PyUnrankedMemRefType
809 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
811 static constexpr
const char *pyClassName =
"UnrankedMemRefType";
814 static void bindDerived(ClassTy &c) {
820 MlirAttribute memSpaceAttr = {};
822 memSpaceAttr = *memorySpace;
827 throw MLIRError(
"Invalid type", errors.take());
828 return PyUnrankedMemRefType(elementType.
getContext(), t);
830 nb::arg(
"element_type"), nb::arg(
"memory_space").none(),
831 nb::arg(
"loc").none() = nb::none(),
"Create a unranked memref type")
834 [](PyUnrankedMemRefType &
self) -> std::optional<MlirAttribute> {
840 "Returns the memory space of the given Unranked MemRef type.");
848 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
850 static constexpr
const char *pyClassName =
"TupleType";
853 static void bindDerived(ClassTy &c) {
859 return PyTupleType(context->getRef(), t);
861 nb::arg(
"elements"), nb::arg(
"context").none() = nb::none(),
862 "Create a tuple type");
865 [](PyTupleType &
self, intptr_t pos) {
868 nb::arg(
"pos"),
"Returns the pos-th type in the tuple type.");
871 [](PyTupleType &
self) -> intptr_t {
874 "Returns the number of types contained in a tuple.");
882 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
884 static constexpr
const char *pyClassName =
"FunctionType";
887 static void bindDerived(ClassTy &c) {
890 [](std::vector<MlirType> inputs, std::vector<MlirType> results,
894 results.size(), results.data());
895 return PyFunctionType(context->getRef(), t);
897 nb::arg(
"inputs"), nb::arg(
"results"),
898 nb::arg(
"context").none() = nb::none(),
899 "Gets a FunctionType from a list of input and result types");
902 [](PyFunctionType &
self) {
911 "Returns the list of input types in the FunctionType.");
914 [](PyFunctionType &
self) {
922 "Returns the list of result types in the FunctionType.");
934 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
936 static constexpr
const char *pyClassName =
"OpaqueType";
939 static void bindDerived(ClassTy &c) {
942 [](std::string dialectNamespace, std::string typeData,
947 return PyOpaqueType(context->getRef(), type);
949 nb::arg(
"dialect_namespace"), nb::arg(
"buffer"),
950 nb::arg(
"context").none() = nb::none(),
951 "Create an unregistered (opaque) dialect type.");
954 [](PyOpaqueType &
self) {
956 return nb::str(stringRef.
data, stringRef.
length);
958 "Returns the dialect namespace for the Opaque type as a string.");
961 [](PyOpaqueType &
self) {
963 return nb::str(stringRef.
data, stringRef.
length);
965 "Returns the data for the Opaque type as a string.");
972 PyIntegerType::bind(m);
973 PyFloatType::bind(m);
974 PyIndexType::bind(m);
975 PyFloat4E2M1FNType::bind(m);
976 PyFloat6E2M3FNType::bind(m);
977 PyFloat6E3M2FNType::bind(m);
978 PyFloat8E4M3FNType::bind(m);
979 PyFloat8E5M2Type::bind(m);
980 PyFloat8E4M3Type::bind(m);
981 PyFloat8E4M3FNUZType::bind(m);
982 PyFloat8E4M3B11FNUZType::bind(m);
983 PyFloat8E5M2FNUZType::bind(m);
984 PyFloat8E3M4Type::bind(m);
985 PyFloat8E8M0FNUType::bind(m);
992 PyComplexType::bind(m);
994 PyVectorType::bind(m);
995 PyRankedTensorType::bind(m);
996 PyUnrankedTensorType::bind(m);
997 PyMemRefType::bind(m);
998 PyUnrankedMemRefType::bind(m);
999 PyTupleType::bind(m);
1000 PyFunctionType::bind(m);
1001 PyOpaqueType::bind(m);
static MlirStringRef toMlirStringRef(const std::string &s)
static MLIRContext * getContext(OpFoldResult val)
Shaped Type Interface - ShapedType.
static const IsAFunctionTy isaFunction
static void bindDerived(ClassTy &c)
PyMlirContextRef & getContext()
Accesses the context reference.
Used in function arguments when None should resolve to the current context manager set instance.
Used in function arguments when None should resolve to the current context manager set instance.
ReferrentTy * get() const
Wrapper around the generic MlirAttribute.
CRTP base classes for Python types that subclass Type and should be castable from it (i....
static void bind(nanobind::module_ &m)
bool(*)(MlirType) IsAFunctionTy
Wrapper around the generic MlirType.
MLIR_CAPI_EXPORTED MlirAttribute mlirAttributeGetNull(void)
Returns an empty attribute.
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 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 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 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 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 wither 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 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 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 mlirAttributeIsNull(MlirAttribute attr)
Checks whether an attribute is null.
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.
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...
A pointer to a sized fragment of a string, not necessarily null-terminated.
const char * data
Pointer to the first symbol.
size_t length
Length of the fragment.
Custom exception that allows access to error diagnostic information.
RAII object that captures any error diagnostics emitted to the provided context.