MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / resize_cv_exec

Method resize_cv_exec

dnn/src/arm_common/resize/resize_cv.cpp:1963–2034  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1961} // anonymous namespace
1962
1963void megdnn::arm_common::resize_cv_exec(
1964 _megdnn_tensor_in src, _megdnn_tensor_out dst,
1965 param::Resize::InterpolationMode imode) {
1966 megdnn_assert(src.layout[3] == 1 || src.layout[3] == 3, "unsupported src channel");
1967 for (size_t i = 0; i < src.layout.shape[0]; ++i) {
1968 if (dst.layout.dtype == dtype::Float32()) {
1969 MIDOUT_BEGIN(megdnn_arm_resizecv_dtype, midout_iv(0)) {
1970 Mat<float> src_mat = TensorND2Mat<float>(src, i);
1971 Mat<float> dst_mat = TensorND2Mat<float>(dst, i);
1972 switch (imode) {
1973 case IMode::INTER_NEAREST:
1974 MIDOUT_BEGIN(megdnn_arm_resizecv_imode, midout_iv(0)) {
1975 resize_nearest_32f(src_mat, dst_mat);
1976 }
1977 MIDOUT_END();
1978 break;
1979 case IMode::INTER_LINEAR:
1980 MIDOUT_BEGIN(megdnn_arm_resizecv_imode, midout_iv(1)) {
1981 resize_linear_32f(src_mat, dst_mat);
1982 }
1983 MIDOUT_END();
1984 break;
1985 case IMode::INTER_CUBIC:
1986 case IMode::INTER_LANCZOS4:
1987 case IMode::INTER_AREA:
1988 MIDOUT_BEGIN(megdnn_arm_resizecv_imode, midout_iv(2)) {
1989 resize_opencv<float>(src_mat, dst_mat, imode);
1990 }
1991 MIDOUT_END();
1992 break;
1993 default:
1994 megdnn_throw("unsupported interpolation mode");
1995 break;
1996 }
1997 }
1998 MIDOUT_END();
1999 } else if (dst.layout.dtype == dtype::Uint8()) {
2000 MIDOUT_BEGIN(megdnn_arm_resizecv_dtype, midout_iv(1)) {
2001 Mat<uchar> src_mat = TensorND2Mat<uchar>(src, i);
2002 Mat<uchar> dst_mat = TensorND2Mat<uchar>(dst, i);
2003 switch (imode) {
2004 case IMode::INTER_NEAREST:
2005 MIDOUT_BEGIN(megdnn_arm_resizecv_imode, midout_iv(0)) {
2006 resize_nearest_8u(src_mat, dst_mat);
2007 }
2008 MIDOUT_END();
2009 break;
2010 case IMode::INTER_LINEAR:
2011 MIDOUT_BEGIN(megdnn_arm_resizecv_imode, midout_iv(1)) {
2012 resize_linear_8u(src_mat, dst_mat);
2013 }
2014 MIDOUT_END();
2015 break;
2016 case IMode::INTER_CUBIC:
2017 case IMode::INTER_LANCZOS4:
2018 case IMode::INTER_AREA:
2019 MIDOUT_BEGIN(megdnn_arm_resizecv_imode, midout_iv(2)) {
2020 resize_opencv<uchar>(src_mat, dst_mat, imode);

Callers

nothing calls this directly

Calls 5

resize_nearest_32fFunction · 0.70
resize_linear_32fFunction · 0.70
resize_nearest_8uFunction · 0.70
resize_linear_8uFunction · 0.70
MIDOUT_BEGINFunction · 0.50

Tested by

no test coverage detected