From 39a6f43bccf4d699718213ab71405faa2edd3b73 Mon Sep 17 00:00:00 2001 From: Yan Chunwei Date: Wed, 25 Oct 2017 22:41:04 -0400 Subject: [PATCH] fix bug (#5106) --- paddle/framework/tensor_array.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/paddle/framework/tensor_array.cc b/paddle/framework/tensor_array.cc index 6f0b84dd1a..0947e33548 100644 --- a/paddle/framework/tensor_array.cc +++ b/paddle/framework/tensor_array.cc @@ -254,13 +254,12 @@ LoDTensor TensorArray::LodPackTwo(const LoDTensor& pre, const LoDTensor& cur, void TensorArray::LodUnpack(const LoDTensor& source, size_t level) { PADDLE_ENFORCE_EQ(level, source.NumLevels() - 1, "only the lowest LoD level supports unpack."); - int non_empty_instances = -1; + const size_t non_empty_instances = source.dims()[0]; size_t index = 0; Vector lowest_lod_level; lowest_lod_level.push_back(index); - for (size_t step = 0; non_empty_instances > 0 || non_empty_instances == -1; - step++) { + for (size_t step = 0; step < non_empty_instances; step++) { size_t num_instances = 0; for (size_t id = 0; id < source.NumElements(level); id++) { auto instance = source; -- GitLab