MCPcopy Create free account
hub / github.com/pytorch/tutorials / _make_sparse

Function _make_sparse

unstable_source/maskedtensor_adagrad.py:100–104  ·  view source on GitHub ↗
(grad, grad_indices, values)

Source from the content-addressed store, hash-verified

98#
99
100def _make_sparse(grad, grad_indices, values):
101 size = grad.size()
102 if grad_indices.numel() == 0 or values.numel() == 0:
103 return torch.empty_like(grad)
104 return torch.sparse_coo_tensor(grad_indices, values, size)
105
106# We don't support sparse gradients
107param = torch.arange(8).reshape(2, 4).float()

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected