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

Method kimpl

dnn/src/aarch64/conv_bias/int8/algos.cpp:97–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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