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

Function rand_stride

tests/python/pytorch/sparse/utils.py:16–23  ·  view source on GitHub ↗

Add stride to the last dimension of a tensor.

(t)

Source from the content-addressed store, hash-verified

14
15
16def rand_stride(t):
17 """Add stride to the last dimension of a tensor."""
18 stride = np.random.randint(2, 4)
19 ret = torch.stack([t] * stride, dim=-1)[..., 0]
20 ret = ret.detach()
21 if torch.is_floating_point(t):
22 ret.requires_grad_()
23 return ret
24
25
26def rand_coo(shape, nnz, dev, nz_dim=None):

Callers 10

rand_cooFunction · 0.85
rand_csrFunction · 0.85
rand_cscFunction · 0.85
rand_coo_uncoalescedFunction · 0.85
rand_csr_uncoalescedFunction · 0.85
rand_csc_uncoalescedFunction · 0.85
test_sddmmFunction · 0.85
test_bsddmmFunction · 0.85
test_spmmFunction · 0.85
test_bspmmFunction · 0.85

Calls

no outgoing calls

Tested by 4

test_sddmmFunction · 0.68
test_bsddmmFunction · 0.68
test_spmmFunction · 0.68
test_bspmmFunction · 0.68