| 13 | namespace { |
| 14 | |
| 15 | void resize_cv_proxy( |
| 16 | _megdnn_tensor_in src, _megdnn_tensor_out dst, InterpolationMode imode, |
| 17 | void* workspace, cudaStream_t stream) { |
| 18 | using namespace megcv; |
| 19 | for (size_t i = 0; i < src.layout.shape[0]; ++i) { |
| 20 | if (dst.layout.dtype == dtype::Float32()) { |
| 21 | Mat<float> src_mat = TensorND2Mat<float>(src, i); |
| 22 | Mat<float> dst_mat = TensorND2Mat<float>(dst, i); |
| 23 | resize::resize_cv<float>( |
| 24 | src_mat.ptr(), dst_mat.ptr(), src_mat.rows(), src_mat.cols(), |
| 25 | dst_mat.rows(), dst_mat.cols(), src_mat.step(), dst_mat.step(), |
| 26 | src_mat.channels(), imode, workspace, stream); |
| 27 | } else if (dst.layout.dtype == dtype::Uint8()) { |
| 28 | Mat<uchar> src_mat = TensorND2Mat<uchar>(src, i); |
| 29 | Mat<uchar> dst_mat = TensorND2Mat<uchar>(dst, i); |
| 30 | resize::resize_cv<uchar>( |
| 31 | src_mat.ptr(), dst_mat.ptr(), src_mat.rows(), src_mat.cols(), |
| 32 | dst_mat.rows(), dst_mat.cols(), src_mat.step(), dst_mat.step(), |
| 33 | src_mat.channels(), imode, workspace, stream); |
| 34 | } else { |
| 35 | megdnn_throw("Unsupported datatype of WarpAffine optr."); |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | } // anonymous namespace |
| 41 | |