r"""Scatter add operator (on first dimension) implementation. Math: y[idx[i], *] += x[i, *] Parameters ---------- x : Tensor The input feature. idx : Tensor The indices array. m : int The length of output. Returns ------- Tensor
(x, idx, m)
| 692 | |
| 693 | |
| 694 | def _scatter_add(x, idx, m): |
| 695 | r"""Scatter add operator (on first dimension) implementation. |
| 696 | |
| 697 | Math: y[idx[i], *] += x[i, *] |
| 698 | |
| 699 | Parameters |
| 700 | ---------- |
| 701 | x : Tensor |
| 702 | The input feature. |
| 703 | idx : Tensor |
| 704 | The indices array. |
| 705 | m : int |
| 706 | The length of output. |
| 707 | |
| 708 | Returns |
| 709 | ------- |
| 710 | Tensor |
| 711 | The output tensor. |
| 712 | """ |
| 713 | out_shp = (m,) + F.shape(x)[1:] |
| 714 | ctx = F.context(x) |
| 715 | dtype = F.dtype(x) |
| 716 | out = F.zeros(out_shp, dtype, ctx) |
| 717 | _CAPI_DGLKernelScatterAdd( |
| 718 | to_dgl_nd(x), to_dgl_nd(idx), to_dgl_nd_for_write(out) |
| 719 | ) |
| 720 | return out |
| 721 | |
| 722 | |
| 723 | def _update_grad_minmax_hetero( |
no test coverage detected