36 nb::enum_<Signedness>(c,
"Signedness")
48 nb::arg(
"width"), nb::arg(
"context") = nb::none(),
49 "Create a signless integer type");
56 nb::arg(
"width"), nb::arg(
"context") = nb::none(),
57 "Create a signed integer type");
64 nb::arg(
"width"), nb::arg(
"context") = nb::none(),
65 "Create an unsigned integer type");
84 nb::arg(
"width"), nb::arg(
"signedness") =
Signless,
85 nb::arg(
"context") = nb::none(),
"Create an integer type");
96 "Returns the width of the integer type");
102 "Returns whether this is a signless integer");
106 "Returns whether this is a signed integer");
112 "Returns whether this is an unsigned integer");
122 nb::arg(
"context") = nb::none(),
"Create a index type.");
128 "Returns the width of the floating-point type");
138 nb::arg(
"context") = nb::none(),
"Create a float4_e2m1fn type.");
148 nb::arg(
"context") = nb::none(),
"Create a float6_e2m3fn type.");
158 nb::arg(
"context") = nb::none(),
"Create a float6_e3m2fn type.");
168 nb::arg(
"context") = nb::none(),
"Create a float8_e4m3fn type.");
178 nb::arg(
"context") = nb::none(),
"Create a float8_e5m2 type.");
188 nb::arg(
"context") = nb::none(),
"Create a float8_e4m3 type.");
198 nb::arg(
"context") = nb::none(),
"Create a float8_e4m3fnuz type.");
208 nb::arg(
"context") = nb::none(),
"Create a float8_e4m3b11fnuz type.");
218 nb::arg(
"context") = nb::none(),
"Create a float8_e5m2fnuz type.");
228 nb::arg(
"context") = nb::none(),
"Create a float8_e3m4 type.");
238 nb::arg(
"context") = nb::none(),
"Create a float8_e8m0fnu type.");
248 nb::arg(
"context") = nb::none(),
"Create a bf16 type.");
258 nb::arg(
"context") = nb::none(),
"Create a f16 type.");
268 nb::arg(
"context") = nb::none(),
"Create a tf32 type.");
278 nb::arg(
"context") = nb::none(),
"Create a f32 type.");
288 nb::arg(
"context") = nb::none(),
"Create a f64 type.");
298 nb::arg(
"context") = nb::none(),
"Create a none type.");
310 throw nb::value_error(
313 nb::cast<std::string>(nb::repr(nb::cast(elementType))),
314 "' and expected floating point or integer type.")
317 "Create a complex type");
324 "Returns element type.");
331 [](
PyShapedType &self) -> nb::typed<nb::object, PyType> {
335 "Returns the element type of the shaped type.");
339 "Returns whether the given shaped type is ranked.");
343 self.requireHasRank();
346 "Returns the rank of the given ranked shaped type.");
352 "Returns whether the given shaped type has a static shape.");
356 self.requireHasRank();
360 "Returns whether the dim-th dimension of the given shaped type is "
365 self.requireHasRank();
369 "Returns whether the dim-th dimension of the given shaped type is "
374 self.requireHasRank();
378 "Returns the dim-th dimension of the given ranked shaped type.");
383 "Returns whether the given dimension size indicates a dynamic "
389 "Returns whether the given dimension size indicates a static "
392 "is_dynamic_stride_or_offset",
394 self.requireHasRank();
398 "Returns whether the given value is used as a placeholder for dynamic "
399 "strides and offsets in shaped types.");
401 "is_static_stride_or_offset",
403 self.requireHasRank();
407 "Returns whether the given shaped type stride or offset value is "
408 "statically-sized.");
412 self.requireHasRank();
414 std::vector<int64_t>
shape;
417 for (
int64_t i = 0; i < rank; ++i)
421 "Returns the shape of the ranked shaped type as a list of integers.");
424 "Returns the value used to indicate dynamic dimensions in shaped "
427 "get_dynamic_stride_or_offset",
429 "Returns the value used to indicate dynamic strides or offsets in "
433void PyShapedType::requireHasRank() {
435 throw nb::value_error(
436 "calling this method requires that the type has a rank.");
443 c.def_static(
"get", &PyVectorType::getChecked, nb::arg(
"shape"),
444 nb::arg(
"element_type"), nb::kw_only(),
445 nb::arg(
"scalable") = nb::none(),
446 nb::arg(
"scalable_dims") = nb::none(),
447 nb::arg(
"loc") = nb::none(),
"Create a vector type")
448 .def_static(
"get_unchecked", &PyVectorType::get, nb::arg(
"shape"),
449 nb::arg(
"element_type"), nb::kw_only(),
450 nb::arg(
"scalable") = nb::none(),
451 nb::arg(
"scalable_dims") = nb::none(),
452 nb::arg(
"context") = nb::none(),
"Create a vector type")
453 .def_prop_ro(
"scalable",
455 .def_prop_ro(
"scalable_dims", [](
PyType self) {
456 std::vector<bool> scalableDims;
458 scalableDims.reserve(rank);
459 for (
size_t i = 0; i < rank; ++i)
466PyVectorType::getChecked(std::vector<int64_t>
shape,
PyType &elementType,
467 std::optional<nb::list> scalable,
468 std::optional<std::vector<int64_t>> scalableDims,
470 if (scalable && scalableDims) {
471 throw nb::value_error(
"'scalable' and 'scalable_dims' kwargs "
472 "are mutually exclusive.");
478 if (scalable->size() !=
shape.size())
479 throw nb::value_error(
"Expected len(scalable) == len(shape).");
481 std::vector<char> scalableDimFlags;
482 scalableDimFlags.reserve(scalable->size());
483 for (
const nb::handle &h : *scalable) {
484 scalableDimFlags.push_back(nb::cast<bool>(h) ? 1 : 0);
488 reinterpret_cast<const bool *
>(scalableDimFlags.data()), elementType);
489 }
else if (scalableDims) {
490 std::vector<char> scalableDimFlags(
shape.size(), 0);
491 for (
int64_t dim : *scalableDims) {
492 if (
static_cast<size_t>(dim) >= scalableDimFlags.size() || dim < 0)
493 throw nb::value_error(
"Scalable dimension index out of bounds.");
494 scalableDimFlags[dim] = 1;
497 loc, shape.size(), shape.data(),
498 reinterpret_cast<const bool *
>(scalableDimFlags.data()), elementType);
504 throw MLIRError(
"Invalid type", errors.take());
505 return PyVectorType(elementType.
getContext(), type);
509 std::optional<nb::list> scalable,
510 std::optional<std::vector<int64_t>> scalableDims,
512 if (scalable && scalableDims) {
513 throw nb::value_error(
"'scalable' and 'scalable_dims' kwargs "
514 "are mutually exclusive.");
517 PyMlirContext::ErrorCapture errors(context->getRef());
520 if (scalable->size() != shape.size())
521 throw nb::value_error(
"Expected len(scalable) == len(shape).");
523 std::vector<char> scalableDimFlags;
524 scalableDimFlags.reserve(scalable->size());
525 for (
const nb::handle &h : *scalable) {
526 scalableDimFlags.push_back(nb::cast<bool>(h) ? 1 : 0);
529 shape.size(), shape.data(),
530 reinterpret_cast<const bool *
>(scalableDimFlags.data()), elementType);
531 }
else if (scalableDims) {
532 std::vector<char> scalableDimFlags(shape.size(), 0);
533 for (int64_t dim : *scalableDims) {
534 if (
static_cast<size_t>(dim) >= scalableDimFlags.size() || dim < 0)
535 throw nb::value_error(
"Scalable dimension index out of bounds.");
536 scalableDimFlags[dim] = 1;
539 shape.size(), shape.data(),
540 reinterpret_cast<const bool *
>(scalableDimFlags.data()), elementType);
545 throw MLIRError(
"Invalid type", errors.take());
546 return PyVectorType(elementType.
getContext(), type);
552 [](std::vector<int64_t>
shape,
PyType &elementType,
562 nb::arg(
"shape"), nb::arg(
"element_type"),
563 nb::arg(
"encoding") = nb::none(), nb::arg(
"loc") = nb::none(),
564 "Create a ranked tensor type");
567 [](std::vector<int64_t>
shape,
PyType &elementType,
568 std::optional<PyAttribute> &encodingAttr,
578 nb::arg(
"shape"), nb::arg(
"element_type"),
579 nb::arg(
"encoding") = nb::none(), nb::arg(
"context") = nb::none(),
580 "Create a ranked tensor type");
584 -> std::optional<nb::typed<nb::object, PyAttribute>> {
586 if (mlirAttributeIsNull(encoding))
602 nb::arg(
"element_type"), nb::arg(
"loc") = nb::none(),
603 "Create a unranked tensor type");
613 nb::arg(
"element_type"), nb::arg(
"context") = nb::none(),
614 "Create a unranked tensor type");
624 MlirAttribute memSpaceAttr =
628 shape.data(), layoutAttr, memSpaceAttr);
633 nb::arg(
"shape"), nb::arg(
"element_type"),
634 nb::arg(
"layout") = nb::none(), nb::arg(
"memory_space") = nb::none(),
635 nb::arg(
"loc") = nb::none(),
"Create a memref type")
638 [](std::vector<int64_t>
shape,
PyType &elementType,
642 MlirAttribute layoutAttr =
644 MlirAttribute memSpaceAttr =
648 layoutAttr, memSpaceAttr);
653 nb::arg(
"shape"), nb::arg(
"element_type"),
654 nb::arg(
"layout") = nb::none(), nb::arg(
"memory_space") = nb::none(),
655 nb::arg(
"context") = nb::none(),
"Create a memref type")
658 [](
PyMemRefType &self) -> nb::typed<nb::object, PyAttribute> {
662 "The layout of the MemRef type.")
664 "get_strides_and_offset",
669 self, strides.data(), &offset)))
670 throw std::runtime_error(
671 "Failed to extract strides and offset from memref.");
672 return {strides, offset};
674 "The strides and offset of the MemRef type.")
681 "The layout of the MemRef type as an affine map.")
685 -> std::optional<nb::typed<nb::object, PyAttribute>> {
687 if (mlirAttributeIsNull(a))
691 "Returns the memory space of the given MemRef type.");
700 MlirAttribute memSpaceAttr = {};
702 memSpaceAttr = *memorySpace;
710 nb::arg(
"element_type"), nb::arg(
"memory_space").none(),
711 nb::arg(
"loc") = nb::none(),
"Create a unranked memref type")
717 MlirAttribute memSpaceAttr = {};
719 memSpaceAttr = *memorySpace;
726 nb::arg(
"element_type"), nb::arg(
"memory_space").none(),
727 nb::arg(
"context") = nb::none(),
"Create a unranked memref type")
731 -> std::optional<nb::typed<nb::object, PyAttribute>> {
733 if (mlirAttributeIsNull(a))
737 "Returns the memory space of the given Unranked MemRef type.");
744 std::vector<MlirType> mlirElements;
745 mlirElements.reserve(elements.size());
746 for (
const auto &element : elements)
747 mlirElements.push_back(element.get());
749 mlirElements.data());
752 nb::arg(
"elements"), nb::arg(
"context") = nb::none(),
753 "Create a tuple type");
757 std::vector<MlirType> elements_(elements.size());
758 std::copy(elements.begin(), elements.end(), elements_.begin());
763 nb::arg(
"elements"), nb::arg(
"context") = nb::none(),
765 nb::sig(
"def get_tuple(elements: Sequence[Type], context: Context | None = None) -> TupleType"),
767 "Create a tuple type");
774 nb::arg(
"pos"),
"Returns the pos-th type in the tuple type.");
780 "Returns the number of types contained in a tuple.");
786 [](std::vector<PyType> inputs, std::vector<PyType> results,
788 std::vector<MlirType> mlirInputs;
789 mlirInputs.reserve(inputs.size());
790 for (
const auto &input : inputs)
791 mlirInputs.push_back(input.get());
792 std::vector<MlirType> mlirResults;
793 mlirResults.reserve(results.size());
794 for (
const auto &
result : results)
795 mlirResults.push_back(
result.get());
798 mlirInputs.data(), results.size(),
802 nb::arg(
"inputs"), nb::arg(
"results"), nb::arg(
"context") = nb::none(),
803 "Gets a FunctionType from a list of input and result types");
806 [](std::vector<PyType> inputs, std::vector<PyType> results,
808 std::vector<MlirType> inputs_(inputs.size());
809 std::copy(inputs.begin(), inputs.end(), inputs_.begin());
810 std::vector<MlirType> results_(results.size());
811 std::copy(results.begin(), results.end(), results_.begin());
814 results_.size(), results_.data());
817 nb::arg(
"inputs"), nb::arg(
"results"), nb::arg(
"context") = nb::none(),
819 nb::sig(
"def get(inputs: Sequence[Type], results: Sequence[Type], context: Context | None = None) -> FunctionType"),
821 "Gets a FunctionType from a list of input and result types");
833 "Returns the list of input types in the FunctionType.");
844 "Returns the list of result types in the FunctionType.");
850 [](
const std::string &dialectNamespace,
const std::string &typeData,
857 nb::arg(
"dialect_namespace"), nb::arg(
"buffer"),
858 nb::arg(
"context") = nb::none(),
859 "Create an unregistered (opaque) dialect type.");
864 return nb::str(stringRef.
data, stringRef.
length);
866 "Returns the dialect namespace for the Opaque type as a string.");
871 return nb::str(stringRef.
data, stringRef.
length);
873 "Returns the data for the Opaque type as a string.");
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)
bool(*)(MlirType) IsAFunctionTy
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)
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.
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)
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()