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

Function TEST_F

dnn/test/arm_common/warp_perspective.cpp:15–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13namespace test {
14
15TEST_F(ARM_COMMON, WARP_PERSPECTIVE_CV) {
16 //! Just for the format NHWC
17 Checker<WarpPerspective, WarpPerspectiveMatIdxProxy> checker(handle());
18 param::WarpPerspective param;
19 class ResizeMatRNG : public RNG {
20 void gen(const TensorND& tensor_) override {
21 auto& gen = RandomState::generator();
22 std::uniform_real_distribution<dt_float32> pdist3(1.9f, 3.1f);
23 std::uniform_real_distribution<dt_float32> pdist(0.9f, 1.1f);
24 std::uniform_real_distribution<dt_float32> pdisth(0.4f, 0.6f);
25 std::uniform_real_distribution<dt_float32> ndist(-1.1f, -0.9f);
26 std::uniform_real_distribution<dt_float32> ndist3(-3.1f, -1.9f);
27 std::uniform_real_distribution<dt_float32> ndisth(-0.6f, -0.4f);
28 std::uniform_int_distribution<int> dice(0, 5);
29 float* ptr = tensor_.ptr<dt_float32>();
30 auto N = tensor_.layout.shape[0];
31 for (size_t n = 0; n < N; ++n) {
32 for (size_t i = 0; i < 9; ++i) {
33 switch (dice(gen)) {
34 case 0:
35 ptr[i] = pdist3(gen);
36 break;
37 case 1:
38 ptr[i] = pdist(gen);
39 break;
40 case 2:
41 ptr[i] = pdisth(gen);
42 break;
43 case 3:
44 ptr[i] = ndist(gen);
45 break;
46 case 4:
47 ptr[i] = ndist3(gen);
48 break;
49 case 5:
50 ptr[i] = ndisth(gen);
51 break;
52 }
53 }
54 // is resize?
55 if (n & 1) {
56 ptr[1] = 0;
57 ptr[3] = 0;
58 ptr[6] = ptr[7] = 0;
59 }
60 ptr += 9;
61 }
62 }
63 } rng;
64
65 using BMode = param::WarpPerspective::BorderMode;
66 param.format = param::WarpPerspective::Format::NHWC;
67 // add for nearest test
68 param.imode = param::WarpPerspective::InterpolationMode::NEAREST;
69 for (auto mode :
70 {BMode::REFLECT_101, BMode::REPLICATE, BMode::REFLECT, BMode::WRAP,
71 BMode::CONSTANT}) {
72 param.bmode = mode;

Callers

nothing calls this directly

Calls 9

set_dtypeMethod · 0.80
benchmark_implFunction · 0.70
get_cv_argsFunction · 0.50
runFunction · 0.50
execMethod · 0.45
execsMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected