From 32f9917b148cba7ea563961ba2f3c34965e64714 Mon Sep 17 00:00:00 2001 From: Florin Iucha Date: Sun, 13 Aug 2023 14:31:25 -0400 Subject: [PATCH 1/2] Build fixes for TensorFlow 2.13.0 --- WORKSPACE | 2 +- coral/detection/adapter.cc | 9 +++++---- coral/pipeline/internal/segment_runner.cc | 14 -------------- coral/tflite_utils.cc | 11 ----------- 4 files changed, 6 insertions(+), 30 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 87ec4c9..3963be9 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -37,7 +37,7 @@ load("@org_tensorflow//tensorflow:workspace0.bzl", "tf_workspace0") tf_workspace0() load("@coral_crosstool//:configure.bzl", "cc_crosstool") -cc_crosstool(name = "crosstool", cpp_version = "c++14") +cc_crosstool(name = "crosstool", cpp_version = "c++17") # External Dependencies http_archive( diff --git a/coral/detection/adapter.cc b/coral/detection/adapter.cc index 785443f..00a93e9 100644 --- a/coral/detection/adapter.cc +++ b/coral/detection/adapter.cc @@ -78,11 +78,12 @@ std::vector GetDetectionResults(const tflite::Interpreter& interpreter, // If a model has signature, we use the signature output tensor names to parse // the results. Otherwise, we parse the results based on some assumption of // the output tensor order and size. - if (!interpreter.signature_def_names().empty()) { - CHECK_EQ(interpreter.signature_def_names().size(), 1); - VLOG(1) << "Signature name: " << *interpreter.signature_def_names()[0]; + const auto interpreter_signature_keys = interpreter.signature_keys(); + if (!interpreter_signature_keys.empty()) { + CHECK_EQ(interpreter_signature_keys.size(), 1); + VLOG(1) << "Signature name: " << *interpreter_signature_keys[0]; const auto& signature_output_map = interpreter.signature_outputs( - interpreter.signature_def_names()[0]->c_str()); + interpreter_signature_keys[0]->c_str()); CHECK_EQ(signature_output_map.size(), 4); count = TensorData( *interpreter.tensor(signature_output_map.at("output_0"))); diff --git a/coral/pipeline/internal/segment_runner.cc b/coral/pipeline/internal/segment_runner.cc index b8c4791..1ce3035 100644 --- a/coral/pipeline/internal/segment_runner.cc +++ b/coral/pipeline/internal/segment_runner.cc @@ -24,20 +24,6 @@ limitations under the License. namespace coral { namespace internal { namespace { -TfLiteFloatArray* TfLiteFloatArrayCopy(const TfLiteFloatArray* src) { - if (!src) { - return nullptr; - } - TfLiteFloatArray* ret = static_cast( - std::malloc(TfLiteFloatArrayGetSizeInBytes(src->size))); - if (!ret) { - return nullptr; - } - ret->size = src->size; - std::memcpy(ret->data, src->data, src->size * sizeof(float)); - return ret; -} - void DmaDelegateFreeBufferHandle(TfLiteContext* context, struct TfLiteDelegate* delegate, TfLiteBufferHandle* handle) { diff --git a/coral/tflite_utils.cc b/coral/tflite_utils.cc index 646ee35..d81f572 100644 --- a/coral/tflite_utils.cc +++ b/coral/tflite_utils.cc @@ -28,17 +28,6 @@ limitations under the License. namespace coral { namespace { -TfLiteFloatArray* TfLiteFloatArrayCopy(const TfLiteFloatArray* src) { - if (!src) return nullptr; - - auto* copy = static_cast( - malloc(TfLiteFloatArrayGetSizeInBytes(src->size))); - CHECK(copy); - copy->size = src->size; - std::memcpy(copy->data, src->data, src->size * sizeof(float)); - return copy; -} - TfLiteAffineQuantization* TfLiteAffineQuantizationCopy( const TfLiteAffineQuantization* src) { if (!src) return nullptr; From 61d30a456628932323972ab54a9389b23275a451 Mon Sep 17 00:00:00 2001 From: Florin Iucha Date: Sun, 13 Aug 2023 18:04:38 -0400 Subject: [PATCH 2/2] Use updated Eigen::indexing::all instead of Eigen::all --- coral/learn/backprop/layers.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coral/learn/backprop/layers.cc b/coral/learn/backprop/layers.cc index 59cfd2f..599c92f 100644 --- a/coral/learn/backprop/layers.cc +++ b/coral/learn/backprop/layers.cc @@ -40,7 +40,7 @@ MatrixXf CrossEntropyGradient(const MatrixXf& c, const MatrixXf& p) { MatrixXf FullyConnected(const MatrixXf& mat_x, const MatrixXf& mat_w, const MatrixXf& mat_b) { MatrixXf mat_y = mat_x * mat_w; - mat_y.array().rowwise() += mat_b.array()(0, Eigen::all); + mat_y.array().rowwise() += mat_b.array()(0, Eigen::indexing::all); return mat_y; }