#include <iostream>
+#include "util/environment.h"
#include "util/benchmark.h"
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:
int main(const int argc, char **argv)
{
- const Thread thread{};
if (!checkParams(argc, argv))
{
const auto filename = argv[1];
bool use_nnapi = false;
+ const auto thread_count = nnfw::util::get_env_int("THREAD", -1);
if (std::getenv("USE_NNAPI") != nullptr)
{
use_nnapi = true;
}
- std::cout << "Num threads: " << thread.value() << std::endl;
+ std::cout << "Num threads: " << thread_count << std::endl;
if (use_nnapi)
{
std::cout << "Use NNAPI" << std::endl;
std::cout << " Name: " << tensor_ptr->name << std::endl;
}
- interpreter->SetNumThreads(thread.value());
+ interpreter->SetNumThreads(thread_count);
std::shared_ptr<nnfw::support::tflite::Session> sess;