| 347 | using af::array; |
| 348 | |
| 349 | TEST(MedianFilter, CPP) { |
| 350 | UNSUPPORTED_BACKEND(AF_BACKEND_ONEAPI); |
| 351 | const dim_t w_len = 3; |
| 352 | const dim_t w_wid = 3; |
| 353 | |
| 354 | vector<dim4> numDims; |
| 355 | vector<vector<float>> in; |
| 356 | vector<vector<float>> tests; |
| 357 | |
| 358 | readTests<float, float, int>( |
| 359 | string(TEST_DIR "/medianfilter/batch_symmetric_pad_3x3_window.test"), |
| 360 | numDims, in, tests); |
| 361 | |
| 362 | dim4 dims = numDims[0]; |
| 363 | array input(dims, &(in[0].front())); |
| 364 | array output = medfilt(input, w_len, w_wid, AF_PAD_SYM); |
| 365 | |
| 366 | vector<float> outData(dims.elements()); |
| 367 | output.host((void*)outData.data()); |
| 368 | |
| 369 | vector<float> currGoldBar = tests[0]; |
| 370 | size_t nElems = currGoldBar.size(); |
| 371 | for (size_t elIter = 0; elIter < nElems; ++elIter) { |
| 372 | ASSERT_EQ(currGoldBar[elIter], outData[elIter]) |
| 373 | << "at: " << elIter << endl; |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | TEST(MedianFilter1d, CPP) { |
| 378 | UNSUPPORTED_BACKEND(AF_BACKEND_ONEAPI); |