aten/src/ATen/native/sparse/SparseTensor.cpp
// TODO: This is wrong: if nnz == 0 but indices/values is not
// empty then we'll return all the values, even the ones that
// are "masked out" by nnz
This is wrong: if nnz == 0 but indices/values is not
empty then we'll return all the values, even the ones that
are "masked out" by nnz
This is wrong : if nnz == 0 but indices / values is not empty then we ' ll return all the values even the ones that are " masked out " by nnz
Tensor _indices_sparse(const SparseTensor& self) {
  auto nnz = self._nnz();
  if (nnz == 0) {
    return _get_sparse_impl(self)->indices();
  }
  return _get_sparse_impl(self)->indices().narrow(1, 0, nnz);
}
Tensor _indices_sparse ( const SparseTensor & self ) { auto nnz = self . _nnz ( ) ; if ( nnz == 0 ) { return _get_sparse_impl ( self ) -> indices ( ) ; } return _get_sparse_impl ( self ) -> indices ( ) . narrow ( 1 , 0 , nnz ) ; }
TODO: This is wrong: if nnz == 0 but indices/values is not
empty then we'll return all the values, even the ones that
are "masked out" by nnz
TODO : This is wrong : if nnz == 0 but indices / values is not empty then we ' ll return all the values even the ones that are " masked out " by nnz
// Narrows don't work on 0-length tensors // TODO: When we handle zero-size dims correctly, this will work and // we can remove the special case.