Skip to content

Commit 9f04d2a

Browse files
committed
Try fix w7900 tests
1 parent 6e0af90 commit 9f04d2a

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

compiler/src/iree/compiler/Codegen/Common/MaterializeEncodingPatterns.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,9 @@ static FailureOr<Operation *> lowerGenericOpWithEncoding(
234234
typeConverter.getEncodingInfo(
235235
cast<RankedTensorType>(outputOperand->get().getType()));
236236
if (IREE::Codegen::isIdentityLayout(outMaterializeEncodingInfo)) {
237-
return rewriter.notifyMatchFailure(
238-
genericOp, "MaterializeEncodingInfo failed for output");
237+
return dropEncodingAndCloneOp(rewriter, genericOp.getOperation(),
238+
convertedInputOperands,
239+
convertedOutputOperands);
239240
}
240241

241242
auto convertedResultType =

compiler/src/iree/compiler/Codegen/ExternalInterfaces/CPUEncodingExternalModels.cpp

-14
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,6 @@ static void transposeInPlace(MaterializeEncodingInfo &info) {
7070
transpose(info.outerDimsPerm);
7171
}
7272

73-
static Operation *dropEncodingAndCloneOp(OpBuilder &builder, Operation *op,
74-
ValueRange convertedInputOperands,
75-
ValueRange convertedOutputOperands) {
76-
SmallVector<Value> operands;
77-
operands.append(convertedInputOperands.begin(), convertedInputOperands.end());
78-
operands.append(convertedOutputOperands.begin(),
79-
convertedOutputOperands.end());
80-
return mlir::clone(
81-
builder, op,
82-
{cast<RankedTensorType>(convertedOutputOperands[0].getType())
83-
.dropEncoding()},
84-
operands);
85-
}
86-
8773
static RankedTensorType
8874
getExpandedType(RankedTensorType type, bool isBatched, bool isTransposed,
8975
SmallVectorImpl<ReassociationIndices> &ri) {

compiler/src/iree/compiler/Codegen/Utils/Utils.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,20 @@ OpFoldResult convertByteOffsetToElementOffset(RewriterBase &rewriter,
11581158
}
11591159
}
11601160

1161+
Operation *dropEncodingAndCloneOp(OpBuilder &builder, Operation *op,
1162+
ValueRange convertedInputOperands,
1163+
ValueRange convertedOutputOperands) {
1164+
SmallVector<Value> operands;
1165+
operands.append(convertedInputOperands.begin(), convertedInputOperands.end());
1166+
operands.append(convertedOutputOperands.begin(),
1167+
convertedOutputOperands.end());
1168+
return mlir::clone(
1169+
builder, op,
1170+
{cast<RankedTensorType>(convertedOutputOperands[0].getType())
1171+
.dropEncoding()},
1172+
operands);
1173+
}
1174+
11611175
LogicalResult isArgmaxOp(linalg::GenericOp genericOp) {
11621176
// Check for 2 results(value, index), and 1 input
11631177
if (genericOp.getNumDpsInits() != 2) {

compiler/src/iree/compiler/Codegen/Utils/Utils.h

+5
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ OpFoldResult convertByteOffsetToElementOffset(RewriterBase &rewriter,
211211
OpFoldResult byteOffset,
212212
Type elementType);
213213

214+
/// Clone an operation and drop all encodings.
215+
Operation *dropEncodingAndCloneOp(OpBuilder &builder, Operation *op,
216+
ValueRange convertedInputOperands,
217+
ValueRange convertedOutputOperands);
218+
214219
/// Check if a linalg.generic is representing an argmax operation.
215220
LogicalResult isArgmaxOp(linalg::GenericOp genericOp);
216221

0 commit comments

Comments
 (0)