int InferenceTFLite::SetPrivateData(void *data)
{
- // Nothing to do yet.
+ if (!data) {
+ LOGE("private data is nullptr. It should not be nullptr.");
+ return INFERENCE_ENGINE_ERROR_INVALID_PARAMETER;
+ }
+
+ auto private_data = static_cast<inference_engine_private_data *>(data);
+
+ // Just skip if it's not number of threads.
+ if (private_data->data_type != INFERENCE_ENGINE_PRIVATE_TYPE_NUM_OF_THREADS)
+ return INFERENCE_ENGINE_ERROR_NONE;
+
+ _number_of_threads = private_data->int_value;
return INFERENCE_ENGINE_ERROR_NONE;
}
}
}
- const char *envNumThreads = std::getenv("TFLITE_NUM_THREADS");
- int numThreads = envNumThreads ? std::atoi(envNumThreads) : MV_INFERENCE_TFLITE_MAX_THREAD_NUM;
+ int numThreads = MV_INFERENCE_TFLITE_MAX_THREAD_NUM;
+
+ if (_number_of_threads > 0) {
+ numThreads = _number_of_threads;
+ } else {
+ const char *envNumThreads = std::getenv("TFLITE_NUM_THREADS");
+ numThreads = envNumThreads ? std::atoi(envNumThreads) : MV_INFERENCE_TFLITE_MAX_THREAD_NUM;
+ }
LOGD("numThreads : [%d]", numThreads);