Skip to content

Compressed sparse validation check fails for empty-batched inputs. #101179

@nikitaved

Description

@nikitaved

🐛 Describe the bug

Moreover, the error message is wrong, as could be seen from below.

In [1]: import torch

In [2]: crow = torch.rand(0, 3).long()

In [3]: col = torch.rand(0, 3).long()

In [4]: vals = torch.rand(0, 3, 64, 64)

In [5]: with torch.sparse.check_sparse_tensor_invariants():
   ...:     torch.sparse_compressed_tensor(crow, col, vals, size=(0, 128, 128), layout=torch.sparse_bsr)
   ...: 
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Input In [5], in <cell line: 1>()
      1 with torch.sparse.check_sparse_tensor_invariants():
----> 2     torch.sparse_compressed_tensor(crow, col, vals, size=(0, 128, 128), layout=torch.sparse_bsr)

RuntimeError: col_indices.shape[-1] must be equal to nnz (=0) as defined by values.shape[1], but got 3

Versions

Current master.

cc @alexsamardzic @pearu @cpuhrsch @amjames @bhosmer

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions