| 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) \ |
nothing calls this directly
no test coverage detected