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

Method Compute

tensorflow/core/kernels/tensor_array_ops.cc:419–446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

417 : OpKernel(context) {}
418
419 void Compute(OpKernelContext* ctx) override {
420 OP_REQUIRES_OK(ctx, SetupFlowControlInputs(ctx, true));
421
422 const Tensor* tensor_index;
423 const Tensor* tensor_value;
424 OP_REQUIRES_OK(ctx, ctx->input("index", &tensor_index));
425 OP_REQUIRES_OK(ctx, ctx->input("value", &tensor_value));
426
427 OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(tensor_index->shape()),
428 errors::InvalidArgument(
429 "TensorArray index must be scalar, but had shape: ",
430 tensor_index->shape().DebugString()));
431
432 TensorArray* tensor_array = nullptr;
433 OP_REQUIRES_OK(ctx, GetTensorArray(ctx, &tensor_array));
434 core::ScopedUnref unref(tensor_array);
435 const int32 index = tensor_index->scalar<int32>()();
436 OP_REQUIRES(
437 ctx, tensor_value->dtype() == tensor_array->ElemType(),
438 errors::InvalidArgument("TensorArray dtype is ",
439 DataTypeString(tensor_array->ElemType()),
440 " but Op is trying to write dtype ",
441 DataTypeString(tensor_value->dtype()), "."));
442 PersistentTensor persistent_tensor(*tensor_value);
443 Status s = tensor_array->WriteOrAggregate<Device, T>(ctx, index,
444 &persistent_tensor);
445 OP_REQUIRES_OK(ctx, s);
446 }
447};
448
449#define REGISTER_WRITE(type) \

Callers

nothing calls this directly

Calls 10

SetupFlowControlInputsFunction · 0.85
InvalidArgumentFunction · 0.85
GetTensorArrayFunction · 0.85
IsScalarFunction · 0.50
DataTypeStringFunction · 0.50
inputMethod · 0.45
shapeMethod · 0.45
DebugStringMethod · 0.45
dtypeMethod · 0.45
ElemTypeMethod · 0.45

Tested by

no test coverage detected