MLIR 22.0.0git
mlir::python::PyConcreteAttribute< DerivedTy, BaseTy > Class Template Reference

CRTP base classes for Python attributes that subclass Attribute and should be castable from it (i.e. More...

#include "Bindings/Python/IRModule.h"

Inheritance diagram for mlir::python::PyConcreteAttribute< DerivedTy, BaseTy >:

Public Types

using ClassTy = nanobind::class_<DerivedTy, BaseTy>
using IsAFunctionTy = bool (*)(MlirAttribute)
using GetTypeIDFunctionTy = MlirTypeID (*)()

Public Member Functions

 PyConcreteAttribute ()=default
 PyConcreteAttribute (PyMlirContextRef contextRef, MlirAttribute attr)
 PyConcreteAttribute (PyAttribute &orig)
Public Member Functions inherited from mlir::python::PyAttribute
 PyAttribute (PyMlirContextRef contextRef, MlirAttribute attr)
bool operator== (const PyAttribute &other) const
 operator MlirAttribute () const
MlirAttribute get () const
nanobind::object getCapsule ()
 Gets a capsule wrapping the void* within the MlirAttribute.
nanobind::object maybeDownCast ()
Public Member Functions inherited from mlir::python::BaseContextObject
 BaseContextObject (PyMlirContextRef ref)
PyMlirContextRefgetContext ()
 Accesses the context reference.

Static Public Member Functions

static MlirAttribute castFrom (PyAttribute &orig)
static void bind (nanobind::module_ &m, PyType_Slot *slots=nullptr)
static void bindDerived (ClassTy &m)
 Implemented by derived classes to add methods to the Python subclass.
Static Public Member Functions inherited from mlir::python::PyAttribute
static PyAttribute createFromCapsule (const nanobind::object &capsule)
 Creates a PyAttribute from the MlirAttribute wrapped by a capsule.

Static Public Attributes

static constexpr GetTypeIDFunctionTy getTypeIdFunction = nullptr

Detailed Description

template<typename DerivedTy, typename BaseTy = PyAttribute>
class mlir::python::PyConcreteAttribute< DerivedTy, BaseTy >

CRTP base classes for Python attributes that subclass Attribute and should be castable from it (i.e.

via something like StringAttr(attr)). By default, attribute class hierarchies are one level deep (i.e. a concrete attribute class extends PyAttribute); however, intermediate python-visible base classes can be modeled by specifying a BaseTy.

Definition at line 1060 of file IRModule.h.

Member Typedef Documentation

◆ ClassTy

template<typename DerivedTy, typename BaseTy = PyAttribute>
using mlir::python::PyConcreteAttribute< DerivedTy, BaseTy >::ClassTy = nanobind::class_<DerivedTy, BaseTy>

Definition at line 1065 of file IRModule.h.

◆ GetTypeIDFunctionTy

template<typename DerivedTy, typename BaseTy = PyAttribute>
using mlir::python::PyConcreteAttribute< DerivedTy, BaseTy >::GetTypeIDFunctionTy = MlirTypeID (*)()

Definition at line 1067 of file IRModule.h.

◆ IsAFunctionTy

template<typename DerivedTy, typename BaseTy = PyAttribute>
using mlir::python::PyConcreteAttribute< DerivedTy, BaseTy >::IsAFunctionTy = bool (*)(MlirAttribute)

Definition at line 1066 of file IRModule.h.

Constructor & Destructor Documentation

◆ PyConcreteAttribute() [1/3]

template<typename DerivedTy, typename BaseTy = PyAttribute>
mlir::python::PyConcreteAttribute< DerivedTy, BaseTy >::PyConcreteAttribute ( )
default

Referenced by PyConcreteAttribute().

◆ PyConcreteAttribute() [2/3]

template<typename DerivedTy, typename BaseTy = PyAttribute>
mlir::python::PyConcreteAttribute< DerivedTy, BaseTy >::PyConcreteAttribute ( PyMlirContextRef contextRef,
MlirAttribute attr )
inline

Definition at line 1071 of file IRModule.h.

◆ PyConcreteAttribute() [3/3]

template<typename DerivedTy, typename BaseTy = PyAttribute>
mlir::python::PyConcreteAttribute< DerivedTy, BaseTy >::PyConcreteAttribute ( PyAttribute & orig)
inline

Member Function Documentation

◆ bind()

◆ bindDerived()

template<typename DerivedTy, typename BaseTy = PyAttribute>
void mlir::python::PyConcreteAttribute< DerivedTy, BaseTy >::bindDerived ( ClassTy & m)
inlinestatic

Implemented by derived classes to add methods to the Python subclass.

Definition at line 1147 of file IRModule.h.

◆ castFrom()

template<typename DerivedTy, typename BaseTy = PyAttribute>
MlirAttribute mlir::python::PyConcreteAttribute< DerivedTy, BaseTy >::castFrom ( PyAttribute & orig)
inlinestatic

Definition at line 1076 of file IRModule.h.

References mlir::python::PyAttribute::PyAttribute().

Referenced by PyConcreteAttribute().

Member Data Documentation

◆ getTypeIdFunction

template<typename DerivedTy, typename BaseTy = PyAttribute>
GetTypeIDFunctionTy mlir::python::PyConcreteAttribute< DerivedTy, BaseTy >::getTypeIdFunction = nullptr
staticconstexpr

Definition at line 1068 of file IRModule.h.


The documentation for this class was generated from the following file: