Refactor tflite_with_ruy setting to rely on a base cc_library define

rather than a header.

PiperOrigin-RevId: 249763564
This commit is contained in:
Jared Duke 2019-05-23 19:58:11 -07:00 committed by TensorFlower Gardener
parent 8bae2b2dad
commit 067387ebdd
12 changed files with 20 additions and 57 deletions

View File

@ -109,21 +109,30 @@ cc_test(
)
cc_library(
name = "tflite_with_ruy",
hdrs = [
"tflite_with_ruy.h",
],
defines = select({
":tflite_with_ruy_explicit_true": [
"TFLITE_WITH_RUY_EXPLICIT_TRUE",
],
":tflite_with_ruy_explicit_false": [
"TFLITE_WITH_RUY_EXPLICIT_FALSE",
],
name = "tflite_with_ruy_enabled",
defines = ["TFLITE_WITH_RUY"],
visibility = ["//visibility:private"],
)
cc_library(
name = "tflite_with_ruy_default",
visibility = ["//visibility:private"],
deps = select({
# TODO(b/133306271): Enable for ARM64 after validating performance.
"//tensorflow:android_arm64": [],
"//conditions:default": [],
}),
)
cc_library(
name = "tflite_with_ruy",
deps = select({
":tflite_with_ruy_explicit_true": [":tflite_with_ruy_enabled"],
":tflite_with_ruy_explicit_false": [],
"//conditions:default": [":tflite_with_ruy_default"],
}),
)
cc_library(
name = "cpu_backend_context",
srcs = [
@ -400,7 +409,6 @@ cc_library(
":lstm_eval",
":op_macros",
":padding",
":tflite_with_ruy",
"//tensorflow/lite:framework",
"//tensorflow/lite:string_util",
"//tensorflow/lite/c:c_api_internal",
@ -656,7 +664,6 @@ cc_test(
deps = [
":builtin_ops",
":test_main",
":tflite_with_ruy",
"//tensorflow/lite:framework",
"//tensorflow/lite/kernels:test_util",
"@com_google_absl//absl/memory",

View File

@ -26,7 +26,6 @@ limitations under the License.
#include "tensorflow/lite/c/c_api_internal.h"
#include "tensorflow/lite/kernels/cpu_backend_support.h"
#include "tensorflow/lite/kernels/eigen_support.h"
#include "tensorflow/lite/kernels/tflite_with_ruy.h"
// b/131835803 forces us to include multithreaded_conv.h before optimized_ops.h
#ifndef TFLITE_WITH_RUY
#include "tensorflow/lite/kernels/internal/optimized/multithreaded_conv.h"

View File

@ -19,7 +19,6 @@ limitations under the License.
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/kernels/test_util.h"
#include "tensorflow/lite/kernels/tflite_with_ruy.h"
#include "tensorflow/lite/model.h"
namespace tflite {

View File

@ -22,7 +22,6 @@ limitations under the License.
#include "tensorflow/lite/kernels/cpu_backend_gemm_custom_gemv.h"
#include "tensorflow/lite/kernels/cpu_backend_gemm_params.h"
#include "tensorflow/lite/kernels/cpu_backend_gemm_ruy.h"
#include "tensorflow/lite/kernels/tflite_with_ruy.h"
#ifndef TFLITE_WITH_RUY
#include "tensorflow/lite/kernels/cpu_backend_gemm_eigen.h"

View File

@ -39,7 +39,6 @@ limitations under the License.
#include "tensorflow/lite/kernels/cpu_backend_gemm_params.h"
#include "tensorflow/lite/kernels/cpu_backend_threadpool.h"
#include "tensorflow/lite/kernels/internal/common.h"
#include "tensorflow/lite/kernels/tflite_with_ruy.h"
namespace tflite {
namespace cpu_backend_gemm {

View File

@ -13,8 +13,6 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/lite/kernels/tflite_with_ruy.h"
#ifndef TFLITE_WITH_RUY
#include "tensorflow/lite/kernels/cpu_backend_gemm_eigen.h"

View File

@ -16,8 +16,6 @@ limitations under the License.
#ifndef TENSORFLOW_LITE_KERNELS_CPU_BACKEND_GEMM_EIGEN_H_
#define TENSORFLOW_LITE_KERNELS_CPU_BACKEND_GEMM_EIGEN_H_
#include "tensorflow/lite/kernels/tflite_with_ruy.h"
#ifndef TFLITE_WITH_RUY
#include "tensorflow/lite/kernels/cpu_backend_context.h"

View File

@ -16,8 +16,6 @@ limitations under the License.
#ifndef TENSORFLOW_LITE_KERNELS_CPU_BACKEND_GEMM_GEMMLOWP_H_
#define TENSORFLOW_LITE_KERNELS_CPU_BACKEND_GEMM_GEMMLOWP_H_
#include "tensorflow/lite/kernels/tflite_with_ruy.h"
#ifndef TFLITE_WITH_RUY
#include <cstdint>

View File

@ -18,7 +18,6 @@ limitations under the License.
#include "tensorflow/lite/kernels/cpu_backend_context.h"
#include "tensorflow/lite/kernels/internal/compatibility.h"
#include "tensorflow/lite/kernels/tflite_with_ruy.h"
#ifdef TFLITE_WITH_RUY
#include "tensorflow/lite/experimental/ruy/context.h"

View File

@ -223,7 +223,6 @@ cc_library(
"@gemmlowp//:profiler",
"//tensorflow/lite/c:c_api_internal",
"//tensorflow/lite/kernels:cpu_backend_context",
"//tensorflow/lite/kernels:tflite_with_ruy",
"//tensorflow/lite/kernels:cpu_backend_threadpool",
"//tensorflow/lite/kernels:cpu_backend_gemm",
] + select({

View File

@ -19,7 +19,6 @@ limitations under the License.
#include "tensorflow/lite/kernels/cpu_backend_threadpool.h"
#include "tensorflow/lite/kernels/internal/optimized/depthwiseconv_float.h"
#include "tensorflow/lite/kernels/internal/optimized/depthwiseconv_uint8.h"
#include "tensorflow/lite/kernels/tflite_with_ruy.h"
namespace tflite {
namespace optimized_ops {

View File

@ -1,31 +0,0 @@
/* Copyright 2019 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.
==============================================================================*/
#ifndef TENSORFLOW_LITE_KERNELS_TFLITE_WITH_RUY_H_
#define TENSORFLOW_LITE_KERNELS_TFLITE_WITH_RUY_H_
#if (defined TFLITE_WITH_RUY_EXPLICIT_TRUE) && \
(defined TFLITE_WITH_RUY_EXPLICIT_FALSE)
#error TFLITE_WITH_RUY_EXPLICIT_TRUE and TFLITE_WITH_RUY_EXPLICIT_FALSE should not be simultaneously defined.
#endif
#if defined TFLITE_WITH_RUY_EXPLICIT_TRUE
#define TFLITE_WITH_RUY
#elif defined TFLITE_WITH_RUY_EXPLICIT_FALSE
// Leave TFLITE_WITH_RUY undefined
#else
// For now leave TFLITE_WITH_RUY undefined, could change defaults here later.
#endif
#endif // TENSORFLOW_LITE_KERNELS_TFLITE_WITH_RUY_H_