Skip to content

Commit acac0d6

Browse files
author
Peter Andreas Entschev
committed
Moved conv_image() to testHelpers.hpp
1 parent 8de0a75 commit acac0d6

3 files changed

Lines changed: 30 additions & 60 deletions

File tree

test/fast.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -68,36 +68,6 @@ typedef ::testing::Types<int, unsigned> FixedTestTypes;
6868
TYPED_TEST_CASE(FloatFAST, FloatTestTypes);
6969
TYPED_TEST_CASE(FixedFAST, FixedTestTypes);
7070

71-
// TODO: perform conversion on device for CUDA and OpenCL
72-
template<typename T>
73-
af_err conv_image(af_array *out, af_array in)
74-
{
75-
af_array outArray;
76-
77-
dim_type d0, d1, d2, d3;
78-
af_get_dims(&d0, &d1, &d2, &d3, in);
79-
dim4 idims(d0, d1, d2, d3);
80-
81-
dim_type nElems = 0;
82-
af_get_elements(&nElems, in);
83-
84-
float *in_data = new float[nElems];
85-
af_get_data_ptr(in_data, in);
86-
87-
T *out_data = new T[nElems];
88-
89-
for (int i = 0; i < nElems; i++)
90-
out_data[i] = (T)in_data[i];
91-
92-
af_create_array(&outArray, out_data, idims.ndims(), idims.get(), (af_dtype) af::dtype_traits<T>::af_type);
93-
94-
std::swap(*out, outArray);
95-
96-
delete [] in_data;
97-
98-
return AF_SUCCESS;
99-
}
100-
10171
template<typename T>
10272
void fastTest(string pTestFile, bool nonmax)
10373
{

test/orb.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -140,36 +140,6 @@ typedef ::testing::Types<float, double> TestTypes;
140140

141141
TYPED_TEST_CASE(ORB, TestTypes);
142142

143-
// TODO: perform conversion on device for CUDA and OpenCL
144-
template<typename T>
145-
af_err conv_image(af_array *out, af_array in)
146-
{
147-
af_array outArray;
148-
149-
dim_type d0, d1, d2, d3;
150-
af_get_dims(&d0, &d1, &d2, &d3, in);
151-
dim4 idims(d0, d1, d2, d3);
152-
153-
dim_type nElems = 0;
154-
af_get_elements(&nElems, in);
155-
156-
float *in_data = new float[nElems];
157-
af_get_data_ptr(in_data, in);
158-
159-
T *out_data = new T[nElems];
160-
161-
for (int i = 0; i < nElems; i++)
162-
out_data[i] = (T)in_data[i];
163-
164-
af_create_array(&outArray, out_data, idims.ndims(), idims.get(), (af_dtype) af::dtype_traits<T>::af_type);
165-
166-
std::swap(*out, outArray);
167-
168-
delete [] in_data;
169-
170-
return AF_SUCCESS;
171-
}
172-
173143
template<typename T>
174144
void orbTest(string pTestFile)
175145
{

test/testHelpers.hpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,3 +408,33 @@ bool noDoubleTests()
408408
return ((isTypeDouble && !isDoubleSupported) ? true : false);
409409
}
410410

411+
// TODO: perform conversion on device for CUDA and OpenCL
412+
template<typename T>
413+
af_err conv_image(af_array *out, af_array in)
414+
{
415+
af_array outArray;
416+
417+
dim_type d0, d1, d2, d3;
418+
af_get_dims(&d0, &d1, &d2, &d3, in);
419+
af::dim4 idims(d0, d1, d2, d3);
420+
421+
dim_type nElems = 0;
422+
af_get_elements(&nElems, in);
423+
424+
float *in_data = new float[nElems];
425+
af_get_data_ptr(in_data, in);
426+
427+
T *out_data = new T[nElems];
428+
429+
for (int i = 0; i < nElems; i++)
430+
out_data[i] = (T)in_data[i];
431+
432+
af_create_array(&outArray, out_data, idims.ndims(), idims.get(), (af_dtype) af::dtype_traits<T>::af_type);
433+
434+
std::swap(*out, outArray);
435+
436+
delete [] in_data;
437+
438+
return AF_SUCCESS;
439+
}
440+

0 commit comments

Comments
 (0)