diff --git a/speechx/speechx/utils/math.cc b/speechx/speechx/utils/math.cc index 289470f6c6efaf8516f4bc00b60376a02761a760..959740a05a3fcaf879fab198a22ae2fee6777a1a 100644 --- a/speechx/speechx/utils/math.cc +++ b/speechx/speechx/utils/math.cc @@ -79,10 +79,12 @@ void TopK(const std::vector& data, int cur = values->size() - 1; while (!pq.empty()) { const auto& item = pq.top(); - pq.pop(); - + (*values)[cur] = item.first; (*indices)[cur] = item.second; + + // item if reference, must pop here + pq.pop(); cur--; } @@ -93,4 +95,4 @@ template void TopK(const std::vector& data, std::vector* values, std::vector* indices); -} // namespace ppspeech \ No newline at end of file +} // namespace ppspeech