2 #ifndef _NNDEPLOY_CLASSIFICATION_CLASSIFICATION_UTIL_H_
3 #define _NNDEPLOY_CLASSIFICATION_CLASSIFICATION_UTIL_H_
22 namespace classification {
32 std::vector<int32_t>
topKIndices(
const T* array,
int array_size,
int topk) {
33 topk = std::min(array_size, topk);
34 std::vector<int32_t> res(topk);
35 std::set<int32_t> searched;
36 for (int32_t i = 0; i < topk; ++i) {
37 T min =
static_cast<T
>(-99999999);
38 for (int32_t j = 0; j < array_size; ++j) {
39 if (searched.find(j) != searched.end()) {
42 if (*(array + j) > min) {
47 searched.insert(res[i]);
std::vector< int32_t > topKIndices(const T *array, int array_size, int topk)