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

Function morphTest

test/morph.cpp:41–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39
40template<typename inType, bool isDilation, bool isVolume>
41void morphTest(string pTestFile) {
42 SUPPORTED_TYPE_CHECK(inType);
43
44 vector<dim4> numDims;
45 vector<vector<inType>> in;
46 vector<vector<inType>> tests;
47
48 readTests<inType, inType, int>(pTestFile, numDims, in, tests);
49
50 dim4 dims = numDims[0];
51 dim4 maskDims = numDims[1];
52 af_array outArray = 0;
53 af_array inArray = 0;
54 af_array maskArray = 0;
55
56 ASSERT_SUCCESS(af_create_array(&inArray, &(in[0].front()), dims.ndims(),
57 dims.get(),
58 (af_dtype)dtype_traits<inType>::af_type));
59 ASSERT_SUCCESS(af_create_array(&maskArray, &(in[1].front()),
60 maskDims.ndims(), maskDims.get(),
61 (af_dtype)dtype_traits<inType>::af_type));
62
63 af_err af_stat;
64 if (isDilation) {
65 if (isVolume) {
66 ASSERT_SUCCESS(af_dilate3(&outArray, inArray, maskArray));
67 } else {
68 ASSERT_SUCCESS(af_dilate(&outArray, inArray, maskArray));
69 }
70 } else {
71 if (isVolume) {
72 ASSERT_SUCCESS(af_erode3(&outArray, inArray, maskArray));
73 } else {
74 ASSERT_SUCCESS(af_erode(&outArray, inArray, maskArray));
75 }
76 }
77
78 for (size_t testIter = 0; testIter < tests.size(); ++testIter) {
79 vector<inType> currGoldBar = tests[testIter];
80 ASSERT_VEC_ARRAY_EQ(currGoldBar, dims, outArray);
81 }
82
83 // cleanup
84 ASSERT_SUCCESS(af_release_array(inArray));
85 ASSERT_SUCCESS(af_release_array(maskArray));
86 ASSERT_SUCCESS(af_release_array(outArray));
87}
88
89TYPED_TEST(Morph, Dilate3x3) {
90 UNSUPPORTED_BACKEND(AF_BACKEND_ONEAPI);

Callers

nothing calls this directly

Calls 8

af_create_arrayFunction · 0.50
af_dilate3Function · 0.50
af_dilateFunction · 0.50
af_erode3Function · 0.50
af_erodeFunction · 0.50
af_release_arrayFunction · 0.50
ndimsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected