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 bf16 type.");
259 nb::arg(
"context") = nb::none(),
"Create a f16 type.");
269 nb::arg(
"context") = nb::none(),
"Create a tf32 type.");
279 nb::arg(
"context") = nb::none(),
"Create a f32 type.");
289 nb::arg(
"context") = nb::none(),
"Create a f64 type.");
299 nb::arg(
"context") = nb::none(),
"Create a none type.");
311 throw nb::value_error(
314 nb::cast<std::string>(nb::repr(nb::cast(elementType))),
315 "' and expected floating point or integer type.")
318 "Create a complex type");
325 "Returns element type.");
332 [](
PyShapedType &self) -> nb::typed<nb::object, PyType> {
336 "Returns the element type of the shaped type.");
340 "Returns whether the given shaped type is ranked.");
344 self.requireHasRank();
347 "Returns the rank of the given ranked shaped type.");
353 "Returns whether the given shaped type has a static shape.");
357 self.requireHasRank();
361 "Returns whether the dim-th dimension of the given shaped type is "
366 self.requireHasRank();
370 "Returns whether the dim-th dimension of the given shaped type is "
375 self.requireHasRank();
379 "Returns the dim-th dimension of the given ranked shaped type.");
384 "Returns whether the given dimension size indicates a dynamic "
390 "Returns whether the given dimension size indicates a static "
393 "is_dynamic_stride_or_offset",
395 self.requireHasRank();
399 "Returns whether the given value is used as a placeholder for dynamic "
400 "strides and offsets in shaped types.");
402 "is_static_stride_or_offset",
404 self.requireHasRank();
408 "Returns whether the given shaped type stride or offset value is "
409 "statically-sized.");
413 self.requireHasRank();
415 std::vector<int64_t>
shape;
418 for (
int64_t i = 0; i < rank; ++i)
422 "Returns the shape of the ranked shaped type as a list of integers.");
425 "Returns the value used to indicate dynamic dimensions in shaped "
428 "get_dynamic_stride_or_offset",
430 "Returns the value used to indicate dynamic strides or offsets in "
434void PyShapedType::requireHasRank() {
436 throw nb::value_error(
437 "calling this method requires that the type has a rank.");
444 c.def_static(
"get", &PyVectorType::getChecked, nb::arg(
"shape"),
445 nb::arg(
"element_type"), nb::kw_only(),
446 nb::arg(
"scalable") = nb::none(),
447 nb::arg(
"scalable_dims") = nb::none(),
448 nb::arg(
"loc") = nb::none(),
"Create a vector type")
449 .def_static(
"get_unchecked", &PyVectorType::get, nb::arg(
"shape"),
450 nb::arg(
"element_type"), nb::kw_only(),
451 nb::arg(
"scalable") = nb::none(),
452 nb::arg(
"scalable_dims") = nb::none(),
453 nb::arg(
"context") = nb::none(),
"Create a vector type")
454 .def_prop_ro(
"scalable",
456 .def_prop_ro(
"scalable_dims", [](
PyType self) {
457 std::vector<bool> scalableDims;
459 scalableDims.reserve(rank);
460 for (
size_t i = 0; i < rank; ++i)
467PyVectorType::getChecked(std::vector<int64_t>
shape,
PyType &elementType,
468 std::optional<nb::list> scalable,
469 std::optional<std::vector<int64_t>> scalableDims,
471 if (scalable && scalableDims) {
472 throw nb::value_error(
"'scalable' and 'scalable_dims' kwargs "
473 "are mutually exclusive.");
479 if (scalable->size() !=
shape.size())
480 throw nb::value_error(
"Expected len(scalable) == len(shape).");
482 std::vector<char> scalableDimFlags;
483 scalableDimFlags.reserve(scalable->size());
484 for (
const nb::handle &h : *scalable) {
485 scalableDimFlags.push_back(nb::cast<bool>(h) ? 1 : 0);
489 reinterpret_cast<const bool *
>(scalableDimFlags.data()), elementType);
490 }
else if (scalableDims) {
491 std::vector<char> scalableDimFlags(
shape.size(), 0);
492 for (
int64_t dim : *scalableDims) {
493 if (
static_cast<size_t>(dim) >= scalableDimFlags.size() || dim < 0)
494 throw nb::value_error(
"Scalable dimension index out of bounds.");
495 scalableDimFlags[dim] = 1;
498 loc, shape.size(), shape.data(),
499 reinterpret_cast<const bool *
>(scalableDimFlags.data()), elementType);
505 throw MLIRError(
"Invalid type", errors.take());
506 return PyVectorType(elementType.
getContext(), type);
510 std::optional<nb::list> scalable,
511 std::optional<std::vector<int64_t>> scalableDims,
513 if (scalable && scalableDims) {
514 throw nb::value_error(
"'scalable' and 'scalable_dims' kwargs "
515 "are mutually exclusive.");
518 PyMlirContext::ErrorCapture errors(context->getRef());
521 if (scalable->size() != shape.size())
522 throw nb::value_error(
"Expected len(scalable) == len(shape).");
524 std::vector<char> scalableDimFlags;
525 scalableDimFlags.reserve(scalable->size());
526 for (
const nb::handle &h : *scalable) {
527 scalableDimFlags.push_back(nb::cast<bool>(h) ? 1 : 0);
530 shape.size(), shape.data(),
531 reinterpret_cast<const bool *
>(scalableDimFlags.data()), elementType);
532 }
else if (scalableDims) {
533 std::vector<char> scalableDimFlags(shape.size(), 0);
534 for (int64_t dim : *scalableDims) {
535 if (
static_cast<size_t>(dim) >= scalableDimFlags.size() || dim < 0)
536 throw nb::value_error(
"Scalable dimension index out of bounds.");
537 scalableDimFlags[dim] = 1;
540 shape.size(), shape.data(),
541 reinterpret_cast<const bool *
>(scalableDimFlags.data()), elementType);
546 throw MLIRError(
"Invalid type", errors.take());
547 return PyVectorType(elementType.
getContext(), type);
553 [](std::vector<int64_t>
shape,
PyType &elementType,
563 nb::arg(
"shape"), nb::arg(
"element_type"),
564 nb::arg(
"encoding") = nb::none(), nb::arg(
"loc") = nb::none(),
565 "Create a ranked tensor type");
568 [](std::vector<int64_t>
shape,
PyType &elementType,
569 std::optional<PyAttribute> &encodingAttr,
579 nb::arg(
"shape"), nb::arg(
"element_type"),
580 nb::arg(
"encoding") = nb::none(), nb::arg(
"context") = nb::none(),
581 "Create a ranked tensor type");
585 -> std::optional<nb::typed<nb::object, PyAttribute>> {
587 if (mlirAttributeIsNull(encoding))
603 nb::arg(
"element_type"), nb::arg(
"loc") = nb::none(),
604 "Create a unranked tensor type");
614 nb::arg(
"element_type"), nb::arg(
"context") = nb::none(),
615 "Create a unranked tensor type");
625 MlirAttribute memSpaceAttr =
629 shape.data(), layoutAttr, memSpaceAttr);
634 nb::arg(
"shape"), nb::arg(
"element_type"),
635 nb::arg(
"layout") = nb::none(), nb::arg(
"memory_space") = nb::none(),
636 nb::arg(
"loc") = nb::none(),
"Create a memref type")
639 [](std::vector<int64_t>
shape,
PyType &elementType,
643 MlirAttribute layoutAttr =
645 MlirAttribute memSpaceAttr =
649 layoutAttr, memSpaceAttr);
654 nb::arg(
"shape"), nb::arg(
"element_type"),
655 nb::arg(
"layout") = nb::none(), nb::arg(
"memory_space") = nb::none(),
656 nb::arg(
"context") = nb::none(),
"Create a memref type")
659 [](
PyMemRefType &self) -> nb::typed<nb::object, PyAttribute> {
663 "The layout of the MemRef type.")
665 "get_strides_and_offset",
670 self, strides.data(), &offset)))
671 throw std::runtime_error(
672 "Failed to extract strides and offset from memref.");
673 return {strides, offset};
675 "The strides and offset of the MemRef type.")
682 "The layout of the MemRef type as an affine map.")
686 -> std::optional<nb::typed<nb::object, PyAttribute>> {
688 if (mlirAttributeIsNull(a))
692 "Returns the memory space of the given MemRef type.");
701 MlirAttribute memSpaceAttr = {};
703 memSpaceAttr = *memorySpace;
711 nb::arg(
"element_type"), nb::arg(
"memory_space").none(),
712 nb::arg(
"loc") = nb::none(),
"Create a unranked memref type")
718 MlirAttribute memSpaceAttr = {};
720 memSpaceAttr = *memorySpace;
727 nb::arg(
"element_type"), nb::arg(
"memory_space").none(),
728 nb::arg(
"context") = nb::none(),
"Create a unranked memref type")
732 -> std::optional<nb::typed<nb::object, PyAttribute>> {
734 if (mlirAttributeIsNull(a))
738 "Returns the memory space of the given Unranked MemRef type.");
745 std::vector<MlirType> mlirElements;
746 mlirElements.reserve(elements.size());
747 for (
const auto &element : elements)
748 mlirElements.push_back(element.get());
750 mlirElements.data());
753 nb::arg(
"elements"), nb::arg(
"context") = nb::none(),
754 "Create a tuple type");
761 nb::arg(
"pos"),
"Returns the pos-th type in the tuple type.");
767 "Returns the number of types contained in a tuple.");
773 [](std::vector<PyType> inputs, std::vector<PyType> results,
775 std::vector<MlirType> mlirInputs;
776 mlirInputs.reserve(inputs.size());
777 for (
const auto &input : inputs)
778 mlirInputs.push_back(input.get());
779 std::vector<MlirType> mlirResults;
780 mlirResults.reserve(results.size());
781 for (
const auto &
result : results)
782 mlirResults.push_back(
result.get());
785 mlirInputs.data(), results.size(),
789 nb::arg(
"inputs"), nb::arg(
"results"), nb::arg(
"context") = nb::none(),
790 "Gets a FunctionType from a list of input and result types");
802 "Returns the list of input types in the FunctionType.");
813 "Returns the list of result types in the FunctionType.");
819 [](
const std::string &dialectNamespace,
const std::string &typeData,
826 nb::arg(
"dialect_namespace"), nb::arg(
"buffer"),
827 nb::arg(
"context") = nb::none(),
828 "Create an unregistered (opaque) dialect type.");
833 return nb::str(stringRef.
data, stringRef.
length);
835 "Returns the dialect namespace for the Opaque type as a string.");
840 return nb::str(stringRef.
data, stringRef.
length);
842 "Returns the data for the Opaque type as a string.");
845static MlirDynamicTypeDefinition
848 size_t dotPos = fullTypeName.find(
'.');
849 if (dotPos == std::string::npos) {
850 throw nb::value_error(
"Expected full type name to be in the format "
851 "'<dialectName>.<typeName>'.");
854 std::string dialectName = fullTypeName.substr(0, dotPos);
855 std::string typeName = fullTypeName.substr(dotPos + 1);
859 throw nb::value_error(
860 (
"Dialect '" + dialectName +
"' is not an extensible dialect.")
865 if (typeDef.ptr ==
nullptr) {
866 throw nb::value_error((
"Dialect '" + dialectName +
867 "' does not contain a type named '" + typeName +
878 [](
const std::string &fullTypeName,
const std::vector<PyAttribute> &attrs,
880 MlirDynamicTypeDefinition typeDef =
883 std::vector<MlirAttribute> mlirAttrs;
884 mlirAttrs.reserve(attrs.size());
885 for (
const auto &attr : attrs)
886 mlirAttrs.push_back(attr.get());
891 nb::arg(
"full_type_name"), nb::arg(
"attributes"),
892 nb::arg(
"context") = nb::none(),
"Create a dynamic type.");
897 std::vector<PyAttribute> params;
898 params.reserve(numParams);
899 for (
size_t i = 0; i < numParams; ++i)
904 "Returns the parameters of the dynamic type as a list of attributes.");
910 return std::string(dialectNamespace.
data, dialectNamespace.
length) +
"." +
911 std::string(
name.data,
name.length);
916 MlirDynamicTypeDefinition typeDef =
920 nb::arg(
"full_type_name"), nb::arg(
"context") = nb::none(),
921 "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 - 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 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()