diff options
author | Jim Flynn <jim.flynn@arm.com> | 2021-09-14 17:53:20 +0100 |
---|---|---|
committer | Kevin May <kevin.may@arm.com> | 2021-09-15 09:47:33 +0000 |
commit | fc8d434bb318aebb433a2f6d8ce9c066cd9c1b1e (patch) | |
tree | 039b76ba740af83166fc73c288db401a65975274 /src/armnnTfLiteParser/TfLiteParser.cpp | |
parent | 932cf3f668cd8843927667e9a9e2b15c91de4974 (diff) | |
download | armnn-fc8d434bb318aebb433a2f6d8ce9c066cd9c1b1e.tar.gz |
IVGCVSW-6181 patch to allow building against tflite > v2.3
Change-Id: I4199239228f7d5f4c819a7fe04cca059a830bf1f
Signed-off-by: Jim Flynn <jim.flynn@arm.com>
Diffstat (limited to 'src/armnnTfLiteParser/TfLiteParser.cpp')
-rw-r--r-- | src/armnnTfLiteParser/TfLiteParser.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/armnnTfLiteParser/TfLiteParser.cpp b/src/armnnTfLiteParser/TfLiteParser.cpp index 305f76931d..8c85d3099a 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) { |