chromium/third_party/tflite/src/tensorflow/lite/kernels/eigen_support.cc

/* Copyright 2018 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/kernels/eigen_support.h"

#include <functional>
#include <memory>
#include <utility>

#include "tensorflow/lite/core/c/common.h"
#include "tensorflow/lite/kernels/internal/optimized/eigen_spatial_convolutions.h"
#include "tensorflow/lite/kernels/op_macros.h"

#ifndef EIGEN_DONT_ALIGN
#include "tensorflow/lite/util.h"
#endif  // EIGEN_DONT_ALIGN

namespace tflite {
namespace eigen_support {
namespace {

// For legacy reasons, we use 4 threads by default unless the thread count is
// explicitly specified by the context.
const int kDefaultNumThreadpoolThreads =;

bool IsValidNumThreads(int num_threads) {}
int GetNumThreads(int num_threads) {}

#ifndef EIGEN_DONT_ALIGN
// Eigen may require buffers to be aligned to 16, 32 or 64 bytes depending on
// hardware architecture and build configurations. If the static assertion
// fails, try to increase `kDefaultTensorAlignment` in `util.h` to 32 or 64.
static_assert;
#endif  // EIGEN_DONT_ALIGN

// Helper routine for updating the global Eigen thread count used for OpenMP.
void SetEigenNbThreads(int threads) {}

// We have a single global threadpool for all convolution operations. This means
// that inferences started from different threads may block each other, but
// since the underlying resource of CPU cores should be consumed by the
// operations anyway, it shouldn't affect overall performance. Note that we
// also avoid ThreadPool creation if the target thread count is 1, avoiding
// unnecessary overhead, and more closely mimicking Gemmlowp threadpool
// behavior.
class EigenThreadPoolWrapper : public Eigen::ThreadPoolInterface {};

// Utility class for lazily creating an Eigen thread pool/device only when used.
class LazyEigenThreadPoolHolder {};

struct RefCountedEigenContext : public TfLiteExternalContext {};

RefCountedEigenContext* GetEigenContext(TfLiteContext* context) {}

TfLiteStatus Refresh(TfLiteContext* context) {}

}  // namespace

void IncrementUsageCounter(TfLiteContext* context) {}

void DecrementUsageCounter(TfLiteContext* context) {}

const Eigen::ThreadPoolDevice* GetThreadPoolDevice(TfLiteContext* context) {}

}  // namespace eigen_support
}  // namespace tflite