context_.tensors_size = 0;
context_.eigen_context = nullptr;
context_.gemm_context = nullptr;
- context_.recommended_num_threads = 0;
+ context_.recommended_num_threads = -1;
// Invalid to call these these except from TfLiteDelegate
SetForbiddenContextFunction(&context_.GetNodeAndRegistration);
void IncrementUsageCounter(TfLiteContext* context) {
auto* ptr = reinterpret_cast<RefCountedEigenContext*>(context->eigen_context);
if (ptr == nullptr) {
- Eigen::setNbThreads(context->recommended_num_threads);
-
+ if (context->recommended_num_threads != -1) {
+ Eigen::setNbThreads(context->recommended_num_threads);
+ }
ptr = new RefCountedEigenContext;
ptr->num_references = 0;
context->eigen_context = ptr;
if (ptr == nullptr) {
ptr = new RefCountedGemmContext;
ptr->gemm_context_ = new gemmlowp::GemmContext();
- ptr->gemm_context_->set_max_num_threads(context->recommended_num_threads);
+ if (context->recommended_num_threads != -1) {
+ ptr->gemm_context_->set_max_num_threads(context->recommended_num_threads);
+ }
ptr->num_references_ = 0;
context->gemm_context = ptr;
}