Skip to content

Commit cb7b206

Browse files
committed
Do not create tosa.reshape for more than one dynamic dims.
1 parent 45998aa commit cb7b206

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/Conversion/TorchToTosa/TorchToTosa.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,12 @@ class ConvertAtenSqueezeOp : public OpConversionPattern<AtenOpT> {
12931293
auto newOutputTy = RankedTensorType::get(
12941294
makeShapeLLVMCompatible(newOutputShape), resultElemTy);
12951295

1296+
if (newOutputTy.getNumDynamicDims() > 1) {
1297+
return rewriter.notifyMatchFailure(
1298+
op, "Squeeze op resulting in multiple dynamic dimensions in the "
1299+
"output is not supported.");
1300+
}
1301+
12961302
auto reshapeOp = rewriter.create<tosa::ReshapeOp>(
12971303
op->getLoc(),
12981304
OpConversionPattern<AtenOpT>::getTypeConverter()->convertType(
@@ -3230,6 +3236,12 @@ LogicalResult ConvertAtenOp<AtenUnsqueezeOp>::matchAndRewrite(
32303236
op, "Only tensor types are currently supported");
32313237
}
32323238

3239+
if (selfType.getNumDynamicDims() > 1) {
3240+
return rewriter.notifyMatchFailure(
3241+
op,
3242+
"AtenUnsqueezeOp with multiple dynamic dimensions is not supported.");
3243+
}
3244+
32333245
auto selfRank = selfType.getRank();
32343246
auto selfElemTy = selfType.getElementType();
32353247
if (!selfElemTy.isIntOrFloat()) {
@@ -3925,6 +3937,11 @@ class ConvertAtenMinMaxDimOp : public OpConversionPattern<AtenOpT> {
39253937
}
39263938

39273939
if (argMaxOp.getType() != indicesType) {
3940+
if (indicesType.getNumDynamicDims() > 1) {
3941+
return rewriter.notifyMatchFailure(
3942+
op, "AtenMaxDimOp resulting in multiple dynamic dimensions in the "
3943+
"output is not supported.");
3944+
}
39283945
argMaxOp = rewriter.create<tosa::ReshapeOp>(
39293946
op->getLoc(), indicesType, argMaxOp,
39303947
tosa::getTosaConstShape(rewriter, op->getLoc(), reducedShape));

0 commit comments

Comments
 (0)