From 2354d3e8a681b282e1fc1b098ecacca3c58e38c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85strand?= Date: Sat, 24 Oct 2020 20:17:10 +0200 Subject: Add APIs for PMU configuration in library Change-Id: I7694ab9dd5ff20c29feb0506bcf36a1cf4983243 --- driver_library/include/ethosu.hpp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'driver_library/include/ethosu.hpp') diff --git a/driver_library/include/ethosu.hpp b/driver_library/include/ethosu.hpp index 12192bf..70d0701 100644 --- a/driver_library/include/ethosu.hpp +++ b/driver_library/include/ethosu.hpp @@ -96,19 +96,46 @@ public: network(network) { std::copy(ifmBegin, ifmEnd, std::back_inserter(ifmBuffers)); std::copy(ofmBegin, ofmEnd, std::back_inserter(ofmBuffers)); - create(); + std::vector counterConfigs = initializeCounterConfig(); + + create(counterConfigs, false); } + template + Inference(std::shared_ptr &network, + const T &ifmBegin, + const T &ifmEnd, + const T &ofmBegin, + const T &ofmEnd, + const U &counters, + bool enableCycleCounter) : + network(network) { + std::copy(ifmBegin, ifmEnd, std::back_inserter(ifmBuffers)); + std::copy(ofmBegin, ofmEnd, std::back_inserter(ofmBuffers)); + std::vector counterConfigs = initializeCounterConfig(); + + if (counters.size() > counterConfigs.size()) + throw EthosU::Exception("PMU Counters argument to large."); + + std::copy(counters.begin(), counters.end(), counterConfigs.begin()); + create(counterConfigs, enableCycleCounter); + } + virtual ~Inference(); - void wait(int timeoutSec = -1); + int wait(int timeoutSec = -1); + const std::vector getPmuCounters(); + uint64_t getCycleCounter(); bool failed(); int getFd(); std::shared_ptr getNetwork(); std::vector> &getIfmBuffers(); std::vector> &getOfmBuffers(); + static uint32_t getMaxPmuEventCounters(); + private: - void create(); + void create(std::vector &counterConfigs, bool enableCycleCounter); + std::vector initializeCounterConfig(); int fd; std::shared_ptr network; -- cgit v1.2.1