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

Function ConvertTo

bench/BenchConvertTo.cpp:25–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23
24template<typename T>
25inline void ConvertTo(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 double alpha = 0.123;
32 double beta = 0.456;
33
34 state.add_global_memory_reads(shape.x * shape.y * shape.z * sizeof(T));
35 state.add_global_memory_writes(shape.x * shape.y * shape.z * sizeof(T));
36
37 cvcuda::ConvertTo op;
38
39 // clang-format off
40
41 if (varShape < 0) // negative var shape means use Tensor
42 {
43 nvcv::Tensor src({{shape.x, shape.y, shape.z, 1}, "NHWC"}, benchutils::GetDataType<T>());
44 nvcv::Tensor dst({{shape.x, shape.y, shape.z, 1}, "NHWC"}, benchutils::GetDataType<T>());
45
46 benchutils::FillTensor<T>(src, benchutils::RandomValues<T>());
47
48 state.exec(nvbench::exec_tag::sync, [&op, &src, &dst, &alpha, &beta](nvbench::launch &launch)
49 {
50 op(launch.get_stream(), src, dst, alpha, beta);
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}
58catch (const std::exception &err)
59{
60 state.skip(err.what());
61}
62
63// clang-format on
64

Callers

nothing calls this directly

Calls 1

whatMethod · 0.80

Tested by

no test coverage detected