Skip to content

fix: DecomposeGenericByUnfoldingPermutation pass #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/Dialect/Linalg/Transforms/Transforms.h"
#include <map>
#include <mlir/IR/BuiltinAttributes.h>
#include <optional>
#include <utility>

Expand Down Expand Up @@ -166,6 +167,11 @@ LogicalResult DecomposeProjectedPermutation::matchAndRewrite(
// out which operand can supply that runtime-value (tensor.dim).
// Leaving it as a future TODO.
if (llvm::any_of(op->getOpOperands(), [](OpOperand &oper) {
// The following rewrite pattern only reasons on RankedTensorTypes
// If that is not the case, then we cannot reason on the shape.
if (!isa<RankedTensorType>(oper.get().getType())) {
return false;
}
auto opType = cast<RankedTensorType>(oper.get().getType());
return ShapedType::isDynamicShape(opType.getShape());
}))
Expand All @@ -181,6 +187,9 @@ LogicalResult DecomposeProjectedPermutation::matchAndRewrite(
// Walk over each input operand and unfold if it is transposed, broadcast
// or mix of two via operand's affine-map.
for (int64_t i = 0; i < op.getNumDpsInputs(); ++i) {
if (!isa<RankedTensorType>(newInitValues[i].getType())) {
continue;
}
auto &map = newMap[i];
auto inputRTType = cast<RankedTensorType>(newInitValues[i].getType());
auto elType = inputRTType.getElementType();
Expand Down