MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / nearest_neighbour_

Function nearest_neighbour_

src/backend/oneapi/nearest_neighbour.cpp:25–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23
24template<typename T, typename To, af_match_type dist_type>
25void nearest_neighbour_(Array<uint>& idx, Array<To>& dist,
26 const Array<T>& query, const Array<T>& train,
27 const uint dist_dim, const uint n_dist) {
28 ONEAPI_NOT_SUPPORTED("nearest_neighbour_ Not supported");
29
30 uint sample_dim = (dist_dim == 0) ? 1 : 0;
31 const dim4& qDims = query.dims();
32 const dim4& tDims = train.dims();
33
34 const dim4 outDims(n_dist, qDims[sample_dim]);
35 const dim4 distDims(tDims[sample_dim], qDims[sample_dim]);
36
37 Array<To> tmp_dists = createEmptyArray<To>(distDims);
38
39 idx = createEmptyArray<uint>(outDims);
40 dist = createEmptyArray<To>(outDims);
41
42 Array<T> queryT = dist_dim == 0 ? transpose(query, false) : query;
43 Array<T> trainT = dist_dim == 0 ? transpose(train, false) : train;
44
45 // kernel::allDistances<T, To>(tmp_dists, queryT, trainT, 1, dist_type);
46
47 topk(dist, idx, tmp_dists, n_dist, 0, AF_TOPK_MIN);
48}
49
50template<typename T, typename To>
51void nearest_neighbour(Array<uint>& idx, Array<To>& dist, const Array<T>& query,

Callers

nothing calls this directly

Calls 3

transposeFunction · 0.70
topkFunction · 0.70
dimsMethod · 0.45

Tested by

no test coverage detected