| 22 | namespace test { |
| 23 | |
| 24 | TEST_F(CUDA, POOLING_FORWARD) { |
| 25 | auto args = pooling::get_args(); |
| 26 | using Format = param::Pooling::Format; |
| 27 | std::vector<DType> dtypes{dtype::Float16(), dtype::BFloat16(), dtype::Float32()}; |
| 28 | if (check_compute_capability(6, 0)) { |
| 29 | // int pooling is supported only for Pascal or higher |
| 30 | dtypes.push_back(dtype::Int8()); |
| 31 | } |
| 32 | for (auto dtype : dtypes) |
| 33 | for (auto format : {Format::NCHW, Format::NHWC}) |
| 34 | for (auto&& arg : args) { |
| 35 | auto param = arg.param; |
| 36 | auto src = arg.ishape; |
| 37 | param.format = format; |
| 38 | if (param.format == Format::NHWC) { |
| 39 | src = cvt_src_or_dst_nchw2nhwc(src); |
| 40 | } |
| 41 | Checker<Pooling> checker(handle_cuda()); |
| 42 | if (dtype == dtype::Int8()) { |
| 43 | // different versions of cuDNN differs in rounding behavior; |
| 44 | // setting eps to 1 to allow for rounding errors. |
| 45 | checker.set_epsilon(1 + 1e-3); |
| 46 | } else if (dtype == dtype::BFloat16()) { |
| 47 | checker.set_epsilon(2e-2); |
| 48 | } else { |
| 49 | checker.set_epsilon(1e-2); |
| 50 | } |
| 51 | checker.set_param(param).set_dtype(0, dtype).set_dtype(1, dtype).exec( |
| 52 | TensorShapeArray{src, {}}); |
| 53 | } |
| 54 | |
| 55 | /* add test for new Mode temporarily */ |
| 56 | for (auto dtype : dtypes) |
| 57 | for (auto format : {Format::NCHW, Format::NHWC}) |
| 58 | for (auto&& arg : args) { |
| 59 | auto param = arg.param; |
| 60 | if (param.mode == Pooling::Mode::AVERAGE) |
| 61 | param.mode = Pooling::Mode::AVERAGE_COUNT_EXCLUDE_PADDING; |
| 62 | else |
| 63 | continue; |
| 64 | auto src = arg.ishape; |
| 65 | param.format = format; |
| 66 | if (param.format == Format::NHWC) { |
| 67 | src = cvt_src_or_dst_nchw2nhwc(src); |
| 68 | } |
| 69 | Checker<Pooling> checker(handle_cuda()); |
| 70 | if (dtype == dtype::Int8()) { |
| 71 | // different versions of cuDNN differs in rounding behavior; |
| 72 | // setting eps to 1 to allow for rounding errors. |
| 73 | checker.set_epsilon(1 + 1e-3); |
| 74 | } else if (dtype == dtype::BFloat16()) { |
| 75 | checker.set_epsilon(2e-2); |
| 76 | } else { |
| 77 | checker.set_epsilon(1e-2); |
| 78 | } |
| 79 | checker.set_param(param).set_dtype(0, dtype).set_dtype(1, dtype).exec( |
| 80 | TensorShapeArray{src, {}}); |
| 81 | } |
nothing calls this directly
no test coverage detected