aboutsummaryrefslogtreecommitdiff
path: root/src/armnnTfLiteParser/TfLiteParser.cpp
diff options
context:
space:
mode:
authorJim Flynn <jim.flynn@arm.com>2021-09-23 12:16:53 +0100
committerKeithARM <keith.davis@arm.com>2021-09-23 15:21:28 +0000
commitfca233eed08f4ec3b793fe76abae540e391f8319 (patch)
tree92c91e0fa06c58d72514ae39fc452b89b9b4b559 /src/armnnTfLiteParser/TfLiteParser.cpp
parentce083d2ea1964411ce5d8f2ff05f6e0004978703 (diff)
downloadarmnn-fca233eed08f4ec3b793fe76abae540e391f8319.tar.gz
IVGCVSW-6181 patch to allow building against tflite > v2.3
Change-Id: I292add699b2af32fab87b98929fe6fee79fdf356 Signed-off-by: Jim Flynn <jim.flynn@arm.com>
Diffstat (limited to 'src/armnnTfLiteParser/TfLiteParser.cpp')
-rw-r--r--src/armnnTfLiteParser/TfLiteParser.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/armnnTfLiteParser/TfLiteParser.cpp b/src/armnnTfLiteParser/TfLiteParser.cpp
index bedefdec2f..68dbbd120f 100644
--- a/src/armnnTfLiteParser/TfLiteParser.cpp
+++ b/src/armnnTfLiteParser/TfLiteParser.cpp
@@ -32,6 +32,8 @@
#include <fmt/format.h>
+#include <tensorflow/lite/version.h>
+
#include <algorithm>
#include <fstream>
#include <iostream>
@@ -767,7 +769,14 @@ INetworkPtr TfLiteParserImpl::CreateNetworkFromModel()
for (OperatorPtr const& op : subgraph->operators)
{
auto const& opCodePtr = m_Model->operator_codes[op->opcode_index];
+
+// work around the introduction of the deprecated_builtin_code introduced in 2.4 in a backwards compatible manner
+#if TF_MAJOR_VERSION > 2 || (TF_MAJOR_VERSION == 2 && TF_MINOR_VERSION > 3)
+ auto builtinCode = std::max(opCodePtr->builtin_code,
+ static_cast<tflite::BuiltinOperator>(opCodePtr->deprecated_builtin_code));
+#else
auto builtinCode = opCodePtr->builtin_code;
+#endif
if (builtinCode > tflite::BuiltinOperator_MAX)
{
@@ -887,7 +896,14 @@ void TfLiteParserImpl::ParseUnsupportedOperator(size_t subgraphIndex, size_t ope
const auto & operatorPtr = m_Model->subgraphs[subgraphIndex]->operators[operatorIndex];
auto opcodeIndex = operatorPtr->opcode_index;
+
+// work around the introduction of the deprecated_builtin_code introduced in 2.4 in a backwards compatible manner
+#if TF_MAJOR_VERSION > 2 || (TF_MAJOR_VERSION == 2 && TF_MINOR_VERSION > 3)
+ auto opcode = std::max(m_Model->operator_codes[opcodeIndex]->builtin_code,
+ static_cast<tflite::BuiltinOperator>(m_Model->operator_codes[opcodeIndex]->deprecated_builtin_code));
+#else
auto opcode = m_Model->operator_codes[opcodeIndex]->builtin_code;
+#endif
if (!m_Options || !m_Options.value().m_StandInLayerForUnsupported)
{
@@ -1601,7 +1617,7 @@ void TfLiteParserImpl::ParseSlice(size_t subgraphIndex, size_t operatorIndex)
for (unsigned int i = 0; i < signedSize.size(); ++i)
{
int signedValue = signedSize[i];
-
+
if (signedValue < -1 || signedValue > static_cast<int>(inputTensorInfo.GetShape()[i] - begin[i]))
{
throw ParseException(fmt::format("Invalid value for size {} size must be in range "