| 46 | |
| 47 | template<typename T> |
| 48 | void topk(Array<T>& vals, Array<unsigned>& idxs, const Array<T>& in, |
| 49 | const int k, const int dim, const af::topkFunction order) { |
| 50 | auto values = createEmptyArray<T>(in.dims()); |
| 51 | auto indices = createEmptyArray<unsigned>(in.dims()); |
| 52 | sort_index(values, indices, in, dim, order & AF_TOPK_MIN); |
| 53 | auto indVec = indexForTopK(k); |
| 54 | vals = index<T>(values, indVec.data()); |
| 55 | idxs = index<unsigned>(indices, indVec.data()); |
| 56 | } |
| 57 | |
| 58 | #define INSTANTIATE(T) \ |
| 59 | template void topk<T>(Array<T>&, Array<unsigned>&, const Array<T>&, \ |
no test coverage detected