| 24 | |
| 25 | template<typename T> |
| 26 | inline void ResizeCropConvertReformat(nvbench::state &state, nvbench::type_list<T>) |
| 27 | try |
| 28 | { |
| 29 | long3 srcShape = benchutils::GetShape<3>(state.get_string("shape")); |
| 30 | long varShape = state.get_int64("varShape"); |
| 31 | |
| 32 | NVCVInterpolationType interpType = benchutils::GetInterpolationType(state.get_string("interpolation")); |
| 33 | |
| 34 | int2 cropPos{1, 1}; |
| 35 | |
| 36 | NVCVSize2D resize; |
| 37 | |
| 38 | if (state.get_string("resizeType") == "EXPAND") |
| 39 | { |
| 40 | resize = NVCVSize2D{(int)(srcShape.y * 2), (int)(srcShape.z * 2)}; |
| 41 | } |
| 42 | else if (state.get_string("resizeType") == "CONTRACT") |
| 43 | { |
| 44 | resize = NVCVSize2D{(int)(srcShape.y / 2), (int)(srcShape.z / 2)}; |
| 45 | } |
| 46 | else |
| 47 | { |
| 48 | throw std::invalid_argument("Invalid resizeType = " + state.get_string("resizeType")); |
| 49 | } |
| 50 | |
| 51 | NVCVChannelManip manip; |
| 52 | |
| 53 | if (state.get_string("manip") == "NO_OP") |
| 54 | { |
| 55 | manip = NVCV_CHANNEL_NO_OP; |
| 56 | } |
| 57 | else if (state.get_string("manip") == "REVERSE") |
| 58 | { |
| 59 | manip = NVCV_CHANNEL_REVERSE; |
| 60 | } |
| 61 | else |
| 62 | { |
| 63 | throw std::invalid_argument("Invalid channel manipulation = " + state.get_string("manip")); |
| 64 | } |
| 65 | |
| 66 | using BT = nvcv::cuda::BaseType<T>; |
| 67 | long nc = nvcv::cuda::NumElements<T>; |
| 68 | |
| 69 | long3 dstShape{srcShape.x, resize.h - cropPos.y, resize.w - cropPos.x}; |
| 70 | |
| 71 | if (dstShape.y <= 0 || dstShape.z <= 0) |
| 72 | { |
| 73 | throw std::invalid_argument("Invalid shape and resizeType"); |
| 74 | } |
| 75 | |
| 76 | state.add_global_memory_reads(srcShape.x * srcShape.y * srcShape.z * sizeof(T)); |
| 77 | state.add_global_memory_writes(dstShape.x * dstShape.y * dstShape.z * sizeof(T)); |
| 78 | |
| 79 | cvcuda::ResizeCropConvertReformat op; |
| 80 | |
| 81 | // clang-format off |
| 82 | |
| 83 | if (varShape < 0) // negative var shape means use Tensor |
nothing calls this directly
no test coverage detected