My Project
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
mlir::Dialect Class Reference

#include <Dialect.h>

Inheritance diagram for mlir::Dialect:
Inheritance graph
[legend]

Classes

class  VariadicOperationAdder
 
class  VariadicOperationAdder< First >
 
struct  VariadicSymbolAdder
 
struct  VariadicSymbolAdder< First >
 

Public Member Functions

virtual ~Dialect ()
 
MLIRContextgetContext () const
 
StringRef getNamespace () const
 
bool allowsUnknownOperations () const
 
bool allowsUnknownTypes () const
 
virtual OperationmaterializeConstant (OpBuilder &builder, Attribute value, Type type, Location loc)
 
virtual Attribute parseAttribute (DialectAsmParser &parser, Type type) const
 Parse an attribute registered to this dialect. More...
 
virtual void printAttribute (Attribute, DialectAsmPrinter &) const
 
virtual Type parseType (DialectAsmParser &parser) const
 Parse a type registered to this dialect. More...
 
virtual void printType (Type, DialectAsmPrinter &) const
 Print a type registered to this dialect. More...
 
virtual LogicalResult verifyRegionArgAttribute (Operation *, unsigned regionIndex, unsigned argIndex, NamedAttribute)
 
virtual LogicalResult verifyRegionResultAttribute (Operation *, unsigned regionIndex, unsigned resultIndex, NamedAttribute)
 
virtual LogicalResult verifyOperationAttribute (Operation *, NamedAttribute)
 
const DialectInterfacegetRegisteredInterface (ClassID *interfaceID)
 
template<typename InterfaceT >
const InterfaceT * getRegisteredInterface ()
 

Static Public Member Functions

static bool isValidNamespace (StringRef str)
 

Public Attributes

DialectConstantFoldHook constantFoldHook
 
DialectConstantDecodeHook decodeHook
 
DialectExtractElementHook extractElementHook
 

Protected Member Functions

 Dialect (StringRef name, MLIRContext *context)
 
template<typename... Args>
void addOperations ()
 
void addOperation (AbstractOperation opInfo)
 
template<typename... Args>
void addTypes ()
 This method is used by derived classes to add their types to the set. More...
 
template<typename... Args>
void addAttributes ()
 This method is used by derived classes to add their attributes to the set. More...
 
void allowUnknownOperations (bool allow=true)
 Enable support for unregistered operations. More...
 
void allowUnknownTypes (bool allow=true)
 Enable support for unregistered types. More...
 
void addInterface (std::unique_ptr< DialectInterface > interface)
 Register a dialect interface with this dialect instance. More...
 
template<typename T , typename T2 , typename... Tys>
void addInterfaces ()
 Register a set of dialect interfaces with this dialect instance. More...
 
template<typename T >
void addInterfaces ()
 

Detailed Description

Dialects are groups of MLIR operations and behavior associated with the entire group. For example, hooks into other systems for constant folding, default named types for asm printing, etc.

Instances of the dialect object are global across all MLIRContext's that may be active in the process.

Constructor & Destructor Documentation

◆ ~Dialect()

Dialect::~Dialect ( )
virtual

◆ Dialect()

Dialect::Dialect ( StringRef  name,
MLIRContext context 
)
protected

The constructor takes a unique namespace for this dialect as well as the context to bind to. Note: The namespace must not contain '.' characters. Note: All operations belonging to this dialect must have names starting with the namespace followed by '.'. Example:

  • "tf" for the TensorFlow ops like "tf.add".

Member Function Documentation

◆ addAttributes()

template<typename... Args>
void mlir::Dialect::addAttributes ( )
inlineprotected

This method is used by derived classes to add their attributes to the set.

◆ addInterface()

void Dialect::addInterface ( std::unique_ptr< DialectInterface interface)
protected

Register a dialect interface with this dialect instance.

Register a set of dialect interfaces with this dialect instance.

◆ addInterfaces() [1/2]

template<typename T , typename T2 , typename... Tys>
void mlir::Dialect::addInterfaces ( )
inlineprotected

Register a set of dialect interfaces with this dialect instance.

◆ addInterfaces() [2/2]

template<typename T >
void mlir::Dialect::addInterfaces ( )
inlineprotected

◆ addOperation()

void Dialect::addOperation ( AbstractOperation  opInfo)
protected

◆ addOperations()

template<typename... Args>
void mlir::Dialect::addOperations ( )
inlineprotected

This method is used by derived classes to add their operations to the set.

◆ addTypes()

template<typename... Args>
void mlir::Dialect::addTypes ( )
inlineprotected

This method is used by derived classes to add their types to the set.

◆ allowsUnknownOperations()

bool mlir::Dialect::allowsUnknownOperations ( ) const
inline

Returns true if this dialect allows for unregistered operations, i.e. operations prefixed with the dialect namespace but not registered with addOperation.

◆ allowsUnknownTypes()

bool mlir::Dialect::allowsUnknownTypes ( ) const
inline

Return true if this dialect allows for unregistered types, i.e., types prefixed with the dialect namespace but not registered with addType. These are represented with OpaqueType.

◆ allowUnknownOperations()

void mlir::Dialect::allowUnknownOperations ( bool  allow = true)
inlineprotected

