MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / ChannelReorder

Function ChannelReorder

bench/BenchChannelReorder.cpp:25–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

whatMethod · 0.80
pushBackMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected