| 75 | } |
| 76 | |
| 77 | void ConvBiasImpl::AlgoQU8MatrixMul::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 | uint8_t src_zp = param.src_type.param<dtype::Quantized8Asymm>().zero_point; |
| 87 | // workspace = tmp..src2 |
| 88 | for (size_t n = 0; n < N; ++n) { |
| 89 | uint8_t* src = const_cast<uint8_t*>(param.src<uint8_t>(n, group_id)); |
| 90 | uint8_t* filter = const_cast<uint8_t*>(param.filter<uint8_t>(group_id)); |
| 91 | uint8_t* dst = static_cast<uint8_t*>(param.dst<uint8_t>(n, group_id)); |
| 92 | int32_t* bias = const_cast<int32_t*>(param.bias<int32_t>(n, group_id)); |
| 93 | |
| 94 | uint8_t *B, *src2; |
| 95 | |
| 96 | if (FH == 1 && FW == 1 && SH == 1 && SW == 1 && PH == 0 && PW == 0) { |
| 97 | // special case: 1x1 |
| 98 | B = const_cast<uint8_t*>(src); |
| 99 | } else { |
| 100 | src2 = static_cast<uint8_t*>(bundle.get(0)); |
| 101 | // copy src to src2; |
| 102 | uint8_t* src2_ptr = src2; |
| 103 | const uint8_t* src_ptr = src; |
| 104 | rep(ic, IC) { |
| 105 | if (PH != 0) { |
| 106 | std::memset(src2_ptr, src_zp, sizeof(uint8_t) * PH * IW2); |
| 107 | src2_ptr += PH * IW2; |
| 108 | } |
| 109 | rep(ih, IH) { |
| 110 | if (PW != 0) |
| 111 | rep(pw, PW) { *(src2_ptr++) = src_zp; } |
| 112 | std::memcpy(src2_ptr, src_ptr, sizeof(uint8_t) * IW); |
| 113 | src2_ptr += IW; |
| 114 | src_ptr += IW; |
| 115 | if (PW != 0) |
| 116 | rep(pw, PW) { *(src2_ptr++) = src_zp; } |
| 117 | } |
| 118 | if (PH != 0) { |
| 119 | std::memset(src2_ptr, src_zp, sizeof(uint8_t) * PH * IW2); |
| 120 | src2_ptr += PH * IW2; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | B = static_cast<uint8_t*>(bundle.get(1)); |
| 125 | if (SH == 1 && SW == 1) { |
| 126 | if (is_xcorr) |
| 127 | img2col<true>(src2, B, OC, OH, OW, IC, IH2, IW2, FH, FW); |
| 128 | else |
| 129 | img2col<false>(src2, B, OC, OH, OW, IC, IH2, IW2, FH, FW); |
| 130 | } else { |
| 131 | if (is_xcorr) |
| 132 | img2col_stride<true>( |
| 133 | src2, B, OC, OH, OW, IC, IH2, IW2, FH, FW, SH, SW); |
| 134 | else |
nothing calls this directly
no test coverage detected