|
MLIR 23.0.0git
|
Helper class for building convolution op matchers with minimal boilerplate. More...
Public Member Functions | |
| ConvMatcherBuilder (LinalgOp op, unsigned spatialRank, SmallVector< int64_t > *d, SmallVector< int64_t > *s, PoolingType poolingType=PoolingType::None) | |
| AffineExpr | dim (unsigned i) |
| Get affine dimension expression for dimension i. | |
| AffineExpr | strided (AffineExpr base, AffineExpr kernel, unsigned idx) |
| Build strided expression: base * stride[idx] + kernel * dilation[idx]. | |
| ConvMatcherBuilder & | matchStride (unsigned iDim, unsigned fDim, unsigned oDim, unsigned idx) |
| Match stride/dilation pattern for a spatial dimension. | |
| ConvMatcherBuilder & | matchMaps (ArrayRef< ArrayRef< AffineExpr > > maps) |
| Match expected indexing maps layout. Returns *this for method chaining. | |
| bool | matchBody (bool containsZeroPointOffset=false) |
| Match body pattern. This should be called last. | |
Helper class for building convolution op matchers with minimal boilerplate.
Reduces repetitive code across Conv1D/2D/3D and Depthwise variants as well as Pooling ops.
Usage: Create an instance with the op, spatial rank, and output pointers for extracted dilations/strides. Then chain matchStride() calls for each spatial dimension, followed by matchMaps() to verify indexing maps, and finally matchBody() to verify the operation body pattern.
The matched flag starts as true and is set to false if any match step fails. This allows chaining multiple match calls; once any match fails, all subsequent calls become no-ops and the final result is false.
The dilations and strides pointers are output parameters that get populated with the extracted dilation and stride values from the operation's indexing maps during matchStride() calls. These values are initially set to 1 for each spatial dimension and updated as patterns are matched.
|
inline |
Definition at line 542 of file Utils.cpp.
References getContext(), and mlir::linalg::None.
Referenced by matchMaps(), and matchStride().
|
inline |
Get affine dimension expression for dimension i.
Definition at line 552 of file Utils.cpp.
References mlir::getAffineDimExpr().
Match body pattern. This should be called last.
Definition at line 578 of file Utils.cpp.
References mlir::linalg::bodyMatcherForConvolutionOps(), mlir::linalg::bodyMatcherForMaxSignedPoolOps(), mlir::linalg::bodyMatcherForMaxUnsignedPoolOps(), mlir::linalg::bodyMatcherForMinSignedPoolOps(), mlir::linalg::bodyMatcherForMinUnsignedPoolOps(), mlir::linalg::bodyMatcherForSumPoolOps(), mlir::Block::getTerminator(), mlir::linalg::MaxSigned, mlir::linalg::MaxUnsigned, mlir::linalg::MinSigned, mlir::linalg::MinUnsigned, mlir::linalg::None, and mlir::linalg::Sum.
|
inline |
Match expected indexing maps layout. Returns *this for method chaining.
Definition at line 571 of file Utils.cpp.
References mlir::linalg::convLayoutMatches(), and ConvMatcherBuilder().
|
inline |
Match stride/dilation pattern for a spatial dimension.
Returns *this for method chaining.
Definition at line 561 of file Utils.cpp.
References ConvMatcherBuilder(), and mlir::linalg::matchConvDimAddExprPattern().
|
inline |