| 143 | } // namespace |
| 144 | |
| 145 | void IncrementUsageCounter(TfLiteContext* context) { |
| 146 | auto* ptr = GetEigenContext(context); |
| 147 | if (ptr == nullptr) { |
| 148 | if (context->recommended_num_threads != -1) { |
| 149 | SetEigenNbThreads(context->recommended_num_threads); |
| 150 | } |
| 151 | ptr = new RefCountedEigenContext; |
| 152 | ptr->type = kTfLiteEigenContext; |
| 153 | ptr->Refresh = Refresh; |
| 154 | ptr->thread_pool_holder.reset( |
| 155 | new LazyEigenThreadPoolHolder(context->recommended_num_threads)); |
| 156 | ptr->num_references = 0; |
| 157 | context->SetExternalContext(context, kTfLiteEigenContext, ptr); |
| 158 | } |
| 159 | ptr->num_references++; |
| 160 | } |
| 161 | |
| 162 | void DecrementUsageCounter(TfLiteContext* context) { |
| 163 | auto* ptr = GetEigenContext(context); |