We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a25c18d commit c369bddCopy full SHA for c369bdd
lib/Conversion/TorchToTosa/TorchToTosa.cpp
@@ -5393,6 +5393,12 @@ LogicalResult ConvertAtenOp<AtenEmptyMemoryFormatOp>::matchAndRewrite(
5393
typeConverter->convertType(op.getType()).template cast<RankedTensorType>();
5394
5395
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
+
5402
if (op.getDtype().getType().template isa<Torch::NoneType>()) {
5403
emptyVal = DenseFPElementsAttr::get(resultType, {0.0F});
5404
} else {
0 commit comments