| 117 | |
| 118 | template<typename T> |
| 119 | void dimCppSmallTest(const string pFileName, |
| 120 | const bool useDeprecatedAPI = false) { |
| 121 | typedef typename varOutType<T>::type outType; |
| 122 | float tol = 0.001f; |
| 123 | if ((af_dtype)af::dtype_traits<T>::af_type == f16) { tol = 0.6f; } |
| 124 | |
| 125 | SUPPORTED_TYPE_CHECK(T); |
| 126 | SUPPORTED_TYPE_CHECK(outType); |
| 127 | |
| 128 | vector<dim4> numDims; |
| 129 | vector<vector<T>> in; |
| 130 | vector<vector<outType>> tests; |
| 131 | |
| 132 | readTests<T, outType, float>(pFileName, numDims, in, tests); |
| 133 | |
| 134 | for (size_t i = 0; i < in.size(); i++) { |
| 135 | array input(numDims[i], &in[i].front(), afHost); |
| 136 | |
| 137 | #pragma GCC diagnostic push |
| 138 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" |
| 139 | array bout = (useDeprecatedAPI ? var(input, true) |
| 140 | : var(input, AF_VARIANCE_SAMPLE)); |
| 141 | array nbout = (useDeprecatedAPI ? var(input, false) |
| 142 | : var(input, AF_VARIANCE_POPULATION)); |
| 143 | |
| 144 | array bout1 = (useDeprecatedAPI ? var(input, true, 1) |
| 145 | : var(input, AF_VARIANCE_SAMPLE, 1)); |
| 146 | array nbout1 = |
| 147 | (useDeprecatedAPI ? var(input, false, 1) |
| 148 | : var(input, AF_VARIANCE_POPULATION, 1)); |
| 149 | #pragma GCC diagnostic pop |
| 150 | |
| 151 | vector<vector<outType>> h_out(4); |
| 152 | |
| 153 | h_out[0].resize(bout.elements()); |
| 154 | h_out[1].resize(nbout.elements()); |
| 155 | h_out[2].resize(bout1.elements()); |
| 156 | h_out[3].resize(nbout1.elements()); |
| 157 | |
| 158 | bout.host(&h_out[0].front()); |
| 159 | nbout.host(&h_out[1].front()); |
| 160 | bout1.host(&h_out[2].front()); |
| 161 | nbout1.host(&h_out[3].front()); |
| 162 | |
| 163 | ASSERT_VEC_ARRAY_NEAR(tests[0], bout.dims(), bout, tol); |
| 164 | ASSERT_VEC_ARRAY_NEAR(tests[1], nbout.dims(), nbout, tol); |
| 165 | ASSERT_VEC_ARRAY_NEAR(tests[2], bout1.dims(), bout1, tol); |
| 166 | ASSERT_VEC_ARRAY_NEAR(tests[3], nbout1.dims(), nbout1, tol); |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | TYPED_TEST(Var, DimCPPSmall) { |
| 171 | dimCppSmallTest<TypeParam>(string(TEST_DIR "/var/var.data")); |