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

Function matchTemplateTest

test/match_template.cpp:42–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40
41template<typename T>
42void matchTemplateTest(string pTestFile, af_match_type pMatchType) {
43 typedef
44 typename cond_type<is_same_type<T, double>::value, double, float>::type
45 outType;
46 SUPPORTED_TYPE_CHECK(T);
47
48 vector<dim4> numDims;
49 vector<vector<T>> in;
50 vector<vector<outType>> tests;
51
52 readTests<T, outType, float>(pTestFile, numDims, in, tests);
53
54 dim4 sDims = numDims[0];
55 dim4 tDims = numDims[1];
56 af_array outArray = 0;
57 af_array sArray = 0;
58 af_array tArray = 0;
59
60 ASSERT_SUCCESS(af_create_array(&sArray, &(in[0].front()), sDims.ndims(),
61 sDims.get(),
62 (af_dtype)dtype_traits<T>::af_type));
63
64 ASSERT_SUCCESS(af_create_array(&tArray, &(in[1].front()), tDims.ndims(),
65 tDims.get(),
66 (af_dtype)dtype_traits<T>::af_type));
67
68 ASSERT_SUCCESS(af_match_template(&outArray, sArray, tArray, pMatchType));
69
70 vector<outType> outData(sDims.elements());
71
72 ASSERT_SUCCESS(af_get_data_ptr((void *)outData.data(), outArray));
73
74 vector<outType> currGoldBar = tests[0];
75 size_t nElems = currGoldBar.size();
76 for (size_t elIter = 0; elIter < nElems; ++elIter) {
77 ASSERT_NEAR(currGoldBar[elIter], outData[elIter], 1.0e-3)
78 << "at: " << elIter << endl;
79 }
80
81 // cleanup
82 ASSERT_SUCCESS(af_release_array(sArray));
83 ASSERT_SUCCESS(af_release_array(tArray));
84 ASSERT_SUCCESS(af_release_array(outArray));
85}
86
87TYPED_TEST(MatchTemplate, Matrix_SAD) {
88 UNSUPPORTED_BACKEND(AF_BACKEND_ONEAPI);

Callers

nothing calls this directly

Calls 7

af_create_arrayFunction · 0.50
af_match_templateFunction · 0.50
af_get_data_ptrFunction · 0.50
af_release_arrayFunction · 0.50
ndimsMethod · 0.45
getMethod · 0.45
elementsMethod · 0.45

Tested by

no test coverage detected