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 <jh1302.park@samsung.com>
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{};
+
const auto filename = argv[1];
bool use_nnapi = false;
TFLITE_ENSURE(builder(&interpreter));
- interpreter->SetNumThreads(1);
+ interpreter->SetNumThreads(thread.value());
std::shared_ptr<nnfw::support::tflite::Session> sess;