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

Function run_check

dnn/test/naive/cvt_color.cpp:94–115  ·  view source on GitHub ↗

check real yuv

Source from the content-addressed store, hash-verified

92
93//! check real yuv
94void run_check(Handle* handle, const size_t IH, const size_t IW) {
95 const size_t OH = IH / 3 * 2;
96 const size_t OW = IW;
97 const size_t OC = 3;
98 SyncedTensor<uint8_t> src(handle, {1, IH, IW, 1}), dst(handle, {1, OH, OW, OC}),
99 expect(handle, {1, OH, OW, OC});
100 auto opr = handle->create_operator<CvtColor>();
101 opr->param().mode = param::CvtColor::Mode::BT601_YUV2BGR_NV21;
102 opr->exec(src.tensornd_dev(), dst.tensornd_dev(), {});
103 naive(src.ptr_host(), IW, src.ptr_host() + OH * IW, IW, expect.ptr_mutable_host(),
104 OW * OC, OW, OH);
105
106 rep(i, OH) rep(j, OW) rep(c, OC) {
107 uint8_t dst_value = dst.ptr_host()[i * OW * OC + j * OC + c];
108 uint8_t expect_value = expect.ptr_host()[i * OW * OC + j * OC + c];
109 megdnn_assert(
110 dst_value == expect_value,
111 "Error: %d(actual) != %d(expect) at(%zu,%zu,%zu)",
112 static_cast<int>(dst_value), static_cast<int>(expect_value), i, j, c);
113 }
114#undef rep
115}
116
117} // namespace
118

Callers 2

TEST_FFunction · 0.70
TESTFunction · 0.50

Calls 4

naiveFunction · 0.85
repFunction · 0.70
paramMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected