38 nb::enum_<Signedness>(c,
"Signedness")
50 nb::arg(
"width"), nb::arg(
"context") = nb::none(),
51 "Create a signless integer type");
58 nb::arg(
"width"), nb::arg(
"context") = nb::none(),
59 "Create a signed integer type");
66 nb::arg(
"width"), nb::arg(
"context") = nb::none(),
67 "Create an unsigned integer type");
86 nb::arg(
"width"), nb::arg(
"signedness") =
Signless,
87 nb::arg(
"context") = nb::none(),
"Create an integer type");
98 "Returns the width of the integer type");
104 "Returns whether this is a signless integer");
108 "Returns whether this is a signed integer");
114 "Returns whether this is an unsigned integer");
124 nb::arg(
"context") = nb::none(),
"Create a index type.");
130 "Returns the width of the floating-point type");
140 nb::arg(
"context") = nb::none(),
"Create a float4_e2m1fn type.");
150 nb::arg(
"context") = nb::none(),
"Create a float6_e2m3fn type.");
160 nb::arg(
"context") = nb::none(),
"Create a float6_e3m2fn type.");
170 nb::arg(
"context") = nb::none(),
"Create a float8_e4m3fn type.");
180 nb::arg(
"context") = nb::none(),
"Create a float8_e5m2 type.");
190 nb::arg(
"context") = nb::none(),
"Create a float8_e4m3 type.");
200 nb::arg(
"context") = nb::none(),
"Create a float8_e4m3fnuz type.");
210 nb::arg(
"context") = nb::none(),
"Create a float8_e4m3b11fnuz type.");
220 nb::arg(
"context") = nb::none(),
"Create a float8_e5m2fnuz type.");
230 nb::arg(
"context") = nb::none(),
"Create a float8_e3m4 type.");
240 nb::arg(
"context") = nb::none(),
"Create a float8_e8m0fnu type.");
250 nb::arg(
"context") = nb::none(),
"Create a bf16 type.");
260 nb::arg(
"context") = nb::none(),
"Create a f16 type.");
270 nb::arg(
"context") = nb::none(),
"Create a tf32 type.");
280 nb::arg(
"context") = nb::none(),
"Create a f32 type.");
290 nb::arg(
"context") = nb::none(),
"Create a f64 type.");
300 nb::arg(
"context") = nb::none(),
"Create a none type.");
312 throw nb::value_error(
313 (Twine(
"invalid '") +
314 nb::cast<std::string>(nb::repr(nb::cast(elementType))) +
315 "' and expected floating point or integer type.")
319 "Create a complex type");
326 "Returns element type.");
333 [](
PyShapedType &self) -> nb::typed<nb::object, PyType> {
337 "Returns the element type of the shaped type.");
341 "Returns whether the given shaped type is ranked.");
345 self.requireHasRank();
348 "Returns the rank of the given ranked shaped type.");
354 "Returns whether the given shaped type has a static shape.");
358 self.requireHasRank();
362 "Returns whether the dim-th dimension of the given shaped type is "
367 self.requireHasRank();
371 "Returns whether the dim-th dimension of the given shaped type is "
376 self.requireHasRank();
380 "Returns the dim-th dimension of the given ranked shaped type.");
385 "Returns whether the given dimension size indicates a dynamic "
391 "Returns whether the given dimension size indicates a static "
394 "is_dynamic_stride_or_offset",
396 self.requireHasRank();
400 "Returns whether the given value is used as a placeholder for dynamic "
401 "strides and offsets in shaped types.");
403 "is_static_stride_or_offset",
405 self.requireHasRank();
409 "Returns whether the given shaped type stride or offset value is "
410 "statically-sized.");
414 self.requireHasRank();
416 std::vector<int64_t>
shape;
419 for (
int64_t i = 0; i < rank; ++i)
423 "Returns the shape of the ranked shaped type as a list of integers.");
426 "Returns the value used to indicate dynamic dimensions in shaped "
429 "get_dynamic_stride_or_offset",
431 "Returns the value used to indicate dynamic strides or offsets in "
435void PyShapedType::requireHasRank() {
437 throw nb::value_error(
438 "calling this method requires that the type has a rank.");
445 c.def_static(
"get", &PyVectorType::getChecked, nb::arg(
"shape"),
446 nb::arg(
"element_type"), nb::kw_only(),
447 nb::arg(
"scalable") = nb::none(),
448 nb::arg(
"scalable_dims") = nb::none(),
449 nb::arg(
"loc") = nb::none(),
"Create a vector type")
450 .def_static(
"get_unchecked", &PyVectorType::get, nb::arg(
"shape"),
451 nb::arg(
"element_type"), nb::kw_only(),
452 nb::arg(
"scalable") = nb::none(),
453 nb::arg(
"scalable_dims") = nb::none(),
454 nb::arg(
"context") = nb::none(),
"Create a vector type")
455 .def_prop_ro(
"scalable",
457 .def_prop_ro(
"scalable_dims", [](
PyType self) {
458 std::vector<bool> scalableDims;
460 scalableDims.reserve(rank);
461 for (
size_t i = 0; i < rank; ++i)
468PyVectorType::getChecked(std::vector<int64_t>
shape,
PyType &elementType,
469 std::optional<nb::list> scalable,
470 std::optional<std::vector<int64_t>> scalableDims,
472 if (scalable && scalableDims) {
473 throw nb::value_error(
"'scalable' and 'scalable_dims' kwargs "
474 "are mutually exclusive.");
480 if (scalable->size() !=
shape.size())
481 throw nb::value_error(
"Expected len(scalable) == len(shape).");
484 *scalable, [](
const nb::handle &h) {
return nb::cast<bool>(h); }));
486 loc,
shape.size(),
shape.data(), scalableDimFlags.data(), elementType);
487 }
else if (scalableDims) {
489 for (
int64_t dim : *scalableDims) {
490 if (
static_cast<size_t>(dim) >= scalableDimFlags.size() || dim < 0)
491 throw nb::value_error(
"Scalable dimension index out of bounds.");
492 scalableDimFlags[dim] =
true;
495 loc, shape.size(), shape.data(), scalableDimFlags.data(), elementType);
501 throw MLIRError(
"Invalid type", errors.take());
502 return PyVectorType(elementType.
getContext(), type);
506 std::optional<nb::list> scalable,
507 std::optional<std::vector<int64_t>> scalableDims,
509 if (scalable && scalableDims) {
510 throw nb::value_error(
"'scalable' and 'scalable_dims' kwargs "
511 "are mutually exclusive.");
514 PyMlirContext::ErrorCapture errors(context->getRef());
517 if (scalable->size() != shape.size())
518 throw nb::value_error(
"Expected len(scalable) == len(shape).");
520 SmallVector<bool> scalableDimFlags = llvm::to_vector(llvm::map_range(
521 *scalable, [](
const nb::handle &h) {
return nb::cast<bool>(h); }));
523 scalableDimFlags.data(), elementType);
524 }
else if (scalableDims) {
525 SmallVector<bool> scalableDimFlags(shape.size(),
false);
526 for (int64_t dim : *scalableDims) {
527 if (
static_cast<size_t>(dim) >= scalableDimFlags.size() || dim < 0)
528 throw nb::value_error(
"Scalable dimension index out of bounds.");
529 scalableDimFlags[dim] =
true;
532 scalableDimFlags.data(), elementType);
537 throw MLIRError(
"Invalid type", errors.take());
538 return PyVectorType(elementType.
getContext(), type);
544 [](std::vector<int64_t>
shape,
PyType &elementType,
554 nb::arg(
"shape"), nb::arg(
"element_type"),
555 nb::arg(
"encoding") = nb::none(), nb::arg(
"loc") = nb::none(),
556 "Create a ranked tensor type");
559 [](std::vector<int64_t>
shape,
PyType &elementType,
560 std::optional<PyAttribute> &encodingAttr,
570 nb::arg(
"shape"), nb::arg(
"element_type"),
571 nb::arg(
"encoding") = nb::none(), nb::arg(
"context") = nb::none(),
572 "Create a ranked tensor type");
576 -> std::optional<nb::typed<nb::object, PyAttribute>> {
578 if (mlirAttributeIsNull(encoding))
594 nb::arg(
"element_type"), nb::arg(
"loc") = nb::none(),
595 "Create a unranked tensor type");
605 nb::arg(
"element_type"), nb::arg(
"context") = nb::none(),
606 "Create a unranked tensor type");
616 MlirAttribute memSpaceAttr =
620 shape.data(), layoutAttr, memSpaceAttr);
625 nb::arg(
"shape"), nb::arg(
"element_type"),
626 nb::arg(
"layout") = nb::none(), nb::arg(
"memory_space") = nb::none(),
627 nb::arg(
"loc") = nb::none(),
"Create a memref type")
630 [](std::vector<int64_t>
shape,
PyType &elementType,
634 MlirAttribute layoutAttr =
636 MlirAttribute memSpaceAttr =
640 layoutAttr, memSpaceAttr);
645 nb::arg(
"shape"), nb::arg(
"element_type"),
646 nb::arg(
"layout") = nb::none(), nb::arg(
"memory_space") = nb::none(),
647 nb::arg(
"context") = nb::none(),
"Create a memref type")
650 [](
PyMemRefType &self) -> nb::typed<nb::object, PyAttribute> {
654 "The layout of the MemRef type.")
656 "get_strides_and_offset",
661 self, strides.data(), &offset)))
662 throw std::runtime_error(
663 "Failed to extract strides and offset from memref.");
664 return {strides, offset};
666 "The strides and offset of the MemRef type.")
673 "The layout of the MemRef type as an affine map.")
677 -> std::optional<nb::typed<nb::object, PyAttribute>> {
679 if (mlirAttributeIsNull(a))
683 "Returns the memory space of the given MemRef type.");
692 MlirAttribute memSpaceAttr = {};
694 memSpaceAttr = *memorySpace;
702 nb::arg(
"element_type"), nb::arg(
"memory_space").none(),
703 nb::arg(
"loc") = nb::none(),
"Create a unranked memref type")
709 MlirAttribute memSpaceAttr = {};
711 memSpaceAttr = *memorySpace;
718 nb::arg(
"element_type"), nb::arg(
"memory_space").none(),
719 nb::arg(
"context") = nb::none(),
"Create a unranked memref type")
723 -> std::optional<nb::typed<nb::object, PyAttribute>> {
725 if (mlirAttributeIsNull(a))
729 "Returns the memory space of the given Unranked MemRef type.");
736 std::vector<MlirType> mlirElements;
737 mlirElements.reserve(elements.size());
738 for (
const auto &element : elements)
739 mlirElements.push_back(element.get());
741 mlirElements.data());
744 nb::arg(
"elements"), nb::arg(
"context") = nb::none(),
745 "Create a tuple type");
749 std::vector<MlirType> elements_(elements.size());
750 std::copy(elements.begin(), elements.end(), elements_.begin());
755 nb::arg(
"elements"), nb::arg(
"context") = nb::none(),
757 nb::sig(
"def get_tuple(elements: Sequence[Type], context: Context | None = None) -> TupleType"),
759 "Create a tuple type");
766 nb::arg(
"pos"),
"Returns the pos-th type in the tuple type.");
772 "Returns the number of types contained in a tuple.");
778 [](std::vector<PyType> inputs, std::vector<PyType> results,
780 std::vector<MlirType> mlirInputs;
781 mlirInputs.reserve(inputs.size());
782 for (
const auto &input : inputs)
783 mlirInputs.push_back(input.get());
784 std::vector<MlirType> mlirResults;
785 mlirResults.reserve(results.size());
786 for (
const auto &
result : results)
787 mlirResults.push_back(
result.get());
790 mlirInputs.data(), results.size(),
794 nb::arg(
"inputs"), nb::arg(
"results"), nb::arg(
"context") = nb::none(),
795 "Gets a FunctionType from a list of input and result types");
798 [](std::vector<PyType> inputs, std::vector<PyType> results,
800 std::vector<MlirType> inputs_(inputs.size());
801 std::copy(inputs.begin(), inputs.end(), inputs_.begin());
802 std::vector<MlirType> results_(results.size());
803 std::copy(results.begin(), results.end(), results_.begin());
806 results_.size(), results_.data());
809 nb::arg(
"inputs"), nb::arg(
"results"), nb::arg(
"context") = nb::none(),
811 nb::sig(
"def get(inputs: Sequence[Type], results: Sequence[Type], context: Context | None = None) -> FunctionType"),
813 "Gets a FunctionType from a list of input and result types");
825 "Returns the list of input types in the FunctionType.");
836 "Returns the list of result types in the FunctionType.");
842 [](
const std::string &dialectNamespace,
const std::string &typeData,
849 nb::arg(
"dialect_namespace"), nb::arg(
"buffer"),
850 nb::arg(
"context") = nb::none(),
851 "Create an unregistered (opaque) dialect type.");
856 return nb::str(stringRef.
data, stringRef.
length);
858 "Returns the dialect namespace for the Opaque type as a string.");
863 return nb::str(stringRef.
data, stringRef.
length);
865 "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.
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()