MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / run_quint8_test

Method run_quint8_test

dnn/test/common/warp_perspective.cpp:267–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267void warp_perspective::run_quint8_test(Handle* handle) {
268 using Param = WarpPerspective::Param;
269 Checker<WarpPerspectiveForward> checker(handle);
270 UniformIntRNG input_rng{0, 255};
271 WarpPerspectiveMatRNG mat_rng;
272 class ResizeBy2xMatRNG : public RNG {
273 void gen(const TensorND& tensor_) override {
274 float* ptr = tensor_.ptr<float>();
275 auto N = tensor_.layout.shape[0];
276 megdnn_assert(
277 tensor_.layout.is_contiguous() && tensor_.layout.ndim == 3 &&
278 tensor_.layout[1] == 3 && tensor_.layout[2] == 3);
279 for (size_t n = 0; n < N; ++n) {
280 // | 1 0 0 |
281 // mat = | 0 1 0 |
282 // | 0 0 2 |
283 // resize_2x
284 ptr[0] = ptr[4] = 1;
285 ptr[8] = 2;
286 ptr[1] = ptr[2] = ptr[3] = ptr[5] = ptr[6] = ptr[7] = 0;
287 ptr += 9;
288 }
289 }
290 } resize_2x_mat_rng;
291 if (handle->type() == Handle::HandleType::CUDA) {
292 // As currently the computation is performed in floating points instead
293 // of full int, it could be slightly different on GPU.
294 checker.set_epsilon(1.1).set_max_avg_error(7e-5);
295 }
296 checker.set_rng(0, &input_rng)
297 .set_rng(1, &mat_rng)
298 .set_dtype(0, dtype::Quantized8Asymm(0.6f, static_cast<uint8_t>(127)))
299 .set_dtype(1, dtype::Float32())
300 .set_dtype(2, dtype::Quantized8Asymm(0.6f, static_cast<uint8_t>(127)))
301 .set_param(
302 {Param::InterpolationMode::LINEAR, Param::BorderMode::CONSTANT,
303 Param::Format::NCHW, 0.f});
304 checker.execs({{99, 48, 17, 17}, {99, 3, 3}, {99, 48, 22, 22}})
305 .execs({{12, 3, 224, 224}, {12, 3, 3}, {12, 3, 256, 256}});
306
307 checker.set_rng(1, &resize_2x_mat_rng);
308 checker.execs({{98, 48, 17, 17}, {98, 3, 3}, {98, 48, 34, 34}})
309 .execs({{13, 3, 224, 224}, {13, 3, 3}, {13, 3, 448, 448}});
310}
311
312// vim: syntax=cpp.doxygen

Callers

nothing calls this directly

Calls 3

set_dtypeMethod · 0.80
typeMethod · 0.45
execsMethod · 0.45

Tested by

no test coverage detected