Multi-Level IR Compiler Framework

OpInterface definitions

FindPayloadReplacementOpInterface (FindPayloadReplacementOpInterface

This interface is queried by the TrackingListener and can be implemented by payload ops to indicate that the lookup should be continue with its operands when looking for payload op replacements.

Example: Consider the case where a tracked “” payload op is replaced with a new “” op, but wrapped in a “tensor.reshape” op. In that case, the mapping of the original “” op should be updated with the new “” op. A “tensor.reshape” is a metadata-only op that should be skipped when inspecting the replacement values of the original “” op. More details can be found at TrackingListener documentation.

Note: Ops that implement CastOpInterface do not need to implement this interface. Such ops are skipped by default. This interface should be implemented by cast-like/metadata-only ops that cannot implement CastOpInterface.



::llvm::SmallVector<::mlir::Value> getNextOperands();

Return the operands at which the lookup for replacement payload ops should continue.

NOTE: This method must be implemented by the user.

PatternDescriptorOpInterface (PatternDescriptorOpInterface

This interface should be implemented by ops that select patterns of a transform.apply_patterns op. It provides a method to populate a rewrite pattern set with patterns.



void populatePatterns(RewritePatternSet &patterns);

Populate patterns into the given pattern set.

NOTE: This method must be implemented by the user.

TransformOpInterface (TransformOpInterface

This interface is to be implemented by operations that identify transformations to be performed on other operations. The former are referred to as transform IR operations. The latter are referred to as payload IR operations. Such transform IR operations provide a fine-grain control mechanism over how transformations are applied by using and defining transform IR values, referred to as handles, that correspond to sets of operations in the payload IR. Transformations are applied starting from the operations identified by handles, but may affect other operations as well. Further restrictions may be imposed by flows that rely on transform IR operations to control transformations.



::mlir::DiagnosedSilenceableFailure apply(::mlir::transform::TransformResults &transformResults, ::mlir::transform::TransformState &state);

Applies the transformation represented by the current operation. This accepts as arguments the object that must be populated with results of the current transformation and a transformation state object that can be used for queries, e.g., to obtain the list of operations on which the transformation represented by the current op is targeted. Returns a special status object indicating whether the transformation succeeded or failed, and, if it failed, whether the failure is recoverable or not.

NOTE: This method must be implemented by the user.


bool allowsRepeatedHandleOperands();

Indicates whether the op instance allows its handle operands to be associated with the same payload operations.

NOTE: This method must be implemented by the user.