[traced-graph][sparse] enable to_dense() for compressed (#133371)

Fixes https://github.com/pytorch/pytorch/issues/133174

Pull Request resolved: https://github.com/pytorch/pytorch/pull/133371
Approved by: https://github.com/ezyang
This commit is contained in:
Aart Bik 2024-08-24 20:33:22 +00:00 committed by PyTorch MergeBot
parent 050aa67e41
commit 1a0d00f1f4
2 changed files with 4 additions and 3 deletions

View File

@ -200,9 +200,6 @@ class TestSparseProp(TestCase):
@parametrize("itype", ITYPES)
@all_sparse_layouts("layout")
def test_todensenet(self, dtype, itype, layout):
if layout is not torch.sparse_coo:
self.skipTest("TODO: support non-coo sparsity (#133174)")
net = ToDenseNet()
for sparse_input in self.generate_simple_inputs(
layout,

View File

@ -278,6 +278,10 @@ class FunctionalTensor(torch.Tensor):
int = _conversion_method_template(dtype=torch.int32)
long = _conversion_method_template(dtype=torch.int64)
# TODO(sparse-team): fixes #133174 but can we do without the relay?
def to_dense(self):
return self.elem.to_dense()
@property
def layout(self):
return self.elem.layout