diff --git a/paddle/phi/core/tensor_array.cc b/paddle/phi/core/tensor_array.cc index 0f8e4ba4c926d28d86f5b54b0923adf8e080fb22..2007e71d5a0fdd7cbce9f9ebf96a713067842905 100644 --- a/paddle/phi/core/tensor_array.cc +++ b/paddle/phi/core/tensor_array.cc @@ -23,13 +23,12 @@ TensorArray::TensorArray(const std::vector& vec) { /// \brief Test whether the tensor's storage in TensorArray is allocated. /// return Whether all tensors in TensorArray is allocated. bool TensorArray::initialized() const { - bool init = true; for (auto tensor : tensors_) { if (!tensor.IsInitialized()) { - init = false; + return false; } } - return init; + return true; } int64_t TensorArray::numel() const {