mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-08 10:00:29 +08:00
[Benchmark] Add precision evaluation api from benchmark (#1310)
* [Benchmark] Init benchmark precision api * [Benchmark] Init benchmark precision api * [Benchmark] Add benchmark precision api * [Benchmark] Calculate the statis of diff * [Benchmark] Calculate the statis of diff * [Benchmark] Calculate the statis of diff * [Benchmark] Calculate the statis of diff * [Benchmark] Calculate the statis of diff * [Benchmark] Add SplitDataLine utils * [Benchmark] Add LexSortByXY func * [Benchmark] Add LexSortByXY func * [Benchmark] Add LexSortDetectionResultByXY func * [Benchmark] Add LexSortDetectionResultByXY func * [Benchmark] Add tensor diff presicion test * [Benchmark] fixed conflicts * [Benchmark] fixed calc tensor diff * fixed build bugs * fixed ci bugs when WITH_TESTING=ON
This commit is contained in:
@@ -214,4 +214,24 @@ std::string Str(const std::vector<T>& shape) {
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void CalculateStatisInfo(const void* src_ptr, int size, double* mean,
|
||||
double* max, double* min) {
|
||||
const T* ptr = static_cast<const T*>(src_ptr);
|
||||
*mean = static_cast<double>(0);
|
||||
*max = static_cast<double>(-99999999);
|
||||
*min = static_cast<double>(99999999);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
if (*(ptr + i) > *max) {
|
||||
*max = *(ptr + i);
|
||||
}
|
||||
if (*(ptr + i) < *min) {
|
||||
*min = *(ptr + i);
|
||||
}
|
||||
*mean += *(ptr + i);
|
||||
}
|
||||
*mean = *mean / size;
|
||||
}
|
||||
|
||||
|
||||
} // namespace fastdeploy
|
||||
|
Reference in New Issue
Block a user