Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions e2e_testing/xfail_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@
"FakeQuantizePerTensorAffineCachemaskModule_basic",
}

# Tests that pass on nightly already, but are still failing on latest stable.
if torch_version_for_comparison() < version.parse("2.1.0.dev"):
TORCHDYNAMO_XFAIL_SET.union({
"EmptyModule_sizeZeroDim",
})

TORCHDYNAMO_CRASHING_SET = {
# No upstream decompositions.
# %6:4 = torch.operator "aten._embedding_bag_forward_only"(%1, %3, %5, %false, %int0, %false, %none, %false, %int-1) : (!torch.tensor<*,f32>, !torch.tensor<*,si64>, !torch.tensor<*,si64>, !torch.bool, !torch.int, !torch.bool, !torch.none, !torch.bool, !torch.int) -> (!torch.tensor, !torch.tensor, !torch.tensor, !torch.tensor)
Expand Down Expand Up @@ -696,6 +702,7 @@
"EmptyModule_falsePinMemory",
"EmptyModule_int",
"EmptyModule_float",
"EmptyModule_sizeZeroDim",
"NewEmptyModuleBool_basic",
"NewEmptyModuleDefaultDtype_basic",
"NewEmptyModuleFalsePinMemory_basic",
Expand Down
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
19 changes: 19 additions & 0 deletions python/torch_mlir_e2e_test/test_suite/constant_alloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,25 @@ def EmptyModule_falsePinMemory(module, tu: TestUtils):
module.forward()


class EmptySizeZeroDimTensorModule(torch.nn.Module):

def __init__(self):
super().__init__()

@export
@annotate_args([
None,
])
def forward(self):
return torch.empty((3, 0, 4),
memory_format=torch.contiguous_format)


@register_test_case(module_factory=lambda: EmptySizeZeroDimTensorModule())
def EmptyModule_sizeZeroDim(module, tu: TestUtils):
module.forward()


# ==============================================================================


Expand Down