28 R
"(Given the arguments required to build an operation, attempts to infer
29its return types. Raises ValueError on failure.)";
32 R
"(Given the arguments required to build an operation, attempts to infer
33its return shaped type components. Raises ValueError on failure.)";
37MlirAttribute unwrapOptionalAttribute(
const nb::object &attribute) {
38 if (attribute.is_none())
42 if (!nb::try_cast<PyAttribute *>(attribute, pyAttribute) || !pyAttribute)
43 throw nb::type_error(
"parameters must be an Attribute or None");
44 return pyAttribute->
get();
47MlirMemoryEffectInstance createMemoryEffectInstance(
49 const nb::object ¶meters,
int stage,
bool effectOnFullRegion,
51 MlirAttribute unwrappedParameters = unwrapOptionalAttribute(parameters);
53 MlirMemoryEffectInstance rawInstance{
nullptr};
57 effectOnFullRegion, resource.
get());
62 if (nb::try_cast<PyOpOperand *>(
target, opOperand) && opOperand) {
64 effect.
get(), *opOperand, unwrappedParameters, stage,
65 effectOnFullRegion, resource.
get());
66 }
else if (nb::try_cast<PyValue *>(
target, value) && value) {
67 MlirValue mlirValue = value->
get();
70 effect.
get(), mlirValue, unwrappedParameters, stage,
71 effectOnFullRegion, resource.
get());
74 effect.
get(), mlirValue, unwrappedParameters, stage,
75 effectOnFullRegion, resource.
get());
78 "target Value must be an OpResult or BlockArgument");
80 }
else if (nb::try_cast<PyAttribute *>(
target, attribute) && attribute) {
81 MlirAttribute symbol = attribute->
get();
83 throw nb::type_error(
"target Attribute must be a SymbolRefAttr");
85 effect.
get(), symbol, unwrappedParameters, stage, effectOnFullRegion,
89 "target must be an OpOperand, OpResult, BlockArgument, "
90 "SymbolRefAttr, or None");
98std::vector<MlirValue> wrapOperands(std::optional<nb::sequence> operandList) {
99 std::vector<MlirValue> mlirOperands;
101 if (!operandList || nb::len(*operandList) == 0) {
106 mlirOperands.reserve(nb::len(*operandList));
107 for (
size_t i = 0, e = nb::len(*operandList); i < e; ++i) {
108 nb::handle operand = (*operandList)[i];
110 if (operand.is_none())
115 val = nb::cast<PyValue *>(operand);
117 throw nb::cast_error();
118 mlirOperands.push_back(val->
get());
120 }
catch (nb::cast_error &err) {
126 auto vals = nb::cast<nb::sequence>(operand);
127 for (nb::handle v : vals) {
129 val = nb::cast<PyValue *>(v);
131 throw nb::cast_error();
132 mlirOperands.push_back(val->
get());
133 }
catch (nb::cast_error &err) {
134 throw nb::value_error(
136 " must be a Value or Sequence of Values (",
142 }
catch (nb::cast_error &err) {
143 throw nb::value_error(
145 " must be a Value or Sequence of Values (",
150 throw nb::cast_error();
158std::vector<MlirRegion>
159wrapRegions(std::optional<std::vector<PyRegion>> regions) {
160 std::vector<MlirRegion> mlirRegions;
163 mlirRegions.reserve(regions->size());
165 mlirRegions.push_back(region);
176 const nb::object ¶meters,
int stage,
bool effectOnFullRegion,
179 effect,
target, parameters, stage, effectOnFullRegion, resource)) {}
199 if (mlirAttributeIsNull(parameters))
208 if (mlirValueIsNull(value))
210 MlirOperation owner =
222 if (mlirAttributeIsNull(symbol))
236 constexpr static const char *
pyClassName =
"InferTypeOpInterface";
251 data->
inferredTypes.reserve(data->inferredTypes.size() + nTypes);
252 for (
intptr_t i = 0; i < nTypes; ++i) {
253 data->inferredTypes.emplace_back(data->pyMlirContext.getRef(), types[i]);
261 std::optional<PyAttribute> attributes,
void *properties,
262 std::optional<std::vector<PyRegion>> regions,
265 std::vector<MlirValue> mlirOperands = wrapOperands(std::move(operandList));
266 std::vector<MlirRegion> mlirRegions = wrapRegions(std::move(regions));
268 std::vector<PyType> inferredTypes;
273 MlirAttribute attributeDict =
277 opNameRef, pyContext.
get(), location.
resolve(), mlirOperands.size(),
278 mlirOperands.data(), attributeDict, properties, mlirRegions.size(),
282 throw nb::value_error(
"Failed to infer result types");
285 return inferredTypes;
290 nb::arg(
"operands") = nb::none(),
291 nb::arg(
"attributes") = nb::none(),
292 nb::arg(
"properties") = nb::none(), nb::arg(
"regions") = nb::none(),
293 nb::arg(
"context") = nb::none(), nb::arg(
"loc") = nb::none(),
303 : shape(std::move(shape)), elementType(elementType), ranked(
true) {}
305 MlirAttribute attribute)
306 : shape(std::move(shape)), elementType(elementType), attribute(attribute),
310 : shape(other.shape), elementType(other.elementType),
311 attribute(other.attribute), ranked(other.ranked) {}
313 static void bind(nb::module_ &m) {
314 nb::class_<PyShapedTypeComponents>(m,
"ShapedTypeComponents")
318 nb::sig(
"def element_type(self) -> Type"),
319 "Returns the element type of the shaped type components.")
325 nb::arg(
"element_type"),
326 "Create an shaped type components object with only the element "
330 [](nb::typed<nb::list, nb::int_> shape,
PyType &elementType) {
333 nb::arg(
"shape"), nb::arg(
"element_type"),
334 "Create a ranked shaped type components object.")
337 [](nb::typed<nb::list, nb::int_> shape,
PyType &elementType,
342 nb::arg(
"shape"), nb::arg(
"element_type"), nb::arg(
"attribute"),
343 "Create a ranked shaped type components object with attribute.")
347 "Returns whether the given shaped type component is ranked.")
353 return nb::int_(self.shape.size());
355 "Returns the rank of the given ranked shaped type components. If "
356 "the shaped type components does not have a rank, None is "
363 return nb::list(self.shape);
365 "Returns the shape of the ranked shaped type components as a list "
366 "of integers. Returns none if the shaped type component does not "
375 MlirType elementType;
376 MlirAttribute attribute;
388 constexpr static const char *
pyClassName =
"InferShapedTypeOpInterface";
401 MlirAttribute attribute,
void *userData) {
404 data->inferredShapedTypeComponents.emplace_back(elementType);
407 for (
intptr_t i = 0; i < rank; ++i) {
408 shapeList.append(
shape[i]);
410 data->inferredShapedTypeComponents.emplace_back(shapeList, elementType,
418 std::optional<nb::sequence> operandList,
419 std::optional<PyAttribute> attributes,
void *properties,
420 std::optional<std::vector<PyRegion>> regions,
422 std::vector<MlirValue> mlirOperands = wrapOperands(std::move(operandList));
423 std::vector<MlirRegion> mlirRegions = wrapRegions(std::move(regions));
425 std::vector<PyShapedTypeComponents> inferredShapedTypeComponents;
430 MlirAttribute attributeDict =
434 opNameRef, pyContext.
get(), location.
resolve(), mlirOperands.size(),
435 mlirOperands.data(), attributeDict, properties, mlirRegions.size(),
439 throw nb::value_error(
"Failed to infer result shape type components");
442 return inferredShapedTypeComponents;
446 cls.def(
"inferReturnTypeComponents",
448 nb::arg(
"operands") = nb::none(),
449 nb::arg(
"attributes") = nb::none(), nb::arg(
"regions") = nb::none(),
450 nb::arg(
"properties") = nb::none(), nb::arg(
"context") = nb::none(),
462 constexpr static const char *
pyClassName =
"ConditionallySpeculatable";
473 nb::handle(
static_cast<PyObject *
>(callbacks.
userData)).inc_ref();
475 callbacks.
destruct = [](
void *userData) {
476 nb::handle(
static_cast<PyObject *
>(userData)).dec_ref();
479 nb::handle pyClass(
static_cast<PyObject *
>(userData));
481 auto pyGetSpeculatability =
482 nb::cast<nb::callable>(nb::getattr(pyClass,
"get_speculatability"));
488 return nb::cast<MlirSpeculatability>(pyGetSpeculatability(opview));
498 "getSpeculatability",
501 throw nb::type_error(
502 "Cannot query speculatability on a static interface");
504 auto *pyOperation = nb::cast<PyOperation *>(operation);
508 "Returns the speculatability of the given operation.");
510 [](
const nb::object &cls,
const nb::object &opName, nb::object
target,
514 return attach(
target, nb::cast<std::string>(opName), context);
516 nb::arg(
"cls"), nb::arg(
"op_name"), nb::kw_only(),
517 nb::arg(
"target").none() = nb::none(),
518 nb::arg(
"context").none() = nb::none(),
519 "Attach the interface subclass to the given operation name.");
530 constexpr static const char *
pyClassName =
"MemoryEffectsOpInterface";
541 nb::handle(
static_cast<PyObject *
>(callbacks.
userData)).inc_ref();
543 callbacks.
destruct = [](
void *userData) {
544 nb::handle(
static_cast<PyObject *
>(userData)).dec_ref();
548 void *callbackUserData,
void *userData) {
549 nb::handle pyClass(
static_cast<PyObject *
>(userData));
553 nb::cast<nb::callable>(nb::getattr(pyClass,
"get_effects"));
561 nb::object
result = pyGetEffects(opview);
562 nb::iterable iterable;
563 if (!nb::try_cast<nb::iterable>(
result, iterable))
564 throw nb::type_error(
"get_effects must return an iterable");
566 std::vector<nb::object> effectObjects;
567 std::vector<MlirMemoryEffectInstance> effects;
568 for (nb::handle
object : iterable) {
570 if (!nb::try_cast<PyMemoryEffectInstance *>(
object, effect) ||
572 throw nb::type_error(
573 "get_effects must return MemoryEffectInstance objects");
575 effectObjects.push_back(nb::borrow<nb::object>(
object));
576 effects.push_back(effect->
get());
578 callback(effects.size(), effects.data(), callbackUserData);
588 throw nb::type_error(
"Cannot query effects on a static interface");
591 auto *operation = nb::cast<PyOperation *>(operationObject);
592 std::vector<PyMemoryEffectInstance> effects;
596 [](
intptr_t numEffects, MlirMemoryEffectInstance *effects,
599 static_cast<std::vector<PyMemoryEffectInstance> *>(userData);
600 result->reserve(result->size() + numEffects);
601 for (intptr_t i = 0; i < numEffects; ++i) {
602 result->emplace_back(mlirMemoryEffectInstanceClone(effects[i]));
611 nb::sig(
"def get_effects(self) -> list[MemoryEffectInstance]"),
612 "Returns the memory effects of the operation.");
614 [](
const nb::object &cls,
const nb::object &opName, nb::object
target,
618 return attach(
target, nb::cast<std::string>(opName), context);
620 nb::arg(
"cls"), nb::arg(
"op_name"), nb::kw_only(),
621 nb::arg(
"target").none() = nb::none(),
622 nb::arg(
"context").none() = nb::none(),
623 "Attach the interface subclass to the given operation name.");
628 nb::enum_<MlirSpeculatability>(m,
"Speculatability")
631 .value(
"RecursivelySpeculatable",
633 nb::class_<PyMemoryEffect>(m,
"MemoryEffect",
"A memory effect.")
640 nb::is_operator(),
"Compares two memory effects for equality.")
641 .def_prop_ro_static(
"Allocate",
646 .def_prop_ro_static(
"Free",
650 .def_prop_ro_static(
"Read",
654 .def_prop_ro_static(
"Write", [](nb::object & ) {
658 nb::class_<PySideEffectResource>(m,
"SideEffectResource",
659 "A side effect resource.")
660 .def_prop_ro_static(
"Default", [](nb::object & ) {
664 nb::class_<PyMemoryEffectInstance>(m,
"MemoryEffectInstance",
665 "A concrete instance of a memory effect.")
667 const nb::object &,
int,
bool,
669 nb::arg(
"effect"), nb::arg(
"target").none() = nb::none(),
670 nb::kw_only(), nb::arg(
"parameters").none() = nb::none(),
671 nb::arg(
"stage") = 0, nb::arg(
"effect_on_full_region") =
false,
672 nb::arg(
"resource") =
674 nb::sig(
"def __init__(self, effect: MemoryEffect, target: "
675 "OpOperand | OpResult | BlockArgument | SymbolRefAttr | "
676 "FlatSymbolRefAttr | None = None, *, parameters: Attribute "
677 "| None = None, stage: int = 0, "
678 "effect_on_full_region: bool = False, resource: "
679 "SideEffectResource = ...) -> None"),
680 "Creates a memory effect instance. The target may be an OpOperand, "
681 "OpResult, BlockArgument, SymbolRefAttr, or None.")
683 "Returns the kind of memory effect.")
685 "Returns the affected side effect resource.")
687 "Returns the stage at which the effect occurs.")
688 .def_prop_ro(
"effect_on_full_region",
690 "Returns whether the effect applies to the full resource.")
692 nb::sig(
"def parameters(self) -> Attribute | None"),
693 "Returns the effect parameters, if any.")
696 nb::sig(
"def value(self) -> OpResult | BlockArgument | None"),
697 "Returns the affected value, if any.")
699 nb::sig(
"def symbol_ref(self) -> SymbolRefAttr | "
700 "FlatSymbolRefAttr | None"),
701 "Returns the affected symbol reference, if any.");
true
Given two iterators into the same block, return "true" if a is before `b.
bool mlirValueIsABlockArgument(MlirValue value)
MlirContext mlirAttributeGetContext(MlirAttribute attribute)
MlirOperation mlirOpResultGetOwner(MlirValue value)
MlirBlock mlirBlockArgumentGetOwner(MlirValue value)
bool mlirValueIsAOpResult(MlirValue value)
MlirContext mlirOperationGetContext(MlirOperation op)
ReferrentTy * get() const
Used in function arguments when None should resolve to the current context manager set instance.
static PyLocation & resolve()
Used in function arguments when None should resolve to the current context manager set instance.
static PyMlirContext & resolve()
Wrapper around the generic MlirAttribute.
MlirAttribute get() const
nanobind::typed< nanobind::object, PyAttribute > maybeDownCast()
static void bind(nanobind::module_ &m)
MlirTypeID(*)() GetTypeIDFunctionTy
const std::string & getOpName()
PyConcreteOpInterface(nanobind::object object, DefaultingPyMlirContext context)
nanobind::typed< nanobind::object, PyOperation > getOperationObject()
Returns the operation instance from which this object was constructed.
nanobind::class_< PyInferTypeOpInterface > ClassTy
bool isStatic()
Returns true if this object was constructed from a subclass of OpView rather than from an operation i...
Wrapper around the ConditionallySpeculatable interface.
static constexpr GetTypeIDFunctionTy getInterfaceID
static constexpr const char * pyClassName
static void bindDerived(ClassTy &cls)
static void attach(nb::object &target, const std::string &opName, DefaultingPyMlirContext ctx)
Attach a new ConditionallySpeculatable FallbackModel to the named operation.
Python wrapper for InferShapedTypeOpInterface.
static constexpr GetTypeIDFunctionTy getInterfaceID
static void bindDerived(ClassTy &cls)
static constexpr const char * pyClassName
static void appendResultsCallback(bool hasRank, intptr_t rank, const int64_t *shape, MlirType elementType, MlirAttribute attribute, void *userData)
Appends the shaped type components provided as unpacked shape, element type, attribute to the user-da...
std::vector< PyShapedTypeComponents > inferReturnTypeComponents(std::optional< nb::sequence > operandList, std::optional< PyAttribute > attributes, void *properties, std::optional< std::vector< PyRegion > > regions, DefaultingPyMlirContext context, DefaultingPyLocation location)
Given the arguments required to build an operation, attempts to infer the shaped type components.
Python wrapper for InferTypeOpInterface.
std::vector< PyType > inferReturnTypes(std::optional< nb::sequence > operandList, std::optional< PyAttribute > attributes, void *properties, std::optional< std::vector< PyRegion > > regions, DefaultingPyMlirContext context, DefaultingPyLocation location)
Given the arguments required to build an operation, attempts to infer its return types.
static void bindDerived(ClassTy &cls)
static constexpr const char * pyClassName
static constexpr GetTypeIDFunctionTy getInterfaceID
static void appendResultsCallback(intptr_t nTypes, MlirType *types, void *userData)
Appends the types provided as the two first arguments to the user-data structure (expects AppendResul...
A memory effect instance.
PySideEffectResource getResource() const
MlirMemoryEffectInstance get() const
PyMemoryEffectInstance(MlirMemoryEffectInstance instance)
PyMemoryEffect getEffect() const
bool getEffectOnFullRegion() const
nanobind::object getParameters() const
nanobind::object getValue() const
nanobind::object getSymbolRef() const
MlirMemoryEffect get() const
Wrapper around the MemoryEffectsOpInterface.
static constexpr GetTypeIDFunctionTy getInterfaceID
std::vector< PyMemoryEffectInstance > getEffects()
static void attach(nb::object &target, const std::string &opName, DefaultingPyMlirContext ctx)
Attach a new MemoryEffectsOpInterface FallbackModel to the named operation.
static void bindDerived(ClassTy &cls)
static constexpr const char * pyClassName
static PyMlirContextRef forContext(MlirContext context)
Returns a context reference for the singleton PyMlirContext wrapper for the given context.
MlirContext get()
Accesses the underlying MlirContext.
nanobind::object createOpView()
Creates an OpView suitable for this operation.
static PyOperationRef forOperation(PyMlirContextRef contextRef, MlirOperation operation, nanobind::object parentKeepAlive=nanobind::object())
Returns a PyOperation for the given MlirOperation, optionally associating it with a parentKeepAlive.
Wrapper around an MlirRegion.
PyShapedTypeComponents(nb::list shape, MlirType elementType)
PyShapedTypeComponents(MlirType elementType)
PyShapedTypeComponents(nb::list shape, MlirType elementType, MlirAttribute attribute)
static PyShapedTypeComponents createFromCapsule(nb::object capsule)
PyShapedTypeComponents(PyShapedTypeComponents &)=delete
PyShapedTypeComponents(PyShapedTypeComponents &&other) noexcept
static void bind(nb::module_ &m)
MlirSideEffectResource get() const
Wrapper around the generic MlirType.
nanobind::typed< nanobind::object, std::variant< PyBlockArgument, PyOpResult, PyValue > > maybeDownCast()
MLIR_CAPI_EXPORTED MlirAttribute mlirAttributeGetNull(void)
Returns an empty attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsASymbolRef(MlirAttribute attr)
Checks whether the given attribute is a symbol reference attribute.
MLIR_CAPI_EXPORTED MlirOperation mlirBlockGetParentOperation(MlirBlock)
Returns the closest surrounding operation that contains this block.
MLIR_CAPI_EXPORTED MlirLogicalResult mlirInferShapedTypeOpInterfaceInferReturnTypes(MlirStringRef opName, MlirContext context, MlirLocation location, intptr_t nOperands, MlirValue *operands, MlirAttribute attributes, void *properties, intptr_t nRegions, MlirRegion *regions, MlirShapedTypeComponentsCallback callback, void *userData)
Infers the return shaped type components of the operation.
MLIR_CAPI_EXPORTED MlirSpeculatability mlirConditionallySpeculatableOpInterfaceGetSpeculatability(MlirOperation operation)
Returns the speculatability of the given operation.
MLIR_CAPI_EXPORTED MlirTypeID mlirMemoryEffectGetEffectID(MlirMemoryEffect effect)
Returns the TypeID identifying the concrete type of the given memory effect.
MLIR_CAPI_EXPORTED MlirTypeID mlirInferTypeOpInterfaceTypeID(void)
Returns the interface TypeID of the InferTypeOpInterface.
MLIR_CAPI_EXPORTED MlirMemoryEffectInstance mlirMemoryEffectInstanceCreateForOpOperand(MlirMemoryEffect effect, MlirOpOperand opOperand, MlirAttribute parameters, int stage, bool effectOnFullRegion, MlirSideEffectResource resource)
Creates a memory effect instance associated with an operation operand.
MLIR_CAPI_EXPORTED MlirAttribute mlirMemoryEffectInstanceGetSymbolRef(MlirMemoryEffectInstance instance)
Returns the symbol reference of the given instance, or a null attribute if there is no associated sym...
MLIR_CAPI_EXPORTED MlirTypeID mlirConditionallySpeculatableOpInterfaceTypeID(void)
Returns the interface TypeID of the ConditionallySpeculatable interface.
MLIR_CAPI_EXPORTED void mlirConditionallySpeculatableOpInterfaceAttachFallbackModel(MlirContext ctx, MlirStringRef opName, MlirConditionallySpeculatableOpInterfaceCallbacks callbacks)
Attach a new FallbackModel for the ConditionallySpeculatable interface to the named operation.
@ MlirSpeculatabilityRecursivelySpeculatable
The operation is speculatable if all nested operations are speculatable.
@ MlirSpeculatabilitySpeculatable
The operation is speculatable.
@ MlirSpeculatabilityNotSpeculatable
The operation is not speculatable.
MLIR_CAPI_EXPORTED MlirSideEffectResource mlirMemoryEffectInstanceGetResource(MlirMemoryEffectInstance instance)
Returns the side effect resource of the given instance.
MLIR_CAPI_EXPORTED MlirMemoryEffect mlirMemoryEffectsReadGet(void)
Returns the singleton instance of the read memory effect.
MLIR_CAPI_EXPORTED MlirSideEffectResource mlirSideEffectsDefaultResourceGet(void)
Returns the singleton instance of the default side effect resource.
MLIR_CAPI_EXPORTED MlirMemoryEffectInstance mlirMemoryEffectInstanceCreate(MlirMemoryEffect effect, MlirAttribute parameters, int stage, bool effectOnFullRegion, MlirSideEffectResource resource)
Creates a memory effect instance without an associated IR entity.
MLIR_CAPI_EXPORTED MlirMemoryEffect mlirMemoryEffectInstanceGetEffect(MlirMemoryEffectInstance instance)
Returns the memory effect of the given instance.
MLIR_CAPI_EXPORTED MlirLogicalResult mlirInferTypeOpInterfaceInferReturnTypes(MlirStringRef opName, MlirContext context, MlirLocation location, intptr_t nOperands, MlirValue *operands, MlirAttribute attributes, void *properties, intptr_t nRegions, MlirRegion *regions, MlirTypesCallback callback, void *userData)
Infers the return types of the operation identified by its canonical given the arguments that will be...
MLIR_CAPI_EXPORTED MlirMemoryEffectInstance mlirMemoryEffectInstanceCreateForOpResult(MlirMemoryEffect effect, MlirValue result, MlirAttribute parameters, int stage, bool effectOnFullRegion, MlirSideEffectResource resource)
Creates a memory effect instance associated with an operation result.
MLIR_CAPI_EXPORTED MlirAttribute mlirMemoryEffectInstanceGetParameters(MlirMemoryEffectInstance instance)
Returns the parameters of the given instance, or a null attribute if there are no parameters.
MLIR_CAPI_EXPORTED MlirMemoryEffect mlirMemoryEffectsFreeGet(void)
Returns the singleton instance of the free memory effect.
MLIR_CAPI_EXPORTED MlirMemoryEffect mlirMemoryEffectsWriteGet(void)
Returns the singleton instance of the write memory effect.
MLIR_CAPI_EXPORTED void mlirMemoryEffectsOpInterfaceGetEffects(MlirOperation operation, MlirMemoryEffectInstancesCallback callback, void *userData)
Gets the memory effects of the given operation.
MLIR_CAPI_EXPORTED MlirTypeID mlirMemoryEffectsOpInterfaceTypeID(void)
Returns the interface TypeID of the MemoryEffectsOpInterface.
void(* MlirMemoryEffectInstancesCallback)(intptr_t numEffects, MlirMemoryEffectInstance *effects, void *userData)
Callback for receiving a batch of memory effect instances.
MLIR_CAPI_EXPORTED MlirTypeID mlirInferShapedTypeOpInterfaceTypeID(void)
Returns the interface TypeID of the InferShapedTypeOpInterface.
MLIR_CAPI_EXPORTED void mlirMemoryEffectsOpInterfaceAttachFallbackModel(MlirContext ctx, MlirStringRef opName, MlirMemoryEffectsOpInterfaceCallbacks callbacks)
Attach a new FallbackModel for the MemoryEffectsOpInterface to the named operation.
MLIR_CAPI_EXPORTED bool mlirMemoryEffectInstanceGetEffectOnFullRegion(MlirMemoryEffectInstance instance)
Returns true if the given instance has effect on every single value of the resource.
MLIR_CAPI_EXPORTED int mlirMemoryEffectInstanceGetStage(MlirMemoryEffectInstance instance)
Returns the stage of the given instance.
MLIR_CAPI_EXPORTED MlirMemoryEffect mlirMemoryEffectsAllocateGet(void)
Returns the singleton instance of the allocate memory effect.
MLIR_CAPI_EXPORTED MlirMemoryEffectInstance mlirMemoryEffectInstanceCreateForSymbol(MlirMemoryEffect effect, MlirAttribute symbol, MlirAttribute parameters, int stage, bool effectOnFullRegion, MlirSideEffectResource resource)
Creates a memory effect instance associated with a symbol.
MLIR_CAPI_EXPORTED MlirValue mlirMemoryEffectInstanceGetValue(MlirMemoryEffectInstance instance)
Returns the value (OpOperand, OpResult, or BlockArgument) of the given instance, or a null value if t...
MLIR_CAPI_EXPORTED MlirMemoryEffectInstance mlirMemoryEffectInstanceCreateForBlockArgument(MlirMemoryEffect effect, MlirValue blockArgument, MlirAttribute parameters, int stage, bool effectOnFullRegion, MlirSideEffectResource resource)
Creates a memory effect instance associated with a block argument.
static MlirStringRef mlirStringRefCreate(const char *str, size_t length)
Constructs a string reference from the pointer and length.
static bool mlirLogicalResultIsFailure(MlirLogicalResult res)
Checks if the given logical result represents a failure.
MLIR_CAPI_EXPORTED bool mlirTypeIDEqual(MlirTypeID typeID1, MlirTypeID typeID2)
Checks if two type ids are equal.
void populateIRInterfaces(nb::module_ &m)
PyObjectRef< PyMlirContext > PyMlirContextRef
Wrapper around MlirContext.
static constexpr const char * inferReturnTypesDoc
static constexpr const char * inferReturnTypeComponentsDoc
nanobind::object classmethod(Func f, Args... args)
Helper for creating an @classmethod.
Include the generated interface declarations.
std::string join(const Ts &...args)
Helper function to concatenate arguments into a std::string.
Callbacks for implementing ConditionallySpeculatable from external code.
void(* destruct)(void *userData)
Optional destructor for user data. Set to nullptr to disable it.
void(* construct)(void *userData)
Optional constructor for user data. Set to nullptr to disable it.
MlirSpeculatability(* getSpeculatability)(MlirOperation op, void *userData)
Returns the speculatability of the given operation.
A logical result value, essentially a boolean with named states.
Callbacks for implementing MemoryEffectsOpInterface from external code.
void(* construct)(void *userData)
Optional constructor for user data. Set to nullptr to disable it.
void(* destruct)(void *userData)
Optional destructor for user data. Set to nullptr to disable it.
void(* getEffects)(MlirOperation op, MlirMemoryEffectInstancesCallback callback, void *callbackUserData, void *userData)
Get memory effects callback.
A pointer to a sized fragment of a string, not necessarily null-terminated.
C-style user-data structure for type appending callback.
std::vector< PyShapedTypeComponents > & inferredShapedTypeComponents
C-style user-data structure for type appending callback.
PyMlirContext & pyMlirContext
std::vector< PyType > & inferredTypes