torch.sparse.as_sparse_gradcheck#
- torch.sparse.as_sparse_gradcheck(gradcheck)[source]#
Decorate function, to extend gradcheck for sparse tensors.
Decorator for torch.autograd.gradcheck or its functools.partialvariants that extends the gradcheck function with support to inputfunctions that operate on or/and return sparse tensors.
The specified gradcheck function itself is guaranteed to operateon strided tensors only.
For example:
>>>gradcheck=torch.sparse.as_sparse_gradcheck(torch.autograd.gradcheck)>>>x=(...torch.tensor([[0,1],[2,3]],dtype=torch.float64)....to_sparse_coo()....requires_grad_(True)...)>>>gradcheck(lambdax:x.to_sparse_csr(),x)True