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

Function findCoeffOfVariance

samples/common/sampleReporting.cpp:82–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80//!
81template <typename T>
82float findCoeffOfVariance(std::vector<InferenceTime> const& timings, T const& toFloat, float mean)
83{
84 if (timings.empty())
85 {
86 return 0;
87 }
88
89 if (mean == 0.F)
90 {
91 return std::numeric_limits<float>::infinity();
92 }
93
94 auto const metricAccumulator = [toFloat, mean](float acc, InferenceTime const& a) {
95 float const diff = toFloat(a) - mean;
96 return acc + diff * diff;
97 };
98 float const variance = std::accumulate(timings.begin(), timings.end(), 0.F, metricAccumulator) / timings.size();
99
100 return std::sqrt(variance) / mean * 100.F;
101}
102
103inline InferenceTime traceToTiming(const InferenceTrace& a)
104{

Callers 1

getPerformanceResultFunction · 0.85

Calls 4

toFloatFunction · 0.85
sqrtFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected