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

Function TEST_F

dnn/test/cuda/elemwise.cpp:79–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79TEST_F(CUDA, ELEMWISE_UINT16) {
80 Checker<ElemwiseForward> checker(handle_cuda());
81 using Mode = ElemwiseForward::Param::Mode;
82 UniformIntRNG ui_rng{0, 255};
83 auto run_unary = [&](size_t N, Mode mode, DType dtype) {
84 checker.set_param(mode).set_dtype(0, dtype);
85 checker.execs({{N}, {}});
86 };
87#define RUN_UNARY_UINT16(_dt) \
88 run_unary(100, Mode::RELU, _dt); \
89 run_unary(100, Mode::RELU6, _dt); \
90 run_unary(100, Mode::NEGATE, _dt); \
91 run_unary(100, Mode::SIGN, _dt); \
92 run_unary(100, Mode::SQUARE, _dt); \
93 run_unary(100, Mode::ABS, _dt);
94 checker.set_rng(0, &ui_rng);
95 RUN_UNARY_UINT16(dtype::Uint16());
96#undef RUN_UNARY_UINT16
97 auto run_binary = [&](size_t N, size_t C, size_t H, size_t W, Mode mode,
98 DType dtype) {
99 checker.set_param(mode).set_dtype(0, dtype).set_dtype(1, dtype);
100 checker.execs({{5}, {5}, {}});
101 checker.execs({{4}, {4}, {}});
102 checker.execs({{4}, {1}, {}});
103 checker.execs({{N, C / 4, H, W, 4}, {N, C / 4, H, W, 4}, {}});
104 checker.execs({{N, C / 4, H, W, 4}, {1, C / 4, 1, 1, 4}, {}});
105 checker.execs({{N, C / 32, H, W, 32}, {N, C / 32, H, W, 32}, {}});
106 checker.execs({{N, C / 32, H, W, 32}, {1, C / 32, 1, 1, 32}, {}});
107 checker.execs({{3, 5, 7}, {3, 5, 7}, {}});
108 checker.execs({{3, 5, 7}, {3, 5, 1}, {}});
109 checker.execs({{3, 5, 1}, {3, 5, 7}, {}});
110 checker.execs({{1}, {3, 5, 7}, {}});
111 checker.execs({{3, 5, 7}, {1}, {}});
112 };
113#define RUN_BINARY_UINT16(_dt) \
114 run_binary(4, 32, 10, 10, Mode::ADD, _dt); \
115 run_binary(4, 32, 10, 10, Mode::MUL, _dt); \
116 run_binary(4, 32, 10, 10, Mode::MAX, _dt); \
117 run_binary(4, 32, 10, 10, Mode::MIN, _dt); \
118 run_binary(4, 32, 10, 10, Mode::SUB, _dt); \
119 run_binary(4, 32, 10, 10, Mode::EQ, _dt); \
120 run_binary(4, 32, 10, 10, Mode::LEQ, _dt); \
121 run_binary(4, 32, 10, 10, Mode::LT, _dt); \
122 run_binary(4, 32, 10, 10, Mode::PRELU, _dt); \
123 run_binary(4, 32, 10, 10, Mode::RMULH, _dt); \
124 run_binary(4, 32, 10, 10, Mode::TANH_GRAD, _dt); \
125 run_binary(4, 32, 10, 10, Mode::SIGMOID_GRAD, _dt); \
126 run_binary(4, 32, 10, 10, Mode::SWITCH_GT0, _dt); \
127 run_binary(4, 32, 10, 10, Mode::FUSE_ADD_RELU, _dt);
128 checker.set_rng(0, &ui_rng).set_rng(1, &ui_rng);
129 RUN_BINARY_UINT16(dtype::Uint16());
130#undef RUN_BINARY_UINT16
131}
132
133TEST_F(CUDA, ELEMWISE_IBYTE) {
134 Checker<ElemwiseForward> checker(handle_cuda());

Callers

nothing calls this directly

Calls 6

set_dtypeMethod · 0.80
run_tensor_addFunction · 0.70
execsMethod · 0.45
genMethod · 0.45
paramMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected