list(APPEND SOURCES "src/tflite_benchmark.cc")
-nnfw_find_package(Boost REQUIRED)
-
add_executable(tflite_benchmark ${SOURCES})
target_link_libraries(tflite_benchmark nnfw_lib_tflite tensorflow-lite ${LIB_PTHREAD} dl nnfw_lib_misc)
-target_include_directories(tflite_benchmark PRIVATE ${Boost_INCLUDE_DIRS})
-
install(TARGETS tflite_benchmark DESTINATION bin)
#include "tflite/Diff.h"
#include "misc/tensor/IndexIterator.h"
-#include <boost/accumulators/accumulators.hpp>
-#include <boost/accumulators/statistics/stats.hpp>
-#include <boost/accumulators/statistics/min.hpp>
-#include <boost/accumulators/statistics/max.hpp>
-#include <boost/accumulators/statistics/mean.hpp>
-
#include <chrono>
#include <iostream>
#include <thread>
return true;
}
+template <typename T> class Accumulator
+{
+public:
+ Accumulator() = default;
+
+ void operator()(T val)
+ {
+ ++_num;
+ _sum += val;
+ _min = std::min(_min, val);
+ _max = std::max(_max, val);
+ }
+
+ T mean() const { return _sum / static_cast<T>(_num); }
+ T min() const { return _min; }
+ T max() const { return _max; }
+
+private:
+ uint32_t _num = 0u;
+ T _sum = 0.0;
+ T _min = std::numeric_limits<T>::max();
+ T _max = std::numeric_limits<T>::lowest();
+};
+
int main(const int argc, char **argv)
{
//
const auto cnt = nnfw::misc::EnvVar("COUNT").asInt(1);
- using namespace boost::accumulators;
-
- accumulator_set<double, stats<tag::mean, tag::min, tag::max>> acc;
+ Accumulator<double> acc;
for (int n = 0; n < cnt; ++n)
{
}
std::cout << "--------" << std::endl;
- std::cout << "Min: " << min(acc) << "ms" << std::endl;
- std::cout << "Max: " << max(acc) << "ms" << std::endl;
- std::cout << "Mean: " << mean(acc) << "ms" << std::endl;
+ std::cout << "Min: " << acc.min() << "ms" << std::endl;
+ std::cout << "Max: " << acc.max() << "ms" << std::endl;
+ std::cout << "Mean: " << acc.mean() << "ms" << std::endl;
return 0;
}