diff --git a/test/expect/TestSparseCSRCPU.test_sparse_csr_print_cpu.expect b/test/expect/TestSparseCSRCPU.test_sparse_csr_print_cpu.expect deleted file mode 100644 index a30958d09d97fb..00000000000000 --- a/test/expect/TestSparseCSRCPU.test_sparse_csr_print_cpu.expect +++ /dev/null @@ -1,176 +0,0 @@ -# shape: torch.Size([10, 10]) -# nnz: 10 -# crow_indices shape: torch.Size([11]) -# col_indices shape: torch.Size([10]) -# values_shape: torch.Size([10]) -########## torch.float32/torch.int32 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, - layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], dtype=torch.int32) -# _col_indices -tensor([0, 1, 0, 1], dtype=torch.int32) -# _values -tensor([1., 2., 3., 4.]) - -########## torch.float64/torch.int32 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, - dtype=torch.float64, layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], dtype=torch.int32) -# _col_indices -tensor([0, 1, 0, 1], dtype=torch.int32) -# _values -tensor([1., 2., 3., 4.], dtype=torch.float64) - - -########## torch.float32/torch.int64 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, - layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4]) -# _col_indices -tensor([0, 1, 0, 1]) -# _values -tensor([1., 2., 3., 4.]) - -########## torch.float64/torch.int64 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, - dtype=torch.float64, layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4]) -# _col_indices -tensor([0, 1, 0, 1]) -# _values -tensor([1., 2., 3., 4.], dtype=torch.float64) - - -# shape: torch.Size([100, 10]) -# nnz: 10 -# crow_indices shape: torch.Size([101]) -# col_indices shape: torch.Size([10]) -# values_shape: torch.Size([10]) -########## torch.float32/torch.int32 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, - layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], dtype=torch.int32) -# _col_indices -tensor([0, 1, 0, 1], dtype=torch.int32) -# _values -tensor([1., 2., 3., 4.]) - -########## torch.float64/torch.int32 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, - dtype=torch.float64, layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], dtype=torch.int32) -# _col_indices -tensor([0, 1, 0, 1], dtype=torch.int32) -# _values -tensor([1., 2., 3., 4.], dtype=torch.float64) - - -########## torch.float32/torch.int64 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, - layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4]) -# _col_indices -tensor([0, 1, 0, 1]) -# _values -tensor([1., 2., 3., 4.]) - -########## torch.float64/torch.int64 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, - dtype=torch.float64, layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4]) -# _col_indices -tensor([0, 1, 0, 1]) -# _values -tensor([1., 2., 3., 4.], dtype=torch.float64) - - -# shape: torch.Size([1000, 10]) -# nnz: 10 -# crow_indices shape: torch.Size([1001]) -# col_indices shape: torch.Size([10]) -# values_shape: torch.Size([10]) -########## torch.float32/torch.int32 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, - layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], dtype=torch.int32) -# _col_indices -tensor([0, 1, 0, 1], dtype=torch.int32) -# _values -tensor([1., 2., 3., 4.]) - -########## torch.float64/torch.int32 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, - dtype=torch.float64, layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], dtype=torch.int32) -# _col_indices -tensor([0, 1, 0, 1], dtype=torch.int32) -# _values -tensor([1., 2., 3., 4.], dtype=torch.float64) - - -########## torch.float32/torch.int64 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, - layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4]) -# _col_indices -tensor([0, 1, 0, 1]) -# _values -tensor([1., 2., 3., 4.]) - -########## torch.float64/torch.int64 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, - dtype=torch.float64, layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4]) -# _col_indices -tensor([0, 1, 0, 1]) -# _values -tensor([1., 2., 3., 4.], dtype=torch.float64) - diff --git a/test/expect/TestSparseCSRCUDA.test_sparse_csr_print_cuda.expect b/test/expect/TestSparseCSRCUDA.test_sparse_csr_print_cuda.expect deleted file mode 100644 index 551092b4a56ee4..00000000000000 --- a/test/expect/TestSparseCSRCUDA.test_sparse_csr_print_cuda.expect +++ /dev/null @@ -1,176 +0,0 @@ -# shape: torch.Size([10, 10]) -# nnz: 10 -# crow_indices shape: torch.Size([11]) -# col_indices shape: torch.Size([10]) -# values_shape: torch.Size([10]) -########## torch.float32/torch.int32 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, - layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], device='cuda:0', dtype=torch.int32) -# _col_indices -tensor([0, 1, 0, 1], device='cuda:0', dtype=torch.int32) -# _values -tensor([1., 2., 3., 4.], device='cuda:0') - -########## torch.float64/torch.int32 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, - dtype=torch.float64, layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], device='cuda:0', dtype=torch.int32) -# _col_indices -tensor([0, 1, 0, 1], device='cuda:0', dtype=torch.int32) -# _values -tensor([1., 2., 3., 4.], device='cuda:0', dtype=torch.float64) - - -########## torch.float32/torch.int64 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, - layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], device='cuda:0') -# _col_indices -tensor([0, 1, 0, 1], device='cuda:0') -# _values -tensor([1., 2., 3., 4.], device='cuda:0') - -########## torch.float64/torch.int64 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, - dtype=torch.float64, layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], device='cuda:0') -# _col_indices -tensor([0, 1, 0, 1], device='cuda:0') -# _values -tensor([1., 2., 3., 4.], device='cuda:0', dtype=torch.float64) - - -# shape: torch.Size([100, 10]) -# nnz: 10 -# crow_indices shape: torch.Size([101]) -# col_indices shape: torch.Size([10]) -# values_shape: torch.Size([10]) -########## torch.float32/torch.int32 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, - layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], device='cuda:0', dtype=torch.int32) -# _col_indices -tensor([0, 1, 0, 1], device='cuda:0', dtype=torch.int32) -# _values -tensor([1., 2., 3., 4.], device='cuda:0') - -########## torch.float64/torch.int32 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, - dtype=torch.float64, layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], device='cuda:0', dtype=torch.int32) -# _col_indices -tensor([0, 1, 0, 1], device='cuda:0', dtype=torch.int32) -# _values -tensor([1., 2., 3., 4.], device='cuda:0', dtype=torch.float64) - - -########## torch.float32/torch.int64 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, - layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], device='cuda:0') -# _col_indices -tensor([0, 1, 0, 1], device='cuda:0') -# _values -tensor([1., 2., 3., 4.], device='cuda:0') - -########## torch.float64/torch.int64 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, - dtype=torch.float64, layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], device='cuda:0') -# _col_indices -tensor([0, 1, 0, 1], device='cuda:0') -# _values -tensor([1., 2., 3., 4.], device='cuda:0', dtype=torch.float64) - - -# shape: torch.Size([1000, 10]) -# nnz: 10 -# crow_indices shape: torch.Size([1001]) -# col_indices shape: torch.Size([10]) -# values_shape: torch.Size([10]) -########## torch.float32/torch.int32 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, - layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], device='cuda:0', dtype=torch.int32) -# _col_indices -tensor([0, 1, 0, 1], device='cuda:0', dtype=torch.int32) -# _values -tensor([1., 2., 3., 4.], device='cuda:0') - -########## torch.float64/torch.int32 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, - dtype=torch.float64, layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], device='cuda:0', dtype=torch.int32) -# _col_indices -tensor([0, 1, 0, 1], device='cuda:0', dtype=torch.int32) -# _values -tensor([1., 2., 3., 4.], device='cuda:0', dtype=torch.float64) - - -########## torch.float32/torch.int64 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, - layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], device='cuda:0') -# _col_indices -tensor([0, 1, 0, 1], device='cuda:0') -# _values -tensor([1., 2., 3., 4.], device='cuda:0') - -########## torch.float64/torch.int64 ########## -# sparse tensor -tensor(crow_indices=tensor([0, 2, 4]), - col_indices=tensor([0, 1, 0, 1]), - values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, - dtype=torch.float64, layout=torch.sparse_csr) -# _crow_indices -tensor([0, 2, 4], device='cuda:0') -# _col_indices -tensor([0, 1, 0, 1], device='cuda:0') -# _values -tensor([1., 2., 3., 4.], device='cuda:0', dtype=torch.float64) - diff --git a/test/expect/TestSparseCompressedCPU.test_print_SparseBSC_cpu.expect b/test/expect/TestSparseCompressedCPU.test_print_SparseBSC_cpu.expect new file mode 100644 index 00000000000000..bcffa8293c9349 --- /dev/null +++ b/test/expect/TestSparseCompressedCPU.test_print_SparseBSC_cpu.expect @@ -0,0 +1,907 @@ +########## torch.float32/torch.int32/batch_shape=()/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([0, 2, 4]), + row_indices=tensor([0, 1, 0, 1]), + values=tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]), size=(2, 2), nnz=4, + layout=torch.sparse_bsc) +# _ccol_indices +tensor([0, 2, 4], dtype=torch.int32) +# _row_indices +tensor([0, 1, 0, 1], dtype=torch.int32) +# _values +tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]) + +########## torch.float32/torch.int32/batch_shape=()/block_shape=(0, 0) ########## +# sparse tensor +tensor(ccol_indices=tensor([0]), + row_indices=tensor([], size=(0,)), + values=tensor([], size=(1, 0, 0)), size=(0, 0), nnz=0, + layout=torch.sparse_bsc) +# _ccol_indices +tensor([0], dtype=torch.int32) +# _row_indices +tensor([], dtype=torch.int32) +# _values +tensor([], size=(1, 0, 0)) + +########## torch.float32/torch.int32/batch_shape=(2,)/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + row_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]), size=(2, 2, 2), nnz=4, + layout=torch.sparse_bsc) +# _ccol_indices +tensor([[0, 2, 4], + [0, 2, 4]], dtype=torch.int32) +# _row_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], dtype=torch.int32) +# _values +tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]) + +########## torch.float32/torch.int32/batch_shape=(2, 3)/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + row_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]), size=(2, 3, 2, 2), nnz=4, + layout=torch.sparse_bsc) +# _ccol_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], dtype=torch.int32) +# _row_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], dtype=torch.int32) +# _values +tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]) + + +########## torch.float64/torch.int32/batch_shape=()/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([0, 2, 4]), + row_indices=tensor([0, 1, 0, 1]), + values=tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]), size=(2, 2), nnz=4, dtype=torch.float64, + layout=torch.sparse_bsc) +# _ccol_indices +tensor([0, 2, 4], dtype=torch.int32) +# _row_indices +tensor([0, 1, 0, 1], dtype=torch.int32) +# _values +tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=()/block_shape=(0, 0) ########## +# sparse tensor +tensor(ccol_indices=tensor([0]), + row_indices=tensor([], size=(0,)), + values=tensor([], size=(1, 0, 0)), size=(0, 0), nnz=0, + dtype=torch.float64, layout=torch.sparse_bsc) +# _ccol_indices +tensor([0], dtype=torch.int32) +# _row_indices +tensor([], dtype=torch.int32) +# _values +tensor([], size=(1, 0, 0), dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=(2,)/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + row_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]), size=(2, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_bsc) +# _ccol_indices +tensor([[0, 2, 4], + [0, 2, 4]], dtype=torch.int32) +# _row_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], dtype=torch.int32) +# _values +tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=(2, 3)/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + row_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]), size=(2, 3, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_bsc) +# _ccol_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], dtype=torch.int32) +# _row_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], dtype=torch.int32) +# _values +tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]], dtype=torch.float64) + + +########## torch.float32/torch.int64/batch_shape=()/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([0, 2, 4]), + row_indices=tensor([0, 1, 0, 1]), + values=tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]), size=(2, 2), nnz=4, + layout=torch.sparse_bsc) +# _ccol_indices +tensor([0, 2, 4]) +# _row_indices +tensor([0, 1, 0, 1]) +# _values +tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]) + +########## torch.float32/torch.int64/batch_shape=()/block_shape=(0, 0) ########## +# sparse tensor +tensor(ccol_indices=tensor([0]), + row_indices=tensor([], size=(0,)), + values=tensor([], size=(1, 0, 0)), size=(0, 0), nnz=0, + layout=torch.sparse_bsc) +# _ccol_indices +tensor([0]) +# _row_indices +tensor([], dtype=torch.int64) +# _values +tensor([], size=(1, 0, 0)) + +########## torch.float32/torch.int64/batch_shape=(2,)/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + row_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]), size=(2, 2, 2), nnz=4, + layout=torch.sparse_bsc) +# _ccol_indices +tensor([[0, 2, 4], + [0, 2, 4]]) +# _row_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]) +# _values +tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]) + +########## torch.float32/torch.int64/batch_shape=(2, 3)/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + row_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]), size=(2, 3, 2, 2), nnz=4, + layout=torch.sparse_bsc) +# _ccol_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]) +# _row_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]) +# _values +tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]) + + +########## torch.float64/torch.int64/batch_shape=()/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([0, 2, 4]), + row_indices=tensor([0, 1, 0, 1]), + values=tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]), size=(2, 2), nnz=4, dtype=torch.float64, + layout=torch.sparse_bsc) +# _ccol_indices +tensor([0, 2, 4]) +# _row_indices +tensor([0, 1, 0, 1]) +# _values +tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=()/block_shape=(0, 0) ########## +# sparse tensor +tensor(ccol_indices=tensor([0]), + row_indices=tensor([], size=(0,)), + values=tensor([], size=(1, 0, 0)), size=(0, 0), nnz=0, + dtype=torch.float64, layout=torch.sparse_bsc) +# _ccol_indices +tensor([0]) +# _row_indices +tensor([], dtype=torch.int64) +# _values +tensor([], size=(1, 0, 0), dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=(2,)/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + row_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]), size=(2, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_bsc) +# _ccol_indices +tensor([[0, 2, 4], + [0, 2, 4]]) +# _row_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]) +# _values +tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=(2, 3)/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + row_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]), size=(2, 3, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_bsc) +# _ccol_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]) +# _row_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]) +# _values +tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]], dtype=torch.float64) + diff --git a/test/expect/TestSparseCompressedCPU.test_print_SparseBSR_cpu.expect b/test/expect/TestSparseCompressedCPU.test_print_SparseBSR_cpu.expect new file mode 100644 index 00000000000000..9f74cd7eb53f28 --- /dev/null +++ b/test/expect/TestSparseCompressedCPU.test_print_SparseBSR_cpu.expect @@ -0,0 +1,907 @@ +########## torch.float32/torch.int32/batch_shape=()/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([0, 2, 4]), + col_indices=tensor([0, 1, 0, 1]), + values=tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]), size=(2, 2), nnz=4, + layout=torch.sparse_bsr) +# _crow_indices +tensor([0, 2, 4], dtype=torch.int32) +# _col_indices +tensor([0, 1, 0, 1], dtype=torch.int32) +# _values +tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]) + +########## torch.float32/torch.int32/batch_shape=()/block_shape=(0, 0) ########## +# sparse tensor +tensor(crow_indices=tensor([0]), + col_indices=tensor([], size=(0,)), + values=tensor([], size=(1, 0, 0)), size=(0, 0), nnz=0, + layout=torch.sparse_bsr) +# _crow_indices +tensor([0], dtype=torch.int32) +# _col_indices +tensor([], dtype=torch.int32) +# _values +tensor([], size=(1, 0, 0)) + +########## torch.float32/torch.int32/batch_shape=(2,)/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + col_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]), size=(2, 2, 2), nnz=4, + layout=torch.sparse_bsr) +# _crow_indices +tensor([[0, 2, 4], + [0, 2, 4]], dtype=torch.int32) +# _col_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], dtype=torch.int32) +# _values +tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]) + +########## torch.float32/torch.int32/batch_shape=(2, 3)/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + col_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]), size=(2, 3, 2, 2), nnz=4, + layout=torch.sparse_bsr) +# _crow_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], dtype=torch.int32) +# _col_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], dtype=torch.int32) +# _values +tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]) + + +########## torch.float64/torch.int32/batch_shape=()/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([0, 2, 4]), + col_indices=tensor([0, 1, 0, 1]), + values=tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]), size=(2, 2), nnz=4, dtype=torch.float64, + layout=torch.sparse_bsr) +# _crow_indices +tensor([0, 2, 4], dtype=torch.int32) +# _col_indices +tensor([0, 1, 0, 1], dtype=torch.int32) +# _values +tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=()/block_shape=(0, 0) ########## +# sparse tensor +tensor(crow_indices=tensor([0]), + col_indices=tensor([], size=(0,)), + values=tensor([], size=(1, 0, 0)), size=(0, 0), nnz=0, + dtype=torch.float64, layout=torch.sparse_bsr) +# _crow_indices +tensor([0], dtype=torch.int32) +# _col_indices +tensor([], dtype=torch.int32) +# _values +tensor([], size=(1, 0, 0), dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=(2,)/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + col_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]), size=(2, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_bsr) +# _crow_indices +tensor([[0, 2, 4], + [0, 2, 4]], dtype=torch.int32) +# _col_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], dtype=torch.int32) +# _values +tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=(2, 3)/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + col_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]), size=(2, 3, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_bsr) +# _crow_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], dtype=torch.int32) +# _col_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], dtype=torch.int32) +# _values +tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]], dtype=torch.float64) + + +########## torch.float32/torch.int64/batch_shape=()/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([0, 2, 4]), + col_indices=tensor([0, 1, 0, 1]), + values=tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]), size=(2, 2), nnz=4, + layout=torch.sparse_bsr) +# _crow_indices +tensor([0, 2, 4]) +# _col_indices +tensor([0, 1, 0, 1]) +# _values +tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]) + +########## torch.float32/torch.int64/batch_shape=()/block_shape=(0, 0) ########## +# sparse tensor +tensor(crow_indices=tensor([0]), + col_indices=tensor([], size=(0,)), + values=tensor([], size=(1, 0, 0)), size=(0, 0), nnz=0, + layout=torch.sparse_bsr) +# _crow_indices +tensor([0]) +# _col_indices +tensor([], dtype=torch.int64) +# _values +tensor([], size=(1, 0, 0)) + +########## torch.float32/torch.int64/batch_shape=(2,)/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + col_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]), size=(2, 2, 2), nnz=4, + layout=torch.sparse_bsr) +# _crow_indices +tensor([[0, 2, 4], + [0, 2, 4]]) +# _col_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]) +# _values +tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]) + +########## torch.float32/torch.int64/batch_shape=(2, 3)/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + col_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]), size=(2, 3, 2, 2), nnz=4, + layout=torch.sparse_bsr) +# _crow_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]) +# _col_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]) +# _values +tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]) + + +########## torch.float64/torch.int64/batch_shape=()/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([0, 2, 4]), + col_indices=tensor([0, 1, 0, 1]), + values=tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]), size=(2, 2), nnz=4, dtype=torch.float64, + layout=torch.sparse_bsr) +# _crow_indices +tensor([0, 2, 4]) +# _col_indices +tensor([0, 1, 0, 1]) +# _values +tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=()/block_shape=(0, 0) ########## +# sparse tensor +tensor(crow_indices=tensor([0]), + col_indices=tensor([], size=(0,)), + values=tensor([], size=(1, 0, 0)), size=(0, 0), nnz=0, + dtype=torch.float64, layout=torch.sparse_bsr) +# _crow_indices +tensor([0]) +# _col_indices +tensor([], dtype=torch.int64) +# _values +tensor([], size=(1, 0, 0), dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=(2,)/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + col_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]), size=(2, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_bsr) +# _crow_indices +tensor([[0, 2, 4], + [0, 2, 4]]) +# _col_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]) +# _values +tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=(2, 3)/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + col_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]), size=(2, 3, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_bsr) +# _crow_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]) +# _col_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]) +# _values +tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]], dtype=torch.float64) + diff --git a/test/expect/TestSparseCompressedCPU.test_print_SparseCSC_cpu.expect b/test/expect/TestSparseCompressedCPU.test_print_SparseCSC_cpu.expect new file mode 100644 index 00000000000000..a449883a3fe20e --- /dev/null +++ b/test/expect/TestSparseCompressedCPU.test_print_SparseCSC_cpu.expect @@ -0,0 +1,379 @@ +########## torch.float32/torch.int32/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([0, 2, 4]), + row_indices=tensor([0, 1, 0, 1]), + values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, + layout=torch.sparse_csc) +# _ccol_indices +tensor([0, 2, 4], dtype=torch.int32) +# _row_indices +tensor([0, 1, 0, 1], dtype=torch.int32) +# _values +tensor([1., 2., 3., 4.]) + +########## torch.float32/torch.int32/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([0]), + row_indices=tensor([], size=(0,)), + values=tensor([], size=(0,)), size=(0, 0), nnz=0, + layout=torch.sparse_csc) +# _ccol_indices +tensor([0], dtype=torch.int32) +# _row_indices +tensor([], dtype=torch.int32) +# _values +tensor([]) + +########## torch.float32/torch.int32/batch_shape=(2,)/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + row_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]), size=(2, 2, 2), nnz=4, + layout=torch.sparse_csc) +# _ccol_indices +tensor([[0, 2, 4], + [0, 2, 4]], dtype=torch.int32) +# _row_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], dtype=torch.int32) +# _values +tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]) + +########## torch.float32/torch.int32/batch_shape=(2, 3)/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + row_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]), size=(2, 3, 2, 2), nnz=4, + layout=torch.sparse_csc) +# _ccol_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], dtype=torch.int32) +# _row_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], dtype=torch.int32) +# _values +tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]) + + +########## torch.float64/torch.int32/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([0, 2, 4]), + row_indices=tensor([0, 1, 0, 1]), + values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_csc) +# _ccol_indices +tensor([0, 2, 4], dtype=torch.int32) +# _row_indices +tensor([0, 1, 0, 1], dtype=torch.int32) +# _values +tensor([1., 2., 3., 4.], dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([0]), + row_indices=tensor([], size=(0,)), + values=tensor([], size=(0,)), size=(0, 0), nnz=0, dtype=torch.float64, + layout=torch.sparse_csc) +# _ccol_indices +tensor([0], dtype=torch.int32) +# _row_indices +tensor([], dtype=torch.int32) +# _values +tensor([], dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=(2,)/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + row_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]), size=(2, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_csc) +# _ccol_indices +tensor([[0, 2, 4], + [0, 2, 4]], dtype=torch.int32) +# _row_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], dtype=torch.int32) +# _values +tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]], dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=(2, 3)/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + row_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]), size=(2, 3, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_csc) +# _ccol_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], dtype=torch.int32) +# _row_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], dtype=torch.int32) +# _values +tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]], dtype=torch.float64) + + +########## torch.float32/torch.int64/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([0, 2, 4]), + row_indices=tensor([0, 1, 0, 1]), + values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, + layout=torch.sparse_csc) +# _ccol_indices +tensor([0, 2, 4]) +# _row_indices +tensor([0, 1, 0, 1]) +# _values +tensor([1., 2., 3., 4.]) + +########## torch.float32/torch.int64/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([0]), + row_indices=tensor([], size=(0,)), + values=tensor([], size=(0,)), size=(0, 0), nnz=0, + layout=torch.sparse_csc) +# _ccol_indices +tensor([0]) +# _row_indices +tensor([], dtype=torch.int64) +# _values +tensor([]) + +########## torch.float32/torch.int64/batch_shape=(2,)/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + row_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]), size=(2, 2, 2), nnz=4, + layout=torch.sparse_csc) +# _ccol_indices +tensor([[0, 2, 4], + [0, 2, 4]]) +# _row_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]) +# _values +tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]) + +########## torch.float32/torch.int64/batch_shape=(2, 3)/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + row_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]), size=(2, 3, 2, 2), nnz=4, + layout=torch.sparse_csc) +# _ccol_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]) +# _row_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]) +# _values +tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]) + + +########## torch.float64/torch.int64/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([0, 2, 4]), + row_indices=tensor([0, 1, 0, 1]), + values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_csc) +# _ccol_indices +tensor([0, 2, 4]) +# _row_indices +tensor([0, 1, 0, 1]) +# _values +tensor([1., 2., 3., 4.], dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([0]), + row_indices=tensor([], size=(0,)), + values=tensor([], size=(0,)), size=(0, 0), nnz=0, dtype=torch.float64, + layout=torch.sparse_csc) +# _ccol_indices +tensor([0]) +# _row_indices +tensor([], dtype=torch.int64) +# _values +tensor([], dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=(2,)/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + row_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]), size=(2, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_csc) +# _ccol_indices +tensor([[0, 2, 4], + [0, 2, 4]]) +# _row_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]) +# _values +tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]], dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=(2, 3)/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + row_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]), size=(2, 3, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_csc) +# _ccol_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]) +# _row_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]) +# _values +tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]], dtype=torch.float64) + diff --git a/test/expect/TestSparseCompressedCPU.test_print_SparseCSR_cpu.expect b/test/expect/TestSparseCompressedCPU.test_print_SparseCSR_cpu.expect new file mode 100644 index 00000000000000..02476652e4b7fc --- /dev/null +++ b/test/expect/TestSparseCompressedCPU.test_print_SparseCSR_cpu.expect @@ -0,0 +1,379 @@ +########## torch.float32/torch.int32/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([0, 2, 4]), + col_indices=tensor([0, 1, 0, 1]), + values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, + layout=torch.sparse_csr) +# _crow_indices +tensor([0, 2, 4], dtype=torch.int32) +# _col_indices +tensor([0, 1, 0, 1], dtype=torch.int32) +# _values +tensor([1., 2., 3., 4.]) + +########## torch.float32/torch.int32/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([0]), + col_indices=tensor([], size=(0,)), + values=tensor([], size=(0,)), size=(0, 0), nnz=0, + layout=torch.sparse_csr) +# _crow_indices +tensor([0], dtype=torch.int32) +# _col_indices +tensor([], dtype=torch.int32) +# _values +tensor([]) + +########## torch.float32/torch.int32/batch_shape=(2,)/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + col_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]), size=(2, 2, 2), nnz=4, + layout=torch.sparse_csr) +# _crow_indices +tensor([[0, 2, 4], + [0, 2, 4]], dtype=torch.int32) +# _col_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], dtype=torch.int32) +# _values +tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]) + +########## torch.float32/torch.int32/batch_shape=(2, 3)/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + col_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]), size=(2, 3, 2, 2), nnz=4, + layout=torch.sparse_csr) +# _crow_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], dtype=torch.int32) +# _col_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], dtype=torch.int32) +# _values +tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]) + + +########## torch.float64/torch.int32/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([0, 2, 4]), + col_indices=tensor([0, 1, 0, 1]), + values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_csr) +# _crow_indices +tensor([0, 2, 4], dtype=torch.int32) +# _col_indices +tensor([0, 1, 0, 1], dtype=torch.int32) +# _values +tensor([1., 2., 3., 4.], dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([0]), + col_indices=tensor([], size=(0,)), + values=tensor([], size=(0,)), size=(0, 0), nnz=0, dtype=torch.float64, + layout=torch.sparse_csr) +# _crow_indices +tensor([0], dtype=torch.int32) +# _col_indices +tensor([], dtype=torch.int32) +# _values +tensor([], dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=(2,)/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + col_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]), size=(2, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_csr) +# _crow_indices +tensor([[0, 2, 4], + [0, 2, 4]], dtype=torch.int32) +# _col_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], dtype=torch.int32) +# _values +tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]], dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=(2, 3)/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + col_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]), size=(2, 3, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_csr) +# _crow_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], dtype=torch.int32) +# _col_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], dtype=torch.int32) +# _values +tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]], dtype=torch.float64) + + +########## torch.float32/torch.int64/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([0, 2, 4]), + col_indices=tensor([0, 1, 0, 1]), + values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, + layout=torch.sparse_csr) +# _crow_indices +tensor([0, 2, 4]) +# _col_indices +tensor([0, 1, 0, 1]) +# _values +tensor([1., 2., 3., 4.]) + +########## torch.float32/torch.int64/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([0]), + col_indices=tensor([], size=(0,)), + values=tensor([], size=(0,)), size=(0, 0), nnz=0, + layout=torch.sparse_csr) +# _crow_indices +tensor([0]) +# _col_indices +tensor([], dtype=torch.int64) +# _values +tensor([]) + +########## torch.float32/torch.int64/batch_shape=(2,)/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + col_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]), size=(2, 2, 2), nnz=4, + layout=torch.sparse_csr) +# _crow_indices +tensor([[0, 2, 4], + [0, 2, 4]]) +# _col_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]) +# _values +tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]) + +########## torch.float32/torch.int64/batch_shape=(2, 3)/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + col_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]), size=(2, 3, 2, 2), nnz=4, + layout=torch.sparse_csr) +# _crow_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]) +# _col_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]) +# _values +tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]) + + +########## torch.float64/torch.int64/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([0, 2, 4]), + col_indices=tensor([0, 1, 0, 1]), + values=tensor([1., 2., 3., 4.]), size=(2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_csr) +# _crow_indices +tensor([0, 2, 4]) +# _col_indices +tensor([0, 1, 0, 1]) +# _values +tensor([1., 2., 3., 4.], dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([0]), + col_indices=tensor([], size=(0,)), + values=tensor([], size=(0,)), size=(0, 0), nnz=0, dtype=torch.float64, + layout=torch.sparse_csr) +# _crow_indices +tensor([0]) +# _col_indices +tensor([], dtype=torch.int64) +# _values +tensor([], dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=(2,)/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + col_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]), size=(2, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_csr) +# _crow_indices +tensor([[0, 2, 4], + [0, 2, 4]]) +# _col_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]) +# _values +tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]], dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=(2, 3)/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + col_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]), size=(2, 3, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_csr) +# _crow_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]) +# _col_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]) +# _values +tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]], dtype=torch.float64) + diff --git a/test/expect/TestSparseCompressedCUDA.test_print_SparseBSC_cuda.expect b/test/expect/TestSparseCompressedCUDA.test_print_SparseBSC_cuda.expect new file mode 100644 index 00000000000000..df75cb3a4f6169 --- /dev/null +++ b/test/expect/TestSparseCompressedCUDA.test_print_SparseBSC_cuda.expect @@ -0,0 +1,907 @@ +########## torch.float32/torch.int32/batch_shape=()/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([0, 2, 4]), + row_indices=tensor([0, 1, 0, 1]), + values=tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]), device='cuda:0', size=(2, 2), nnz=4, + layout=torch.sparse_bsc) +# _ccol_indices +tensor([0, 2, 4], device='cuda:0', dtype=torch.int32) +# _row_indices +tensor([0, 1, 0, 1], device='cuda:0', dtype=torch.int32) +# _values +tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], device='cuda:0') + +########## torch.float32/torch.int32/batch_shape=()/block_shape=(0, 0) ########## +# sparse tensor +tensor(ccol_indices=tensor([0]), + row_indices=tensor([], size=(0,)), + values=tensor([], size=(1, 0, 0)), device='cuda:0', size=(0, 0), nnz=0, + layout=torch.sparse_bsc) +# _ccol_indices +tensor([0], device='cuda:0', dtype=torch.int32) +# _row_indices +tensor([], device='cuda:0', dtype=torch.int32) +# _values +tensor([], device='cuda:0', size=(1, 0, 0)) + +########## torch.float32/torch.int32/batch_shape=(2,)/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + row_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]), device='cuda:0', size=(2, 2, 2), nnz=4, + layout=torch.sparse_bsc) +# _ccol_indices +tensor([[0, 2, 4], + [0, 2, 4]], device='cuda:0', dtype=torch.int32) +# _row_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], device='cuda:0', dtype=torch.int32) +# _values +tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], device='cuda:0') + +########## torch.float32/torch.int32/batch_shape=(2, 3)/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + row_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]), device='cuda:0', size=(2, 3, 2, 2), + nnz=4, layout=torch.sparse_bsc) +# _ccol_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], device='cuda:0', dtype=torch.int32) +# _row_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], device='cuda:0', dtype=torch.int32) +# _values +tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]], device='cuda:0') + + +########## torch.float64/torch.int32/batch_shape=()/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([0, 2, 4]), + row_indices=tensor([0, 1, 0, 1]), + values=tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]), device='cuda:0', size=(2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_bsc) +# _ccol_indices +tensor([0, 2, 4], device='cuda:0', dtype=torch.int32) +# _row_indices +tensor([0, 1, 0, 1], device='cuda:0', dtype=torch.int32) +# _values +tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=()/block_shape=(0, 0) ########## +# sparse tensor +tensor(ccol_indices=tensor([0]), + row_indices=tensor([], size=(0,)), + values=tensor([], size=(1, 0, 0)), device='cuda:0', size=(0, 0), nnz=0, + dtype=torch.float64, layout=torch.sparse_bsc) +# _ccol_indices +tensor([0], device='cuda:0', dtype=torch.int32) +# _row_indices +tensor([], device='cuda:0', dtype=torch.int32) +# _values +tensor([], device='cuda:0', size=(1, 0, 0), dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=(2,)/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + row_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]), device='cuda:0', size=(2, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_bsc) +# _ccol_indices +tensor([[0, 2, 4], + [0, 2, 4]], device='cuda:0', dtype=torch.int32) +# _row_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], device='cuda:0', dtype=torch.int32) +# _values +tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=(2, 3)/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + row_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]), device='cuda:0', size=(2, 3, 2, 2), + nnz=4, dtype=torch.float64, layout=torch.sparse_bsc) +# _ccol_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], device='cuda:0', dtype=torch.int32) +# _row_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], device='cuda:0', dtype=torch.int32) +# _values +tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]], device='cuda:0', dtype=torch.float64) + + +########## torch.float32/torch.int64/batch_shape=()/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([0, 2, 4]), + row_indices=tensor([0, 1, 0, 1]), + values=tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]), device='cuda:0', size=(2, 2), nnz=4, + layout=torch.sparse_bsc) +# _ccol_indices +tensor([0, 2, 4], device='cuda:0') +# _row_indices +tensor([0, 1, 0, 1], device='cuda:0') +# _values +tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], device='cuda:0') + +########## torch.float32/torch.int64/batch_shape=()/block_shape=(0, 0) ########## +# sparse tensor +tensor(ccol_indices=tensor([0]), + row_indices=tensor([], size=(0,)), + values=tensor([], size=(1, 0, 0)), device='cuda:0', size=(0, 0), nnz=0, + layout=torch.sparse_bsc) +# _ccol_indices +tensor([0], device='cuda:0') +# _row_indices +tensor([], device='cuda:0', dtype=torch.int64) +# _values +tensor([], device='cuda:0', size=(1, 0, 0)) + +########## torch.float32/torch.int64/batch_shape=(2,)/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + row_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]), device='cuda:0', size=(2, 2, 2), nnz=4, + layout=torch.sparse_bsc) +# _ccol_indices +tensor([[0, 2, 4], + [0, 2, 4]], device='cuda:0') +# _row_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], device='cuda:0') +# _values +tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], device='cuda:0') + +########## torch.float32/torch.int64/batch_shape=(2, 3)/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + row_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]), device='cuda:0', size=(2, 3, 2, 2), + nnz=4, layout=torch.sparse_bsc) +# _ccol_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], device='cuda:0') +# _row_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], device='cuda:0') +# _values +tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]], device='cuda:0') + + +########## torch.float64/torch.int64/batch_shape=()/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([0, 2, 4]), + row_indices=tensor([0, 1, 0, 1]), + values=tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]), device='cuda:0', size=(2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_bsc) +# _ccol_indices +tensor([0, 2, 4], device='cuda:0') +# _row_indices +tensor([0, 1, 0, 1], device='cuda:0') +# _values +tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=()/block_shape=(0, 0) ########## +# sparse tensor +tensor(ccol_indices=tensor([0]), + row_indices=tensor([], size=(0,)), + values=tensor([], size=(1, 0, 0)), device='cuda:0', size=(0, 0), nnz=0, + dtype=torch.float64, layout=torch.sparse_bsc) +# _ccol_indices +tensor([0], device='cuda:0') +# _row_indices +tensor([], device='cuda:0', dtype=torch.int64) +# _values +tensor([], device='cuda:0', size=(1, 0, 0), dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=(2,)/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + row_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]), device='cuda:0', size=(2, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_bsc) +# _ccol_indices +tensor([[0, 2, 4], + [0, 2, 4]], device='cuda:0') +# _row_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], device='cuda:0') +# _values +tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=(2, 3)/block_shape=(1, 2) ########## +# sparse tensor +tensor(ccol_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + row_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]), device='cuda:0', size=(2, 3, 2, 2), + nnz=4, dtype=torch.float64, layout=torch.sparse_bsc) +# _ccol_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], device='cuda:0') +# _row_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], device='cuda:0') +# _values +tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]], device='cuda:0', dtype=torch.float64) + diff --git a/test/expect/TestSparseCompressedCUDA.test_print_SparseBSR_cuda.expect b/test/expect/TestSparseCompressedCUDA.test_print_SparseBSR_cuda.expect new file mode 100644 index 00000000000000..5ab909227272ad --- /dev/null +++ b/test/expect/TestSparseCompressedCUDA.test_print_SparseBSR_cuda.expect @@ -0,0 +1,907 @@ +########## torch.float32/torch.int32/batch_shape=()/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([0, 2, 4]), + col_indices=tensor([0, 1, 0, 1]), + values=tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]), device='cuda:0', size=(2, 2), nnz=4, + layout=torch.sparse_bsr) +# _crow_indices +tensor([0, 2, 4], device='cuda:0', dtype=torch.int32) +# _col_indices +tensor([0, 1, 0, 1], device='cuda:0', dtype=torch.int32) +# _values +tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], device='cuda:0') + +########## torch.float32/torch.int32/batch_shape=()/block_shape=(0, 0) ########## +# sparse tensor +tensor(crow_indices=tensor([0]), + col_indices=tensor([], size=(0,)), + values=tensor([], size=(1, 0, 0)), device='cuda:0', size=(0, 0), nnz=0, + layout=torch.sparse_bsr) +# _crow_indices +tensor([0], device='cuda:0', dtype=torch.int32) +# _col_indices +tensor([], device='cuda:0', dtype=torch.int32) +# _values +tensor([], device='cuda:0', size=(1, 0, 0)) + +########## torch.float32/torch.int32/batch_shape=(2,)/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + col_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]), device='cuda:0', size=(2, 2, 2), nnz=4, + layout=torch.sparse_bsr) +# _crow_indices +tensor([[0, 2, 4], + [0, 2, 4]], device='cuda:0', dtype=torch.int32) +# _col_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], device='cuda:0', dtype=torch.int32) +# _values +tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], device='cuda:0') + +########## torch.float32/torch.int32/batch_shape=(2, 3)/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + col_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]), device='cuda:0', size=(2, 3, 2, 2), + nnz=4, layout=torch.sparse_bsr) +# _crow_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], device='cuda:0', dtype=torch.int32) +# _col_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], device='cuda:0', dtype=torch.int32) +# _values +tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]], device='cuda:0') + + +########## torch.float64/torch.int32/batch_shape=()/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([0, 2, 4]), + col_indices=tensor([0, 1, 0, 1]), + values=tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]), device='cuda:0', size=(2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_bsr) +# _crow_indices +tensor([0, 2, 4], device='cuda:0', dtype=torch.int32) +# _col_indices +tensor([0, 1, 0, 1], device='cuda:0', dtype=torch.int32) +# _values +tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=()/block_shape=(0, 0) ########## +# sparse tensor +tensor(crow_indices=tensor([0]), + col_indices=tensor([], size=(0,)), + values=tensor([], size=(1, 0, 0)), device='cuda:0', size=(0, 0), nnz=0, + dtype=torch.float64, layout=torch.sparse_bsr) +# _crow_indices +tensor([0], device='cuda:0', dtype=torch.int32) +# _col_indices +tensor([], device='cuda:0', dtype=torch.int32) +# _values +tensor([], device='cuda:0', size=(1, 0, 0), dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=(2,)/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + col_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]), device='cuda:0', size=(2, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_bsr) +# _crow_indices +tensor([[0, 2, 4], + [0, 2, 4]], device='cuda:0', dtype=torch.int32) +# _col_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], device='cuda:0', dtype=torch.int32) +# _values +tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=(2, 3)/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + col_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]), device='cuda:0', size=(2, 3, 2, 2), + nnz=4, dtype=torch.float64, layout=torch.sparse_bsr) +# _crow_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], device='cuda:0', dtype=torch.int32) +# _col_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], device='cuda:0', dtype=torch.int32) +# _values +tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]], device='cuda:0', dtype=torch.float64) + + +########## torch.float32/torch.int64/batch_shape=()/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([0, 2, 4]), + col_indices=tensor([0, 1, 0, 1]), + values=tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]), device='cuda:0', size=(2, 2), nnz=4, + layout=torch.sparse_bsr) +# _crow_indices +tensor([0, 2, 4], device='cuda:0') +# _col_indices +tensor([0, 1, 0, 1], device='cuda:0') +# _values +tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], device='cuda:0') + +########## torch.float32/torch.int64/batch_shape=()/block_shape=(0, 0) ########## +# sparse tensor +tensor(crow_indices=tensor([0]), + col_indices=tensor([], size=(0,)), + values=tensor([], size=(1, 0, 0)), device='cuda:0', size=(0, 0), nnz=0, + layout=torch.sparse_bsr) +# _crow_indices +tensor([0], device='cuda:0') +# _col_indices +tensor([], device='cuda:0', dtype=torch.int64) +# _values +tensor([], device='cuda:0', size=(1, 0, 0)) + +########## torch.float32/torch.int64/batch_shape=(2,)/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + col_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]), device='cuda:0', size=(2, 2, 2), nnz=4, + layout=torch.sparse_bsr) +# _crow_indices +tensor([[0, 2, 4], + [0, 2, 4]], device='cuda:0') +# _col_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], device='cuda:0') +# _values +tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], device='cuda:0') + +########## torch.float32/torch.int64/batch_shape=(2, 3)/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + col_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]), device='cuda:0', size=(2, 3, 2, 2), + nnz=4, layout=torch.sparse_bsr) +# _crow_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], device='cuda:0') +# _col_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], device='cuda:0') +# _values +tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]], device='cuda:0') + + +########## torch.float64/torch.int64/batch_shape=()/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([0, 2, 4]), + col_indices=tensor([0, 1, 0, 1]), + values=tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]), device='cuda:0', size=(2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_bsr) +# _crow_indices +tensor([0, 2, 4], device='cuda:0') +# _col_indices +tensor([0, 1, 0, 1], device='cuda:0') +# _values +tensor([[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=()/block_shape=(0, 0) ########## +# sparse tensor +tensor(crow_indices=tensor([0]), + col_indices=tensor([], size=(0,)), + values=tensor([], size=(1, 0, 0)), device='cuda:0', size=(0, 0), nnz=0, + dtype=torch.float64, layout=torch.sparse_bsr) +# _crow_indices +tensor([0], device='cuda:0') +# _col_indices +tensor([], device='cuda:0', dtype=torch.int64) +# _values +tensor([], device='cuda:0', size=(1, 0, 0), dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=(2,)/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + col_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]), device='cuda:0', size=(2, 2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_bsr) +# _crow_indices +tensor([[0, 2, 4], + [0, 2, 4]], device='cuda:0') +# _col_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], device='cuda:0') +# _values +tensor([[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=(2, 3)/block_shape=(1, 2) ########## +# sparse tensor +tensor(crow_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + col_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]]), device='cuda:0', size=(2, 3, 2, 2), + nnz=4, dtype=torch.float64, layout=torch.sparse_bsr) +# _crow_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], device='cuda:0') +# _col_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], device='cuda:0') +# _values +tensor([[[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]], + + + + [[[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]], + + + [[[ 1., 11.]], + + [[ 2., 22.]], + + [[ 3., 33.]], + + [[ 4., 44.]]]]], device='cuda:0', dtype=torch.float64) + diff --git a/test/expect/TestSparseCompressedCUDA.test_print_SparseCSC_cuda.expect b/test/expect/TestSparseCompressedCUDA.test_print_SparseCSC_cuda.expect new file mode 100644 index 00000000000000..4292bfcd219940 --- /dev/null +++ b/test/expect/TestSparseCompressedCUDA.test_print_SparseCSC_cuda.expect @@ -0,0 +1,379 @@ +########## torch.float32/torch.int32/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([0, 2, 4]), + row_indices=tensor([0, 1, 0, 1]), + values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, + layout=torch.sparse_csc) +# _ccol_indices +tensor([0, 2, 4], device='cuda:0', dtype=torch.int32) +# _row_indices +tensor([0, 1, 0, 1], device='cuda:0', dtype=torch.int32) +# _values +tensor([1., 2., 3., 4.], device='cuda:0') + +########## torch.float32/torch.int32/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([0]), + row_indices=tensor([], size=(0,)), + values=tensor([], size=(0,)), device='cuda:0', size=(0, 0), nnz=0, + layout=torch.sparse_csc) +# _ccol_indices +tensor([0], device='cuda:0', dtype=torch.int32) +# _row_indices +tensor([], device='cuda:0', dtype=torch.int32) +# _values +tensor([], device='cuda:0') + +########## torch.float32/torch.int32/batch_shape=(2,)/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + row_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]), device='cuda:0', size=(2, 2, 2), + nnz=4, layout=torch.sparse_csc) +# _ccol_indices +tensor([[0, 2, 4], + [0, 2, 4]], device='cuda:0', dtype=torch.int32) +# _row_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], device='cuda:0', dtype=torch.int32) +# _values +tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]], device='cuda:0') + +########## torch.float32/torch.int32/batch_shape=(2, 3)/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + row_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]), device='cuda:0', size=(2, 3, 2, 2), + nnz=4, layout=torch.sparse_csc) +# _ccol_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], device='cuda:0', dtype=torch.int32) +# _row_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], device='cuda:0', dtype=torch.int32) +# _values +tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]], device='cuda:0') + + +########## torch.float64/torch.int32/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([0, 2, 4]), + row_indices=tensor([0, 1, 0, 1]), + values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_csc) +# _ccol_indices +tensor([0, 2, 4], device='cuda:0', dtype=torch.int32) +# _row_indices +tensor([0, 1, 0, 1], device='cuda:0', dtype=torch.int32) +# _values +tensor([1., 2., 3., 4.], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([0]), + row_indices=tensor([], size=(0,)), + values=tensor([], size=(0,)), device='cuda:0', size=(0, 0), nnz=0, + dtype=torch.float64, layout=torch.sparse_csc) +# _ccol_indices +tensor([0], device='cuda:0', dtype=torch.int32) +# _row_indices +tensor([], device='cuda:0', dtype=torch.int32) +# _values +tensor([], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=(2,)/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + row_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]), device='cuda:0', size=(2, 2, 2), + nnz=4, dtype=torch.float64, layout=torch.sparse_csc) +# _ccol_indices +tensor([[0, 2, 4], + [0, 2, 4]], device='cuda:0', dtype=torch.int32) +# _row_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], device='cuda:0', dtype=torch.int32) +# _values +tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=(2, 3)/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + row_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]), device='cuda:0', size=(2, 3, 2, 2), + nnz=4, dtype=torch.float64, layout=torch.sparse_csc) +# _ccol_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], device='cuda:0', dtype=torch.int32) +# _row_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], device='cuda:0', dtype=torch.int32) +# _values +tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]], device='cuda:0', dtype=torch.float64) + + +########## torch.float32/torch.int64/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([0, 2, 4]), + row_indices=tensor([0, 1, 0, 1]), + values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, + layout=torch.sparse_csc) +# _ccol_indices +tensor([0, 2, 4], device='cuda:0') +# _row_indices +tensor([0, 1, 0, 1], device='cuda:0') +# _values +tensor([1., 2., 3., 4.], device='cuda:0') + +########## torch.float32/torch.int64/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([0]), + row_indices=tensor([], size=(0,)), + values=tensor([], size=(0,)), device='cuda:0', size=(0, 0), nnz=0, + layout=torch.sparse_csc) +# _ccol_indices +tensor([0], device='cuda:0') +# _row_indices +tensor([], device='cuda:0', dtype=torch.int64) +# _values +tensor([], device='cuda:0') + +########## torch.float32/torch.int64/batch_shape=(2,)/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + row_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]), device='cuda:0', size=(2, 2, 2), + nnz=4, layout=torch.sparse_csc) +# _ccol_indices +tensor([[0, 2, 4], + [0, 2, 4]], device='cuda:0') +# _row_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], device='cuda:0') +# _values +tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]], device='cuda:0') + +########## torch.float32/torch.int64/batch_shape=(2, 3)/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + row_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]), device='cuda:0', size=(2, 3, 2, 2), + nnz=4, layout=torch.sparse_csc) +# _ccol_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], device='cuda:0') +# _row_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], device='cuda:0') +# _values +tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]], device='cuda:0') + + +########## torch.float64/torch.int64/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([0, 2, 4]), + row_indices=tensor([0, 1, 0, 1]), + values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_csc) +# _ccol_indices +tensor([0, 2, 4], device='cuda:0') +# _row_indices +tensor([0, 1, 0, 1], device='cuda:0') +# _values +tensor([1., 2., 3., 4.], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([0]), + row_indices=tensor([], size=(0,)), + values=tensor([], size=(0,)), device='cuda:0', size=(0, 0), nnz=0, + dtype=torch.float64, layout=torch.sparse_csc) +# _ccol_indices +tensor([0], device='cuda:0') +# _row_indices +tensor([], device='cuda:0', dtype=torch.int64) +# _values +tensor([], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=(2,)/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + row_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]), device='cuda:0', size=(2, 2, 2), + nnz=4, dtype=torch.float64, layout=torch.sparse_csc) +# _ccol_indices +tensor([[0, 2, 4], + [0, 2, 4]], device='cuda:0') +# _row_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], device='cuda:0') +# _values +tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=(2, 3)/block_shape=() ########## +# sparse tensor +tensor(ccol_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + row_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]), device='cuda:0', size=(2, 3, 2, 2), + nnz=4, dtype=torch.float64, layout=torch.sparse_csc) +# _ccol_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], device='cuda:0') +# _row_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], device='cuda:0') +# _values +tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]], device='cuda:0', dtype=torch.float64) + diff --git a/test/expect/TestSparseCompressedCUDA.test_print_SparseCSR_cuda.expect b/test/expect/TestSparseCompressedCUDA.test_print_SparseCSR_cuda.expect new file mode 100644 index 00000000000000..918f2570807f7a --- /dev/null +++ b/test/expect/TestSparseCompressedCUDA.test_print_SparseCSR_cuda.expect @@ -0,0 +1,379 @@ +########## torch.float32/torch.int32/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([0, 2, 4]), + col_indices=tensor([0, 1, 0, 1]), + values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, + layout=torch.sparse_csr) +# _crow_indices +tensor([0, 2, 4], device='cuda:0', dtype=torch.int32) +# _col_indices +tensor([0, 1, 0, 1], device='cuda:0', dtype=torch.int32) +# _values +tensor([1., 2., 3., 4.], device='cuda:0') + +########## torch.float32/torch.int32/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([0]), + col_indices=tensor([], size=(0,)), + values=tensor([], size=(0,)), device='cuda:0', size=(0, 0), nnz=0, + layout=torch.sparse_csr) +# _crow_indices +tensor([0], device='cuda:0', dtype=torch.int32) +# _col_indices +tensor([], device='cuda:0', dtype=torch.int32) +# _values +tensor([], device='cuda:0') + +########## torch.float32/torch.int32/batch_shape=(2,)/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + col_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]), device='cuda:0', size=(2, 2, 2), + nnz=4, layout=torch.sparse_csr) +# _crow_indices +tensor([[0, 2, 4], + [0, 2, 4]], device='cuda:0', dtype=torch.int32) +# _col_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], device='cuda:0', dtype=torch.int32) +# _values +tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]], device='cuda:0') + +########## torch.float32/torch.int32/batch_shape=(2, 3)/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + col_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]), device='cuda:0', size=(2, 3, 2, 2), + nnz=4, layout=torch.sparse_csr) +# _crow_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], device='cuda:0', dtype=torch.int32) +# _col_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], device='cuda:0', dtype=torch.int32) +# _values +tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]], device='cuda:0') + + +########## torch.float64/torch.int32/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([0, 2, 4]), + col_indices=tensor([0, 1, 0, 1]), + values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_csr) +# _crow_indices +tensor([0, 2, 4], device='cuda:0', dtype=torch.int32) +# _col_indices +tensor([0, 1, 0, 1], device='cuda:0', dtype=torch.int32) +# _values +tensor([1., 2., 3., 4.], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([0]), + col_indices=tensor([], size=(0,)), + values=tensor([], size=(0,)), device='cuda:0', size=(0, 0), nnz=0, + dtype=torch.float64, layout=torch.sparse_csr) +# _crow_indices +tensor([0], device='cuda:0', dtype=torch.int32) +# _col_indices +tensor([], device='cuda:0', dtype=torch.int32) +# _values +tensor([], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=(2,)/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + col_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]), device='cuda:0', size=(2, 2, 2), + nnz=4, dtype=torch.float64, layout=torch.sparse_csr) +# _crow_indices +tensor([[0, 2, 4], + [0, 2, 4]], device='cuda:0', dtype=torch.int32) +# _col_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], device='cuda:0', dtype=torch.int32) +# _values +tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int32/batch_shape=(2, 3)/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + col_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]), device='cuda:0', size=(2, 3, 2, 2), + nnz=4, dtype=torch.float64, layout=torch.sparse_csr) +# _crow_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], device='cuda:0', dtype=torch.int32) +# _col_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], device='cuda:0', dtype=torch.int32) +# _values +tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]], device='cuda:0', dtype=torch.float64) + + +########## torch.float32/torch.int64/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([0, 2, 4]), + col_indices=tensor([0, 1, 0, 1]), + values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, + layout=torch.sparse_csr) +# _crow_indices +tensor([0, 2, 4], device='cuda:0') +# _col_indices +tensor([0, 1, 0, 1], device='cuda:0') +# _values +tensor([1., 2., 3., 4.], device='cuda:0') + +########## torch.float32/torch.int64/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([0]), + col_indices=tensor([], size=(0,)), + values=tensor([], size=(0,)), device='cuda:0', size=(0, 0), nnz=0, + layout=torch.sparse_csr) +# _crow_indices +tensor([0], device='cuda:0') +# _col_indices +tensor([], device='cuda:0', dtype=torch.int64) +# _values +tensor([], device='cuda:0') + +########## torch.float32/torch.int64/batch_shape=(2,)/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + col_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]), device='cuda:0', size=(2, 2, 2), + nnz=4, layout=torch.sparse_csr) +# _crow_indices +tensor([[0, 2, 4], + [0, 2, 4]], device='cuda:0') +# _col_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], device='cuda:0') +# _values +tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]], device='cuda:0') + +########## torch.float32/torch.int64/batch_shape=(2, 3)/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + col_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]), device='cuda:0', size=(2, 3, 2, 2), + nnz=4, layout=torch.sparse_csr) +# _crow_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], device='cuda:0') +# _col_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], device='cuda:0') +# _values +tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]], device='cuda:0') + + +########## torch.float64/torch.int64/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([0, 2, 4]), + col_indices=tensor([0, 1, 0, 1]), + values=tensor([1., 2., 3., 4.]), device='cuda:0', size=(2, 2), nnz=4, + dtype=torch.float64, layout=torch.sparse_csr) +# _crow_indices +tensor([0, 2, 4], device='cuda:0') +# _col_indices +tensor([0, 1, 0, 1], device='cuda:0') +# _values +tensor([1., 2., 3., 4.], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=()/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([0]), + col_indices=tensor([], size=(0,)), + values=tensor([], size=(0,)), device='cuda:0', size=(0, 0), nnz=0, + dtype=torch.float64, layout=torch.sparse_csr) +# _crow_indices +tensor([0], device='cuda:0') +# _col_indices +tensor([], device='cuda:0', dtype=torch.int64) +# _values +tensor([], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=(2,)/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([[0, 2, 4], + [0, 2, 4]]), + col_indices=tensor([[0, 1, 0, 1], + [0, 1, 0, 1]]), + values=tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]]), device='cuda:0', size=(2, 2, 2), + nnz=4, dtype=torch.float64, layout=torch.sparse_csr) +# _crow_indices +tensor([[0, 2, 4], + [0, 2, 4]], device='cuda:0') +# _col_indices +tensor([[0, 1, 0, 1], + [0, 1, 0, 1]], device='cuda:0') +# _values +tensor([[1., 2., 3., 4.], + [1., 2., 3., 4.]], device='cuda:0', dtype=torch.float64) + +########## torch.float64/torch.int64/batch_shape=(2, 3)/block_shape=() ########## +# sparse tensor +tensor(crow_indices=tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]]), + col_indices=tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]]), + values=tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]]), device='cuda:0', size=(2, 3, 2, 2), + nnz=4, dtype=torch.float64, layout=torch.sparse_csr) +# _crow_indices +tensor([[[0, 2, 4], + [0, 2, 4], + [0, 2, 4]], + + [[0, 2, 4], + [0, 2, 4], + [0, 2, 4]]], device='cuda:0') +# _col_indices +tensor([[[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]], + + [[0, 1, 0, 1], + [0, 1, 0, 1], + [0, 1, 0, 1]]], device='cuda:0') +# _values +tensor([[[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]], + + [[1., 2., 3., 4.], + [1., 2., 3., 4.], + [1., 2., 3., 4.]]], device='cuda:0', dtype=torch.float64) + diff --git a/test/test_sparse_csr.py b/test/test_sparse_csr.py index 75a10aa27f1481..84d20ef6d32cfd 100644 --- a/test/test_sparse_csr.py +++ b/test/test_sparse_csr.py @@ -151,6 +151,13 @@ def sparse_compressed_nonblock_layouts(test_name='layout'): subtest(torch.sparse_csr, name='SparseCSR'), subtest(torch.sparse_csc, name='SparseCSC')]) +sparse_compressed_indices_methods = { + torch.sparse_csr: (torch.Tensor.crow_indices, torch.Tensor.col_indices), + torch.sparse_csc: (torch.Tensor.ccol_indices, torch.Tensor.row_indices), + torch.sparse_bsr: (torch.Tensor.crow_indices, torch.Tensor.col_indices), + torch.sparse_bsc: (torch.Tensor.ccol_indices, torch.Tensor.row_indices), +} + class TestSparseCompressed(TestCase): """Testing sparse compressed (CSR, CSC, BSR, BSC) tensor generic features. @@ -178,7 +185,7 @@ def _generate_small_inputs(self, layout, device, dtype, index_dtype): torch.tensor([], device=device, dtype=index_dtype), torch.tensor([], device=device, dtype=dtype), (0, 0)) - for batch_shape in {(2, 3), (2,)}: + for batch_shape in [(2,), (2, 3)]: prod = reduce(mul, batch_shape, 1) yield (torch.tensor([0, 2, 4], device=device, dtype=index_dtype).repeat(prod, 1).reshape(*batch_shape, -1), torch.tensor([0, 1, 0, 1], device=device, dtype=index_dtype).repeat(prod, 1).reshape(*batch_shape, -1), @@ -194,7 +201,7 @@ def _generate_small_inputs(self, layout, device, dtype, index_dtype): torch.tensor([], device=device, dtype=index_dtype), torch.tensor([], device=device, dtype=dtype).reshape(1, 0, 0), (0, 0)) - for batch_shape in {(2, 3), (2,)}: + for batch_shape in [(2,), (2, 3)]: prod = reduce(mul, batch_shape, 1) yield (torch.tensor([0, 2, 4], device=device, dtype=index_dtype).repeat(prod, 1).reshape(*batch_shape, -1), torch.tensor([0, 1, 0, 1], device=device, dtype=index_dtype).repeat(prod, 1).reshape(*batch_shape, -1), @@ -221,18 +228,7 @@ def test_sparse_compressed_constructor(self, layout, device, dtype, torch.sparse_bsr: torch.sparse_bsr_tensor, torch.sparse_bsc: torch.sparse_bsc_tensor, }[layout] - compressed_indices_mth = { - torch.sparse_csr: torch.Tensor.crow_indices, - torch.sparse_csc: torch.Tensor.ccol_indices, - torch.sparse_bsr: torch.Tensor.crow_indices, - torch.sparse_bsc: torch.Tensor.ccol_indices, - }[layout] - plain_indices_mth = { - torch.sparse_csr: torch.Tensor.col_indices, - torch.sparse_csc: torch.Tensor.row_indices, - torch.sparse_bsr: torch.Tensor.col_indices, - torch.sparse_bsc: torch.Tensor.row_indices, - }[layout] + compressed_indices_mth, plain_indices_mth = sparse_compressed_indices_methods[layout] for index_dtype in [torch.int32, torch.int64]: for compressed_indices, plain_indices, values, size in self._generate_small_inputs(layout, device, dtype, index_dtype): if input_kind == 'list': @@ -278,18 +274,11 @@ def test_sparse_compressed_constructor(self, layout, device, dtype, def test_empty(self, layout, device, dtype): ns = [5, 2, 0] batch_shapes = [(), (2,), (2, 3)] - compressed_indices_mth = { - torch.sparse_csr: torch.Tensor.crow_indices, - torch.sparse_csc: torch.Tensor.ccol_indices, - }[layout] - plain_indices_mth = { - torch.sparse_csr: torch.Tensor.col_indices, - torch.sparse_csc: torch.Tensor.row_indices, - }[layout] compressed_dim = { torch.sparse_csr: -2, torch.sparse_csc: -1, }[layout] + compressed_indices_mth, plain_indices_mth = sparse_compressed_indices_methods[layout] for m, n, b in itertools.product(ns, ns, batch_shapes): shape = (*b, m, n) result = torch.empty(shape, dtype=dtype, device=device, layout=layout) @@ -328,6 +317,52 @@ def test_clone(self, layout, device, dtype): cloned_sparse = sparse.clone() self.assertEqual(sparse, cloned_sparse) + @all_sparse_compressed_layouts() + def test_print(self, layout, device): + compressed_indices_mth, plain_indices_mth = sparse_compressed_indices_methods[layout] + printed = [] + for index_dtype in [torch.int32, torch.int64]: + for dtype in [torch.float32, torch.float64]: + for compressed_indices, plain_indices, values, size in self._generate_small_inputs( + layout, device, dtype, index_dtype): + batch_shape = tuple(size[:-2]) + block_shape = tuple(values.shape[-2:]) if layout in {torch.sparse_bsr, torch.sparse_bsc} else () + if size not in [(2, 2), (0, 0), (2, 3, 2, 2), (2, 2, 2)]: + # Skip inputs that are not in the list of + # expected sizes to ensure the stability of + # test_print in the case + # _generate_small_inputs is extended with new + # inputs + continue + if block_shape not in [(), (0, 0), (1, 2)]: + # Skip inputs that are not in the list of + # expected block sizes to ensure test_print + # stability. + continue + printed.append("########## {}/{}/batch_shape={}/block_shape={} ##########".format( + dtype, index_dtype, batch_shape, block_shape)) + x = torch.sparse_compressed_tensor(compressed_indices, + plain_indices, + values, dtype=dtype, layout=layout, device=device) + printed.append("# sparse tensor") + printed.append(str(x)) + printed.append(f"# _{compressed_indices_mth.__name__}") + printed.append(str(compressed_indices_mth(x))) + printed.append(f"# _{plain_indices_mth.__name__}") + printed.append(str(plain_indices_mth(x))) + printed.append("# _values") + printed.append(str(x.values())) + printed.append('') + printed.append('') + orig_maxDiff = self.maxDiff + self.maxDiff = None + try: + self.assertExpected('\n'.join(printed)) + self.maxDiff = orig_maxDiff + except Exception: + self.maxDiff = orig_maxDiff + raise + class TestSparseCSR(TestCase): @@ -635,43 +670,6 @@ def test_factory_device_type_inference(self, device, dtype): t.crow_indices().device == t.values().device t.col_indices().device == t.values().device - def test_sparse_csr_print(self, device): - orig_maxDiff = self.maxDiff - self.maxDiff = None - shape_nnz = [ - ((10, 10), 10), - ((100, 10), 10), - ((1000, 10), 10) - ] - printed = [] - for shape, nnz in shape_nnz: - values_shape = torch.Size((nnz,)) - col_indices_shape = torch.Size((nnz,)) - crow_indices_shape = torch.Size((shape[0] + 1,)) - printed.append("# shape: {}".format(torch.Size(shape))) - printed.append("# nnz: {}".format(nnz)) - printed.append("# crow_indices shape: {}".format(crow_indices_shape)) - printed.append("# col_indices shape: {}".format(col_indices_shape)) - printed.append("# values_shape: {}".format(values_shape)) - for index_dtype in [torch.int32, torch.int64]: - for dtype in floating_types(): - printed.append("########## {}/{} ##########".format(dtype, index_dtype)) - x = torch.sparse_csr_tensor(torch.tensor([0, 2, 4], dtype=index_dtype), - torch.tensor([0, 1, 0, 1], dtype=index_dtype), - torch.tensor([1, 2, 3, 4]), dtype=dtype, device=device) - printed.append("# sparse tensor") - printed.append(str(x)) - printed.append("# _crow_indices") - printed.append(str(x.crow_indices())) - printed.append("# _col_indices") - printed.append(str(x.col_indices())) - printed.append("# _values") - printed.append(str(x.values())) - printed.append('') - printed.append('') - self.assertExpected('\n'.join(printed)) - self.maxDiff = orig_maxDiff - @dtypes(*all_types_and_complex_and(torch.half, torch.bool, torch.bfloat16)) def test_sparse_csr_from_dense(self, device, dtype): dense = torch.tensor([[4, 5, 0], [0, 0, 0], [1, 0, 0]], dtype=dtype, device=device) diff --git a/torch/_tensor_str.py b/torch/_tensor_str.py index b70967c7b3a48d..b1c53091bf6016 100644 --- a/torch/_tensor_str.py +++ b/torch/_tensor_str.py @@ -366,19 +366,23 @@ def _str_intern(inp, *, tensor_contents=None): if not has_default_dtype: suffixes.append('dtype=' + str(self.dtype)) if not custom_contents_provided: + compressed_indices_method, plain_indices_method = { + torch.sparse_csr: (torch.Tensor.crow_indices, torch.Tensor.col_indices), + torch.sparse_csc: (torch.Tensor.ccol_indices, torch.Tensor.row_indices), + torch.sparse_bsr: (torch.Tensor.crow_indices, torch.Tensor.col_indices), + torch.sparse_bsc: (torch.Tensor.ccol_indices, torch.Tensor.row_indices), + }[self.layout] if self.layout in {torch.sparse_csr, torch.sparse_bsr}: cdimname, pdimname = 'row', 'column' else: cdimname, pdimname = 'column', 'row' compressed_indices_prefix = f'c{cdimname[:3]}_indices=tensor(' - # TODO: revise using crow_indices() method per https://github.com/pytorch/pytorch/issues/76638 - compressed_indices = self.crow_indices().detach() + compressed_indices = compressed_indices_method(self).detach() compressed_indices_str = _tensor_str(compressed_indices, indent + len(compressed_indices_prefix)) if compressed_indices.numel() == 0: compressed_indices_str += ', size=' + str(tuple(compressed_indices.shape)) plain_indices_prefix = f'{pdimname[:3]}_indices=tensor(' - # TODO: revise using col_indices() method per https://github.com/pytorch/pytorch/issues/76638 - plain_indices = self.col_indices().detach() + plain_indices = plain_indices_method(self).detach() plain_indices_str = _tensor_str(plain_indices, indent + len(plain_indices_prefix)) if plain_indices.numel() == 0: plain_indices_str += ', size=' + str(tuple(plain_indices.shape))