MLIR 22.0.0git
mlir::linalg::ControlDropUnitDims Struct Reference

Transformation to drop unit-extent dimensions from linalg.generic operations. More...

#include "mlir/Dialect/Linalg/Transforms/Transforms.h"

Public Types

enum class  RankReductionStrategy { ReassociativeReshape , ExtractInsertSlice }
using ControlFnTy = std::function<SmallVector<unsigned>(Operation *)>
 Instances of this type are used to control which dimensions of an operand are considered for dropping unit extent dimensions.
using CollapseFnTy
 Instances of this type are used to control how operand values are collapsed after dropping unit extent dimensions.
using ExpandFnTy
 Instances of this type are used to control how result values are expanded into their original shape after dropping unit extent dimensions.

Public Attributes

RankReductionStrategy rankReductionStrategy
ControlFnTy controlFn
 Function to control which dimensions, if any, are to be considered for dropping unit extent dimensions.
CollapseFnTy collapseFn
 Function to control how operands are collapsed into their new target shape after dropping unit extent dimensions.
ExpandFnTy expandFn
 Function to control how results are expanded into their original shape after dropping unit extent dimensions.

Detailed Description

Transformation to drop unit-extent dimensions from linalg.generic operations.

Definition at line 521 of file Transforms.h.

Member Typedef Documentation

◆ CollapseFnTy

Initial value:
std::function<FailureOr<Value>(
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition Location.h:76
This class coordinates the application of a rewrite on a set of IR, providing a way for clients to tr...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition Value.h:96
Transformation to drop unit-extent dimensions from linalg.generic operations.
Definition Transforms.h:521

Instances of this type are used to control how operand values are collapsed after dropping unit extent dimensions.

Next to the control struct, rewriter and location, the function receives the operand value to collapse, the new target shape and how old dimensions should be grouped. The function needs to insert the necessary operations to collapse the operand to the target shape and returns the new operand value. If the operand should not be collapsed, the function should return failure, leading to the transformation to be aborted.

Definition at line 559 of file Transforms.h.

◆ ControlFnTy

Instances of this type are used to control which dimensions of an operand are considered for dropping unit extent dimensions.

The parameter to the function is the operation itself, the expected return is a list of dimensions to consider for dropping unit extent dimensions. If the operation should not be have any dimensions dropped, implementations should return an empty list.

Definition at line 533 of file Transforms.h.

◆ ExpandFnTy

Initial value:
std::function<FailureOr<Value>(

Instances of this type are used to control how result values are expanded into their original shape after dropping unit extent dimensions.

Next to the control construct, rewriter and location, the function recieves the result value, the original value to replace and and information on how the new dimensions were grouped. The function needs to insert the necessary operations to expand the result to the original shape and returns the new result value. If the result should not be expanded, the function should return failure, leading to the transformation to be aborted.

Definition at line 586 of file Transforms.h.

Member Enumeration Documentation

◆ RankReductionStrategy

Enumerator
ReassociativeReshape 
ExtractInsertSlice 

Definition at line 522 of file Transforms.h.

Member Data Documentation

◆ collapseFn

CollapseFnTy mlir::linalg::ControlDropUnitDims::collapseFn
Initial value:
=
[](RewriterBase &rewriter, Location loc, Value operand,
ArrayRef<int64_t> targetShape,
const ControlDropUnitDims &control) -> FailureOr<Value> {
return collapseValue(rewriter, loc, operand, targetShape, reassociation,
control);
}

Function to control how operands are collapsed into their new target shape after dropping unit extent dimensions.

For the default behavior

See also
linalg::collapseValue. Users of the dropUnitDims interface can override the default behavior by setting this member to their own implementation.

Definition at line 568 of file Transforms.h.

◆ controlFn

ControlFnTy mlir::linalg::ControlDropUnitDims::controlFn
Initial value:
= [](Operation *op) {
if (auto genericOp = dyn_cast_or_null<GenericOp>(op)) {
return llvm::to_vector(llvm::seq<unsigned>(0, genericOp.getNumLoops()));
}
if (auto padOp = dyn_cast_or_null<tensor::PadOp>(op)) {
return llvm::to_vector(
llvm::seq<unsigned>(0, padOp.getSourceType().getRank()));
}
}
Operation is the basic unit of execution within MLIR.
Definition Operation.h:88

Function to control which dimensions, if any, are to be considered for dropping unit extent dimensions.

The default behavior is to consider all dimensions of a linalg.generic or tensor.pad operation for dropping. Users of the dropUnitDims interface can override the default behavior by setting this member to their own implementation.

Definition at line 540 of file Transforms.h.

◆ expandFn

ExpandFnTy mlir::linalg::ControlDropUnitDims::expandFn
Initial value:
=
[](RewriterBase &rewriter, Location loc, Value result, Value origDest,
const ControlDropUnitDims &control) -> FailureOr<Value> {
return expandValue(rewriter, loc, result, origDest, reassociation, control);
}

Function to control how results are expanded into their original shape after dropping unit extent dimensions.

The default behavior

See also
linalg::expandValue. Users of the dropUnitDims interface can override the default behavior by setting this member to their own implementation.

Definition at line 595 of file Transforms.h.

◆ rankReductionStrategy

RankReductionStrategy mlir::linalg::ControlDropUnitDims::rankReductionStrategy

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