src.utils.sparse.slicing_torch

src.utils.sparse.slicing_torch(s_t, slice, preserve_dim=False)[source]

A slicing function for torch sparse tensors. :param s_t: input sparse tensor :param slice: tensor containing indices, -1 stands for all.

For example, (1, -1) returns the second row of a 2d tensor.

Parameters

preserve_dim – If True, the dimension of the original tensor will be preserved, i.e. 1 will be padded for those removed dimensions.

Returns

sliced sparse tensor