| 1164 | arg_contrast_size = args_with_computation_contrast.size(); |
| 1165 | megdnn_assert(arg_size == arg_contrast_size); |
| 1166 | rep(i, arg_size) { |
| 1167 | TensorLayout dst_layout, dst_layout_contrast; |
| 1168 | auto opr = single_thread_handle.get()->create_operator<ConvBias>(); |
| 1169 | |
| 1170 | auto& arg_with_computation = args_with_computation[i]; |
| 1171 | auto& arg = arg_with_computation.first; |
| 1172 | opr->param() = arg.param; |
| 1173 | opr->deduce_layout( |
| 1174 | {arg.src, data_type[0]}, {arg.filter, data_type[1]}, |
| 1175 | {arg.bias, data_type[2]}, {}, dst_layout); |
| 1176 | float computation = arg_with_computation.second; |
| 1177 | benchmarker.set_param(arg.param); |
| 1178 | auto used = benchmarker.exec({arg.src, arg.filter, arg.bias, {}, {}}) / RUNS; |
| 1179 | |
| 1180 | auto& arg_with_computation_contrast = args_with_computation_contrast[i]; |
| 1181 | auto& arg_contrast = arg_with_computation_contrast.first; |
| 1182 | opr->param() = arg_contrast.param; |
| 1183 | opr->deduce_layout( |
| 1184 | {arg_contrast.src, data_type_contrast[0]}, |
| 1185 | {arg_contrast.filter, data_type_contrast[1]}, |
| 1186 | {arg_contrast.bias, data_type_contrast[2]}, {}, dst_layout_contrast); |
| 1187 | float computation_contrast = arg_with_computation_contrast.second; |
| 1188 | benchmarker_contrast.set_param(arg_contrast.param); |
| 1189 | auto used_contrast = benchmarker_contrast.exec( |
| 1190 | {arg_contrast.src, |
| 1191 | arg_contrast.filter, |
| 1192 | arg_contrast.bias, |
| 1193 | {}, |
| 1194 | {}}) / |
| 1195 | RUNS; |
| 1196 | |
| 1197 | printf("Bench case: \n"); |
| 1198 | printf("padding: %u, stride: %u, nonline mode: %s\n", arg.param.pad_h, |
| 1199 | arg.param.stride_h, nonlinemode2string[arg.param.nonlineMode].c_str()); |
| 1200 | printf("%s %s %s\n", arg.src.to_string().c_str(), |
| 1201 | arg.filter.to_string().c_str(), arg.bias.to_string().c_str()); |
| 1202 | printf("%s %s %s\n", arg_contrast.src.to_string().c_str(), |
| 1203 | arg_contrast.filter.to_string().c_str(), |
| 1204 | arg_contrast.bias.to_string().c_str()); |
| 1205 | |
| 1206 | printf("%s: %f gflops;\n%s: %f gflops\n" |
| 1207 | "spead up = %f\n", |
| 1208 | algo_name.c_str(), computation / used, algo_name_contrast.c_str(), |
| 1209 | computation_contrast / used_contrast, used_contrast / used); |
| 1210 | } |
| 1211 | } |
| 1212 | #endif // MEGDNN_WITH_BENCHMARK |
| 1213 |
no test coverage detected