Enable support for unregistered operations.

◆ allowUnknownTypes()

void mlir::Dialect::allowUnknownTypes ( bool  allow = true)
inlineprotected

Enable support for unregistered types.

◆ getContext()

MLIRContext* mlir::Dialect::getContext ( ) const
inline

◆ getNamespace()

StringRef mlir::Dialect::getNamespace ( ) const
inline

◆ getRegisteredInterface() [1/2]

const DialectInterface* mlir::Dialect::getRegisteredInterface ( ClassID interfaceID)
inline

Lookup an interface for the given ID if one is registered, otherwise nullptr.

◆ getRegisteredInterface() [2/2]

template<typename InterfaceT >
const InterfaceT* mlir::Dialect::getRegisteredInterface ( )
inline

◆ isValidNamespace()

bool Dialect::isValidNamespace ( StringRef  str)
static

Utility function that returns if the given string is a valid dialect namespace.

◆ materializeConstant()

virtual Operation* mlir::Dialect::materializeConstant ( OpBuilder builder,
Attribute  value,
Type  type,
Location  loc 
)
inlinevirtual

Registered hook to materialize a single constant operation from a given attribute value with the desired resultant type. This method should use the provided builder to create the operation without changing the insertion position. The generated operation is expected to be constant like, i.e. single result, zero operands, non side-effecting, etc. On success, this hook should return the value generated to represent the constant value. Otherwise, it should return null on failure.

Reimplemented in mlir::spirv::SPIRVDialect, mlir::AffineOpsDialect, mlir::StandardOpsDialect, and mlir::vector::VectorOpsDialect.

◆ parseAttribute()

Attribute Dialect::parseAttribute ( DialectAsmParser parser,
Type  type 
) const
virtual

Parse an attribute registered to this dialect.

Parse an attribute registered to this dialect. If 'type' is nonnull, it refers to the expected type of the attribute.

◆ parseType()

Type Dialect::parseType ( DialectAsmParser parser) const
virtual

◆ printAttribute()

virtual void mlir::Dialect::printAttribute ( Attribute  ,
DialectAsmPrinter  
) const
inlinevirtual

Print an attribute registered to this dialect. Note: The type of the attribute need not be printed by this method as it is always printed by the caller.

◆ printType()

virtual void mlir::Dialect::printType ( Type  ,
DialectAsmPrinter  
) const
inlinevirtual

◆ verifyOperationAttribute()

virtual LogicalResult mlir::Dialect::verifyOperationAttribute ( Operation ,
NamedAttribute   
)
inlinevirtual

Verify an attribute from this dialect on the given operation. Returns failure if the verification failed, success otherwise.

Reimplemented in mlir::gpu::GPUDialect, and mlir::spirv::SPIRVDialect.

◆ verifyRegionArgAttribute()

LogicalResult Dialect::verifyRegionArgAttribute ( Operation ,
unsigned  regionIndex,
unsigned  argIndex,
NamedAttribute   
)
virtual

Verify an attribute from this dialect on the argument at 'argIndex' for the region at 'regionIndex' on the given operation. Returns failure if the verification failed, success otherwise. This hook may optionally be invoked from any operation containing a region.

Reimplemented in mlir::LLVM::LLVMDialect, and mlir::spirv::SPIRVDialect.

◆ verifyRegionResultAttribute()

LogicalResult Dialect::verifyRegionResultAttribute ( Operation ,
unsigned  regionIndex,
unsigned  resultIndex,
NamedAttribute   
)
virtual

Verify an attribute from this dialect on the result at 'resultIndex' for the region at 'regionIndex' on the given operation. Returns failure if the verification failed, success otherwise. This hook may optionally be invoked from any operation containing a region.

Reimplemented in mlir::spirv::SPIRVDialect.

Member Data Documentation

◆ constantFoldHook

DialectConstantFoldHook mlir::Dialect::constantFoldHook
Initial value:
=
[](Operation *op, ArrayRef<Attribute> operands,
SmallVectorImpl<Attribute> &results) { return failure(); }

Registered fallback constant fold hook for the dialect. Like the constant fold hook of each operation, it attempts to constant fold the operation with the specified constant operand values - the elements in "operands" will correspond directly to the operands of the operation, but may be null if non-constant. If constant folding is successful, this fills in the results vector. If not, this returns failure and results is unspecified.

◆ decodeHook

DialectConstantDecodeHook mlir::Dialect::decodeHook
Initial value:
=
[](const OpaqueElementsAttr input, ElementsAttr &output) { return true; }

Registered hook to decode opaque constants associated with this dialect. The hook function attempts to decode an opaque constant tensor into a tensor with non-opaque content. If decoding is successful, this method returns false and sets 'output' attribute. If not, it returns true and leaves 'output' unspecified. The default hook fails to decode.

◆ extractElementHook

DialectExtractElementHook mlir::Dialect::extractElementHook
Initial value:
=
[](const OpaqueElementsAttr input, ArrayRef<uint64_t> index) {
return Attribute();
}

Registered hook to extract an element from an opaque constant associated with this dialect. If element has been successfully extracted, this method returns that element. If not, it returns an empty attribute. The default hook fails to extract an element.


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