| 264 | bool use_exclusive_lock_; |
| 265 | |
| 266 | void DoCompute(OpKernelContext* c) { |
| 267 | const Tensor& indices = c->input(1); |
| 268 | const Tensor& updates = c->input(2); |
| 269 | Tensor params; |
| 270 | TensorShape params_shape; |
| 271 | |
| 272 | if (dtype_ == DT_RESOURCE) { |
| 273 | core::RefCountPtr<Var> v; |
| 274 | OP_REQUIRES_OK(c, LookupResource(c, HandleFromInput(c, 0), &v)); |
| 275 | Tensor* t = v->tensor(); |
| 276 | params = *t; |
| 277 | params_shape = params.shape(); |
| 278 | } else if (IsRefType(c->input_dtype(0))) { |
| 279 | params = c->mutable_input(0, use_exclusive_lock_); |
| 280 | params_shape = params.shape(); |
| 281 | c->forward_ref_input_to_ref_output(0, 0); |
| 282 | OP_REQUIRES(c, params.IsInitialized(), |
| 283 | errors::FailedPrecondition("Null ref for params")); |
| 284 | } else { |
| 285 | Tensor* params_ptr; |
| 286 | params_shape = c->input(0).shape(); |
| 287 | if (!c->forward_input_to_output_with_shape(0, 0, params_shape, |
| 288 | ¶ms_ptr)) { |
| 289 | // We weren't able to forward the input to output, so just |
| 290 | // allocate a new output tensor and copy the values over. |
| 291 | OP_REQUIRES_OK(c, c->allocate_output(0, params_shape, ¶ms_ptr)); |
| 292 | params = *params_ptr; |
| 293 | functor::DenseUpdate<Device, T, ASSIGN> copy; |
| 294 | const Tensor& input_copy = c->input(0); |
| 295 | copy(c->eigen_device<Device>(), params.flat<T>(), input_copy.flat<T>()); |
| 296 | } else { |
| 297 | params = *params_ptr; |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | OP_REQUIRES_OK( |
| 302 | c, functor::DoScatterNd<Device, T, Index, op>( |
| 303 | c, indices, updates, params_shape, ¶ms, false /*allocate*/)); |
| 304 | } |
| 305 | }; |
| 306 | |
| 307 | #define REGISTER_SCATTER_ND_KERNEL_INDEX(type, index_type, dev, name) \ |
nothing calls this directly
no test coverage detected