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

Function TEST

test/nearest_neighbour.cpp:185–220  ·  view source on GitHub ↗

//////////////////////////////// CPP ////////////////////////////////

Source from the content-addressed store, hash-verified

183///////////////////////////////////// CPP ////////////////////////////////
184//
185TEST(NearestNeighbourSSD, CPP) {
186 UNSUPPORTED_BACKEND(AF_BACKEND_ONEAPI);
187 vector<dim4> numDims;
188 vector<vector<uint>> in;
189 vector<vector<uint>> tests;
190
191 readTests<uint, uint, uint>(TEST_DIR
192 "/nearest_neighbour/ssd_500_5000_dim0.test",
193 numDims, in, tests);
194
195 dim4 qDims = numDims[0];
196 dim4 tDims = numDims[1];
197
198 array query(qDims, &(in[0].front()));
199 array train(tDims, &(in[1].front()));
200
201 array idx, dist;
202 nearestNeighbour(idx, dist, query, train, 0, 1, AF_SSD);
203
204 vector<uint> goldIdx = tests[0];
205 vector<uint> goldDist = tests[1];
206 size_t nElems = goldIdx.size();
207 uint *outIdx = new uint[nElems];
208 uint *outDist = new uint[nElems];
209
210 idx.host(outIdx);
211 dist.host(outDist);
212
213 for (size_t elIter = 0; elIter < nElems; ++elIter) {
214 ASSERT_EQ(goldDist[elIter], outDist[elIter])
215 << "at: " << elIter << endl;
216 }
217
218 delete[] outIdx;
219 delete[] outDist;
220}
221
222TEST(NearestNeighbourSAD, CPP) {
223 UNSUPPORTED_BACKEND(AF_BACKEND_ONEAPI);

Callers

nothing calls this directly

Calls 4

nearestNeighbourFunction · 0.85
randuFunction · 0.85
hostMethod · 0.80
dim4Class · 0.50

Tested by

no test coverage detected