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

Function PairwiseMatcher

bench/BenchPairwiseMatcher.cpp:25–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23
24template<typename ST>
25inline void PairwiseMatcher(nvbench::state &state, nvbench::type_list<ST>)
26try
27{
28 long3 shape = benchutils::GetShape<3>(state.get_string("shape"));
29
30 int matchesPerPoint = static_cast<int>(state.get_int64("matchesPerPoint"));
31
32 bool crossCheck = state.get_string("crossCheck") == "T";
33 bool readNumSets = state.get_string("readNumSets") == "T";
34 bool writeDistances = state.get_string("writeDistances") == "T";
35
36 NVCVNormType normType = benchutils::GetNormType(state.get_string("normType"));
37
38 NVCVPairwiseMatcherType algoChoice;
39
40 if (state.get_string("algoChoice") == "BRUTE_FORCE")
41 {
42 algoChoice = NVCV_BRUTE_FORCE;
43 }
44 else
45 {
46 throw std::invalid_argument("Unexpected algorithm choice = " + state.get_string("algoChoice"));
47 }
48
49 int maxMatches = shape.y * matchesPerPoint;
50
51 cvcuda::PairwiseMatcher op(algoChoice);
52
53 state.add_global_memory_reads((crossCheck ? 3 : 2) * shape.x * shape.y * shape.z * sizeof(ST));
54 state.add_global_memory_writes(shape.x * (sizeof(int) + maxMatches * (2 * sizeof(int) + sizeof(float))));
55
56 // clang-format off
57
58 nvcv::Tensor set1({{shape.x, shape.y, shape.z}, "NMD"}, benchutils::GetDataType<ST>());
59 nvcv::Tensor set2({{shape.x, shape.y, shape.z}, "NMD"}, benchutils::GetDataType<ST>());
60
61 nvcv::Tensor matches({{shape.x, maxMatches, 2}, "NMD"}, nvcv::TYPE_S32);
62
63 nvcv::Tensor numMatches({{shape.x}, "N"}, nvcv::TYPE_S32);
64
65 nvcv::Tensor numSet1, numSet2, distances;
66
67 if (readNumSets)
68 {
69 numSet1 = nvcv::Tensor({{shape.x}, "N"}, nvcv::TYPE_S32);
70 numSet2 = nvcv::Tensor({{shape.x}, "N"}, nvcv::TYPE_S32);
71
72 benchutils::FillTensor<int>(numSet1, [&shape](auto &){ return shape.y; });
73 benchutils::FillTensor<int>(numSet2, [&shape](auto &){ return shape.y; });
74 }
75 if (writeDistances)
76 {
77 distances = nvcv::Tensor({{shape.x, maxMatches}, "NM"}, nvcv::TYPE_F32);
78 }
79
80 benchutils::FillTensor<ST>(set1, benchutils::RandomValues<ST>());
81 benchutils::FillTensor<ST>(set2, benchutils::RandomValues<ST>());
82

Callers

nothing calls this directly

Calls 3

GetNormTypeFunction · 0.85
whatMethod · 0.80
TensorClass · 0.50

Tested by

no test coverage detected