diff --git a/oneflow/core/common/steady_vector.h b/oneflow/core/common/steady_vector.h index 266de344fba..ecffd083c14 100644 --- a/oneflow/core/common/steady_vector.h +++ b/oneflow/core/common/steady_vector.h @@ -53,12 +53,13 @@ class SteadyVector { void push_back(const T& elem) { std::unique_lock lock(mutex_); - int granularity = GetGranularity(size_); - if (size_ + 1 == (1 << granularity)) { + size_t size = size_; + int granularity = GetGranularity(size); + if (size + 1 == (1 << granularity)) { CHECK_LT(granularity, N); granularity2data_[granularity].reset(new T[1 << granularity]); } - this->Mut(size_) = elem; + this->Mut(size) = elem; ++size_; }