| 23 | |
| 24 | template<typename T> |
| 25 | inline void MinAreaRect(nvbench::state &state, nvbench::type_list<T>) |
| 26 | try |
| 27 | { |
| 28 | long2 shape = benchutils::GetShape<2>(state.get_string("shape")); |
| 29 | long varShape = state.get_int64("varShape"); |
| 30 | |
| 31 | state.add_global_memory_reads(shape.x * shape.y * sizeof(T)); |
| 32 | state.add_global_memory_writes(shape.x * 8 * sizeof(float) + shape.x * sizeof(int)); |
| 33 | |
| 34 | cvcuda::MinAreaRect op(shape.x); |
| 35 | |
| 36 | // clang-format off |
| 37 | |
| 38 | if (varShape < 0) // negative var shape means use Tensor |
| 39 | { |
| 40 | nvcv::Tensor src({{shape.x, shape.y, 2}, "NWC"}, benchutils::GetDataType<T>()); |
| 41 | nvcv::Tensor dst({{shape.x, 8}, "NW"}, nvcv::TYPE_F32); |
| 42 | nvcv::Tensor points({{1, shape.x}, "NW"}, nvcv::TYPE_S32); |
| 43 | |
| 44 | benchutils::FillTensor<T>(src, benchutils::RandomValues<T>()); |
| 45 | benchutils::FillTensor<float>(dst, benchutils::RandomValues<float>(0.f, 1.f)); |
| 46 | benchutils::FillTensor<int>(points, benchutils::RandomValues<int>(10, 100)); |
| 47 | |
| 48 | state.exec(nvbench::exec_tag::sync, [&op, &src, &dst, &points, &shape](nvbench::launch &launch) |
| 49 | { |
| 50 | op(launch.get_stream(), src, dst, points, shape.x); |
| 51 | }); |
| 52 | } |
| 53 | else // zero and positive var shape means use ImageBatchVarShape |
| 54 | { |
| 55 | throw std::invalid_argument("ImageBatchVarShape not implemented for this operator"); |
| 56 | } |
| 57 | } |
| 58 | catch (const std::exception &err) |
| 59 | { |
| 60 | state.skip(err.what()); |
| 61 | } |
| 62 | |
| 63 | // clang-format on |
| 64 | |