(self, dy)
| 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 | |
| 406 | def segment_reduce(op, x, offsets): |
nothing calls this directly
no test coverage detected