Skip to content

Commit c369bdd

Browse files
TinaAMDmgehre-amd
authored andcommitted
Support for zero-sized dimensions in aten.empty.memory_format
1 parent a25c18d commit c369bdd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/Conversion/TorchToTosa/TorchToTosa.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5393,6 +5393,12 @@ LogicalResult ConvertAtenOp<AtenEmptyMemoryFormatOp>::matchAndRewrite(
53935393
typeConverter->convertType(op.getType()).template cast<RankedTensorType>();
53945394

53955395
DenseElementsAttr emptyVal;
5396+
// Create an empty tensor if all dimensions are zero
5397+
if (llvm::all_of(resultType.getShape(), [](int dimSize){ return dimSize == 0;})) {
5398+
rewriter.replaceOpWithNewOp<tosa::ConstOp>(op, resultType, emptyVal);
5399+
return success();
5400+
}
5401+
53965402
if (op.getDtype().getType().template isa<Torch::NoneType>()) {
53975403
emptyVal = DenseFPElementsAttr::get(resultType, {0.0F});
53985404
} else {

0 commit comments

Comments
 (0)