Fix compilation for TF Lite and NNAPI after TF rebase
Test: mma
Change-Id: Ib433915396a571ec3584b32af2d528629acdaa01
diff --git a/tensorflow/core/platform/default/logging.cc b/tensorflow/core/platform/default/logging.cc
index f962a0c..a676ffb 100644
--- a/tensorflow/core/platform/default/logging.cc
+++ b/tensorflow/core/platform/default/logging.cc
@@ -16,13 +16,18 @@
#include "tensorflow/core/platform/default/logging.h"
// TODO(b/142492876): Avoid depending on absl internal.
+#ifdef TF_ANDROID_ENABLE_LOG_EVERY_N_SECONDS
#include "absl/base/internal/cycleclock.h"
+#endif
+#if !defined(PLATFORM_POSIX_ANDROID)
#include "absl/base/internal/sysinfo.h"
+#endif
#include "tensorflow/core/platform/env_time.h"
#include "tensorflow/core/platform/macros.h"
#if defined(PLATFORM_POSIX_ANDROID)
#include <android/log.h>
+
#include <iostream>
#include <sstream>
#endif
@@ -143,12 +148,14 @@
return result;
}
+#if !defined(PLATFORM_POSIX_ANDROID)
bool EmitThreadIdFromEnv() {
const char* tf_env_var_val = getenv("TF_CPP_LOG_THREAD_ID");
return tf_env_var_val == nullptr
? false
: ParseInteger(tf_env_var_val, strlen(tf_env_var_val)) != 0;
}
+#endif
} // namespace
@@ -254,8 +261,7 @@
const size_t tid_buffer_size = 10;
char tid_buffer[tid_buffer_size] = "";
if (log_thread_id) {
- snprintf(tid_buffer, sizeof(tid_buffer), " %7u",
- absl::base_internal::GetTID());
+ snprintf(tid_buffer, sizeof(tid_buffer), " %7u", gettid());
}
// TODO(jeff,sanjay): Replace this with something that logs through the env.
fprintf(stderr, "%s.%06d: %c%s %s:%d] %s\n", time_buffer, micros_remainder,
@@ -380,6 +386,7 @@
return (new_value & (new_value - 1)) == 0;
}
+#ifdef TF_ANDROID_ENABLE_LOG_EVERY_N_SECONDS
bool LogEveryNSecState::ShouldLog(double seconds) {
LossyIncrement(&counter_);
const int64 now_cycles = absl::base_internal::CycleClock::Now();
@@ -392,6 +399,7 @@
std::memory_order_relaxed, std::memory_order_relaxed));
return true;
}
+#endif
} // namespace internal
} // namespace tensorflow
diff --git a/tensorflow/core/platform/default/logging.h b/tensorflow/core/platform/default/logging.h
index d9b9b16..32443a4 100644
--- a/tensorflow/core/platform/default/logging.h
+++ b/tensorflow/core/platform/default/logging.h
@@ -173,6 +173,7 @@
std::atomic<uint32> counter_{0};
};
+#ifdef TF_ANDROID_ENABLE_LOG_EVERY_N_SECONDS
class LogEveryNSecState {
public:
bool ShouldLog(double seconds);
@@ -183,6 +184,7 @@
// Cycle count according to CycleClock that we should next log at.
std::atomic<int64> next_log_time_cycles_{0};
};
+#endif
// This macro has a lot going on!
//
diff --git a/tensorflow/core/platform/tstring.h b/tensorflow/core/platform/tstring.h
index 3fe1be2..6dfee77 100644
--- a/tensorflow/core/platform/tstring.h
+++ b/tensorflow/core/platform/tstring.h
@@ -26,7 +26,6 @@
// TODO(dero): This include is temporary, and will be superfluous once
// absl::string_view is aliased to std::string_view.
-#include "absl/strings/string_view.h"
namespace absl {
#ifdef ABSL_NAMESPACE_BEGIN
ABSL_NAMESPACE_BEGIN
@@ -111,9 +110,9 @@
tstring(const char* str, size_t len);
tstring(const char* str); // NOLINT TODO(b/147740521): Make explicit.
tstring(size_t n, char c);
- explicit tstring(const absl::string_view str);
+ explicit tstring(const std::string_view str);
#ifdef PLATFORM_GOOGLE
- explicit tstring(const absl::Cord& cord);
+ explicit tstring(const std::Cord& cord);
#endif // PLATFORM_GOOGLE
// Copy
@@ -130,9 +129,9 @@
tstring& operator=(const std::string& str);
tstring& operator=(const char* str);
tstring& operator=(char ch);
- tstring& operator=(const absl::string_view str);
+ tstring& operator=(const std::string_view str);
#ifdef PLATFORM_GOOGLE
- tstring& operator=(const absl::Cord& cord);
+ tstring& operator=(const std::Cord& cord);
#endif // PLATFORM_GOOGLE
// View Assignment
@@ -154,10 +153,10 @@
// TODO(b/147740521): Make explicit.
operator std::string() const; // NOLINT
// TODO(b/147740521): Make explicit.
- operator absl::string_view() const; // NOLINT
+ operator std::string_view() const; // NOLINT
#ifdef PLATFORM_GOOGLE
template <typename T,
- typename std::enable_if<std::is_same<T, absl::AlphaNum>::value,
+ typename std::enable_if<std::is_same<T, std::AlphaNum>::value,
T>::type* = nullptr>
operator T() const; // NOLINT TODO(b/147740521): Remove.
#endif // PLATFORM_GOOGLE
@@ -202,7 +201,7 @@
// View Assignment
tstring& assign_as_view(const tstring& str);
tstring& assign_as_view(const std::string& str);
- tstring& assign_as_view(const absl::string_view str);
+ tstring& assign_as_view(const std::string_view str);
tstring& assign_as_view(const char* str, size_t len);
tstring& assign_as_view(const char* str);
@@ -256,11 +255,11 @@
inline tstring::tstring(const std::string& str)
: tstring(str.data(), str.size()) {}
-inline tstring::tstring(const absl::string_view str)
+inline tstring::tstring(const std::string_view str)
: tstring(str.data(), str.size()) {}
#ifdef PLATFORM_GOOGLE
-inline tstring::tstring(const absl::Cord& cord) {
+inline tstring::tstring(const std::Cord& cord) {
TF_TString_Init(&tstr_);
TF_TString_ResizeUninitialized(&tstr_, cord.size());
@@ -312,14 +311,14 @@
return *this;
}
-inline tstring& tstring::operator=(const absl::string_view str) {
+inline tstring& tstring::operator=(const std::string_view str) {
TF_TString_Copy(&tstr_, str.data(), str.size());
return *this;
}
#ifdef PLATFORM_GOOGLE
-inline tstring& tstring::operator=(const absl::Cord& cord) {
+inline tstring& tstring::operator=(const std::Cord& cord) {
TF_TString_ResizeUninitialized(&tstr_, cord.size());
cord.CopyToArray(data());
@@ -388,15 +387,15 @@
return std::string(data(), size());
}
-inline tstring::operator absl::string_view() const {
- return absl::string_view(data(), size());
+inline tstring::operator std::string_view() const {
+ return std::string_view(data(), size());
}
#ifdef PLATFORM_GOOGLE
template <typename T, typename std::enable_if<
- std::is_same<T, absl::AlphaNum>::value, T>::type*>
+ std::is_same<T, std::AlphaNum>::value, T>::type*>
inline tstring::operator T() const {
- return T(absl::string_view(*this));
+ return T(std::string_view(*this));
}
#endif // PLATFORM_GOOGLE
@@ -488,7 +487,7 @@
return *this;
}
-inline tstring& tstring::assign_as_view(const absl::string_view str) {
+inline tstring& tstring::assign_as_view(const std::string_view str) {
assign_as_view(str.data(), str.size());
return *this;
diff --git a/tensorflow/lite/Android.bp b/tensorflow/lite/Android.bp
index 64fd4b7..ccc442e 100644
--- a/tensorflow/lite/Android.bp
+++ b/tensorflow/lite/Android.bp
@@ -32,7 +32,7 @@
cc_library_static {
name: "libtflite_context",
defaults: ["tflite_defaults"],
- srcs: ["c/c_api_internal.c"],
+ srcs: ["c/common.c"],
cflags: [
"-Wno-typedef-redefinition",
"-Wno-visibility",
@@ -49,6 +49,7 @@
"core/api/error_reporter.cc",
"core/api/flatbuffer_conversions.cc",
"core/api/op_resolver.cc",
+ "core/api/tensor_utils.cc",
"core/subgraph.cc",
"delegates/nnapi/nnapi_delegate.cc",
"delegates/nnapi/quant_lstm_sup.cc",
@@ -61,20 +62,31 @@
"model.cc",
"mutable_op_resolver.cc",
"nnapi/nnapi_implementation.cc",
+ "nnapi/nnapi_util.cc",
"optional_debug_tools.cc",
"simple_memory_arena.cc",
"stderr_reporter.cc",
"string_util.cc",
+ "tools/optimize/sparsity/format_converter.cc",
"util.cc",
"kernels/cpu_backend_context.cc",
"kernels/cpu_backend_gemm_eigen.cc",
"kernels/eigen_support.cc",
- "experimental/resource_variable/resource_variable.cc",
+ "experimental/resource/resource_variable.cc",
"experimental/ruy/allocator.cc",
"experimental/ruy/block_map.cc",
"experimental/ruy/blocking_counter.cc",
"experimental/ruy/context.cc",
- "experimental/ruy/detect_dotprod.cc",
+ "experimental/ruy/detect_arm.cc",
+ "experimental/ruy/detect_x86.cc",
+ "experimental/ruy/have_built_path_for_avx2.cc",
+ "experimental/ruy/have_built_path_for_avx512.cc",
+ "experimental/ruy/have_built_path_for_avxvnni.cc",
+ "experimental/ruy/have_built_path_for_sse42.cc",
+ "experimental/ruy/kernel_arm32.cc",
+ "experimental/ruy/kernel_arm64.cc",
+ "experimental/ruy/pack_arm.cc",
+ "experimental/ruy/prepacked_cache.cc",
"experimental/ruy/thread_pool.cc",
"experimental/ruy/trmul.cc",
"experimental/ruy/tune.cc",
diff --git a/tensorflow/lite/delegates/flex/java/src/main/native/flex_delegate_jni.cc b/tensorflow/lite/delegates/flex/java/src/main/native/flex_delegate_jni.cc
index 957c523..7b9bf43 100644
--- a/tensorflow/lite/delegates/flex/java/src/main/native/flex_delegate_jni.cc
+++ b/tensorflow/lite/delegates/flex/java/src/main/native/flex_delegate_jni.cc
@@ -25,7 +25,8 @@
JNIEXPORT void JNICALL
Java_org_tensorflow_lite_flex_FlexDelegate_nativeInitTensorFlow(JNIEnv* env,
jclass clazz) {
- ::tflite::InitTensorFlow();
+ // Flex support not available in Android tree.
+ // ::tflite::InitTensorFlow();
}
JNIEXPORT jlong JNICALL
diff --git a/tensorflow/lite/delegates/nnapi/acceleration_test_util.cc b/tensorflow/lite/delegates/nnapi/acceleration_test_util.cc
index c4843ed..4fa6e81 100644
--- a/tensorflow/lite/delegates/nnapi/acceleration_test_util.cc
+++ b/tensorflow/lite/delegates/nnapi/acceleration_test_util.cc
@@ -18,7 +18,7 @@
namespace tflite {
-absl::optional<NnapiAccelerationTestParams> GetNnapiAccelerationTestParam(
+std::optional<NnapiAccelerationTestParams> GetNnapiAccelerationTestParam(
std::string test_id) {
return GetAccelerationTestParam<NnapiAccelerationTestParams>(test_id);
}
diff --git a/tensorflow/lite/delegates/nnapi/acceleration_test_util.h b/tensorflow/lite/delegates/nnapi/acceleration_test_util.h
index e99225e..fd49edc 100644
--- a/tensorflow/lite/delegates/nnapi/acceleration_test_util.h
+++ b/tensorflow/lite/delegates/nnapi/acceleration_test_util.h
@@ -15,8 +15,8 @@
#ifndef TENSORFLOW_LITE_DELEGATES_NNAPI_ACCELERATION_TEST_UTIL_H_
#define TENSORFLOW_LITE_DELEGATES_NNAPI_ACCELERATION_TEST_UTIL_H_
-#include <gtest/gtest.h>
-#include "absl/types/optional.h"
+#include <optional>
+
#include "tensorflow/lite/delegates/nnapi/nnapi_delegate_kernel.h"
namespace tflite {
@@ -44,7 +44,7 @@
};
// Returns the NNAPI acceleration test configuration for the given test id.
-absl::optional<NnapiAccelerationTestParams> GetNnapiAccelerationTestParam(
+std::optional<NnapiAccelerationTestParams> GetNnapiAccelerationTestParam(
std::string test_id);
} // namespace tflite
diff --git a/tensorflow/lite/delegates/nnapi/java/Android.bp b/tensorflow/lite/delegates/nnapi/java/Android.bp
new file mode 100644
index 0000000..65c3de2
--- /dev/null
+++ b/tensorflow/lite/delegates/nnapi/java/Android.bp
@@ -0,0 +1,23 @@
+// Copyright (C) 2020 The Android Open Source Project
+//
+// 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.
+
+filegroup {
+ name: "tflite_nnapi_delegate_java",
+ srcs: [
+ "src/main/java/org/tensorflow/lite/nnapi/*.java",
+ ],
+ visibility: [
+ "//visibility:public"
+ ],
+}
diff --git a/tensorflow/lite/delegates/nnapi/nnapi_delegate.cc b/tensorflow/lite/delegates/nnapi/nnapi_delegate.cc
index 7d86772..39858d0 100644
--- a/tensorflow/lite/delegates/nnapi/nnapi_delegate.cc
+++ b/tensorflow/lite/delegates/nnapi/nnapi_delegate.cc
@@ -39,8 +39,6 @@
#include <unistd.h>
#endif
-#include "absl/memory/memory.h"
-#include "absl/types/optional.h"
#include "tensorflow/lite/allocation.h"
#include "tensorflow/lite/builtin_op_data.h"
#include "tensorflow/lite/builtin_ops.h"
@@ -3185,7 +3183,7 @@
}
// Determine the list of operations the device actually supports
- auto support_flags = absl::make_unique<bool[]>(nodes_.size());
+ auto support_flags = std::make_unique<bool[]>(nodes_.size());
RETURN_TFLITE_ERROR_IF_NN_ERROR(
context,
@@ -3686,11 +3684,11 @@
// Get op type and operands
// Fails if the Validate function failed
int nn_op_type;
- TF_LITE_ENSURE_STATUS(Map(context, reg->builtin_code, reg->version,
- target_sdk_version,
- {context, &builder, node, &model_state_outputs_,
- &model_state_tfl_inputs_, &feedback_loops_},
- &nn_op_type));
+ TF_LITE_ENSURE_STATUS(
+ Map(context, reg->builtin_code, reg->version, target_sdk_version,
+ {context, &builder, node, &model_state_outputs_,
+ &model_state_tfl_inputs_, &feedback_loops_, nnapi_errno},
+ &nn_op_type));
// Map outputs to NN API tensor indices.
int output_tensor_flags = 0;
@@ -3827,17 +3825,17 @@
delegate_state_cache.emplace(cache_key, delegate_state);
}
-absl::optional<NNAPIDelegateKernel*>
+std::optional<NNAPIDelegateKernel*>
StatefulNnApiDelegate::Data::GetCachedDelegateKernel(
const TfLiteDelegateParams* delegate_params) {
const int cache_key = delegate_params->nodes_to_replace->data[0];
const auto cached_state = delegate_state_cache.find(cache_key);
if (cached_state != std::end(delegate_state_cache)) {
- auto result = absl::optional<NNAPIDelegateKernel*>(cached_state->second);
+ auto result = std::optional<NNAPIDelegateKernel*>(cached_state->second);
delegate_state_cache.erase(cached_state);
return result;
} else {
- return absl::nullopt;
+ return std::nullopt;
}
}
@@ -4099,7 +4097,7 @@
delegate_data->delegate_state_cache.clear();
for (int idx = 0; idx < num_partitions; idx++) {
const auto& partition_params = params_array[idx];
- auto kernel_state = absl::make_unique<NNAPIDelegateKernel>();
+ auto kernel_state = std::make_unique<NNAPIDelegateKernel>();
TfLiteDelegateParams params_with_delegate = partition_params;
params_with_delegate.delegate = delegate;
TF_LITE_ENSURE_STATUS(
diff --git a/tensorflow/lite/delegates/nnapi/nnapi_delegate.h b/tensorflow/lite/delegates/nnapi/nnapi_delegate.h
index 57a8b33..84c7b97 100644
--- a/tensorflow/lite/delegates/nnapi/nnapi_delegate.h
+++ b/tensorflow/lite/delegates/nnapi/nnapi_delegate.h
@@ -20,7 +20,6 @@
#include <unordered_map>
#include <vector>
-#include "absl/types/optional.h"
#include "tensorflow/lite/c/common.h"
typedef struct ANeuralNetworksMemory ANeuralNetworksMemory;
@@ -167,7 +166,7 @@
void CacheDelegateKernel(const TfLiteDelegateParams* delegate_params,
NNAPIDelegateKernel* delegate_state);
// Returns a cached NNAPIDelegateKernel if available.
- absl::optional<NNAPIDelegateKernel*> GetCachedDelegateKernel(
+ std::optional<NNAPIDelegateKernel*> GetCachedDelegateKernel(
const TfLiteDelegateParams* delegate_params);
};
diff --git a/tensorflow/lite/java/Android.bp b/tensorflow/lite/java/Android.bp
index 3b502b6..7145aa1 100644
--- a/tensorflow/lite/java/Android.bp
+++ b/tensorflow/lite/java/Android.bp
@@ -19,8 +19,11 @@
"android-support-annotations",
],
srcs: [
+ ":tflite_nnapi_delegate_java",
"src/main/java/org/tensorflow/lite/*.java",
],
+ static_libs: [
+ ],
}
cc_library_shared {
diff --git a/tensorflow/lite/kernels/Android.bp b/tensorflow/lite/kernels/Android.bp
index 10e097d..55bd4b7 100644
--- a/tensorflow/lite/kernels/Android.bp
+++ b/tensorflow/lite/kernels/Android.bp
@@ -19,13 +19,16 @@
srcs: [
"kernel_util.cc",
"internal/tensor_utils.cc",
+ "internal/transpose_utils.cc",
"internal/quantization_util.cc",
"internal/reference/portable_tensor_utils.cc",
"internal/optimized/neon_tensor_utils.cc",
"internal/optimized/sse_tensor_utils.cc",
],
header_libs: [
+ "flatbuffer_headers",
"gemmlowp_headers",
+ "libeigen",
],
cflags: [
"-Wno-extern-c-compat",
@@ -51,6 +54,8 @@
"comparisons.cc",
"concatenation.cc",
"conv.cc",
+ "densify.cc",
+ "depth_to_space.cc",
"depthwise_conv.cc",
"dequantize.cc",
"detection_postprocess.cc",
@@ -83,6 +88,8 @@
"mirror_pad.cc",
"mul.cc",
"neg.cc",
+ "non_max_suppression.cc",
+ "numeric_verify.cc",
"one_hot.cc",
"pad.cc",
"pack.cc",
@@ -99,6 +106,8 @@
"resize_bilinear.cc",
"resize_nearest_neighbor.cc",
"round.cc",
+ "scatter_nd.cc",
+ "segment_sum.cc",
"select.cc",
"shape.cc",
"skip_gram.cc",
@@ -126,9 +135,11 @@
"zeros_like.cc",
"internal/kernel_utils.cc",
"internal/tensor_utils.cc",
+ "internal/transpose_utils.cc",
"internal/quantization_util.cc",
"internal/reference/portable_tensor_utils.cc",
"internal/optimized/neon_tensor_utils.cc",
+ "internal/optimized/sse_tensor_utils.cc",
],
header_libs: [
"flatbuffer_headers",
diff --git a/tensorflow/lite/kernels/acceleration_test_util.cc b/tensorflow/lite/kernels/acceleration_test_util.cc
index 0dffd22..19a4877 100644
--- a/tensorflow/lite/kernels/acceleration_test_util.cc
+++ b/tensorflow/lite/kernels/acceleration_test_util.cc
@@ -14,6 +14,8 @@
==============================================================================*/
#include "tensorflow/lite/kernels/acceleration_test_util.h"
+#include <gtest/gtest.h>
+
#include <algorithm>
#include <array>
#include <atomic>
@@ -24,7 +26,6 @@
#include <string>
#include <unordered_map>
-#include "absl/types/optional.h"
#include "tensorflow/lite/kernels/acceleration_test_util_internal.h"
#include "tensorflow/lite/minimal_logging.h"
diff --git a/tensorflow/lite/kernels/acceleration_test_util.h b/tensorflow/lite/kernels/acceleration_test_util.h
index 75b5d79..a6a88d5 100644
--- a/tensorflow/lite/kernels/acceleration_test_util.h
+++ b/tensorflow/lite/kernels/acceleration_test_util.h
@@ -15,7 +15,7 @@
#ifndef TENSORFLOW_LITE_KERNELS_ACCELERATION_TEST_UTIL_H_
#define TENSORFLOW_LITE_KERNELS_ACCELERATION_TEST_UTIL_H_
-#include <gtest/gtest.h>
+#include <string>
namespace tflite {
diff --git a/tensorflow/lite/kernels/acceleration_test_util_internal.h b/tensorflow/lite/kernels/acceleration_test_util_internal.h
index 8999af7..4b33766 100644
--- a/tensorflow/lite/kernels/acceleration_test_util_internal.h
+++ b/tensorflow/lite/kernels/acceleration_test_util_internal.h
@@ -18,13 +18,12 @@
#include <algorithm>
#include <atomic>
#include <functional>
+#include <optional>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
-#include "absl/types/optional.h"
-#include "re2/re2.h"
#include "tensorflow/lite/minimal_logging.h"
namespace tflite {
@@ -47,7 +46,8 @@
is_blacklist_(is_blacklist) {}
bool Matches(const std::string& test_id) {
- return RE2::FullMatch(test_id, test_id_rex_);
+ // Always return false on Android because there is no re2 library available.
+ return false;
}
bool IsBlacklistEntry() const { return is_blacklist_; }
const T& TestConfig() const { return test_config_; }
@@ -66,7 +66,7 @@
// and the parse function to convert configuration lines into configuration
// objects.
template <typename T>
-absl::optional<T> GetAccelerationTestParam(std::string test_id) {
+std::optional<T> GetAccelerationTestParam(std::string test_id) {
static std::atomic<std::vector<ConfigurationEntry<T>>*> test_config_ptr;
if (test_config_ptr.load() == nullptr) {
@@ -94,9 +94,9 @@
[&test_id](ConfigurationEntry<T> elem) { return elem.Matches(test_id); });
if (test_config_iter != test_config->end() &&
!test_config_iter->IsBlacklistEntry()) {
- return absl::optional<T>(test_config_iter->TestConfig());
+ return std::optional<T>(test_config_iter->TestConfig());
} else {
- return absl::optional<T>();
+ return std::optional<T>();
}
}
diff --git a/tensorflow/lite/kernels/dequantize.h b/tensorflow/lite/kernels/dequantize.h
index 3d9e7cc..76fe1ae 100644
--- a/tensorflow/lite/kernels/dequantize.h
+++ b/tensorflow/lite/kernels/dequantize.h
@@ -15,7 +15,7 @@
#ifndef TENSORFLOW_LITE_KERNELS_DEQUANTIZE_H_
#define TENSORFLOW_LITE_KERNELS_DEQUANTIZE_H_
-#include "third_party/eigen3/Eigen/Core"
+#include "Eigen/Core"
#include "tensorflow/lite/c/builtin_op_data.h"
#include "tensorflow/lite/c/common.h"
#include "tensorflow/lite/kernels/internal/optimized/optimized_ops.h"
diff --git a/tensorflow/lite/kernels/internal/tensor_utils.h b/tensorflow/lite/kernels/internal/tensor_utils.h
index c90b258..5b6f549 100644
--- a/tensorflow/lite/kernels/internal/tensor_utils.h
+++ b/tensorflow/lite/kernels/internal/tensor_utils.h
@@ -18,7 +18,7 @@
#include <algorithm>
#include <cmath>
-#include "third_party/eigen3/Eigen/Core"
+#include "Eigen/Core"
#include "tensorflow/lite/c/builtin_op_data.h"
#include "tensorflow/lite/kernels/cpu_backend_context.h"
diff --git a/tensorflow/lite/kernels/lstm.cc b/tensorflow/lite/kernels/lstm.cc
index 8fd0e9b..532d69c 100644
--- a/tensorflow/lite/kernels/lstm.cc
+++ b/tensorflow/lite/kernels/lstm.cc
@@ -21,7 +21,6 @@
#include <memory>
#include <vector>
-#include "absl/memory/memory.h"
#include "tensorflow/lite/c/builtin_op_data.h"
#include "tensorflow/lite/c/common.h"
#include "tensorflow/lite/kernels/cpu_backend_context.h"
@@ -651,7 +650,7 @@
TF_LITE_ENSURE_EQ(context, weight_shape.DimensionsCount(), 2);
const int row = weight_shape.Dims(0);
const int col = weight_shape.Dims(1);
- *output = absl::make_unique<int32_t[]>(row);
+ *output = std::make_unique<int32_t[]>(row);
if (bias_tensor == nullptr) {
memset(output->get(), 0, row * sizeof(int32_t));
} else {
diff --git a/tensorflow/lite/kernels/numeric_verify.cc b/tensorflow/lite/kernels/numeric_verify.cc
index 798e2b4..edc7305 100644
--- a/tensorflow/lite/kernels/numeric_verify.cc
+++ b/tensorflow/lite/kernels/numeric_verify.cc
@@ -18,7 +18,7 @@
#include <cstdint>
#include <vector>
-#include "third_party/eigen3/Eigen/Core"
+#include "Eigen/Core"
#include "tensorflow/lite/c/builtin_op_data.h"
#include "tensorflow/lite/c/common.h"
#include "tensorflow/lite/kernels/dequantize.h"
diff --git a/tensorflow/lite/kernels/test_util.cc b/tensorflow/lite/kernels/test_util.cc
index cbb39c2..b2e8b76 100644
--- a/tensorflow/lite/kernels/test_util.cc
+++ b/tensorflow/lite/kernels/test_util.cc
@@ -314,7 +314,7 @@
} // namespace
void SingleOpModel::ExpectOpAcceleratedWithNnapi(const std::string& test_id) {
- absl::optional<NnapiAccelerationTestParams> validation_params =
+ std::optional<NnapiAccelerationTestParams> validation_params =
GetNnapiAccelerationTestParam(test_id);
if (!validation_params.has_value()) {
return;
diff --git a/tensorflow/lite/testing/nnapi_tflite_zip_tests/join.h b/tensorflow/lite/testing/nnapi_tflite_zip_tests/join.h
index b845f7e..a04021a 100644
--- a/tensorflow/lite/testing/nnapi_tflite_zip_tests/join.h
+++ b/tensorflow/lite/testing/nnapi_tflite_zip_tests/join.h
@@ -22,7 +22,7 @@
#include <iomanip>
#include <sstream>
-#include "tensorflow/lite/string_tflite.h"
+#include "tensorflow/lite/string_type.h"
namespace tflite {
namespace testing {
diff --git a/tensorflow/lite/testing/nnapi_tflite_zip_tests/split.h b/tensorflow/lite/testing/nnapi_tflite_zip_tests/split.h
index cdb5381..e799e17 100644
--- a/tensorflow/lite/testing/nnapi_tflite_zip_tests/split.h
+++ b/tensorflow/lite/testing/nnapi_tflite_zip_tests/split.h
@@ -22,7 +22,7 @@
#include <string>
#include <utility>
#include <vector>
-#include "tensorflow/lite/string_tflite.h"
+#include "tensorflow/lite/string_type.h"
namespace tflite {
namespace testing {
diff --git a/tensorflow/lite/testing/nnapi_tflite_zip_tests/test_runner.h b/tensorflow/lite/testing/nnapi_tflite_zip_tests/test_runner.h
index 1a8f765..2e47f7b 100644
--- a/tensorflow/lite/testing/nnapi_tflite_zip_tests/test_runner.h
+++ b/tensorflow/lite/testing/nnapi_tflite_zip_tests/test_runner.h
@@ -22,7 +22,7 @@
#include <memory>
#include <string>
#include <vector>
-#include "tensorflow/lite/string_tflite.h"
+#include "tensorflow/lite/string_type.h"
namespace tflite {
namespace testing {
diff --git a/tensorflow/lite/testing/nnapi_tflite_zip_tests/tokenize.cc b/tensorflow/lite/testing/nnapi_tflite_zip_tests/tokenize.cc
index 95251dc..97a2cb1 100644
--- a/tensorflow/lite/testing/nnapi_tflite_zip_tests/tokenize.cc
+++ b/tensorflow/lite/testing/nnapi_tflite_zip_tests/tokenize.cc
@@ -18,7 +18,7 @@
#include "tokenize.h"
#include <istream>
#include <string>
-#include "tensorflow/lite/string_tflite.h"
+#include "tensorflow/lite/string_type.h"
namespace tflite {
namespace testing {
diff --git a/tensorflow/lite/testing/nnapi_tflite_zip_tests/util.h b/tensorflow/lite/testing/nnapi_tflite_zip_tests/util.h
index 883c5e0..967a012 100644
--- a/tensorflow/lite/testing/nnapi_tflite_zip_tests/util.h
+++ b/tensorflow/lite/testing/nnapi_tflite_zip_tests/util.h
@@ -21,7 +21,7 @@
#include <cstdio>
#include "tensorflow/lite/core/api/error_reporter.h"
-#include "tensorflow/lite/string_tflite.h"
+#include "tensorflow/lite/string_type.h"
namespace tflite {
diff --git a/tensorflow/lite/tflite_static.bp b/tensorflow/lite/tflite_static.bp
index 1c97ca6..770f5a5 100644
--- a/tensorflow/lite/tflite_static.bp
+++ b/tensorflow/lite/tflite_static.bp
@@ -20,10 +20,11 @@
srcs: [
"allocation.cc",
"arena_planner.cc",
- "c/c_api_internal.c",
+ "c/common.c",
"core/api/error_reporter.cc",
"core/api/flatbuffer_conversions.cc",
"core/api/op_resolver.cc",
+ "core/api/tensor_utils.cc",
"core/subgraph.cc",
"delegates/nnapi/nnapi_delegate.cc",
"delegates/nnapi/quant_lstm_sup.cc",
@@ -58,6 +59,8 @@
"kernels/conv.cc",
"kernels/cpu_backend_context.cc",
"kernels/cpu_backend_gemm_eigen.cc",
+ "kernels/densify.cc",
+ "kernels/depth_to_space.cc",
"kernels/depthwise_conv.cc",
"kernels/dequantize.cc",
"kernels/detection_postprocess.cc",
@@ -90,6 +93,8 @@
"kernels/mirror_pad.cc",
"kernels/mul.cc",
"kernels/neg.cc",
+ "kernels/non_max_suppression.cc",
+ "kernels/numeric_verify.cc",
"kernels/one_hot.cc",
"kernels/pad.cc",
"kernels/pack.cc",
@@ -107,6 +112,8 @@
"kernels/reverse.cc",
"kernels/reverse_sequence.cc",
"kernels/round.cc",
+ "kernels/scatter_nd.cc",
+ "kernels/segment_sum.cc",
"kernels/select.cc",
"kernels/shape.cc",
"kernels/skip_gram.cc",
@@ -132,21 +139,33 @@
"kernels/zeros_like.cc",
"kernels/internal/kernel_utils.cc",
"kernels/internal/tensor_utils.cc",
+ "kernels/internal/transpose_utils.cc",
"kernels/internal/quantization_util.cc",
"kernels/internal/reference/portable_tensor_utils.cc",
"kernels/internal/optimized/neon_tensor_utils.cc",
"kernels/internal/optimized/sse_tensor_utils.cc",
"nnapi/nnapi_implementation.cc",
- "experimental/resource_variable/resource_variable.cc",
+ "nnapi/nnapi_util.cc",
+ "experimental/resource/resource_variable.cc",
"experimental/ruy/allocator.cc",
"experimental/ruy/block_map.cc",
"experimental/ruy/blocking_counter.cc",
"experimental/ruy/context.cc",
- "experimental/ruy/detect_dotprod.cc",
+ "experimental/ruy/detect_arm.cc",
+ "experimental/ruy/detect_x86.cc",
+ "experimental/ruy/have_built_path_for_avx2.cc",
+ "experimental/ruy/have_built_path_for_avx512.cc",
+ "experimental/ruy/have_built_path_for_avxvnni.cc",
+ "experimental/ruy/have_built_path_for_sse42.cc",
+ "experimental/ruy/kernel_arm64.cc",
+ "experimental/ruy/kernel_arm32.cc",
+ "experimental/ruy/pack_arm.cc",
+ "experimental/ruy/prepacked_cache.cc",
"experimental/ruy/thread_pool.cc",
"experimental/ruy/trmul.cc",
"experimental/ruy/tune.cc",
"experimental/ruy/wait.cc",
+ "tools/optimize/sparsity/format_converter.cc",
],
include_dirs: [
"external/eigen",
diff --git a/tensorflow/lite/tools/android/remove_absl.sh b/tensorflow/lite/tools/android/remove_absl.sh
new file mode 100755
index 0000000..bdafdca
--- /dev/null
+++ b/tensorflow/lite/tools/android/remove_absl.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+# Copyright (C) 2020 The Android Open Source Project
+#
+# 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.
+
+tensorflow_project="$ANDROID_BUILD_TOP/external/tensorflow"
+
+files_with_absl=(
+ "$tensorflow_project/tensorflow/core/platform/tstring.h"
+ "$tensorflow_project/tensorflow/lite/delegates/nnapi/acceleration_test_util.cc"
+ "$tensorflow_project/tensorflow/lite/delegates/nnapi/nnapi_delegate.cc"
+ "$tensorflow_project/tensorflow/lite/delegates/nnapi/nnapi_delegate.h"
+ "$tensorflow_project/tensorflow/lite/kernels/lstm.cc"
+ "$tensorflow_project/tensorflow/lite/delegates/nnapi/acceleration_test_util.h"
+ "$tensorflow_project/tensorflow/lite/kernels/test_util.cc"
+ "$tensorflow_project/tensorflow/lite/kernels/acceleration_test_util.cc",
+ "$tensorflow_project/tensorflow/lite/kernels/acceleration_test_util_internal.h"
+)
+
+for file in "${files_with_absl[@]}"
+do
+ echo $file
+ sed -i '/^#include.*absl.*$/d' $file
+ sed -i '/\/\/.*absl::.*/!s/absl::/std::/g' $file
+done