| 71 | } // namespace |
| 72 | |
| 73 | Interpreter::Interpreter(ErrorReporter* error_reporter) |
| 74 | : error_reporter_(error_reporter ? error_reporter |
| 75 | : DefaultErrorReporter()) { |
| 76 | // TODO(b/128420794): Include the TFLite runtime version in the log. |
| 77 | // Prod logging is useful for mobile platforms where scraping console logs is |
| 78 | // critical for debugging. |
| 79 | #if defined(TFLITE_IS_MOBILE_PLATFORM) |
| 80 | TFLITE_LOG_PROD_ONCE(TFLITE_LOG_INFO, "Initialized TensorFlow Lite runtime."); |
| 81 | #else |
| 82 | TFLITE_LOG_ONCE(TFLITE_LOG_INFO, "Initialized TensorFlow Lite runtime."); |
| 83 | #endif |
| 84 | |
| 85 | // There's always at least 1 subgraph which is the primary subgraph. |
| 86 | AddSubgraphs(1); |
| 87 | context_ = primary_subgraph().context(); |
| 88 | |
| 89 | // Reserve some space for the tensors to avoid excessive resizing. |
| 90 | for (int i = 0; i < kTfLiteMaxExternalContexts; ++i) { |
| 91 | external_contexts_[i] = nullptr; |
| 92 | } |
| 93 | |
| 94 | // This operation is cheap because we allocate the CPU context resources (i.e. |
| 95 | // threads) lazily. |
| 96 | own_external_cpu_backend_context_.reset(new ExternalCpuBackendContext()); |
| 97 | external_contexts_[kTfLiteCpuBackendContext] = |
| 98 | own_external_cpu_backend_context_.get(); |
| 99 | |
| 100 | UseNNAPI(false); |
| 101 | } |
| 102 | |
| 103 | Interpreter::~Interpreter() {} |
| 104 |
no test coverage detected