Skip to content
Open
Changes from 4 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
8 changes: 8 additions & 0 deletions lib/Conversion/TorchToTosa/TorchToTosa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5392,6 +5392,14 @@ LogicalResult ConvertAtenOp<AtenEmptyMemoryFormatOp>::matchAndRewrite(
auto resultType =
typeConverter->convertType(op.getType()).template cast<RankedTensorType>();

// TOSA does not allow empty dimensions, so we can't lower this while
// preserving the shape.
if (llvm::any_of(resultType.getShape(),
[](int dimSize) { return dimSize == 0; })) {
return rewriter.notifyMatchFailure(
op, "Cannot lower tensors with 0-sized dimensions to TOSA.");
}

DenseElementsAttr emptyVal;
if (op.getDtype().getType().template isa<Torch::NoneType>()) {
emptyVal = DenseFPElementsAttr::get(resultType, {0.0F});
Expand Down