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

Method backward

python/dgl/backend/mxnet/sparse.py:390–403  ·  view source on GitHub ↗
(self, dy)

Source from the content-addressed store, hash-verified

388 return y
389
390 def backward(self, dy):
391 (arg,) = self.saved_tensors
392 offsets = self.offsets
393 m = offsets[-1].asscalar()
394 if self.op == "sum":
395 offsets_np = asnumpy(offsets[1:])
396 indices_np = np.zeros((m + 1,), dtype=offsets_np.dtype)
397 np.add.at(indices_np, offsets_np, np.ones_like(offsets_np))
398 indices_np = np.cumsum(indices_np, -1)[:-1]
399 indices = zerocopy_from_numpy(indices_np)
400 dx = dy[indices]
401 else:
402 dx = _bwd_segment_cmp(dy, arg, m)
403 return dx
404
405
406def segment_reduce(op, x, offsets):

Callers

nothing calls this directly

Calls 3

_bwd_segment_cmpFunction · 0.85
asnumpyFunction · 0.70
zerocopy_from_numpyFunction · 0.70

Tested by

no test coverage detected