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

Function TEST

test/cast.cpp:110–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108COMPLEX_REAL_TESTS(cdouble, double)
109
110TEST(CAST_TEST, Test_JIT_DuplicateCastNoop) {
111 // Does a trivial cast - check JIT kernel trace to ensure a __noop is
112 // generated since we don't have a way to test it directly
113 SUPPORTED_TYPE_CHECK(double);
114 af_dtype ta = (af_dtype)dtype_traits<float>::af_type;
115 af_dtype tb = (af_dtype)dtype_traits<double>::af_type;
116 dim4 dims(num, 1, 1, 1);
117 af_array a, b, c;
118 af_randu(&a, dims.ndims(), dims.get(), ta);
119
120 af_cast(&b, a, tb);
121 af_cast(&c, b, ta);
122
123 std::vector<float> a_vals(num);
124 std::vector<float> c_vals(num);
125 ASSERT_SUCCESS(af_get_data_ptr((void **)&a_vals[0], a));
126 ASSERT_SUCCESS(af_get_data_ptr((void **)&c_vals[0], c));
127
128 for (size_t i = 0; i < num; ++i) { ASSERT_FLOAT_EQ(a_vals[i], c_vals[i]); }
129
130 af_release_array(a);
131 af_release_array(b);
132 af_release_array(c);
133}
134
135TEST(Cast, ImplicitCast) {
136 using namespace af;

Callers

nothing calls this directly

Calls 12

randuFunction · 0.85
constantFunction · 0.85
seqClass · 0.85
asMethod · 0.80
maxFunction · 0.70
absFunction · 0.70
af_randuFunction · 0.50
af_castFunction · 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