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

Method Compute

tensorflow/core/kernels/tensor_array_ops.cc:504–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

502 }
503
504 void Compute(OpKernelContext* ctx) override {
505 OP_REQUIRES_OK(ctx, SetupFlowControlInputs(ctx, false));
506
507 const Tensor* tensor_index;
508 OP_REQUIRES_OK(ctx, ctx->input("index", &tensor_index));
509
510 OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(tensor_index->shape()),
511 errors::InvalidArgument(
512 "TensorArray index must be scalar, but had shape: ",
513 tensor_index->shape().DebugString()));
514
515 TensorArray* tensor_array = nullptr;
516 OP_REQUIRES_OK(ctx, GetTensorArray(ctx, &tensor_array));
517 core::ScopedUnref unref(tensor_array);
518
519 const int32 index = tensor_index->scalar<int32>()();
520 OP_REQUIRES(
521 ctx, dtype_ == tensor_array->ElemType(),
522 errors::InvalidArgument(
523 "TensorArray dtype is ", DataTypeString(tensor_array->ElemType()),
524 " but Op requested dtype ", DataTypeString(dtype_), "."));
525 PersistentTensor value;
526 Status s = tensor_array->Read<Device, T>(ctx, index, &value);
527 OP_REQUIRES_OK(ctx, s);
528 ctx->set_output(0, *value.AccessTensor(ctx));
529 }
530
531 private:
532 DataType dtype_;

Callers

nothing calls this directly

Calls 11

SetupFlowControlInputsFunction · 0.85
InvalidArgumentFunction · 0.85
GetTensorArrayFunction · 0.85
AccessTensorMethod · 0.80
IsScalarFunction · 0.50
DataTypeStringFunction · 0.50
inputMethod · 0.45
shapeMethod · 0.45
DebugStringMethod · 0.45
ElemTypeMethod · 0.45
set_outputMethod · 0.45

Tested by

no test coverage detected