37 nb::enum_<Signedness>(c,
"Signedness")
49 nb::arg(
"width"), nb::arg(
"context") = nb::none(),
50 "Create a signless integer type");
57 nb::arg(
"width"), nb::arg(
"context") = nb::none(),
58 "Create a signed integer type");
65 nb::arg(
"width"), nb::arg(
"context") = nb::none(),
66 "Create an unsigned integer type");
85 nb::arg(
"width"), nb::arg(
"signedness") =
Signless,
86 nb::arg(
"context") = nb::none(),
"Create an integer type");
97 "Returns the width of the integer type");
103 "Returns whether this is a signless integer");
107 "Returns whether this is a signed integer");
113 "Returns whether this is an unsigned integer");
123 nb::arg(
"context") = nb::none(),
"Create a index type.");
129 "Returns the width of the floating-point type");
139 nb::arg(
"context") = nb::none(),
"Create a float4_e2m1fn type.");
149 nb::arg(
"context") = nb::none(),
"Create a float6_e2m3fn type.");
159 nb::arg(
"context") = nb::none(),
"Create a float6_e3m2fn type.");
169 nb::arg(
"context") = nb::none(),
"Create a float8_e4m3fn type.");
179 nb::arg(
"context") = nb::none(),
"Create a float8_e5m2 type.");
189 nb::arg(
"context") = nb::none(),
"Create a float8_e4m3 type.");
199 nb::arg(
"context") = nb::none(),
"Create a float8_e4m3fnuz type.");
209 nb::arg(
"context") = nb::none(),
"Create a float8_e4m3b11fnuz type.");
219 nb::arg(
"context") = nb::none(),
"Create a float8_e5m2fnuz type.");
229 nb::arg(
"context") = nb::none(),
"Create a float8_e3m4 type.");
239 nb::arg(
"context") = nb::none(),
"Create a float8_e8m0fnu type.");
249 nb::arg(
"context") = nb::none(),
"Create a float8_e5m3fnu type.");
259 nb::arg(
"context") = nb::none(),
"Create a bf16 type.");
269 nb::arg(
"context") = nb::none(),
"Create a f16 type.");
279 nb::arg(
"context") = nb::none(),
"Create a tf32 type.");
289 nb::arg(
"context") = nb::none(),
"Create a f32 type.");
299 nb::arg(
"context") = nb::none(),
"Create a f64 type.");
309 nb::arg(
"context") = nb::none(),
"Create a none type.");
321 throw nb::value_error(
324 nb::cast<std::string>(nb::repr(nb::cast(elementType))),
325 "' and expected floating point or integer type.")
328 "Create a complex type");
335 "Returns element type.");
342 [](
PyShapedType &self) -> nb::typed<nb::object, PyType> {
346 "Returns the element type of the shaped type.");
350 "Returns whether the given shaped type is ranked.");
354 self.requireHasRank();
357 "Returns the rank of the given ranked shaped type.");
363 "Returns whether the given shaped type has a static shape.");
367 self.requireHasRank();
371 "Returns whether the dim-th dimension of the given shaped type is "
376 self.requireHasRank();
380 "Returns whether the dim-th dimension of the given shaped type is "
385 self.requireHasRank();
389 "Returns the dim-th dimension of the given ranked shaped type.");
394 "Returns whether the given dimension size indicates a dynamic "
400 "Returns whether the given dimension size indicates a static "
403 "is_dynamic_stride_or_offset",
405 self.requireHasRank();
409 "Returns whether the given value is used as a placeholder for dynamic "
410 "strides and offsets in shaped types.");
412 "is_static_stride_or_offset",
414 self.requireHasRank();
418 "Returns whether the given shaped type stride or offset value is "
419 "statically-sized.");
423 self.requireHasRank();
425 std::vector<int64_t>
shape;
428 for (
int64_t i = 0; i < rank; ++i)
432 "Returns the shape of the ranked shaped type as a list of integers.");
435 "Returns the value used to indicate dynamic dimensions in shaped "
438 "get_dynamic_stride_or_offset",
440 "Returns the value used to indicate dynamic strides or offsets in "
444void PyShapedType::requireHasRank() {
446 throw nb::value_error(
447 "calling this method requires that the type has a rank.");
454 c.def_static(
"get", &PyVectorType::getChecked, nb::arg(
"shape"),
455 nb::arg(
"element_type"), nb::kw_only(),
456 nb::arg(
"scalable") = nb::none(),
457 nb::arg(
"scalable_dims") = nb::none(),
458 nb::arg(
"loc") = nb::none(),
"Create a vector type")
459 .def_static(
"get_unchecked", &PyVectorType::get, nb::arg(
"shape"),
460 nb::arg(
"element_type"), nb::kw_only(),
461 nb::arg(
"scalable") = nb::none(),
462 nb::arg(
"scalable_dims") = nb::none(),
463 nb::arg(
"context") = nb::none(),
"Create a vector type")
464 .def_prop_ro(
"scalable",
466 .def_prop_ro(
"scalable_dims", [](
PyType self) {
467 std::vector<bool> scalableDims;
469 scalableDims.reserve(rank);
470 for (
size_t i = 0; i < rank; ++i)
477PyVectorType::getChecked(std::vector<int64_t>
shape,
PyType &elementType,
478 std::optional<nb::sequence> scalable,
479 std::optional<std::vector<int64_t>> scalableDims,
481 if (scalable && scalableDims) {
482 throw nb::value_error(
"'scalable' and 'scalable_dims' kwargs "
483 "are mutually exclusive.");
489 if (nb::len(*scalable) !=
shape.size())
490 throw nb::value_error(
"Expected len(scalable) == len(shape).");
492 std::vector<char> scalableDimFlags;
493 scalableDimFlags.reserve(nb::len(*scalable));
494 for (
const nb::handle &h : *scalable) {
495 scalableDimFlags.push_back(nb::cast<bool>(h) ? 1 : 0);
499 reinterpret_cast<const bool *
>(scalableDimFlags.data()), elementType);
500 }
else if (scalableDims) {
501 std::vector<char> scalableDimFlags(
shape.size(), 0);
502 for (
int64_t dim : *scalableDims) {
503 if (
static_cast<size_t>(dim) >= scalableDimFlags.size() || dim < 0)
504 throw nb::value_error(
"Scalable dimension index out of bounds.");
505 scalableDimFlags[dim] = 1;
508 loc, shape.size(), shape.data(),
509 reinterpret_cast<const bool *
>(scalableDimFlags.data()), elementType);
515 throw MLIRError(
"Invalid type", errors.take());
516 return PyVectorType(elementType.
getContext(), type);
520 std::optional<nb::sequence> scalable,
521 std::optional<std::vector<int64_t>> scalableDims,
523 if (scalable && scalableDims) {
524 throw nb::value_error(
"'scalable' and 'scalable_dims' kwargs "
525 "are mutually exclusive.");
528 PyMlirContext::ErrorCapture errors(context->getRef());
531 if (nb::len(*scalable) != shape.size())
532 throw nb::value_error(
"Expected len(scalable) == len(shape).");
534 std::vector<char> scalableDimFlags;
535 scalableDimFlags.reserve(nb::len(*scalable));
536 for (
const nb::handle &h : *scalable) {
537 scalableDimFlags.push_back(nb::cast<bool>(h) ? 1 : 0);
540 shape.size(), shape.data(),
541 reinterpret_cast<const bool *
>(scalableDimFlags.data()), elementType);
542 }
else if (scalableDims) {
543 std::vector<char> scalableDimFlags(shape.size(), 0);
544 for (int64_t dim : *scalableDims) {
545 if (
static_cast<size_t>(dim) >= scalableDimFlags.size() || dim < 0)
546 throw nb::value_error(
"Scalable dimension index out of bounds.");
547 scalableDimFlags[dim] = 1;
550 shape.size(), shape.data(),
551 reinterpret_cast<const bool *
>(scalableDimFlags.data()), elementType);
556 throw MLIRError(
"Invalid type", errors.take());
557 return PyVectorType(elementType.
getContext(), type);
563 [](std::vector<int64_t>
shape,
PyType &elementType,
573 nb::arg(
"shape"), nb::arg(
"element_type"),
574 nb::arg(
"encoding") = nb::none(), nb::arg(
"loc") = nb::none(),
575 "Create a ranked tensor type");
578 [](std::vector<int64_t>
shape,
PyType &elementType,
579 std::optional<PyAttribute> &encodingAttr,
589 nb::arg(
"shape"), nb::arg(
"element_type"),
590 nb::arg(
"encoding") = nb::none(), nb::arg(
"context") = nb::none(),
591 "Create a ranked tensor type");
595 -> std::optional<nb::typed<nb::object, PyAttribute>> {
597 if (mlirAttributeIsNull(encoding))
613 nb::arg(
"element_type"), nb::arg(
"loc") = nb::none(),
614 "Create a unranked tensor type");
624 nb::arg(
"element_type"), nb::arg(
"context") = nb::none(),
625 "Create a unranked tensor type");
635 MlirAttribute memSpaceAttr =
639 shape.data(), layoutAttr, memSpaceAttr);
644 nb::arg(
"shape"), nb::arg(
"element_type"),
645 nb::arg(
"layout") = nb::none(), nb::arg(
"memory_space") = nb::none(),
646 nb::arg(
"loc") = nb::none(),
"Create a memref type")
649 [](std::vector<int64_t>
shape,
PyType &elementType,
653 MlirAttribute layoutAttr =
655 MlirAttribute memSpaceAttr =
659 layoutAttr, memSpaceAttr);
664 nb::arg(
"shape"), nb::arg(
"element_type"),
665 nb::arg(
"layout") = nb::none(), nb::arg(
"memory_space") = nb::none(),
666 nb::arg(
"context") = nb::none(),
"Create a memref type")
669 [](
PyMemRefType &self) -> nb::typed<nb::object, PyAttribute> {
673 "The layout of the MemRef type.")
675 "get_strides_and_offset",
680 self, strides.data(), &offset)))
681 throw std::runtime_error(
682 "Failed to extract strides and offset from memref.");
683 return {strides, offset};
685 "The strides and offset of the MemRef type.")
692 "The layout of the MemRef type as an affine map.")
696 -> std::optional<nb::typed<nb::object, PyAttribute>> {
698 if (mlirAttributeIsNull(a))
702 "Returns the memory space of the given MemRef type.");
711 MlirAttribute memSpaceAttr = {};
713 memSpaceAttr = *memorySpace;
721 nb::arg(
"element_type"), nb::arg(
"memory_space").none(),
722 nb::arg(
"loc") = nb::none(),
"Create a unranked memref type")
728 MlirAttribute memSpaceAttr = {};
730 memSpaceAttr = *memorySpace;
737 nb::arg(
"element_type"), nb::arg(
"memory_space").none(),
738 nb::arg(
"context") = nb::none(),
"Create a unranked memref type")
742 -> std::optional<nb::typed<nb::object, PyAttribute>> {
744 if (mlirAttributeIsNull(a))
748 "Returns the memory space of the given Unranked MemRef type.");
755 std::vector<MlirType> mlirElements;
756 mlirElements.reserve(elements.size());
757 for (
const auto &element : elements)
758 mlirElements.push_back(element.get());
760 mlirElements.data());
763 nb::arg(
"elements"), nb::arg(
"context") = nb::none(),
764 "Create a tuple type");
771 nb::arg(
"pos"),
"Returns the pos-th type in the tuple type.");
777 "Returns the number of types contained in a tuple.");
783 [](std::vector<PyType> inputs, std::vector<PyType> results,
785 std::vector<MlirType> mlirInputs;
786 mlirInputs.reserve(inputs.size());
787 for (
const auto &input : inputs)
788 mlirInputs.push_back(input.get());
789 std::vector<MlirType> mlirResults;
790 mlirResults.reserve(results.size());
791 for (
const auto &
result : results)
792 mlirResults.push_back(
result.get());
795 mlirInputs.data(), results.size(),
799 nb::arg(
"inputs"), nb::arg(
"results"), nb::arg(
"context") = nb::none(),
800 "Gets a FunctionType from a list of input and result types");
812 "Returns the list of input types in the FunctionType.");
823 "Returns the list of result types in the FunctionType.");
829 [](
const std::string &dialectNamespace,
const std::string &typeData,
836 nb::arg(
"dialect_namespace"), nb::arg(
"buffer"),
837 nb::arg(
"context") = nb::none(),
838 "Create an unregistered (opaque) dialect type.");
843 return nb::str(stringRef.
data, stringRef.
length);
845 "Returns the dialect namespace for the Opaque type as a string.");
850 return nb::str(stringRef.
data, stringRef.
length);
852 "Returns the data for the Opaque type as a string.");
855static MlirDynamicTypeDefinition
858 size_t dotPos = fullTypeName.find(
'.');
859 if (dotPos == std::string::npos) {
860 throw nb::value_error(
"Expected full type name to be in the format "
861 "'<dialectName>.<typeName>'.");
864 std::string dialectName = fullTypeName.substr(0, dotPos);
865 std::string typeName = fullTypeName.substr(dotPos + 1);
869 throw nb::value_error(
870 (
"Dialect '" + dialectName +
"' is not an extensible dialect.")
875 if (typeDef.ptr ==
nullptr) {
876 throw nb::value_error((
"Dialect '" + dialectName +
877 "' does not contain a type named '" + typeName +
888 [](
const std::string &fullTypeName,
const std::vector<PyAttribute> &attrs,
890 MlirDynamicTypeDefinition typeDef =
893 std::vector<MlirAttribute> mlirAttrs;
894 mlirAttrs.reserve(attrs.size());
895 for (
const auto &attr : attrs)
896 mlirAttrs.push_back(attr.get());
901 nb::arg(
"full_type_name"), nb::arg(
"attributes"),
902 nb::arg(
"context") = nb::none(),
"Create a dynamic type.");
907 std::vector<PyAttribute> params;
908 params.reserve(numParams);
909 for (
size_t i = 0; i < numParams; ++i)
914 "Returns the parameters of the dynamic type as a list of attributes.");
920 return std::string(dialectNamespace.
data, dialectNamespace.
length) +
"." +
921 std::string(
name.data,
name.length);
926 MlirDynamicTypeDefinition typeDef =
930 nb::arg(
"full_type_name"), nb::arg(
"context") = nb::none(),
931 "Look up the TypeID for the given dynamic type name.");
ReferrentTy * get() const
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.
Wrapper around the generic MlirAttribute.
nanobind::typed< nanobind::object, PyAttribute > maybeDownCast()
Floating Point Type subclass - BF16Type.
static void bindDerived(ClassTy &c)
Complex Type subclass - ComplexType.
static void bindDerived(ClassTy &c)
nanobind::class_< PyIntegerType, PyType > ClassTy
static void bind(nanobind::module_ &m)
static const MlirStringRef name
bool(*)(MlirType) IsAFunctionTy
User-level object for accessing dialects with dotted syntax such as: ctx.dialect.std.
MlirDialect getDialectForKey(const std::string &key, bool attrError)
static void bindDerived(ClassTy &c)
Floating Point Type subclass - F16Type.
static void bindDerived(ClassTy &c)
Floating Point Type subclass - F32Type.
static void bindDerived(ClassTy &c)
Floating Point Type subclass - F64Type.
static void bindDerived(ClassTy &c)
Floating Point Type subclass - Float4E2M1FNType.
static void bindDerived(ClassTy &c)
Floating Point Type subclass - Float6E2M3FNType.
static void bindDerived(ClassTy &c)
Floating Point Type subclass - Float6E3M2FNType.
static void bindDerived(ClassTy &c)
Floating Point Type subclass - Float8E3M4Type.
static void bindDerived(ClassTy &c)
Floating Point Type subclass - Float8E4M3B11FNUZ.
static void bindDerived(ClassTy &c)
Floating Point Type subclass - Float8E4M3FNType.
static void bindDerived(ClassTy &c)
Floating Point Type subclass - Float8E4M3FNUZ.
static void bindDerived(ClassTy &c)
Floating Point Type subclass - Float8E4M3Type.
static void bindDerived(ClassTy &c)
Floating Point Type subclass - Float8E5M2FNUZ.
static void bindDerived(ClassTy &c)
Floating Point Type subclass - Float8E5M2Type.
static void bindDerived(ClassTy &c)
Floating Point Type subclass - Float8E5M3FNUType.
static void bindDerived(ClassTy &c)
Floating Point Type subclass - Float8E8M0FNUType.
static void bindDerived(ClassTy &c)
static void bindDerived(ClassTy &c)
static void bindDerived(ClassTy &c)
Index Type subclass - IndexType.
static void bindDerived(ClassTy &c)
static void bindDerived(ClassTy &c)
Ranked MemRef Type subclass - MemRefType.
static void bindDerived(ClassTy &c)
None Type subclass - NoneType.
static void bindDerived(ClassTy &c)
Opaque Type subclass - OpaqueType.
static void bindDerived(ClassTy &c)
Ranked Tensor Type subclass - RankedTensorType.
static void bindDerived(ClassTy &c)
Shaped Type Interface - ShapedType.
static const IsAFunctionTy isaFunction
static void bindDerived(ClassTy &c)
Floating Point Type subclass - TF32Type.
static void bindDerived(ClassTy &c)
Tuple Type subclass - TupleType.
static void bindDerived(ClassTy &c)
A TypeID provides an efficient and unique identifier for a specific C++ type.
Wrapper around the generic MlirType.
PyType(PyMlirContextRef contextRef, MlirType type)
Unranked MemRef Type subclass - UnrankedMemRefType.
static void bindDerived(ClassTy &c)
Unranked Tensor Type subclass - UnrankedTensorType.
static void bindDerived(ClassTy &c)
Vector Type subclass - VectorType.
static void bindDerived(ClassTy &c)
MLIR_CAPI_EXPORTED MlirAttribute mlirAttributeGetNull(void)
Returns an empty attribute.
MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGet(intptr_t rank, const int64_t *shape, MlirType elementType, MlirAttribute encoding)
Creates a tensor type of a fixed rank with the given shape, element type, and optional encoding in th...
MLIR_CAPI_EXPORTED bool mlirIntegerTypeIsSignless(MlirType type)
Checks whether the given integer type is signless.
MLIR_CAPI_EXPORTED MlirAttribute mlirRankedTensorTypeGetEncoding(MlirType type)
Gets the 'encoding' attribute from the ranked tensor type, returning a null attribute if none.
MLIR_CAPI_EXPORTED bool mlirTypeIsAInteger(MlirType type)
Checks whether the given type is an integer type.
MLIR_CAPI_EXPORTED MlirAffineMap mlirMemRefTypeGetAffineMap(MlirType type)
Returns the affine map of the given MemRef type.
MLIR_CAPI_EXPORTED unsigned mlirFloatTypeGetWidth(MlirType type)
Returns the bitwidth of a floating-point type.
MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDimSize(MlirType type, intptr_t dim)
Returns the dim-th dimension of the given ranked shaped type.
MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeGet(MlirContext ctx, unsigned bitwidth)
Creates a signless integer type of the given bitwidth in the context.
MLIR_CAPI_EXPORTED MlirStringRef mlirOpaqueTypeGetData(MlirType type)
Returns the raw data as a string reference.
MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGetInput(MlirType type, intptr_t pos)
Returns the pos-th input type.
MLIR_CAPI_EXPORTED MlirType mlirIndexTypeGet(MlirContext ctx)
Creates an index type in the given context.
MLIR_CAPI_EXPORTED bool mlirShapedTypeIsStaticDim(MlirType type, intptr_t dim)
Checks whether the dim-th dimension of the given shaped type is static.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E3M4TypeGet(MlirContext ctx)
Creates an f8E3M4 type in the given context.
MLIR_CAPI_EXPORTED bool mlirShapedTypeIsStaticStrideOrOffset(int64_t val)
Checks whether the given dimension value of a stride or an offset is statically-sized.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E5M2FNUZTypeGet(MlirContext ctx)
Creates an f8E5M2FNUZ type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E8M0FNUTypeGet(MlirContext ctx)
Creates an f8E8M0FNU type in the given context.
MLIR_CAPI_EXPORTED bool mlirIntegerTypeIsUnsigned(MlirType type)
Checks whether the given integer type is unsigned.
MLIR_CAPI_EXPORTED unsigned mlirIntegerTypeGetWidth(MlirType type)
Returns the bitwidth of an integer type.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E5M2TypeGet(MlirContext ctx)
Creates an f8E5M2 type in the given context.
MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetRank(MlirType type)
Returns the rank of the given ranked shaped type.
MLIR_CAPI_EXPORTED MlirType mlirF64TypeGet(MlirContext ctx)
Creates a f64 type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeSignedGet(MlirContext ctx, unsigned bitwidth)
Creates a signed integer type of the given bitwidth in the context.
MLIR_CAPI_EXPORTED MlirType mlirUnrankedTensorTypeGetChecked(MlirLocation loc, MlirType elementType)
Same as "mlirUnrankedTensorTypeGet" but returns a nullptr wrapping MlirType on illegal arguments,...
MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGetScalableChecked(MlirLocation loc, intptr_t rank, const int64_t *shape, const bool *scalable, MlirType elementType)
Same as "mlirVectorTypeGetScalable" but returns a nullptr wrapping MlirType on illegal arguments,...
MLIR_CAPI_EXPORTED MlirType mlirF16TypeGet(MlirContext ctx)
Creates an f16 type in the given context.
MLIR_CAPI_EXPORTED MlirAttribute mlirMemRefTypeGetMemorySpace(MlirType type)
Returns the memory space of the given MemRef type.
MLIR_CAPI_EXPORTED bool mlirTypeIsAF64(MlirType type)
Checks whether the given type is an f64 type.
MLIR_CAPI_EXPORTED MlirType mlirFloat6E2M3FNTypeGet(MlirContext ctx)
Creates an f6E2M3FN type in the given context.
MLIR_CAPI_EXPORTED bool mlirTypeIsAF16(MlirType type)
Checks whether the given type is an f16 type.
MLIR_CAPI_EXPORTED bool mlirIntegerTypeIsSigned(MlirType type)
Checks whether the given integer type is signed.
MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGetChecked(MlirLocation loc, intptr_t rank, const int64_t *shape, MlirType elementType, MlirAttribute encoding)
Same as "mlirRankedTensorTypeGet" but returns a nullptr wrapping MlirType on illegal arguments,...
MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGetScalable(intptr_t rank, const int64_t *shape, const bool *scalable, MlirType elementType)
Creates a scalable vector type with the shape identified by its rank and dimensions.
MLIR_CAPI_EXPORTED MlirType mlirShapedTypeGetElementType(MlirType type)
Returns the element type of the shaped type.
MLIR_CAPI_EXPORTED intptr_t mlirFunctionTypeGetNumInputs(MlirType type)
Returns the number of input types.
MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGetChecked(MlirLocation loc, intptr_t rank, const int64_t *shape, MlirType elementType)
Same as "mlirVectorTypeGet" but returns a nullptr wrapping MlirType on illegal arguments,...
MLIR_CAPI_EXPORTED MlirType mlirNoneTypeGet(MlirContext ctx)
Creates a None type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirComplexTypeGet(MlirType elementType)
Creates a complex type with the given element type in the same context as the element type.
MLIR_CAPI_EXPORTED MlirStringRef mlirOpaqueTypeGetDialectNamespace(MlirType type)
Returns the namespace of the dialect with which the given opaque type is associated.
MLIR_CAPI_EXPORTED bool mlirShapedTypeHasStaticShape(MlirType type)
Checks whether the given shaped type has a static shape.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3TypeGet(MlirContext ctx)
Creates an f8E4M3 type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirBF16TypeGet(MlirContext ctx)
Creates a bf16 type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirF32TypeGet(MlirContext ctx)
Creates an f32 type in the given context.
MLIR_CAPI_EXPORTED bool mlirShapedTypeHasRank(MlirType type)
Checks whether the given shaped type is ranked.
MLIR_CAPI_EXPORTED MlirLogicalResult mlirMemRefTypeGetStridesAndOffset(MlirType type, int64_t *strides, int64_t *offset)
Returns the strides of the MemRef if the layout map is in strided form.
MLIR_CAPI_EXPORTED bool mlirTypeIsAShaped(MlirType type)
Checks whether the given type is a Shaped type.
MLIR_CAPI_EXPORTED intptr_t mlirTupleTypeGetNumTypes(MlirType type)
Returns the number of types contained in a tuple.
MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGet(intptr_t rank, const int64_t *shape, MlirType elementType)
Creates a vector type of the shape identified by its rank and dimensions, with the given element type...
MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeUnsignedGet(MlirContext ctx, unsigned bitwidth)
Creates an unsigned integer type of the given bitwidth in the context.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3FNTypeGet(MlirContext ctx)
Creates an f8E4M3FN type in the given context.
MLIR_CAPI_EXPORTED bool mlirTypeIsAF32(MlirType type)
Checks whether the given type is an f32 type.
MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGet(MlirContext ctx, intptr_t numInputs, MlirType const *inputs, intptr_t numResults, MlirType const *results)
Creates a function type, mapping a list of input types to result types.
MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicStrideOrOffset(int64_t val)
Checks whether the given value is used as a placeholder for dynamic strides and offsets in shaped typ...
MLIR_CAPI_EXPORTED MlirType mlirTupleTypeGetType(MlirType type, intptr_t pos)
Returns the pos-th type in the tuple type.
MLIR_CAPI_EXPORTED bool mlirVectorTypeIsDimScalable(MlirType type, intptr_t dim)
Checks whether the "dim"-th dimension of the given vector is scalable.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E5M3FNUTypeGet(MlirContext ctx)
Creates an f8E5M3FNU type in the given context.
MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicDim(MlirType type, intptr_t dim)
Checks whether the dim-th dimension of the given shaped type is dynamic.
MLIR_CAPI_EXPORTED MlirType mlirFloat6E3M2FNTypeGet(MlirContext ctx)
Creates an f6E3M2FN type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirUnrankedMemRefTypeGet(MlirType elementType, MlirAttribute memorySpace)
Creates an Unranked MemRef type with the given element type and in the given memory space.
MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGetChecked(MlirLocation loc, MlirType elementType, intptr_t rank, const int64_t *shape, MlirAttribute layout, MlirAttribute memorySpace)
Same as "mlirMemRefTypeGet" but returns a nullptr-wrapping MlirType o illegal arguments,...
MLIR_CAPI_EXPORTED bool mlirTypeIsABF16(MlirType type)
Checks whether the given type is a bf16 type.
MLIR_CAPI_EXPORTED MlirType mlirOpaqueTypeGet(MlirContext ctx, MlirStringRef dialectNamespace, MlirStringRef typeData)
Creates an opaque type in the given context associated with the dialect identified by its namespace.
MLIR_CAPI_EXPORTED intptr_t mlirFunctionTypeGetNumResults(MlirType type)
Returns the number of result types.
MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicSize(int64_t size)
Checks whether the given value is used as a placeholder for dynamic sizes in shaped types.
MLIR_CAPI_EXPORTED MlirType mlirUnrankedMemRefTypeGetChecked(MlirLocation loc, MlirType elementType, MlirAttribute memorySpace)
Same as "mlirUnrankedMemRefTypeGet" but returns a nullptr wrapping MlirType on illegal arguments,...
MLIR_CAPI_EXPORTED bool mlirShapedTypeIsStaticSize(int64_t size)
Checks whether the given shaped type dimension value is statically-sized.
MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGet(MlirType elementType, intptr_t rank, const int64_t *shape, MlirAttribute layout, MlirAttribute memorySpace)
Creates a MemRef type with the given rank and shape, a potentially empty list of affine layout maps,...
MLIR_CAPI_EXPORTED MlirType mlirUnrankedTensorTypeGet(MlirType elementType)
Creates an unranked tensor type with the given element type in the same context as the element type.
MLIR_CAPI_EXPORTED bool mlirVectorTypeIsScalable(MlirType type)
Checks whether the given vector type is scalable, i.e., has at least one scalable dimension.
MLIR_CAPI_EXPORTED MlirType mlirComplexTypeGetElementType(MlirType type)
Returns the element type of the given complex type.
MLIR_CAPI_EXPORTED MlirAttribute mlirUnrankedMemrefGetMemorySpace(MlirType type)
Returns the memory spcae of the given Unranked MemRef type.
MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDynamicStrideOrOffset(void)
Returns the value indicating a dynamic stride or offset in a shaped type.
MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDynamicSize(void)
Returns the value indicating a dynamic size in a shaped type.
MLIR_CAPI_EXPORTED MlirAttribute mlirMemRefTypeGetLayout(MlirType type)
Returns the layout of the given MemRef type.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3B11FNUZTypeGet(MlirContext ctx)
Creates an f8E4M3B11FNUZ type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirTupleTypeGet(MlirContext ctx, intptr_t numElements, MlirType const *elements)
Creates a tuple type that consists of the given list of elemental types.
MLIR_CAPI_EXPORTED MlirType mlirFloat8E4M3FNUZTypeGet(MlirContext ctx)
Creates an f8E4M3FNUZ type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGetResult(MlirType type, intptr_t pos)
Returns the pos-th result type.
MLIR_CAPI_EXPORTED MlirType mlirTF32TypeGet(MlirContext ctx)
Creates a TF32 type in the given context.
MLIR_CAPI_EXPORTED MlirType mlirFloat4E2M1FNTypeGet(MlirContext ctx)
Creates an f4E2M1FN type in the given context.
MLIR_CAPI_EXPORTED MlirDynamicTypeDefinition mlirDynamicTypeGetTypeDef(MlirType type)
Get the type definition of the given dynamic type.
MLIR_CAPI_EXPORTED bool mlirDialectIsAExtensibleDialect(MlirDialect dialect)
Check if the given dialect is an extensible dialect.
MLIR_CAPI_EXPORTED MlirDialect mlirDynamicTypeDefinitionGetDialect(MlirDynamicTypeDefinition typeDef)
Get the dialect that the given dynamic type definition belongs to.
MLIR_CAPI_EXPORTED intptr_t mlirDynamicTypeGetNumParams(MlirType type)
Get the number of parameters in the given dynamic type.
MLIR_CAPI_EXPORTED MlirType mlirDynamicTypeGet(MlirDynamicTypeDefinition typeDef, MlirAttribute *attrs, intptr_t numAttrs)
Get a dynamic type by instantiating the given type definition with the provided attributes.
MLIR_CAPI_EXPORTED MlirDynamicTypeDefinition mlirExtensibleDialectLookupTypeDefinition(MlirDialect dialect, MlirStringRef typeName)
Look up a registered type definition by type name in the given dialect.
MLIR_CAPI_EXPORTED MlirTypeID mlirDynamicTypeDefinitionGetTypeID(MlirDynamicTypeDefinition typeDef)
Get the type ID of a dynamic type definition.
MLIR_CAPI_EXPORTED MlirAttribute mlirDynamicTypeGetParam(MlirType type, intptr_t index)
Get the parameter at the given index in the provided dynamic type.
MLIR_CAPI_EXPORTED MlirStringRef mlirDynamicTypeDefinitionGetName(MlirDynamicTypeDefinition typeDef)
Get the name of the given dynamic type definition.
MLIR_CAPI_EXPORTED MlirStringRef mlirDialectGetNamespace(MlirDialect dialect)
Returns the namespace of the given dialect.
static bool mlirTypeIsNull(MlirType type)
Checks whether a type is null.
static bool mlirLogicalResultIsFailure(MlirLogicalResult res)
Checks if the given logical result represents a failure.
MLIR_PYTHON_API_EXPORTED void populateIRTypes(nanobind::module_ &m)
MLIR_PYTHON_API_EXPORTED int mlirTypeIsAIntegerOrFloat(MlirType type)
MlirStringRef toMlirStringRef(const std::string &s)
static MlirDynamicTypeDefinition getDynamicTypeDef(const std::string &fullTypeName, DefaultingPyMlirContext context)
Include the generated interface declarations.
std::string join(const Ts &...args)
Helper function to concatenate arguments into a std::string.
A pointer to a sized fragment of a string, not necessarily null-terminated.
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.
std::vector< PyDiagnostic::DiagnosticInfo > take()