| 176 | } |
| 177 | |
| 178 | std::string ConvGeneral::GetKernelBody(TContext* context) const { |
| 179 | std::stringstream ss; |
| 180 | std::string noline_mode = context->haveAttr("nonlineMode") |
| 181 | ? context->getAttrStr("nonlineMode") |
| 182 | : "IDENTITY"; |
| 183 | auto sparse_str = context->getAttrStr("sparse"); |
| 184 | auto filter_format_str = get_format(context); |
| 185 | auto src_format_str = get_src_foramt(filter_format_str); |
| 186 | auto dst_format_str = get_dst_foramt(filter_format_str); |
| 187 | bool with_bias = is_bias(context); |
| 188 | auto src_dtype = context->getAttrOprand("operand:0").dtype; |
| 189 | auto flt_dtype = context->getAttrOprand("operand:1").dtype; |
| 190 | int dst_idx = context->getAttrInt("nr_operands") - 1; |
| 191 | std::string dst_dtype = |
| 192 | context->getAttrOprand("operand:" + std::to_string(dst_idx)).dtype; |
| 193 | |
| 194 | auto src_specifier = Utils::cvt_dtype_specifier(src_dtype); |
| 195 | auto flt_specifier = Utils::cvt_dtype_specifier(flt_dtype); |
| 196 | auto dst_specifier = Utils::cvt_dtype_specifier(dst_dtype); |
| 197 | std::string bias_specifier; |
| 198 | if (with_bias) { |
| 199 | auto bias_dtype = context->getAttrOprand("operand:2").dtype; |
| 200 | bias_specifier = Utils::cvt_dtype_specifier(bias_dtype); |
| 201 | } |
| 202 | std::string acc_specifier = "float"; |
| 203 | if (src_specifier == "int8_t" && flt_specifier == "int8_t") { |
| 204 | acc_specifier = "int"; |
| 205 | } |
| 206 | if (src_specifier == "gi_float16_t" && flt_specifier == "gi_float16_t") { |
| 207 | acc_specifier = "gi_float16_t"; |
| 208 | } |
| 209 | |
| 210 | uint32_t spatial_start = 2; |
| 211 | uint32_t channel_pos = 1; |
| 212 | uint32_t batch_pos = 0; |
| 213 | uint32_t ocpg_ratio = 1; |
| 214 | uint32_t icpg_ratio = 1; |
| 215 | |
| 216 | std::string group_str = "1"; |
| 217 | if (filter_format_str == "NCHW") { |
| 218 | if (sparse_str == "GROUP") { |
| 219 | group_str = "filter_weight->layout.dims[0]"; |
| 220 | } |
| 221 | } else if (filter_format_str == "NCHW44") { |
| 222 | ocpg_ratio = 4; |
| 223 | icpg_ratio = 4; |
| 224 | if (sparse_str == "GROUP") { |
| 225 | group_str = "filter_weight->layout.dims[0] * 4"; |
| 226 | } |
| 227 | } else if (filter_format_str == "NCHW_NCHW44") { |
| 228 | ocpg_ratio = 4; |
| 229 | icpg_ratio = 1; |
| 230 | CC_ASSERT(sparse_str == "DENSE"); |
| 231 | } else if (filter_format_str == "NCHW88") { |
| 232 | ocpg_ratio = 8; |
| 233 | icpg_ratio = 8; |
| 234 | if (sparse_str == "GROUP") { |
| 235 | group_str = "filter_weight->layout.dims[0] * 8"; |
nothing calls this directly
no test coverage detected