From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Thu, 31 May 2018 06:22:47 +0000 (+0900) Subject: [tfliite_benchmark] Allow Thread configuration (#1473) X-Git-Tag: 0.2~757 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0527653391f96a4814efdf7f265ed01b81d6ee57;p=platform%2Fcore%2Fml%2Fnnfw.git [tfliite_benchmark] Allow Thread configuration (#1473) This commit revises tflite_benchmark to read thread configuration from THREAD environment variable. This commit also changes the default configuration as -1 to enable multi-threading. Signed-off-by: Jonghyun Park --- diff --git a/tools/tflite_benchmark/src/tflite_benchmark.cc b/tools/tflite_benchmark/src/tflite_benchmark.cc index 91e22e7..4f1f32d 100644 --- a/tools/tflite_benchmark/src/tflite_benchmark.cc +++ b/tools/tflite_benchmark/src/tflite_benchmark.cc @@ -33,6 +33,27 @@ using namespace tflite; using namespace tflite::ops::builtin; +class Thread +{ +public: + // Use threads as much as possible + Thread() : _value(-1) + { + auto env = std::getenv("THREAD"); + + if (env) + { + _value = atoi(env); + } + } + +public: + int32_t value(void) const { return _value; } + +private: + int32_t _value; +}; + class Count { public: @@ -55,6 +76,8 @@ private: int main(const int argc, char **argv) { + const Thread thread{}; + const auto filename = argv[1]; bool use_nnapi = false; @@ -76,7 +99,7 @@ int main(const int argc, char **argv) TFLITE_ENSURE(builder(&interpreter)); - interpreter->SetNumThreads(1); + interpreter->SetNumThreads(thread.value()); std::shared_ptr sess;