3#include "mlir/Dialect/Linalg/IR/Linalg.h"
4#include "mlir/IR/PatternMatch.h"
13 using OpRewritePattern<GenericOp>::OpRewritePattern;
17 bool checkIndexingMaps(ArrayAttr maps,
const std::vector<bool>& reduced_mask,
long long dim)
const;
21 bool equalShapes(
const ArrayRef<int64_t>& shape1,
const ArrayRef<int64_t>& shape2)
const;
22 long long determineDimension(
const ArrayRef<int64_t>& full_shape,
const ArrayRef<int64_t>& reduced_shape)
const;
24 template<
typename ElemOp>
26 if (region.getBlocks().size() != 1) {
29 auto& block = region.getBlocks().front();
31 block.getOperations().size() == 2 && llvm::dyn_cast_or_null<ElemOp>(block.getOperations().front()) &&
32 llvm::dyn_cast_or_null<YieldOp>(block.getOperations().back())
36 bool isFillOp(FillOp fill_op, uint64_t constant)
const;
38 LogicalResult
matchAndRewrite(GenericOp generic_op, PatternRewriter& rewriter)
const override;
Definition CustomSpecializeBatchNorm.h:8
Definition CustomPasses.h:6
y[..., d, ...] = exp(x) / sum_d(exp(x_d))
Definition CustomSpecializeSoftmax.h:12
long long determineDimension(const ArrayRef< int64_t > &full_shape, const ArrayRef< int64_t > &reduced_shape) const
bool checkIteratorTypes(ArrayAttr types, size_t rank, long long dim=-1) const
bool equalShapes(const ArrayRef< int64_t > &shape1, const ArrayRef< int64_t > &shape2) const
bool isFillOp(FillOp fill_op, uint64_t constant) const
bool checkIndexingMap(Attribute attr, long long dim=-1) const
bool isElementwiseRegion(Region ®ion) const
Definition CustomSpecializeSoftmax.h:25
LogicalResult matchAndRewrite(GenericOp generic_op, PatternRewriter &rewriter) const override
bool checkIndexingMapCollapsed(Attribute attr, long long dim) const
bool checkIndexingMaps(ArrayAttr maps, const std::vector< bool > &reduced_mask, long long dim) const