MLIR 22.0.0git
mlir::transform::TransformEachOpTrait< OpTy > Class Template Reference

Trait implementing the TransformOpInterface for operations applying a transformation to a single operation handle and producing an arbitrary number of handles and parameter values. More...

#include "mlir/Dialect/Transform/Interfaces/TransformInterfaces.h"

Inheritance diagram for mlir::transform::TransformEachOpTrait< OpTy >:

Public Member Functions

DiagnosedSilenceableFailure apply (transform::TransformRewriter &rewriter, TransformResults &transformResults, TransformState &state)
 Calls applyToOne for every payload operation associated with the operand of this transform IR op, the following case disjunction happens:

Static Public Member Functions

static LogicalResult verifyTrait (Operation *op)
 Checks that the op matches the expectations of this trait.

Additional Inherited Members

Protected Member Functions inherited from mlir::OpTrait::TraitBase< OpTy, TransformEachOpTrait >
OperationgetOperation ()
 Return the ultimate Operation being worked on.

Detailed Description

template<typename OpTy>
class mlir::transform::TransformEachOpTrait< OpTy >

Trait implementing the TransformOpInterface for operations applying a transformation to a single operation handle and producing an arbitrary number of handles and parameter values.

The op must implement a method with the following signature:

  • DiagnosedSilenceableFailure applyToOne(OpTy, ApplyToEachResultList &results, TransformState &state) to perform a transformation that is applied in turn to all payload IR operations that correspond to the handle of the transform IR operation. In applyToOne, OpTy is either Operation* or a concrete payload IR Op class that the transformation is applied to (and NOT the class of the transform IR op). The applyToOne method takes an empty results vector that it fills with zero, one or multiple operations depending on the number of results expected by the transform op. The number of results must match the number of results of the transform op. applyToOne is allowed to fill the results with all null elements to signify that the transformation did not apply to the payload IR operations. Such null elements are filtered out from results before return.

The transform op having this trait is expected to have a single operand.

Definition at line 1217 of file TransformInterfaces.h.

Member Function Documentation

◆ apply()

template<typename OpTy>
mlir::DiagnosedSilenceableFailure mlir::transform::TransformEachOpTrait< OpTy >::apply ( transform::TransformRewriter & rewriter,
TransformResults & transformResults,
TransformState & state )

Calls applyToOne for every payload operation associated with the operand of this transform IR op, the following case disjunction happens:

  1. If not target payload ops are associated to the operand then fill the results vector with the expected number of null elements and return success. This is the corner case handling that allows propagating the "no-op" case gracefully to improve usability.
  2. If any applyToOne returns definiteFailure, the transformation is immediately considered definitely failed and we return.
  3. All applications of applyToOne are checked to return a number of results expected by the transform IR op. If not, this is a definite failure and we return early.
  4. If applyToOne produces ops, associate them with the result of this transform op.
  5. If any applyToOne return silenceableFailure, the transformation is considered silenceable.
  6. Otherwise the transformation is considered successful.

Definition at line 1557 of file TransformInterfaces.h.

References mlir::transform::detail::applyTransformToEach(), mlir::transform::detail::checkNestedConsumption(), mlir::DiagnosedSilenceableFailure::definiteFailure(), mlir::transform::TransformOptions::getExpensiveChecksEnabled(), mlir::OpTrait::TraitBase< OpTy, TransformEachOpTrait >::getOperation(), mlir::transform::TransformState::getOptions(), mlir::transform::TransformState::getPayloadOps(), mlir::transform::isHandleConsumed(), result, mlir::transform::TransformResults::set(), mlir::transform::detail::setApplyToOneResults(), mlir::transform::TransformResults::setParams(), mlir::transform::TransformResults::setValues(), mlir::DiagnosedSilenceableFailure::success(), and ValueRange.

◆ verifyTrait()

template<typename OpTy>
llvm::LogicalResult mlir::transform::TransformEachOpTrait< OpTy >::verifyTrait ( Operation * op)
static

Checks that the op matches the expectations of this trait.

Definition at line 1613 of file TransformInterfaces.h.

References mlir::Operation::emitError(), mlir::OperationName::getInterface(), mlir::Operation::getName(), and success().


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