From 067387ebddc34873fd5f6529b22024b3b339eb9e Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Thu, 23 May 2019 19:58:11 -0700 Subject: [PATCH] Refactor tflite_with_ruy setting to rely on a base cc_library define rather than a header. PiperOrigin-RevId: 249763564 --- tensorflow/lite/kernels/BUILD | 33 +++++++++++-------- tensorflow/lite/kernels/conv.cc | 1 - tensorflow/lite/kernels/conv_test.cc | 1 - tensorflow/lite/kernels/cpu_backend_gemm.h | 1 - .../kernels/cpu_backend_gemm_custom_gemv.h | 1 - .../lite/kernels/cpu_backend_gemm_eigen.cc | 2 -- .../lite/kernels/cpu_backend_gemm_eigen.h | 2 -- .../lite/kernels/cpu_backend_gemm_gemmlowp.h | 2 -- .../lite/kernels/cpu_backend_threadpool.h | 1 - tensorflow/lite/kernels/internal/BUILD | 1 - .../optimized/depthwiseconv_multithread.h | 1 - tensorflow/lite/kernels/tflite_with_ruy.h | 31 ----------------- 12 files changed, 20 insertions(+), 57 deletions(-) delete mode 100644 tensorflow/lite/kernels/tflite_with_ruy.h diff --git a/tensorflow/lite/kernels/BUILD b/tensorflow/lite/kernels/BUILD index f92e7febd6b..b9d0cd1d0a5 100644 --- a/tensorflow/lite/kernels/BUILD +++ b/tensorflow/lite/kernels/BUILD @@ -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", diff --git a/tensorflow/lite/kernels/conv.cc b/tensorflow/lite/kernels/conv.cc index 5ed36fbb60c..072d6c6fc2c 100644 --- a/tensorflow/lite/kernels/conv.cc +++ b/tensorflow/lite/kernels/conv.cc @@ -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" diff --git a/tensorflow/lite/kernels/conv_test.cc b/tensorflow/lite/kernels/conv_test.cc index 482407bf406..835c274933b 100644 --- a/tensorflow/lite/kernels/conv_test.cc +++ b/tensorflow/lite/kernels/conv_test.cc @@ -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 { diff --git a/tensorflow/lite/kernels/cpu_backend_gemm.h b/tensorflow/lite/kernels/cpu_backend_gemm.h index 04a7bfe7a0a..6ede8d2fc49 100644 --- a/tensorflow/lite/kernels/cpu_backend_gemm.h +++ b/tensorflow/lite/kernels/cpu_backend_gemm.h @@ -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" diff --git a/tensorflow/lite/kernels/cpu_backend_gemm_custom_gemv.h b/tensorflow/lite/kernels/cpu_backend_gemm_custom_gemv.h index 7cf68b54891..017f1660e8c 100644 --- a/tensorflow/lite/kernels/cpu_backend_gemm_custom_gemv.h +++ b/tensorflow/lite/kernels/cpu_backend_gemm_custom_gemv.h @@ -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 { diff --git a/tensorflow/lite/kernels/cpu_backend_gemm_eigen.cc b/tensorflow/lite/kernels/cpu_backend_gemm_eigen.cc index 190367b12a9..6bdbf81ced3 100644 --- a/tensorflow/lite/kernels/cpu_backend_gemm_eigen.cc +++ b/tensorflow/lite/kernels/cpu_backend_gemm_eigen.cc @@ -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" diff --git a/tensorflow/lite/kernels/cpu_backend_gemm_eigen.h b/tensorflow/lite/kernels/cpu_backend_gemm_eigen.h index 4caa16ece64..bd4733dcfae 100644 --- a/tensorflow/lite/kernels/cpu_backend_gemm_eigen.h +++ b/tensorflow/lite/kernels/cpu_backend_gemm_eigen.h @@ -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" diff --git a/tensorflow/lite/kernels/cpu_backend_gemm_gemmlowp.h b/tensorflow/lite/kernels/cpu_backend_gemm_gemmlowp.h index 075ec8f80e4..3c63443ecf4 100644 --- a/tensorflow/lite/kernels/cpu_backend_gemm_gemmlowp.h +++ b/tensorflow/lite/kernels/cpu_backend_gemm_gemmlowp.h @@ -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 diff --git a/tensorflow/lite/kernels/cpu_backend_threadpool.h b/tensorflow/lite/kernels/cpu_backend_threadpool.h index 31a8caa3b50..d1e1d14c3c2 100644 --- a/tensorflow/lite/kernels/cpu_backend_threadpool.h +++ b/tensorflow/lite/kernels/cpu_backend_threadpool.h @@ -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" diff --git a/tensorflow/lite/kernels/internal/BUILD b/tensorflow/lite/kernels/internal/BUILD index 008db76d8ae..a908e3c4b65 100644 --- a/tensorflow/lite/kernels/internal/BUILD +++ b/tensorflow/lite/kernels/internal/BUILD @@ -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({ diff --git a/tensorflow/lite/kernels/internal/optimized/depthwiseconv_multithread.h b/tensorflow/lite/kernels/internal/optimized/depthwiseconv_multithread.h index 3af6cf48fd4..05a1476b518 100644 --- a/tensorflow/lite/kernels/internal/optimized/depthwiseconv_multithread.h +++ b/tensorflow/lite/kernels/internal/optimized/depthwiseconv_multithread.h @@ -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 { diff --git a/tensorflow/lite/kernels/tflite_with_ruy.h b/tensorflow/lite/kernels/tflite_with_ruy.h deleted file mode 100644 index 0220d557a1d..00000000000 --- a/tensorflow/lite/kernels/tflite_with_ruy.h +++ /dev/null @@ -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_