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

Method kimpl

dnn/src/armv7/conv_bias/int8/algos.cpp:77–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77void ConvBiasImpl::AlgoS8MatrixMul::kimpl(
78 const NCBKernParam& param, const NCBKernIndex& ncb_index) {
79 auto is_xcorr = !param.filter_meta.should_flip;
80 UNPACK_CONV_NCB_KERN_SIZES(param);
81 auto bundle = get_bundle(param);
82 bundle.set(param.workspace_ptr);
83 auto IH2 = IH + 2 * PH;
84 auto IW2 = IW + 2 * PW;
85 size_t group_id = ncb_index.ndrange_id[0];
86 // workspace = tmp..src2
87 for (size_t n = 0; n < N; ++n) {
88 dt_int8* src = const_cast<dt_int8*>(param.src<dt_int8>(n, group_id));
89 dt_int8* filter = const_cast<dt_int8*>(param.filter<dt_int8>(group_id));
90 dt_int8* dst = static_cast<dt_int8*>(param.dst<dt_int8>(n, group_id));
91 dt_int32* bias = const_cast<dt_int32*>(param.bias<dt_int32>(n, group_id));
92
93 dt_int8 *B, *src2;
94 if (FH == 1 && FW == 1 && SH == 1 && SW == 1 && PH == 0 && PW == 0) {
95 // special case: 1x1
96 B = const_cast<dt_int8*>(src);
97 } else {
98 src2 = static_cast<dt_int8*>(bundle.get(0));
99 // copy src to src2;
100 dt_int8* src2_ptr = src2;
101 const dt_int8* src_ptr = src;
102 rep(ic, IC) {
103 if (PH != 0) {
104 std::memset(src2_ptr, 0, sizeof(dt_int8) * PH * IW2);
105 src2_ptr += PH * IW2;
106 }
107 rep(ih, IH) {
108 if (PW != 0)
109 rep(pw, PW) { *(src2_ptr++) = 0.0f; }
110 std::memcpy(src2_ptr, src_ptr, sizeof(dt_int8) * IW);
111 src2_ptr += IW;
112 src_ptr += IW;
113 if (PW != 0)
114 rep(pw, PW) { *(src2_ptr++) = 0.0f; }
115 }
116 if (PH != 0) {
117 std::memset(src2_ptr, 0, sizeof(dt_int8) * PH * IW2);
118 src2_ptr += PH * IW2;
119 }
120 }
121
122 B = static_cast<dt_int8*>(bundle.get(1));
123 if (SH == 1 && SW == 1) {
124 if (is_xcorr)
125 img2col<true>(src2, B, OC, OH, OW, IC, IH2, IW2, FH, FW);
126 else
127 img2col<false>(src2, B, OC, OH, OW, IC, IH2, IW2, FH, FW);
128 } else {
129 if (is_xcorr)
130 img2col_stride<true>(
131 src2, B, OC, OH, OW, IC, IH2, IW2, FH, FW, SH, SW);
132 else
133 img2col_stride<false>(
134 src2, B, OC, OH, OW, IC, IH2, IW2, FH, FW, SH, SW);

Callers

nothing calls this directly

Calls 3

get_bundleFunction · 0.50
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected