| 48 | } |
| 49 | |
| 50 | void BatchConvBiasForwardImpl::exec( |
| 51 | _megdnn_tensor_in src, _megdnn_tensor_in filter, _megdnn_tensor_in bias, |
| 52 | _megdnn_tensor_in z, _megdnn_tensor_out dst, _megdnn_workspace workspace) { |
| 53 | #if !MGE_BUILD_WITHOUT_NAIVE_EXEC |
| 54 | auto filter_meta = check_exec( |
| 55 | src.layout, filter.layout, bias.layout, z.layout, dst.layout, |
| 56 | workspace.size); |
| 57 | WorkspaceBundle ws = get_workspace_bundle( |
| 58 | workspace.raw_ptr, src.layout, filter.layout, bias.layout, z.layout, |
| 59 | dst.layout); |
| 60 | auto sfb = dst; |
| 61 | if (bias.layout.dtype.enumv() != dst.layout.dtype.enumv()) { |
| 62 | sfb = TensorND{ws.get(0), TensorLayout{dst.layout, bias.layout.dtype}}; |
| 63 | } |
| 64 | |
| 65 | #define DISPATCH_RAW(in_dt, bias_dt, out_dt, cmode, func) \ |
| 66 | else if ( \ |
| 67 | src.layout.dtype.enumv() == DTypeTrait<dtype::in_dt>::enumv && \ |
| 68 | filter.layout.dtype.enumv() == DTypeTrait<dtype::in_dt>::enumv && \ |
| 69 | bias.layout.dtype.enumv() == DTypeTrait<dtype::bias_dt>::enumv && \ |
| 70 | sfb.layout.dtype.enumv() == DTypeTrait<dtype::out_dt>::enumv && \ |
| 71 | param().compute_mode == Param::ComputeMode::cmode) { \ |
| 72 | MEGDNN_DISPATCH_CPU_KERN_OPR( \ |
| 73 | func(src, filter, bias, sfb, nullptr, filter_meta)); \ |
| 74 | } |
| 75 | #define DISPATCH(in_dt, out_dt) \ |
| 76 | DISPATCH_RAW( \ |
| 77 | in_dt, out_dt, out_dt, DEFAULT, \ |
| 78 | (forward_bias< \ |
| 79 | DTypeTrait<dtype::in_dt>::ctype, DTypeTrait<dtype::in_dt>::ctype, \ |
| 80 | DTypeTrait<dtype::out_dt>::ctype, \ |
| 81 | DTypeTrait<dtype::out_dt>::ctype, \ |
| 82 | BatchConvBiasForward::CanonizedFilterMeta, \ |
| 83 | BatchConvFilterVisitor>)) |
| 84 | if (0) { |
| 85 | } |
| 86 | DISPATCH(QuantizedS8, QuantizedS32) |
| 87 | else { |
| 88 | megdnn_throw(ssprintf( |
| 89 | "unsupported naive BatchConvBias(%s, %s, %s, %s) -> %s", |
| 90 | src.layout.dtype.name(), filter.layout.dtype.name(), |
| 91 | bias.layout.dtype.name(), z.layout.dtype.name(), |
| 92 | dst.layout.dtype.name())); |
| 93 | } |
| 94 | #undef DISPATCH |
| 95 | #undef DISPATCH_RAW |
| 96 | MEGDNN_DISPATCH_CPU_KERN_OPR(handle_z_inp_and_activation_naive( |
| 97 | param().nonlineMode, sfb, z, dst, reinterpret_cast<dt_byte*>(ws.get(1)))); |
| 98 | #else |
| 99 | __builtin_trap(); |
| 100 | #endif |
| 101 | } |
| 102 | |
| 103 | std::vector<BatchConvBiasForward::Algorithm*> BatchConvBiasForwardImpl:: |
| 104 | get_all_algorithms( |
nothing calls this directly
no test coverage detected