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

Method kimpl

dnn/src/aarch64/conv_bias/quint8/algos.cpp:99–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99void ConvBiasImpl::AlgoQU8MatrixMul::kimpl(
100 const NCBKernParam& param, const NCBKernIndex& ncb_index) {
101 auto is_xcorr = !param.filter_meta.should_flip;
102 UNPACK_CONV_NCB_KERN_SIZES(param);
103 auto bundle = get_bundle(param);
104 bundle.set(param.workspace_ptr);
105 auto IH2 = IH + 2 * PH;
106 auto IW2 = IW + 2 * PW;
107 size_t group_id = ncb_index.ndrange_id[0];
108 uint8_t src_zp = param.src_type.param<dtype::Quantized8Asymm>().zero_point;
109 // workspace = tmp..src2
110 for (size_t n = 0; n < N; ++n) {
111 uint8_t* src = const_cast<uint8_t*>(param.src<uint8_t>(n, group_id));
112 uint8_t* filter = const_cast<uint8_t*>(param.filter<uint8_t>(group_id));
113 uint8_t* dst = static_cast<uint8_t*>(param.dst<uint8_t>(n, group_id));
114 int32_t* bias = const_cast<int32_t*>(param.bias<int32_t>(n, group_id));
115
116 uint8_t *B, *src2;
117 if (FH == 1 && FW == 1 && SH == 1 && SW == 1 && PH == 0 && PW == 0) {
118 // special case: 1x1
119 B = const_cast<uint8_t*>(src);
120 } else {
121 src2 = static_cast<uint8_t*>(bundle.get(0));
122 // copy src to src2;
123 uint8_t* src2_ptr = src2;
124 const uint8_t* src_ptr = src;
125 rep(ic, IC) {
126 if (PH != 0) {
127 std::memset(src2_ptr, src_zp, sizeof(uint8_t) * PH * IW2);
128 src2_ptr += PH * IW2;
129 }
130 rep(ih, IH) {
131 if (PW != 0)
132 rep(pw, PW) { *(src2_ptr++) = src_zp; }
133 std::memcpy(src2_ptr, src_ptr, sizeof(uint8_t) * IW);
134 src2_ptr += IW;
135 src_ptr += IW;
136 if (PW != 0)
137 rep(pw, PW) { *(src2_ptr++) = src_zp; }
138 }
139 if (PH != 0) {
140 std::memset(src2_ptr, src_zp, sizeof(uint8_t) * PH * IW2);
141 src2_ptr += PH * IW2;
142 }
143 }
144
145 B = static_cast<uint8_t*>(bundle.get(1));
146 if (SH == 1 && SW == 1) {
147 if (is_xcorr)
148 img2col<true>(src2, B, OC, OH, OW, IC, IH2, IW2, FH, FW);
149 else
150 img2col<false>(src2, B, OC, OH, OW, IC, IH2, IW2, FH, FW);
151 } else {
152 if (is_xcorr)
153 img2col_stride<true>(
154 src2, B, OC, OH, OW, IC, IH2, IW2, FH, FW, SH, SW);
155 else
156 img2col_stride<false>(

Callers

nothing calls this directly

Calls 3

get_bundleFunction · 0.50
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected