| 35 | |
| 36 | template <typename T> |
| 37 | void ConvolutionForwardImpl::AlgoMatmul::exec_internal(const ExecArgs& args) { |
| 38 | auto&& fm = args.filter_meta; |
| 39 | size_t N = args.src_layout->shape[0], IC = fm.icpg, IH = args.src_layout->shape[2], |
| 40 | IW = args.src_layout->shape[3], OC = fm.ocpg, OH = args.dst_layout->shape[2], |
| 41 | OW = args.dst_layout->shape[3], FH = fm.spatial[0], FW = fm.spatial[1], |
| 42 | PH = fm.padding[0], PW = fm.padding[1], SH = fm.stride[0], SW = fm.stride[1], |
| 43 | DH = fm.dilation[0], DW = fm.dilation[1]; |
| 44 | auto stream = hip_stream(args.handle); |
| 45 | auto wbundle = matmul_get_workspace_bundle(args); |
| 46 | wbundle.set(args.workspace.raw_ptr); |
| 47 | T* dst_t = static_cast<T*>(wbundle.get(0)); |
| 48 | T* col = static_cast<T*>(wbundle.get(1)); |
| 49 | convolution::im2col<T>( |
| 50 | args.src_tensor->ptr<T>(), col, N, args.src_layout->stride[0], IC, IH, IW, |
| 51 | FH, FW, OH, OW, PH, PW, SH, SW, DH, DW, stream); |
| 52 | TensorLayout Al({OC, IC * FH * FW}, typename DTypeTrait<T>::dtype()), |
| 53 | Bl({IC * FH * FW, OH * OW * N}, typename DTypeTrait<T>::dtype()), |
| 54 | Cl({OC, OH * OW * N}, typename DTypeTrait<T>::dtype()); |
| 55 | TensorND A(args.filter_tensor->ptr<T>(), Al), B(col, Bl), C(dst_t, Cl); |
| 56 | if (fm.should_flip) { |
| 57 | convolution::flip_filter(args, wbundle.get_workspace(2), A.get_ref_ptr()); |
| 58 | } |
| 59 | args.handle->matmul_opr()->exec(A, B, C, Workspace()); |
| 60 | TensorLayout C2l({OC * OH * OW, N}, typename DTypeTrait<T>::dtype()), C3l = C2l; |
| 61 | C3l.stride[0] = 1; |
| 62 | C3l.stride[1] = args.dst_tensor->layout.stride[0]; |
| 63 | TensorND C2(dst_t, C2l); |
| 64 | TensorND C3(args.dst_tensor->ptr<T>(), C3l); |
| 65 | args.handle->relayout_opr()->exec(C2, C3); |
| 66 | } |
| 67 | |
| 68 | // vim: syntax=cpp.doxygen |
nothing calls this directly
no test coverage detected