diff --git a/tensorflow/core/common_runtime/eager/execute.cc b/tensorflow/core/common_runtime/eager/execute.cc index 594c0352086305..4ad2e2d60aa2af 100644 --- a/tensorflow/core/common_runtime/eager/execute.cc +++ b/tensorflow/core/common_runtime/eager/execute.cc @@ -303,6 +303,9 @@ Status GetDeviceForInput(const EagerContext& ctx, TensorHandle* tensor_handle, const Tensor* tensor; // TODO(fishx): Avoid blocking here. TF_RETURN_IF_ERROR(tensor_handle->Tensor(&tensor)); + if (tensor->NumElements() == 0) { + return errors::InvalidArgument("Empty resource handle"); + } const ResourceHandle& handle = tensor->flat()(0); device_name = handle.device();