MCPcopy
hub / github.com/dmlc/dgl / rand_diag

Function rand_diag

tests/python/pytorch/sparse/utils.py:86–92  ·  view source on GitHub ↗
(shape, nnz, dev, nz_dim=None)

Source from the content-addressed store, hash-verified

84
85
86def rand_diag(shape, nnz, dev, nz_dim=None):
87 nnz = min(shape)
88 if nz_dim is None:
89 val = torch.randn(nnz, device=dev, requires_grad=True)
90 else:
91 val = torch.randn(nnz, nz_dim, device=dev, requires_grad=True)
92 return diag(val, shape)
93
94
95def rand_coo_uncoalesced(shape, nnz, dev):

Callers

nothing calls this directly

Calls 2

diagFunction · 0.90
minFunction · 0.50

Tested by

no test coverage detected