MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / DoCompute

Method DoCompute

tensorflow/core/kernels/scatter_nd_op.cc:266–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 &params_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, &params_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, &params, false /*allocate*/));
304 }
305};
306
307#define REGISTER_SCATTER_ND_KERNEL_INDEX(type, index_type, dev, name) \

Callers

nothing calls this directly

Calls 14

LookupResourceFunction · 0.85
HandleFromInputFunction · 0.85
IsRefTypeFunction · 0.85
FailedPreconditionFunction · 0.85
allocate_outputMethod · 0.80
copyFunction · 0.50
inputMethod · 0.45
tensorMethod · 0.45
shapeMethod · 0.45
input_dtypeMethod · 0.45

Tested by

no test coverage detected