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

Method resize_cv_exec

dnn/src/naive/resize/resize_cv.cpp:1345–1420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1343} // anonymous namespace
1344
1345void megdnn::naive::resize_cv_exec(
1346 _megdnn_tensor_in src, _megdnn_tensor_out dst,
1347 param::Resize::InterpolationMode imode) {
1348#if !MGE_BUILD_WITHOUT_NAIVE_EXEC
1349 megdnn_assert(src.layout[3] == 1 || src.layout[3] == 3, "unsupported src channel");
1350 for (size_t i = 0; i < src.layout.shape[0]; ++i) {
1351 if (dst.layout.dtype == dtype::Float32()) {
1352 MIDOUT_BEGIN(megdnn_naive_resizecv_dtype, midout_iv(0)) {
1353 Mat<float> src_mat = TensorND2Mat<float>(src, i);
1354 Mat<float> dst_mat = TensorND2Mat<float>(dst, i);
1355 switch (imode) {
1356 case IMode::INTER_NEAREST:
1357 MIDOUT_BEGIN(megdnn_naive_resizecv_imode, midout_iv(0)) {
1358 resize_nearest_32f(src_mat, dst_mat);
1359 }
1360 MIDOUT_END();
1361 break;
1362 case IMode::INTER_LINEAR:
1363 MIDOUT_BEGIN(megdnn_naive_resizecv_imode, midout_iv(1)) {
1364 resize_linear_32f(src_mat, dst_mat);
1365 }
1366 MIDOUT_END();
1367 break;
1368 case IMode::INTER_CUBIC:
1369 case IMode::INTER_LANCZOS4:
1370 case IMode::INTER_AREA:
1371 MIDOUT_BEGIN(megdnn_naive_resizecv_imode, midout_iv(2)) {
1372 resize_opencv<float>(src_mat, dst_mat, imode);
1373 }
1374 MIDOUT_END();
1375 break;
1376 default:
1377 megdnn_throw("unsupported interpolation mode");
1378 break;
1379 }
1380 }
1381 MIDOUT_END();
1382 } else if (dst.layout.dtype == dtype::Uint8()) {
1383 MIDOUT_BEGIN(megdnn_naive_resizecv_dtype, midout_iv(1)) {
1384 Mat<uchar> src_mat = TensorND2Mat<uchar>(src, i);
1385 Mat<uchar> dst_mat = TensorND2Mat<uchar>(dst, i);
1386 switch (imode) {
1387 case IMode::INTER_NEAREST:
1388 MIDOUT_BEGIN(megdnn_naive_resizecv_imode, midout_iv(0)) {
1389 resize_nearest_8u(src_mat, dst_mat);
1390 }
1391 MIDOUT_END();
1392 break;
1393 case IMode::INTER_LINEAR:
1394 MIDOUT_BEGIN(megdnn_naive_resizecv_imode, midout_iv(1)) {
1395 resize_linear_8u(src_mat, dst_mat);
1396 }
1397 MIDOUT_END();
1398 break;
1399 case IMode::INTER_CUBIC:
1400 case IMode::INTER_LANCZOS4:
1401 case IMode::INTER_AREA:
1402 MIDOUT_BEGIN(megdnn_naive_resizecv_imode, midout_iv(2)) {

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