31 static int mlirTypeIsAIntegerOrFloat(MlirType type) {
39 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
41 static constexpr
const char *pyClassName =
"IntegerType";
44 static void bindDerived(ClassTy &c) {
49 return PyIntegerType(context->getRef(), t);
51 py::arg(
"width"), py::arg(
"context") = py::none(),
52 "Create a signless integer type");
57 return PyIntegerType(context->getRef(), t);
59 py::arg(
"width"), py::arg(
"context") = py::none(),
60 "Create a signed integer type");
65 return PyIntegerType(context->getRef(), t);
67 py::arg(
"width"), py::arg(
"context") = py::none(),
68 "Create an unsigned integer type");
69 c.def_property_readonly(
72 "Returns the width of the integer type");
73 c.def_property_readonly(
75 [](PyIntegerType &
self) ->
bool {
78 "Returns whether this is a signless integer");
79 c.def_property_readonly(
81 [](PyIntegerType &
self) ->
bool {
84 "Returns whether this is a signed integer");
85 c.def_property_readonly(
87 [](PyIntegerType &
self) ->
bool {
90 "Returns whether this is an unsigned integer");
98 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
100 static constexpr
const char *pyClassName =
"IndexType";
103 static void bindDerived(ClassTy &c) {
108 return PyIndexType(context->getRef(), t);
110 py::arg(
"context") = py::none(),
"Create a index type.");
117 static constexpr
const char *pyClassName =
"FloatType";
120 static void bindDerived(ClassTy &c) {
121 c.def_property_readonly(
123 "Returns the width of the floating-point type");
128 class PyFloat4E2M1FNType
132 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
134 static constexpr
const char *pyClassName =
"Float4E2M1FNType";
137 static void bindDerived(ClassTy &c) {
142 return PyFloat4E2M1FNType(context->getRef(), t);
144 py::arg(
"context") = py::none(),
"Create a float4_e2m1fn type.");
149 class PyFloat6E2M3FNType
153 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
155 static constexpr
const char *pyClassName =
"Float6E2M3FNType";
158 static void bindDerived(ClassTy &c) {
163 return PyFloat6E2M3FNType(context->getRef(), t);
165 py::arg(
"context") = py::none(),
"Create a float6_e2m3fn type.");
170 class PyFloat6E3M2FNType
174 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
176 static constexpr
const char *pyClassName =
"Float6E3M2FNType";
179 static void bindDerived(ClassTy &c) {
184 return PyFloat6E3M2FNType(context->getRef(), t);
186 py::arg(
"context") = py::none(),
"Create a float6_e3m2fn type.");
191 class PyFloat8E4M3FNType
195 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
197 static constexpr
const char *pyClassName =
"Float8E4M3FNType";
200 static void bindDerived(ClassTy &c) {
205 return PyFloat8E4M3FNType(context->getRef(), t);
207 py::arg(
"context") = py::none(),
"Create a float8_e4m3fn type.");
212 class PyFloat8E5M2Type :
public PyConcreteType<PyFloat8E5M2Type, PyFloatType> {
215 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
217 static constexpr
const char *pyClassName =
"Float8E5M2Type";
220 static void bindDerived(ClassTy &c) {
225 return PyFloat8E5M2Type(context->getRef(), t);
227 py::arg(
"context") = py::none(),
"Create a float8_e5m2 type.");
232 class PyFloat8E4M3Type :
public PyConcreteType<PyFloat8E4M3Type, PyFloatType> {
235 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
237 static constexpr
const char *pyClassName =
"Float8E4M3Type";
240 static void bindDerived(ClassTy &c) {
245 return PyFloat8E4M3Type(context->getRef(), t);
247 py::arg(
"context") = py::none(),
"Create a float8_e4m3 type.");
252 class PyFloat8E4M3FNUZType
256 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
258 static constexpr
const char *pyClassName =
"Float8E4M3FNUZType";
261 static void bindDerived(ClassTy &c) {
266 return PyFloat8E4M3FNUZType(context->getRef(), t);
268 py::arg(
"context") = py::none(),
"Create a float8_e4m3fnuz type.");
273 class PyFloat8E4M3B11FNUZType
277 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
279 static constexpr
const char *pyClassName =
"Float8E4M3B11FNUZType";
282 static void bindDerived(ClassTy &c) {
287 return PyFloat8E4M3B11FNUZType(context->getRef(), t);
289 py::arg(
"context") = py::none(),
"Create a float8_e4m3b11fnuz type.");
294 class PyFloat8E5M2FNUZType
298 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
300 static constexpr
const char *pyClassName =
"Float8E5M2FNUZType";
303 static void bindDerived(ClassTy &c) {
308 return PyFloat8E5M2FNUZType(context->getRef(), t);
310 py::arg(
"context") = py::none(),
"Create a float8_e5m2fnuz type.");
315 class PyFloat8E3M4Type :
public PyConcreteType<PyFloat8E3M4Type, PyFloatType> {
318 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
320 static constexpr
const char *pyClassName =
"Float8E3M4Type";
323 static void bindDerived(ClassTy &c) {
328 return PyFloat8E3M4Type(context->getRef(), t);
330 py::arg(
"context") = py::none(),
"Create a float8_e3m4 type.");
335 class PyFloat8E8M0FNUType
339 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
341 static constexpr
const char *pyClassName =
"Float8E8M0FNUType";
344 static void bindDerived(ClassTy &c) {
349 return PyFloat8E8M0FNUType(context->getRef(), t);
351 py::arg(
"context") = py::none(),
"Create a float8_e8m0fnu type.");
356 class PyBF16Type :
public PyConcreteType<PyBF16Type, PyFloatType> {
359 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
361 static constexpr
const char *pyClassName =
"BF16Type";
364 static void bindDerived(ClassTy &c) {
369 return PyBF16Type(context->getRef(), t);
371 py::arg(
"context") = py::none(),
"Create a bf16 type.");
379 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
381 static constexpr
const char *pyClassName =
"F16Type";
384 static void bindDerived(ClassTy &c) {
389 return PyF16Type(context->getRef(), t);
391 py::arg(
"context") = py::none(),
"Create a f16 type.");
396 class PyTF32Type :
public PyConcreteType<PyTF32Type, PyFloatType> {
399 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
401 static constexpr
const char *pyClassName =
"FloatTF32Type";
404 static void bindDerived(ClassTy &c) {
409 return PyTF32Type(context->getRef(), t);
411 py::arg(
"context") = py::none(),
"Create a tf32 type.");
419 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
421 static constexpr
const char *pyClassName =
"F32Type";
424 static void bindDerived(ClassTy &c) {
429 return PyF32Type(context->getRef(), t);
431 py::arg(
"context") = py::none(),
"Create a f32 type.");
439 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
441 static constexpr
const char *pyClassName =
"F64Type";
444 static void bindDerived(ClassTy &c) {
449 return PyF64Type(context->getRef(), t);
451 py::arg(
"context") = py::none(),
"Create a f64 type.");
459 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
461 static constexpr
const char *pyClassName =
"NoneType";
464 static void bindDerived(ClassTy &c) {
469 return PyNoneType(context->getRef(), t);
471 py::arg(
"context") = py::none(),
"Create a none type.");
479 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
481 static constexpr
const char *pyClassName =
"ComplexType";
484 static void bindDerived(ClassTy &c) {
489 if (mlirTypeIsAIntegerOrFloat(elementType)) {
491 return PyComplexType(elementType.
getContext(), t);
493 throw py::value_error(
494 (Twine(
"invalid '") +
495 py::repr(py::cast(elementType)).cast<std::string>() +
496 "' and expected floating point or integer type.")
499 "Create a complex type");
500 c.def_property_readonly(
503 "Returns element type.");
511 c.def_property_readonly(
514 "Returns the element type of the shaped type.");
515 c.def_property_readonly(
518 "Returns whether the given shaped type is ranked.");
519 c.def_property_readonly(
522 self.requireHasRank();
525 "Returns the rank of the given ranked shaped type.");
526 c.def_property_readonly(
531 "Returns whether the given shaped type has a static shape.");
535 self.requireHasRank();
539 "Returns whether the dim-th dimension of the given shaped type is "
544 self.requireHasRank();
548 "Returns the dim-th dimension of the given ranked shaped type.");
553 "Returns whether the given dimension size indicates a dynamic "
556 "is_dynamic_stride_or_offset",
558 self.requireHasRank();
562 "Returns whether the given value is used as a placeholder for dynamic "
563 "strides and offsets in shaped types.");
564 c.def_property_readonly(
567 self.requireHasRank();
569 std::vector<int64_t> shape;
572 for (int64_t i = 0; i < rank; ++i)
576 "Returns the shape of the ranked shaped type as a list of integers.");
579 "Returns the value used to indicate dynamic dimensions in shaped "
582 "get_dynamic_stride_or_offset",
584 "Returns the value used to indicate dynamic strides or offsets in "
588 void mlir::PyShapedType::requireHasRank() {
590 throw py::value_error(
591 "calling this method requires that the type has a rank.");
601 class PyVectorType :
public PyConcreteType<PyVectorType, PyShapedType> {
604 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
606 static constexpr
const char *pyClassName =
"VectorType";
609 static void bindDerived(ClassTy &c) {
611 py::arg(
"element_type"), py::kw_only(),
612 py::arg(
"scalable") = py::none(),
613 py::arg(
"scalable_dims") = py::none(),
614 py::arg(
"loc") = py::none(),
"Create a vector type")
615 .def_property_readonly(
618 .def_property_readonly(
"scalable_dims", [](MlirType
self) {
619 std::vector<bool> scalableDims;
621 scalableDims.reserve(rank);
622 for (
size_t i = 0; i < rank; ++i)
629 static PyVectorType
get(std::vector<int64_t> shape,
PyType &elementType,
630 std::optional<py::list> scalable,
631 std::optional<std::vector<int64_t>> scalableDims,
633 if (scalable && scalableDims) {
634 throw py::value_error(
"'scalable' and 'scalable_dims' kwargs "
635 "are mutually exclusive.");
641 if (scalable->size() != shape.size())
642 throw py::value_error(
"Expected len(scalable) == len(shape).");
645 *scalable, [](
const py::handle &h) {
return h.cast<
bool>(); }));
647 scalableDimFlags.data(),
649 }
else if (scalableDims) {
651 for (int64_t dim : *scalableDims) {
652 if (
static_cast<size_t>(dim) >= scalableDimFlags.size() || dim < 0)
653 throw py::value_error(
"Scalable dimension index out of bounds.");
654 scalableDimFlags[dim] =
true;
657 scalableDimFlags.data(),
664 throw MLIRError(
"Invalid type", errors.take());
665 return PyVectorType(elementType.
getContext(), type);
670 class PyRankedTensorType
674 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
676 static constexpr
const char *pyClassName =
"RankedTensorType";
679 static void bindDerived(ClassTy &c) {
682 [](std::vector<int64_t> shape,
PyType &elementType,
686 loc, shape.size(), shape.data(), elementType,
689 throw MLIRError(
"Invalid type", errors.take());
690 return PyRankedTensorType(elementType.
getContext(), t);
692 py::arg(
"shape"), py::arg(
"element_type"),
693 py::arg(
"encoding") = py::none(), py::arg(
"loc") = py::none(),
694 "Create a ranked tensor type");
695 c.def_property_readonly(
697 [](PyRankedTensorType &
self) -> std::optional<MlirAttribute> {
707 class PyUnrankedTensorType
711 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
713 static constexpr
const char *pyClassName =
"UnrankedTensorType";
716 static void bindDerived(ClassTy &c) {
723 throw MLIRError(
"Invalid type", errors.take());
724 return PyUnrankedTensorType(elementType.
getContext(), t);
726 py::arg(
"element_type"), py::arg(
"loc") = py::none(),
727 "Create a unranked tensor type");
732 class PyMemRefType :
public PyConcreteType<PyMemRefType, PyShapedType> {
735 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
737 static constexpr
const char *pyClassName =
"MemRefType";
740 static void bindDerived(ClassTy &c) {
743 [](std::vector<int64_t> shape,
PyType &elementType,
748 MlirAttribute memSpaceAttr =
752 shape.data(), layoutAttr, memSpaceAttr);
754 throw MLIRError(
"Invalid type", errors.take());
755 return PyMemRefType(elementType.
getContext(), t);
757 py::arg(
"shape"), py::arg(
"element_type"),
758 py::arg(
"layout") = py::none(), py::arg(
"memory_space") = py::none(),
759 py::arg(
"loc") = py::none(),
"Create a memref type")
760 .def_property_readonly(
762 [](PyMemRefType &
self) -> MlirAttribute {
765 "The layout of the MemRef type.")
767 "get_strides_and_offset",
768 [](PyMemRefType &
self) -> std::pair<std::vector<int64_t>, int64_t> {
772 self, strides.data(), &offset)))
773 throw std::runtime_error(
774 "Failed to extract strides and offset from memref.");
775 return {strides, offset};
777 "The strides and offset of the MemRef type.")
778 .def_property_readonly(
784 "The layout of the MemRef type as an affine map.")
785 .def_property_readonly(
787 [](PyMemRefType &
self) -> std::optional<MlirAttribute> {
793 "Returns the memory space of the given MemRef type.");
798 class PyUnrankedMemRefType
802 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
804 static constexpr
const char *pyClassName =
"UnrankedMemRefType";
807 static void bindDerived(ClassTy &c) {
813 MlirAttribute memSpaceAttr = {};
815 memSpaceAttr = *memorySpace;
820 throw MLIRError(
"Invalid type", errors.take());
821 return PyUnrankedMemRefType(elementType.
getContext(), t);
823 py::arg(
"element_type"), py::arg(
"memory_space"),
824 py::arg(
"loc") = py::none(),
"Create a unranked memref type")
825 .def_property_readonly(
827 [](PyUnrankedMemRefType &
self) -> std::optional<MlirAttribute> {
833 "Returns the memory space of the given Unranked MemRef type.");
841 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
843 static constexpr
const char *pyClassName =
"TupleType";
846 static void bindDerived(ClassTy &c) {
852 return PyTupleType(context->getRef(), t);
854 py::arg(
"elements"), py::arg(
"context") = py::none(),
855 "Create a tuple type");
858 [](PyTupleType &
self, intptr_t pos) {
861 py::arg(
"pos"),
"Returns the pos-th type in the tuple type.");
862 c.def_property_readonly(
864 [](PyTupleType &
self) -> intptr_t {
867 "Returns the number of types contained in a tuple.");
875 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
877 static constexpr
const char *pyClassName =
"FunctionType";
880 static void bindDerived(ClassTy &c) {
883 [](std::vector<MlirType> inputs, std::vector<MlirType> results,
887 results.size(), results.data());
888 return PyFunctionType(context->getRef(), t);
890 py::arg(
"inputs"), py::arg(
"results"), py::arg(
"context") = py::none(),
891 "Gets a FunctionType from a list of input and result types");
892 c.def_property_readonly(
894 [](PyFunctionType &
self) {
903 "Returns the list of input types in the FunctionType.");
904 c.def_property_readonly(
906 [](PyFunctionType &
self) {
914 "Returns the list of result types in the FunctionType.");
926 static constexpr GetTypeIDFunctionTy getTypeIdFunction =
928 static constexpr
const char *pyClassName =
"OpaqueType";
931 static void bindDerived(ClassTy &c) {
934 [](std::string dialectNamespace, std::string typeData,
939 return PyOpaqueType(context->getRef(), type);
941 py::arg(
"dialect_namespace"), py::arg(
"buffer"),
942 py::arg(
"context") = py::none(),
943 "Create an unregistered (opaque) dialect type.");
944 c.def_property_readonly(
946 [](PyOpaqueType &
self) {
948 return py::str(stringRef.
data, stringRef.
length);
950 "Returns the dialect namespace for the Opaque type as a string.");
951 c.def_property_readonly(
953 [](PyOpaqueType &
self) {
955 return py::str(stringRef.
data, stringRef.
length);
957 "Returns the data for the Opaque type as a string.");
964 PyIntegerType::bind(m);
965 PyFloatType::bind(m);
966 PyIndexType::bind(m);
967 PyFloat4E2M1FNType::bind(m);
968 PyFloat6E2M3FNType::bind(m);
969 PyFloat6E3M2FNType::bind(m);
970 PyFloat8E4M3FNType::bind(m);
971 PyFloat8E5M2Type::bind(m);
972 PyFloat8E4M3Type::bind(m);
973 PyFloat8E4M3FNUZType::bind(m);
974 PyFloat8E4M3B11FNUZType::bind(m);
975 PyFloat8E5M2FNUZType::bind(m);
976 PyFloat8E3M4Type::bind(m);
977 PyFloat8E8M0FNUType::bind(m);
984 PyComplexType::bind(m);
986 PyVectorType::bind(m);
987 PyRankedTensorType::bind(m);
988 PyUnrankedTensorType::bind(m);
989 PyMemRefType::bind(m);
990 PyUnrankedMemRefType::bind(m);
991 PyTupleType::bind(m);
992 PyFunctionType::bind(m);
993 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(pybind11::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(pybind11::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.