MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / findPercentile

Function findPercentile

samples/common/sampleReporting.cpp:43–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41//!
42template <typename T>
43float findPercentile(float percentile, std::vector<InferenceTime> const& timings, T const& toFloat)
44{
45 int32_t const all = static_cast<int32_t>(timings.size());
46 int32_t const exclude = static_cast<int32_t>((1 - percentile / 100) * all);
47 if (timings.empty())
48 {
49 return std::numeric_limits<float>::infinity();
50 }
51 if (percentile < 0.F || percentile > 100.F)
52 {
53 throw std::runtime_error("percentile is not in [0, 100]!");
54 }
55 return toFloat(timings[std::max(all - 1 - exclude, 0)]);
56}
57
58//!
59//! \brief Find median in a sorted sequence of timings

Callers 1

getPerformanceResultFunction · 0.85

Calls 4

toFloatFunction · 0.85
maxFunction · 0.85
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected