#include "tensorflow/lite/kernels/cpu_backend_context.h"
#include <memory>
#ifdef TFLITE_KERNEL_USE_XNNPACK
#include "pthreadpool.h"
#endif
#ifdef TFLITE_HAVE_CPUINFO
#include "include/cpuinfo.h"
#endif
#include "public/gemmlowp.h"
#include "ruy/context.h"
#include "ruy/path.h"
#include "tensorflow/lite/core/c/common.h"
#include "tensorflow/lite/core/macros.h"
#include "tensorflow/lite/external_cpu_backend_context.h"
#include "tensorflow/lite/kernels/internal/compatibility.h"
#include "tensorflow/lite/kernels/op_macros.h"
namespace {
const int kDefaultNumThreadpoolThreads = …;
}
namespace tflite {
#if TFLITE_HAS_ATTRIBUTE_WEAK && !defined(__APPLE__)
extern TFLITE_ATTRIBUTE_WEAK bool UseGemmlowpOnX86();
#endif
#if defined(TFLITE_HAVE_CPUINFO)
CpuBackendContext::CpuInfo::~CpuInfo() { … }
bool CpuBackendContext::CpuInfo::EnsureInitialized() { … }
CpuBackendContext::CpuInfo::InitStatus
CpuBackendContext::CpuInfo::Initialize() { … }
bool CpuBackendContext::CpuInfo::Avx2Fma() { … }
bool CpuBackendContext::CpuInfo::Avx() { … }
bool CpuBackendContext::CpuInfo::Avx512() { … }
#else
CpuBackendContext::CpuInfo::~CpuInfo() {}
bool CpuBackendContext::CpuInfo::EnsureInitialized() {
if (init_status_ == InitStatus::kNotYetAttempted) {
init_status_ = InitStatus::kInitialized;
}
TFLITE_DCHECK_EQ(init_status_, InitStatus::kInitialized);
return true;
}
bool CpuBackendContext::CpuInfo::Avx2Fma() { return false; }
bool CpuBackendContext::CpuInfo::Avx() { return false; }
bool CpuBackendContext::CpuInfo::Avx512() { return false; }
#endif
CpuBackendContext* CpuBackendContext::GetFromContext(TfLiteContext* context) { … }
CpuBackendContext::CpuBackendContext()
: … { … }
CpuBackendContext::~CpuBackendContext() { … }
void CpuBackendContext::SetMaxNumThreads(int max_num_threads) { … }
void CpuBackendContext::SetUseCaching(bool flag) { … }
#ifdef TFLITE_KERNEL_USE_XNNPACK
pthreadpool_t CpuBackendContext::get_xnnpack_threadpool() { … }
#endif
bool CpuBackendContext::PreferGemmlowpOnX86() { … }
bool CpuBackendContext::RuyHasAvxOrAbove() { … }
}