[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:
DefTruth
2023-02-16 17:16:14 +08:00
committed by GitHub
parent bdfb7b0008
commit ee85a3cade
14 changed files with 575 additions and 29 deletions

View File

@@ -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