chromium/third_party/tflite/src/tensorflow/lite/core/interpreter.cc

/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include "tensorflow/lite/core/interpreter.h"

#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>

#include <functional>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "ruy/denormal.h"  // from @ruy
#include "tensorflow/compiler/mlir/lite/experimental/remat/metadata_util.h"
#include "tensorflow/lite/allocation.h"
#include "tensorflow/lite/core/api/error_reporter.h"
#include "tensorflow/lite/core/api/profiler.h"
#include "tensorflow/lite/core/c/c_api_types.h"
#include "tensorflow/lite/core/signature_runner.h"
#include "tensorflow/lite/core/subgraph.h"
#include "tensorflow/lite/external_cpu_backend_context.h"
#include "tensorflow/lite/interpreter_options.h"
#include "tensorflow/lite/logger.h"
#include "tensorflow/lite/minimal_logging.h"
#include "tensorflow/lite/profiling/root_profiler.h"
#include "tensorflow/lite/profiling/telemetry/c/telemetry_setting.h"
#include "tensorflow/lite/profiling/telemetry/telemetry.h"
#include "tensorflow/lite/stderr_reporter.h"
#include "tensorflow/lite/util.h"

// TODO(b/139446230): Move to portable platform header.
#if defined(__ANDROID__)
#define TFLITE_IS_MOBILE_PLATFORM
#endif  // defined(__ANDROID__)

#if defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_IPHONE_SIMULATOR
#define TFLITE_IS_MOBILE_PLATFORM
#elif TARGET_OS_IPHONE
#define TFLITE_IS_MOBILE_PLATFORM
#endif
#endif  // defined(__APPLE__)

// TODO(b/132087118): move static_assert to c_api_internal when compiled with
// C++.
static_assert;

namespace tflite {

namespace {

// Gets the current TfLiteQuantization from the legacy TfLiteQuantizationParams.
TfLiteQuantization GetQuantizationFromLegacy(
    const TfLiteQuantizationParams& legacy_quantization) {}

// TODO(b/153131797): We have put 'delegate_status' to 0 in the following macro
// temporarily because delegate-specific error codes are either not retrievable
// at the moment, which we will add later.
#define TF_LITE_ENSURE_STATUS_WITH_SCOPED_INSTRUMENTATION(runtime_event, a)

}  // namespace

Interpreter::Interpreter(ErrorReporter* error_reporter)
    :{}

Interpreter::~Interpreter() {}

void Interpreter::SetExternalContext(TfLiteExternalContextType type,
                                     TfLiteExternalContext* ctx) {}

TfLiteStatus Interpreter::SetInputs(std::vector<int> inputs) {}

TfLiteStatus Interpreter::SetOutputs(std::vector<int> outputs) {}

TfLiteStatus Interpreter::SetVariables(std::vector<int> variables) {}

TfLiteStatus Interpreter::AllocateTensors() {}

void Interpreter::AddSubgraphs(int subgraphs_to_add,
                               int* first_new_subgraph_index) {}

TfLiteStatus Interpreter::AddNodeWithParameters(
    const std::vector<int>& inputs, const std::vector<int>& outputs,
    const char* init_data, size_t init_data_size, void* builtin_data,
    const TfLiteRegistration* registration, int* node_index) {}

TfLiteStatus Interpreter::ResizeInputTensor(int tensor_index,
                                            const std::vector<int>& dims) {}

TfLiteStatus Interpreter::ResizeInputTensorStrict(
    int tensor_index, const std::vector<int>& dims) {}

TfLiteStatus Interpreter::Invoke() {}

TfLiteStatus Interpreter::AddTensors(int tensors_to_add,
                                     int* first_new_tensor_index) {}

TfLiteStatus Interpreter::SetTensorParametersReadOnly(
    int tensor_index, TfLiteType type, const char* name,
    const std::vector<int>& dims, TfLiteQuantization quantization,
    const char* buffer, size_t bytes, const Allocation* allocation) {}

TfLiteStatus Interpreter::SetTensorParametersReadWrite(
    int tensor_index, TfLiteType type, const char* name,
    const std::vector<int>& dims, TfLiteQuantization quantization,
    bool is_variable) {}

TfLiteStatus Interpreter::SetTensorParametersReadOnly(
    int tensor_index, TfLiteType type, const char* name, size_t rank,
    const int* dims, TfLiteQuantizationParams quantization, const char* buffer,
    size_t bytes, const Allocation* allocation) {}

TfLiteStatus Interpreter::SetTensorParametersReadWrite(
    int tensor_index, TfLiteType type, const char* name, size_t rank,
    const int* dims, TfLiteQuantizationParams quantization, bool is_variable,
    size_t rank_dims_signature, const int* dims_signature) {}

TfLiteStatus Interpreter::SetExecutionPlan(const std::vector<int>& new_plan) {}

TfLiteStatus Interpreter::SetNumThreads(int num_threads) {}

TfLiteStatus Interpreter::ApplyLazyDelegateProviders() {}

TfLiteStatus Interpreter::ModifyGraphWithDelegateImpl(
    TfLiteDelegate* delegate) {}

TfLiteStatus Interpreter::RemoveAllDelegates() {}

TfLiteStatus Interpreter::SetMetadata(
    const std::map<std::string, std::string>& metadata) {}

TfLiteStatus Interpreter::SetTelemetrySettings(
    std::unique_ptr<TfLiteTelemetryInterpreterSettings> settings) {}

TfLiteStatus Interpreter::ReportTelemetrySettings(const char* setting_name) {}

bool Interpreter::IsFullyDelegated() const {}

void Interpreter::SetProfilerImpl(std::unique_ptr<Profiler> profiler) {}

void Interpreter::SetSubgraphProfiler() {}

TfLiteStatus Interpreter::ApplyOptionsImpl(InterpreterOptions* options) {}

TfLiteStatus Interpreter::EnableCancellation() {}

TfLiteStatus Interpreter::Cancel() {}

void Interpreter::AddProfiler(std::unique_ptr<Profiler> profiler) {}

impl::SignatureRunner* Interpreter::GetSignatureRunner(
    const char* signature_key) {}

}  // namespace tflite