| 199 | template <typename Device, typename T, typename Index, scatter_op::UpdateOp op> |
| 200 | struct ScatterFunctorBase { |
| 201 | Index operator()(OpKernelContext* c, const Device& d, |
| 202 | typename TTypes<T>::Matrix params, |
| 203 | typename TTypes<T>::ConstMatrix updates, |
| 204 | typename TTypes<Index>::ConstFlat indices) { |
| 205 | // indices and params sizes were validated in DoCompute(). |
| 206 | const Index N = static_cast<Index>(indices.size()); |
| 207 | const Index limit = static_cast<Index>(params.dimension(0)); |
| 208 | for (Index i = 0; i < N; i++) { |
| 209 | // Grab the index and check its validity. Do this carefully, |
| 210 | // to avoid checking the value and grabbing it again from |
| 211 | // memory a second time (a security risk since it may change in between). |
| 212 | const Index index = ::tensorflow::internal::SubtleMustCopy(indices(i)); |
| 213 | if (!FastBoundsCheck(index, limit)) return i; |
| 214 | // Copy last Ndim-1 dimensions of updates[i] to params[index] |
| 215 | scatter_op::internal::Assign<op>::Run(params.template chip<0>(index), |
| 216 | updates.template chip<0>(i)); |
| 217 | } |
| 218 | return -1; |
| 219 | } |
| 220 | }; |
| 221 | |
| 222 | template <typename Device, typename Index> |
nothing calls this directly
no test coverage detected