From 45f273cdd4e3e0d414bbd406e23f8612b759ca76 Mon Sep 17 00:00:00 2001 From: taerim Date: Sun, 3 Sep 2017 01:08:10 +0900 Subject: [PATCH] In TensorArrayPackOrGatherOp, when num == 0, look for static shape also in the TensorArray object. --- tensorflow/core/kernels/tensor_array_ops.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tensorflow/core/kernels/tensor_array_ops.cc b/tensorflow/core/kernels/tensor_array_ops.cc index 075bacb43..c795ecfb6 100644 --- a/tensorflow/core/kernels/tensor_array_ops.cc +++ b/tensorflow/core/kernels/tensor_array_ops.cc @@ -597,15 +597,24 @@ class TensorArrayPackOrGatherOp : public OpKernel { // If there are no elements to return, return a zero-element Tensor with // shape [0] + element_shape_ if (num_indices == 0) { - OP_REQUIRES(ctx, element_shape_.IsFullyDefined(), + PartialTensorShape partial_empty_shape; + OP_REQUIRES(ctx, element_shape_.MergeWith(tensor_array->ElemShape(), + &partial_empty_shape).ok(), + errors::InvalidArgument( + "Attr element shape ", element_shape_.DebugString(), + " is not compatible with TensorArray element shape ", + tensor_array->ElemShape().DebugString())); + + OP_REQUIRES(ctx, partial_empty_shape.OsFullyDefined(), errors::Unimplemented( "TensorArray has size zero, but element shape ", - element_shape_.DebugString(), + partial_empty_shape.DebugString(), " is not fully defined. " "Currently only static shapes are supported when packing " "zero-size TensorArrays.")); + TensorShape empty_shape; - element_shape_.AsTensorShape(&empty_shape); + partial_empty_shape.AsTensorShape(&empty_shape); empty_shape.InsertDim(0, 0); Tensor* empty_unused; OP_REQUIRES_OK(ctx, ctx->allocate_output(0, empty_shape, &empty_unused));