| 103 | Interpreter::~Interpreter() {} |
| 104 | |
| 105 | void Interpreter::SetExternalContext(TfLiteExternalContextType type, |
| 106 | TfLiteExternalContext* ctx) { |
| 107 | if (ctx == own_external_cpu_backend_context_.get()) { |
| 108 | error_reporter_->Report( |
| 109 | "WARNING: The passed external context is identical to the internally " |
| 110 | "owned one."); |
| 111 | return; |
| 112 | } |
| 113 | |
| 114 | // We have an internally owned external context of kTfLiteCpuBackendContext. |
| 115 | // If it's overwritten here, we will release the resource of the internally |
| 116 | // owned external context. |
| 117 | // Note: the 'max thread count' info associated with the overwritten context |
| 118 | // will be lost here, and such info is now detemined by the new context, thus |
| 119 | // affecting how much parallelism a TFLite op would have. |
| 120 | if (kTfLiteCpuBackendContext == type && |
| 121 | external_contexts_[kTfLiteCpuBackendContext] == |
| 122 | own_external_cpu_backend_context_.get()) { |
| 123 | own_external_cpu_backend_context_.reset(); |
| 124 | } |
| 125 | |
| 126 | // This essentially changes the "external_contexts_[type]". |
| 127 | primary_subgraph().SetExternalContext(type, ctx); |
| 128 | } |
| 129 | |
| 130 | TfLiteStatus Interpreter::SetInputs(std::vector<int> inputs) { |
| 131 | return primary_subgraph().SetInputs(inputs); |