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

Function translateTest

test/translate.cpp:49–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47
48template<typename T>
49void translateTest(string pTestFile, const unsigned resultIdx, dim4 odims,
50 const float tx, const float ty, const af_interp_type method,
51 const float max_fail_count = 0.0001) {
52 SUPPORTED_TYPE_CHECK(T);
53
54 vector<dim4> numDims;
55 vector<vector<T>> in;
56 vector<vector<float>> tests;
57 readTests<T, float, float>(pTestFile, numDims, in, tests);
58
59 af_array inArray = 0;
60 af_array outArray = 0;
61
62 dim4 dims = numDims[0];
63
64 ASSERT_SUCCESS(af_create_array(&inArray, &(in[0].front()), dims.ndims(),
65 dims.get(),
66 (af_dtype)dtype_traits<T>::af_type));
67
68 ASSERT_SUCCESS(
69 af_translate(&outArray, inArray, tx, ty, odims[0], odims[1], method));
70
71 // Get result
72 T* outData = new T[tests[resultIdx].size()];
73 ASSERT_SUCCESS(af_get_data_ptr((void*)outData, outArray));
74
75 // Compare result
76 size_t nElems = tests[resultIdx].size();
77
78 size_t fail_count = 0;
79 for (size_t elIter = 0; elIter < nElems; ++elIter) {
80 if (abs((T)tests[resultIdx][elIter] - outData[elIter]) > 0.0001) {
81 fail_count++;
82 }
83 }
84 ASSERT_EQ(true, (((float)fail_count / (float)(nElems)) <= max_fail_count))
85 << "Fail Count = " << fail_count << endl;
86
87 // Delete
88 delete[] outData;
89
90 if (inArray != 0) af_release_array(inArray);
91 if (outArray != 0) af_release_array(outArray);
92}
93
94TYPED_TEST(Translate, Small1) {
95 translateTest<TypeParam>(

Callers

nothing calls this directly

Calls 7

absFunction · 0.70
af_create_arrayFunction · 0.50
af_translateFunction · 0.50
af_get_data_ptrFunction · 0.50
af_release_arrayFunction · 0.50
ndimsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected