aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikhil Raj <nikhil.raj@arm.com>2021-04-19 16:59:48 +0100
committerNikhil Raj <nikhil.raj@arm.com>2021-04-27 17:37:11 +0100
commit5d955cf70ae0c5558d4f431f0fc6bd4552cd43a5 (patch)
tree4fb59200899808b8b008d6f48322d0d799b8b631
parent4a621c43174b6bdd9dc0bff839b245bc2139d6a6 (diff)
downloadarmnn-5d955cf70ae0c5558d4f431f0fc6bd4552cd43a5.tar.gz
IVGCVSW-5721 Remove the Tensorflow Parser from ArmNN
Signed-off-by: Nikhil Raj <nikhil.raj@arm.com> Change-Id: Ida37d3ee3a1af0c75aa905199bd861726c646846
-rw-r--r--CMakeLists.txt88
-rw-r--r--cmake/AddDllCopyCommands.cmake8
-rw-r--r--cmake/GlobalConfig.cmake22
-rw-r--r--cmake/ParserVersion.cmake18
-rw-r--r--include/armnnTfParser/ITfParser.hpp77
-rw-r--r--include/armnnTfParser/Version.hpp29
-rw-r--r--python/pyarmnn/examples/image_classification/example_utils.py2
-rwxr-xr-xpython/pyarmnn/setup.py1
-rw-r--r--python/pyarmnn/src/pyarmnn/__init__.py13
-rw-r--r--python/pyarmnn/src/pyarmnn/swig/armnn_tfparser.i102
-rwxr-xr-xpython/pyarmnn/swig_generate.py1
-rw-r--r--python/pyarmnn/test/test_generated.py4
-rw-r--r--python/pyarmnn/test/test_tf_parser.py133
-rw-r--r--src/armnnConverter/ArmnnConverter.cpp16
-rwxr-xr-xsrc/armnnTfParser/TfParser.cpp3745
-rw-r--r--src/armnnTfParser/TfParser.hpp276
-rw-r--r--src/armnnTfParser/test/Activations.cpp109
-rw-r--r--src/armnnTfParser/test/AddN.cpp180
-rw-r--r--src/armnnTfParser/test/Addition.cpp78
-rw-r--r--src/armnnTfParser/test/Assert.cpp299
-rw-r--r--src/armnnTfParser/test/BiasAdd.cpp104
-rw-r--r--src/armnnTfParser/test/BroadcastForAdd.cpp149
-rw-r--r--src/armnnTfParser/test/Concat.cpp183
-rw-r--r--src/armnnTfParser/test/ConcatOfConcats.cpp316
-rw-r--r--src/armnnTfParser/test/Constant.cpp321
-rw-r--r--src/armnnTfParser/test/Convolution2d.cpp444
-rw-r--r--src/armnnTfParser/test/DepthwiseConvolution2d.cpp190
-rw-r--r--src/armnnTfParser/test/Equal.cpp139
-rw-r--r--src/armnnTfParser/test/ExpandDims.cpp313
-rw-r--r--src/armnnTfParser/test/FullyConnected.cpp579
-rw-r--r--src/armnnTfParser/test/FusedBatchNorm.cpp212
-rw-r--r--src/armnnTfParser/test/Gather.cpp184
-rw-r--r--src/armnnTfParser/test/Greater.cpp139
-rw-r--r--src/armnnTfParser/test/Identity.cpp161
-rw-r--r--src/armnnTfParser/test/LocalResponseNormalization.cpp120
-rw-r--r--src/armnnTfParser/test/Maximum.cpp144
-rw-r--r--src/armnnTfParser/test/MaximumForLeakyRelu.cpp168
-rw-r--r--src/armnnTfParser/test/Mean.cpp178
-rw-r--r--src/armnnTfParser/test/Minimum.cpp165
-rw-r--r--src/armnnTfParser/test/MultiOutput.cpp144
-rw-r--r--src/armnnTfParser/test/Multiplication.cpp172
-rw-r--r--src/armnnTfParser/test/Pad.cpp107
-rw-r--r--src/armnnTfParser/test/PassThru.cpp52
-rw-r--r--src/armnnTfParser/test/Pooling.cpp186
-rw-r--r--src/armnnTfParser/test/RealDiv.cpp169
-rw-r--r--src/armnnTfParser/test/Reshape.cpp85
-rw-r--r--src/armnnTfParser/test/ResizeBilinear.cpp114
-rw-r--r--src/armnnTfParser/test/Rsqrt.cpp59
-rw-r--r--src/armnnTfParser/test/Shape.cpp93
-rw-r--r--src/armnnTfParser/test/Softmax.cpp55
-rw-r--r--src/armnnTfParser/test/Split.cpp398
-rw-r--r--src/armnnTfParser/test/Squeeze.cpp107
-rw-r--r--src/armnnTfParser/test/Stack.cpp174
-rw-r--r--src/armnnTfParser/test/StridedSlice.cpp283
-rw-r--r--src/armnnTfParser/test/Sub.cpp135
-rw-r--r--src/armnnTfParser/test/TestDependencies.cpp296
-rw-r--r--src/armnnTfParser/test/TestMultiInputsOutputs.cpp92
-rw-r--r--src/armnnTfParser/test/Transpose.cpp151
-rw-r--r--tests/CMakeLists.txt53
-rw-r--r--tests/ExecuteNetwork/ExecuteNetwork.cpp14
-rw-r--r--tests/ExecuteNetwork/ExecuteNetworkProgramOptions.cpp3
-rw-r--r--tests/ImageTensorGenerator/ImageTensorGenerator.hpp4
-rw-r--r--tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp8
-rw-r--r--tests/MultipleNetworksCifar10/MultipleNetworksCifar10.cpp4
-rw-r--r--tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp3
-rw-r--r--tests/TfCifar10-Armnn/TfCifar10-Armnn.cpp38
-rw-r--r--tests/TfCifar10-Armnn/Validation.txt1000
-rw-r--r--tests/TfInceptionV3-Armnn/TfInceptionV3-Armnn.cpp70
-rw-r--r--tests/TfInceptionV3-Armnn/Validation.txt201
-rw-r--r--tests/TfMnist-Armnn/TfMnist-Armnn.cpp39
-rw-r--r--tests/TfMnist-Armnn/Validation.txt1000
-rw-r--r--tests/TfMobileNet-Armnn/TfMobileNet-Armnn.cpp78
-rw-r--r--tests/TfMobileNet-Armnn/Validation.txt201
-rw-r--r--tests/TfMobileNet-Armnn/labels.txt1001
-rw-r--r--tests/TfResNext_Quantized-Armnn/TfResNext_Quantized-Armnn.cpp46
75 files changed, 15 insertions, 16030 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1234e69f5e..4f43a41f4d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -124,31 +124,6 @@ if(BUILD_ONNX_PARSER)
set_target_properties(armnnOnnxParser PROPERTIES VERSION ${ONNX_PARSER_LIB_VERSION} SOVERSION ${ONNX_PARSER_LIB_SOVERSION})
endif()
-if(BUILD_TF_PARSER)
- set(armnn_tf_parser_sources)
- list(APPEND armnn_tf_parser_sources
- include/armnnTfParser/ITfParser.hpp
- include/armnnTfParser/Version.hpp
- src/armnnTfParser/TfParser.hpp
- src/armnnTfParser/TfParser.cpp
- ${TF_PROTOBUFS}
- )
- # The generated tensorflow protobuf .cc files are not warning clean and we can't fix them.
- if(COMPILER_IS_GNU_LIKE)
- set_source_files_properties(${TF_PROTOBUFS} PROPERTIES COMPILE_FLAGS "-Wno-unused-variable -Wno-unused-parameter -Wno-conversion -Wno-sign-conversion -Wno-error=deprecated-declarations")
- endif()
-
- add_library_ex(armnnTfParser SHARED ${armnn_tf_parser_sources})
-
- target_include_directories(armnnTfParser PRIVATE src/armnnUtils)
-
- target_link_libraries(armnnTfParser armnn)
-
- # Protobuf (use the specific version tensorflow wants)
- target_link_libraries(armnnTfParser ${PROTOBUF_LIBRARIES})
- set_target_properties(armnnTfParser PROPERTIES VERSION ${TF_PARSER_LIB_VERSION} SOVERSION ${TF_PARSER_LIB_SOVERSION})
-endif()
-
list(APPEND armnn_sources
include/armnn/ArmNN.hpp
include/armnn/BackendHelper.hpp
@@ -539,11 +514,6 @@ if(BUILD_ONNX_PARSER)
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
-if(BUILD_TF_PARSER)
- install(TARGETS armnnTfParser
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
-endif()
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
@@ -655,54 +625,6 @@ if(BUILD_UNIT_TESTS)
)
endif()
- if(BUILD_TF_PARSER AND ARMNNREF)
- list(APPEND unittest_sources
- src/armnnTfParser/test/Activations.cpp
- src/armnnTfParser/test/Addition.cpp
- src/armnnTfParser/test/AddN.cpp
- src/armnnTfParser/test/Assert.cpp
- src/armnnTfParser/test/BiasAdd.cpp
- src/armnnTfParser/test/BroadcastForAdd.cpp
- src/armnnTfParser/test/Convolution2d.cpp
- src/armnnTfParser/test/Concat.cpp
- src/armnnTfParser/test/ConcatOfConcats.cpp
- src/armnnTfParser/test/DepthwiseConvolution2d.cpp
- src/armnnTfParser/test/Equal.cpp
- src/armnnTfParser/test/ExpandDims.cpp
- src/armnnTfParser/test/FusedBatchNorm.cpp
- src/armnnTfParser/test/Gather.cpp
- src/armnnTfParser/test/Greater.cpp
- src/armnnTfParser/test/Identity.cpp
- src/armnnTfParser/test/LocalResponseNormalization.cpp
- src/armnnTfParser/test/Maximum.cpp
- src/armnnTfParser/test/MaximumForLeakyRelu.cpp
- src/armnnTfParser/test/Mean.cpp
- src/armnnTfParser/test/Minimum.cpp
- src/armnnTfParser/test/Multiplication.cpp
- src/armnnTfParser/test/Pad.cpp
- src/armnnTfParser/test/MultiOutput.cpp
- src/armnnTfParser/test/PassThru.cpp
- src/armnnTfParser/test/Pooling.cpp
- src/armnnTfParser/test/RealDiv.cpp
- src/armnnTfParser/test/Reshape.cpp
- src/armnnTfParser/test/ResizeBilinear.cpp
- src/armnnTfParser/test/Rsqrt.cpp
- src/armnnTfParser/test/Shape.cpp
- src/armnnTfParser/test/Softmax.cpp
- src/armnnTfParser/test/TestDependencies.cpp
- src/armnnTfParser/test/FullyConnected.cpp
- src/armnnTfParser/test/Constant.cpp
- src/armnnTfParser/test/TestMultiInputsOutputs.cpp
- src/armnnTfParser/test/Split.cpp
- src/armnnTfParser/test/Squeeze.cpp
- src/armnnTfParser/test/Stack.cpp
- src/armnnTfParser/test/Sub.cpp
- src/armnnTfParser/test/StridedSlice.cpp
- src/armnnTfParser/test/Transpose.cpp
- )
-
- endif()
-
if(BUILD_TF_LITE_PARSER AND ARMNNREF)
list(APPEND unittest_sources
src/armnnTfLiteParser/test/Activations.cpp
@@ -885,10 +807,6 @@ if(BUILD_UNIT_TESTS)
target_link_libraries(UnitTests armnn)
target_link_libraries(UnitTests armnnUtils)
- if(BUILD_TF_PARSER)
- target_link_libraries(UnitTests armnnTfParser)
- endif()
-
if(BUILD_GATORD_MOCK)
target_link_libraries(UnitTests gatordMockService)
endif()
@@ -921,7 +839,7 @@ if(BUILD_UNIT_TESTS)
addDllCopyCommands(UnitTests)
endif()
-if (BUILD_ARMNN_SERIALIZER AND (BUILD_TF_PARSER OR BUILD_TF_LITE_PARSER OR BUILD_ONNX_PARSER) AND ARMNNREF)
+if (BUILD_ARMNN_SERIALIZER AND (BUILD_TF_LITE_PARSER OR BUILD_ONNX_PARSER) AND ARMNNREF)
set(ArmnnConverter_sources
src/armnnConverter/ArmnnConverter.cpp)
@@ -933,10 +851,6 @@ if (BUILD_ARMNN_SERIALIZER AND (BUILD_TF_PARSER OR BUILD_TF_LITE_PARSER OR BUILD
target_link_libraries(ArmnnConverter armnnOnnxParser)
endif()
- if(BUILD_TF_PARSER)
- target_link_libraries(ArmnnConverter armnnTfParser)
- endif()
-
if(BUILD_TF_LITE_PARSER)
target_link_libraries(ArmnnConverter armnnTfLiteParser)
endif()
diff --git a/cmake/AddDllCopyCommands.cmake b/cmake/AddDllCopyCommands.cmake
index 6190170dbc..b32215adc8 100644
--- a/cmake/AddDllCopyCommands.cmake
+++ b/cmake/AddDllCopyCommands.cmake
@@ -39,14 +39,6 @@ macro(addDllCopyCommands target)
addDllCopyCommand(${target} "$<TARGET_FILE_DIR:armnn>/armnn.dll" "$<TARGET_FILE_DIR:armnn>/armnn.dll")
endif()
- # armnnTfParser.dll
- if ("armnnTfParser" IN_LIST target_deps)
- addDllCopyCommand(${target} "$<TARGET_FILE_DIR:armnnTfParser>/armnnTfParser.dll"
- "$<TARGET_FILE_DIR:armnnTfParser>/armnnTfParser.dll")
- addDllCopyCommand(${target} "${PROTOBUF_ROOT}/bin/libprotobufd.dll"
- "${PROTOBUF_ROOT}/bin/libprotobuf.dll")
- endif()
-
# armnnTfLiteParser.dll
if ("armnnTfLiteParser" IN_LIST target_deps)
addDllCopyCommand(${target} "$<TARGET_FILE_DIR:armnnTfLiteParser>/armnnTfLiteParser.dll"
diff --git a/cmake/GlobalConfig.cmake b/cmake/GlobalConfig.cmake
index ca02284509..e932020bce 100644
--- a/cmake/GlobalConfig.cmake
+++ b/cmake/GlobalConfig.cmake
@@ -3,7 +3,6 @@
# Copyright 2020 NXP
# SPDX-License-Identifier: MIT
#
-option(BUILD_TF_PARSER "Build Tensorflow parser" OFF)
option(BUILD_ONNX_PARSER "Build Onnx parser" OFF)
option(BUILD_UNIT_TESTS "Build unit tests" ON)
option(BUILD_TESTS "Build test applications" OFF)
@@ -157,7 +156,7 @@ endif()
find_dependency(Threads)
# Favour the protobuf passed on command line
-if(BUILD_TF_PARSER OR BUILD_ONNX_PARSER)
+if(BUILD_ONNX_PARSER)
find_library(PROTOBUF_LIBRARY_DEBUG NAMES "protobufd"
PATHS ${PROTOBUF_ROOT}/lib
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
@@ -177,21 +176,7 @@ if(BUILD_TF_PARSER OR BUILD_ONNX_PARSER)
include_directories(SYSTEM "${PROTOBUF_INCLUDE_DIRS}")
add_definitions(-DPROTOBUF_USE_DLLS)
-endif()
-
-if(BUILD_TF_PARSER)
- add_definitions(-DARMNN_TF_PARSER)
- find_path(TF_GENERATED_SOURCES "tensorflow/core/protobuf/saved_model.pb.cc")
-
- # C++ sources generated for tf protobufs
- file(GLOB_RECURSE TF_PROTOBUFS "${TF_GENERATED_SOURCES}/*.pb.cc")
-
- # C++ headers generated for tf protobufs
- include_directories(SYSTEM "${TF_GENERATED_SOURCES}")
-endif()
-
-if(BUILD_ONNX_PARSER)
add_definitions(-DARMNN_ONNX_PARSER)
find_path(ONNX_GENERATED_SOURCES "onnx/onnx.pb.cc")
@@ -405,11 +390,6 @@ else()
endif()
-
-if(NOT BUILD_TF_PARSER)
- message(STATUS "Tensorflow parser support is disabled")
-endif()
-
if(NOT BUILD_TF_LITE_PARSER)
message(STATUS "Tensorflow Lite parser support is disabled")
endif()
diff --git a/cmake/ParserVersion.cmake b/cmake/ParserVersion.cmake
index 2120bf7057..44b1709880 100644
--- a/cmake/ParserVersion.cmake
+++ b/cmake/ParserVersion.cmake
@@ -32,20 +32,4 @@ set(TFLITE_PARSER_MINOR_VERSION ${CMAKE_MATCH_1})
set(TFLITE_PARSER_LIB_VERSION "${TFLITE_PARSER_MAJOR_VERSION}.${TFLITE_PARSER_MINOR_VERSION}")
# Define LIB soversion
-set(TFLITE_PARSER_LIB_SOVERSION "${TFLITE_PARSER_MAJOR_VERSION}")
-
-
-# Read the TfParser version components from file
-file(READ ${CMAKE_CURRENT_LIST_DIR}/../include/armnnTfParser/Version.hpp tfVersion)
-
-# Parse the TfParser version components
-string(REGEX MATCH "#define TF_PARSER_MAJOR_VERSION ([0-9]*)" _ ${tfVersion})
-set(TF_PARSER_MAJOR_VERSION ${CMAKE_MATCH_1})
-string(REGEX MATCH "#define TF_PARSER_MINOR_VERSION ([0-9]*)" _ ${tfVersion})
-set(TF_PARSER_MINOR_VERSION ${CMAKE_MATCH_1})
-
-# Define LIB version
-set(TF_PARSER_LIB_VERSION "${TF_PARSER_MAJOR_VERSION}.${TF_PARSER_MINOR_VERSION}")
-
-# Define LIB soversion
-set(TF_PARSER_LIB_SOVERSION "${TF_PARSER_MAJOR_VERSION}") \ No newline at end of file
+set(TFLITE_PARSER_LIB_SOVERSION "${TFLITE_PARSER_MAJOR_VERSION}") \ No newline at end of file
diff --git a/include/armnnTfParser/ITfParser.hpp b/include/armnnTfParser/ITfParser.hpp
deleted file mode 100644
index 91e4cb39bf..0000000000
--- a/include/armnnTfParser/ITfParser.hpp
+++ /dev/null
@@ -1,77 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-#pragma once
-
-#include "armnn/Types.hpp"
-#include "armnn/Tensor.hpp"
-#include "armnn/INetwork.hpp"
-
-#include <map>
-#include <memory>
-#include <unordered_map>
-#include <vector>
-
-namespace armnnTfParser
-{
-
-using BindingPointInfo = armnn::BindingPointInfo;
-
-class ITfParser;
-using ITfParserPtr = std::unique_ptr<ITfParser, void(*)(ITfParser* parser)>;
-
-/// Parses a directed acyclic graph from a tensorflow protobuf file.
-class ITfParser
-{
-public:
- static ITfParser* CreateRaw();
- static ITfParserPtr Create();
- static void Destroy(ITfParser* parser);
-
- /// Create the network from a protobuf text file on the disk.
- armnn::INetworkPtr CreateNetworkFromTextFile(
- const char* graphFile,
- const std::map<std::string, armnn::TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs);
-
- /// Create the network from a protobuf binary file on the disk.
- armnn::INetworkPtr CreateNetworkFromBinaryFile(
- const char* graphFile,
- const std::map<std::string, armnn::TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs);
-
- /// Create the network directly from protobuf text in a string. Useful for debugging/testing.
- armnn::INetworkPtr CreateNetworkFromString(
- const char* protoText,
- const std::map<std::string, armnn::TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs);
-
- /// Retrieve binding info (layer id and tensor info) for the network input identified by the given layer name.
- BindingPointInfo GetNetworkInputBindingInfo(const std::string& name) const;
-
- /// Retrieve binding info (layer id and tensor info) for the network output identified by the given layer name.
- BindingPointInfo GetNetworkOutputBindingInfo(const std::string& name) const;
-
-private:
- template <typename T>
- friend class ParsedConstTfOperation;
- friend class ParsedMatMulTfOperation;
- friend class ParsedMulTfOperation;
- friend class ParsedTfOperation;
- friend class SingleLayerParsedTfOperation;
- friend class DeferredSingleLayerParsedTfOperation;
- friend class ParsedIdentityTfOperation;
-
- template <template<typename> class OperatorType, typename T>
- friend struct MakeTfOperation;
-
-
- ITfParser();
- ~ITfParser();
-
- struct TfParserImpl;
- std::unique_ptr<TfParserImpl> pTfParserImpl;
-};
-
-}
diff --git a/include/armnnTfParser/Version.hpp b/include/armnnTfParser/Version.hpp
deleted file mode 100644
index 25449f3180..0000000000
--- a/include/armnnTfParser/Version.hpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//
-// Copyright © 2021 Arm Ltd and Contributors. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#pragma once
-
-namespace armnnTfParser
-{
-
-/// Macro utils
-#define STRINGIFY_VALUE(s) STRINGIFY_MACRO(s)
-#define STRINGIFY_MACRO(s) #s
-
-// tfParser version components
-#define TF_PARSER_MAJOR_VERSION 24
-#define TF_PARSER_MINOR_VERSION 1
-#define TF_PARSER_PATCH_VERSION 0
-
-/// TF_PARSER_VERSION: "X.Y.Z"
-/// where:
-/// X = Major version number
-/// Y = Minor version number
-/// Z = Patch version number
-#define TF_PARSER_VERSION STRINGIFY_VALUE(TF_PARSER_MAJOR_VERSION) "." \
- STRINGIFY_VALUE(TF_PARSER_MINOR_VERSION) "." \
- STRINGIFY_VALUE(TF_PARSER_PATCH_VERSION)
-
-} //namespace armnnTfParser
diff --git a/python/pyarmnn/examples/image_classification/example_utils.py b/python/pyarmnn/examples/image_classification/example_utils.py
index bd43d60da5..657f9d3559 100644
--- a/python/pyarmnn/examples/image_classification/example_utils.py
+++ b/python/pyarmnn/examples/image_classification/example_utils.py
@@ -72,7 +72,7 @@ def parse_command_line(desc: str = ""):
parser.add_argument("-d", "--data-dir", help="Data directory which contains all the images.",
action="store", default="")
parser.add_argument("-m", "--model-dir",
- help="Model directory which contains the model file (TF, TFLite, ONNX).", action="store",
+ help="Model directory which contains the model file (TFLite, ONNX).", action="store",
default="")
return parser.parse_args()
diff --git a/python/pyarmnn/setup.py b/python/pyarmnn/setup.py
index 9d9f561ef9..78868549f3 100755
--- a/python/pyarmnn/setup.py
+++ b/python/pyarmnn/setup.py
@@ -284,7 +284,6 @@ if __name__ == '__main__':
add_parsers_ext('OnnxParser', extensions_to_build)
- add_parsers_ext('TfParser', extensions_to_build)
add_parsers_ext('TfLiteParser', extensions_to_build)
add_parsers_ext('Deserializer', extensions_to_build)
diff --git a/python/pyarmnn/src/pyarmnn/__init__.py b/python/pyarmnn/src/pyarmnn/__init__.py
index 410e66be11..5cb8bfb6cd 100644
--- a/python/pyarmnn/src/pyarmnn/__init__.py
+++ b/python/pyarmnn/src/pyarmnn/__init__.py
@@ -22,19 +22,6 @@ except ImportError as err:
raise RuntimeError(message)
try:
- from ._generated.pyarmnn_tfparser import ITfParser
-except ImportError as err:
- logger = logging.getLogger(__name__)
- message = "Your ArmNN library instance does not support TF models parser functionality. "
- logger.warning("%s Skipped ITfParser import.", message)
- logger.debug(str(err))
-
-
- def ITfParser():
- """In case people try importing without having Arm NN built with this parser."""
- raise RuntimeError(message)
-
-try:
from ._generated.pyarmnn_tfliteparser import ITfLiteParser, TfLiteParserOptions
except ImportError as err:
logger = logging.getLogger(__name__)
diff --git a/python/pyarmnn/src/pyarmnn/swig/armnn_tfparser.i b/python/pyarmnn/src/pyarmnn/swig/armnn_tfparser.i
deleted file mode 100644
index 03729abbf8..0000000000
--- a/python/pyarmnn/src/pyarmnn/swig/armnn_tfparser.i
+++ /dev/null
@@ -1,102 +0,0 @@
-//
-// Copyright © 2020 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-%module pyarmnn_tfparser
-%{
-#define SWIG_FILE_WITH_INIT
-#include "armnnTfParser/ITfParser.hpp"
-#include "armnn/INetwork.hpp"
-%}
-
-//typemap definitions and other common stuff
-%include "standard_header.i"
-
-namespace std {
- %template(BindingPointInfo) pair<int, armnn::TensorInfo>;
- %template(MapStringTensorShape) map<std::string, armnn::TensorShape>;
- %template(StringVector) vector<string>;
-}
-
-namespace armnnTfParser
-{
-%feature("docstring",
-"
-Interface for creating a parser object using TensorFlow (https://www.tensorflow.org/) frozen pb files.
-
-Parsers are used to automatically construct Arm NN graphs from model files.
-
-") ITfParser;
-%nodefaultctor ITfParser;
-class ITfParser
-{
-public:
- %feature("docstring",
- "
- Retrieve binding info (layer id and `TensorInfo`) for the network input identified by the given layer name.
-
- Args:
- name (str): Name of the input.
-
- Returns:
- tuple: (`int`, `TensorInfo`).
- ") GetNetworkInputBindingInfo;
- std::pair<int, armnn::TensorInfo> GetNetworkInputBindingInfo(const std::string& name);
-
- %feature("docstring",
- "
- Retrieve binding info (layer id and `TensorInfo`) for the network output identified by the given layer name.
-
- Args:
- name (str): Name of the output.
-
- Returns:
- tuple: (`int`, `TensorInfo`).
- ") GetNetworkOutputBindingInfo;
- std::pair<int, armnn::TensorInfo> GetNetworkOutputBindingInfo(const std::string& name);
-};
-
-%extend ITfParser {
- // This is not a substitution of the default constructor of the Armnn class. It tells swig to create custom __init__
- // method for ITfParser python object that will use static factory method to do the job.
-
- ITfParser() {
- return armnnTfParser::ITfParser::CreateRaw();
- }
-
- // The following does not replace a real destructor of the Armnn class.
- // It creates a functions that will be called when swig object goes out of the scope to clean resources.
- // so the user doesn't need to call ITfParser::Destroy himself.
- // $self` is a pointer to extracted ArmNN ITfParser object.
-
- ~ITfParser() {
- armnnTfParser::ITfParser::Destroy($self);
- }
-
- %feature("docstring",
- "
- Create the network from a pb Protocol buffer file.
-
- Args:
- graphFile (str): Path to the tf model to be parsed.
- inputShapes (dict): A dict containing the input name as a key and `TensorShape` as a value.
- requestedOutputs (list of str): A list of the output tensor names.
-
- Returns:
- INetwork: Parsed network.
-
- Raises:
- RuntimeError: If model file was not found.
- ") CreateNetworkFromBinaryFile;
- %newobject CreateNetworkFromBinaryFile;
- armnn::INetwork* CreateNetworkFromBinaryFile(const char* graphFile,
- const std::map<std::string, armnn::TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs) {
- return $self->CreateNetworkFromBinaryFile(graphFile, inputShapes, requestedOutputs).release();
- }
-
-}
-
-}
-// Clear exception typemap.
-%exception;
diff --git a/python/pyarmnn/swig_generate.py b/python/pyarmnn/swig_generate.py
index a2352c9063..e6e2b346be 100755
--- a/python/pyarmnn/swig_generate.py
+++ b/python/pyarmnn/swig_generate.py
@@ -108,7 +108,6 @@ if __name__ == "__main__":
wrap_names = ['armnn_version',
'armnn',
'armnn_onnxparser',
- 'armnn_tfparser',
'armnn_tfliteparser',
'armnn_deserializer']
diff --git a/python/pyarmnn/test/test_generated.py b/python/pyarmnn/test/test_generated.py
index f27d565c2b..60d686afcb 100644
--- a/python/pyarmnn/test/test_generated.py
+++ b/python/pyarmnn/test/test_generated.py
@@ -9,7 +9,6 @@ import pyarmnn._generated.pyarmnn as generated_armnn
import pyarmnn._generated.pyarmnn as generated_deserializer
import pyarmnn._generated.pyarmnn_onnxparser as generated_onnx
import pyarmnn._generated.pyarmnn_tfliteparser as generated_tflite
-import pyarmnn._generated.pyarmnn_tfparser as generated_tf
swig_independent_classes = ('IBackend',
'IDeviceSpec',
@@ -28,8 +27,7 @@ def get_classes(swig_independent_classes: Tuple):
inspect.getmembers(generated_armnn, inspect.isclass) +
inspect.getmembers(generated_deserializer, inspect.isclass) +
inspect.getmembers(generated_tflite, inspect.isclass) +
- inspect.getmembers(generated_onnx, inspect.isclass) +
- inspect.getmembers(generated_tf, inspect.isclass)))
+ inspect.getmembers(generated_onnx, inspect.isclass)))
@pytest.mark.parametrize("class_instance", get_classes(swig_independent_classes), ids=lambda x: 'class={}'.format(x[0]))
diff --git a/python/pyarmnn/test/test_tf_parser.py b/python/pyarmnn/test/test_tf_parser.py
deleted file mode 100644
index 796dd71e7b..0000000000
--- a/python/pyarmnn/test/test_tf_parser.py
+++ /dev/null
@@ -1,133 +0,0 @@
-# Copyright © 2020 Arm Ltd. All rights reserved.
-# SPDX-License-Identifier: MIT
-import os
-
-import pytest
-import pyarmnn as ann
-import numpy as np
-
-
-@pytest.fixture()
-def parser(shared_data_folder):
- """
- Parse and setup the test network to be used for the tests below
- """
-
- # create tf parser
- parser = ann.ITfParser()
-
- # path to model
- path_to_model = os.path.join(shared_data_folder, 'mock_model.pb')
-
- # tensor shape [1, 28, 28, 1]
- tensorshape = {'input': ann.TensorShape((1, 28, 28, 1))}
-
- # requested_outputs
- requested_outputs = ["output"]
-
- # parse tf binary & create network
- parser.CreateNetworkFromBinaryFile(path_to_model, tensorshape, requested_outputs)
-
- yield parser
-
-
-def test_tf_parser_swig_destroy():
- assert ann.ITfParser.__swig_destroy__, "There is a swig python destructor defined"
- assert ann.ITfParser.__swig_destroy__.__name__ == "delete_ITfParser"
-
-
-def test_check_tf_parser_swig_ownership(parser):
- # Check to see that SWIG has ownership for parser. This instructs SWIG to take
- # ownership of the return value. This allows the value to be automatically
- # garbage-collected when it is no longer in use
- assert parser.thisown
-
-
-def test_tf_parser_get_network_input_binding_info(parser):
- input_binding_info = parser.GetNetworkInputBindingInfo("input")
-
- tensor = input_binding_info[1]
- assert tensor.GetDataType() == 1
- assert tensor.GetNumDimensions() == 4
- assert tensor.GetNumElements() == 28*28*1
- assert tensor.GetQuantizationOffset() == 0
- assert tensor.GetQuantizationScale() == 0
-
-
-def test_tf_parser_get_network_output_binding_info(parser):
- output_binding_info = parser.GetNetworkOutputBindingInfo("output")
-
- tensor = output_binding_info[1]
- assert tensor.GetDataType() == 1
- assert tensor.GetNumDimensions() == 2
- assert tensor.GetNumElements() == 10
- assert tensor.GetQuantizationOffset() == 0
- assert tensor.GetQuantizationScale() == 0
-
-
-def test_tf_filenotfound_exception(shared_data_folder):
- parser = ann.ITfParser()
-
- # path to model
- path_to_model = os.path.join(shared_data_folder, 'some_unknown_model.pb')
-
- # tensor shape [1, 1, 1, 1]
- tensorshape = {'input': ann.TensorShape((1, 1, 1, 1))}
-
- # requested_outputs
- requested_outputs = [""]
-
- # parse tf binary & create network
-
- with pytest.raises(RuntimeError) as err:
- parser.CreateNetworkFromBinaryFile(path_to_model, tensorshape, requested_outputs)
-
- # Only check for part of the exception since the exception returns
- # absolute path which will change on different machines.
- assert 'failed to open' in str(err.value)
-
-
-def test_tf_parser_end_to_end(shared_data_folder):
- parser = ann.ITfParser = ann.ITfParser()
-
- tensorshape = {'input': ann.TensorShape((1, 28, 28, 1))}
- requested_outputs = ["output"]
-
- network = parser.CreateNetworkFromBinaryFile(os.path.join(shared_data_folder, 'mock_model.pb'),
- tensorshape, requested_outputs)
-
- input_binding_info = parser.GetNetworkInputBindingInfo("input")
-
- # load test image data stored in input_tf.npy
- input_tensor_data = np.load(os.path.join(shared_data_folder, 'tf_parser/input_tf.npy')).astype(np.float32)
-
- preferred_backends = [ann.BackendId('CpuAcc'), ann.BackendId('CpuRef')]
-
- options = ann.CreationOptions()
- runtime = ann.IRuntime(options)
-
- opt_network, messages = ann.Optimize(network, preferred_backends, runtime.GetDeviceSpec(), ann.OptimizerOptions())
-
- assert 0 == len(messages)
-
- net_id, messages = runtime.LoadNetwork(opt_network)
-
- assert "" == messages
-
- input_tensors = ann.make_input_tensors([input_binding_info], [input_tensor_data])
-
- outputs_binding_info = []
-
- for output_name in requested_outputs:
- outputs_binding_info.append(parser.GetNetworkOutputBindingInfo(output_name))
-
- output_tensors = ann.make_output_tensors(outputs_binding_info)
-
- runtime.EnqueueWorkload(net_id, input_tensors, output_tensors)
- output_vectors = ann.workload_tensors_to_ndarray(output_tensors)
-
- # Load golden output file for result comparison.
- golden_output = np.load(os.path.join(shared_data_folder, 'tf_parser/golden_output_tf.npy'))
-
- # Check that output matches golden output to 4 decimal places (there are slight rounding differences after this)
- np.testing.assert_almost_equal(output_vectors[0], golden_output, decimal=4)
diff --git a/src/armnnConverter/ArmnnConverter.cpp b/src/armnnConverter/ArmnnConverter.cpp
index 6f05325bba..c1190d8bdb 100644
--- a/src/armnnConverter/ArmnnConverter.cpp
+++ b/src/armnnConverter/ArmnnConverter.cpp
@@ -10,9 +10,6 @@
#if defined(ARMNN_SERIALIZER)
#include <armnnSerializer/ISerializer.hpp>
#endif
-#if defined(ARMNN_TF_PARSER)
-#include <armnnTfParser/ITfParser.hpp>
-#endif
#if defined(ARMNN_TF_LITE_PARSER)
#include <armnnTfLiteParser/ITfLiteParser.hpp>
#endif
@@ -405,19 +402,6 @@ int main(int argc, char* argv[])
return EXIT_FAILURE;
#endif
}
- else if (modelFormat.find("tensorflow") != std::string::npos)
- {
-#if defined(ARMNN_TF_PARSER)
- if (!converter.CreateNetwork<armnnTfParser::ITfParser>())
- {
- ARMNN_LOG(fatal) << "Failed to load model from file";
- return EXIT_FAILURE;
- }
-#else
- ARMNN_LOG(fatal) << "Not built with Tensorflow parser support.";
- return EXIT_FAILURE;
-#endif
- }
else if (modelFormat.find("tflite") != std::string::npos)
{
#if defined(ARMNN_TF_LITE_PARSER)
diff --git a/src/armnnTfParser/TfParser.cpp b/src/armnnTfParser/TfParser.cpp
deleted file mode 100755
index 1e566fe943..0000000000
--- a/src/armnnTfParser/TfParser.cpp
+++ /dev/null
@@ -1,3745 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "TfParser.hpp"
-
-#include "armnnTfParser/Version.hpp"
-
-#include <armnn/TypesUtils.hpp>
-#include <armnn/Descriptors.hpp>
-
-#include <armnnUtils/Permute.hpp>
-#include <armnnUtils/DataLayoutIndexed.hpp>
-#include <armnnUtils/Transpose.hpp>
-#include <armnn/utility/IgnoreUnused.hpp>
-#include <armnn/utility/NumericCast.hpp>
-#include <armnn/utility/PolymorphicDowncast.hpp>
-
-#include <GraphTopologicalSort.hpp>
-#include <ParserHelper.hpp>
-
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <google/protobuf/text_format.h>
-
-#include <tensorflow/core/framework/graph.pb.h>
-
-#include <fmt/core.h>
-#include <fmt/format.h>
-#include <iostream>
-#include <numeric>
-
-using namespace armnnUtils;
-using namespace armnn;
-
-namespace armnnTfParser
-{
-
-ITfParser::ITfParser() : pTfParserImpl(new ITfParser::TfParserImpl()){}
-
-ITfParser::~ITfParser() = default;
-
-ITfParser *ITfParser::CreateRaw()
-{
- return new ITfParser();
-}
-
-ITfParserPtr ITfParser::Create()
-{
- return ITfParserPtr(CreateRaw(), &ITfParser::Destroy);
-}
-
-void ITfParser::Destroy(ITfParser *parser)
-{
- delete parser;
-}
-
-armnn::INetworkPtr ITfParser::CreateNetworkFromTextFile(const char* graphFile,
- const std::map<std::string, armnn::TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs)
-{
- return pTfParserImpl->CreateNetworkFromTextFile(graphFile, inputShapes, requestedOutputs);
-}
-
-armnn::INetworkPtr ITfParser::CreateNetworkFromBinaryFile(const char* graphFile,
- const std::map<std::string, armnn::TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs)
-{
- return pTfParserImpl->CreateNetworkFromBinaryFile(graphFile, inputShapes, requestedOutputs);
-}
-
-armnn::INetworkPtr ITfParser::CreateNetworkFromString(const char* protoText,
- const std::map<std::string, armnn::TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs)
-{
- return pTfParserImpl->CreateNetworkFromString(protoText, inputShapes, requestedOutputs);
-}
-
-BindingPointInfo ITfParser::GetNetworkInputBindingInfo(const std::string& name) const
-{
- return pTfParserImpl->GetNetworkInputBindingInfo(name);
-}
-
-BindingPointInfo ITfParser::GetNetworkOutputBindingInfo(const std::string& name) const
-{
- return pTfParserImpl->GetNetworkOutputBindingInfo(name);
-}
-namespace
-{
-
-const PermutationVector NHWCToArmNN = { 0, 2, 3, 1 };
-const PermutationVector ArmNNToNHWC = { 0, 3, 1, 2 };
-
-
-template <typename Callable>
-void ReadMandatoryNodeAttributeImpl(const tensorflow::NodeDef& nodeDef,
- const std::string& attribName,
- tensorflow::AttrValue::ValueCase expectedValueCase,
- Callable callable)
-{
- auto iter = nodeDef.attr().find(attribName);
- if (iter != nodeDef.attr().end())
- {
- const auto& attrValue = iter->second;
- if (attrValue.value_case() == expectedValueCase)
- {
- callable(attrValue);
- }
- else
- {
- throw ParseException(
- fmt::format("Attribute {} of node {} expected to have {} as tensorflow::AttrValue::ValueCase, "
- "but found {} instead {}",
- attribName,
- nodeDef.name(),
- static_cast<int>(expectedValueCase),
- static_cast<int>(attrValue.value_case()),
- CHECK_LOCATION().AsString()));
- }
- }
- else
- {
- throw ParseException(
- fmt::format("Could not find required attribute {} in node {} {}",
- attribName,
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-}
-
-template <typename Callable>
-void ReadOptionalNodeAttributeImpl(const tensorflow::NodeDef& nodeDef,
- const std::string& attribName,
- tensorflow::AttrValue::ValueCase expectedValueCase,
- Callable callable)
-{
- auto iter = nodeDef.attr().find(attribName);
- if (iter != nodeDef.attr().end())
- {
- const auto& attrValue = iter->second;
- if (attrValue.value_case() == expectedValueCase)
- {
- callable(attrValue);
- }
- else
- {
- throw ParseException(
- fmt::format("Attribute {} of node {} expected to have {} as tensorflow::AttrValue::ValueCase, "
- "but found {} instead {}",
- attribName,
- nodeDef.name(),
- static_cast<int>(expectedValueCase),
- static_cast<int>(attrValue.value_case()),
- CHECK_LOCATION().AsString()));
- }
- }
-}
-
-float ReadMandatoryNodeFloatAttribute(const tensorflow::NodeDef& nodeDef, const std::string& name)
-{
- float attribValue = 0.0f;
- ReadMandatoryNodeAttributeImpl(nodeDef, name, tensorflow::AttrValue::kF,
- [&attribValue](const tensorflow::AttrValue& attrValue)
- {
- attribValue = attrValue.f();
- });
- return attribValue;
-}
-
-int32_t ReadMandatoryNodeInt32Attribute(const tensorflow::NodeDef& nodeDef, const std::string& name)
-{
- int32_t attribValue = 0u;
- ReadMandatoryNodeAttributeImpl(nodeDef, name, tensorflow::AttrValue::kI,
- [&attribValue](const tensorflow::AttrValue& attrValue)
- {
- attribValue = static_cast<int32_t>(attrValue.i());
- });
- return attribValue;
-}
-
-bool ReadMandatoryNodeBoolAttribute(const tensorflow::NodeDef& nodeDef, const std::string& name)
-{
- bool attribValue = false;
- ReadMandatoryNodeAttributeImpl(nodeDef, name, tensorflow::AttrValue::kB,
- [&attribValue](const tensorflow::AttrValue& attrValue)
- {
- attribValue = static_cast<bool>(attrValue.b());
- });
- return attribValue;
-}
-
-uint32_t ReadMandatoryNodeUint32Attribute(const tensorflow::NodeDef& nodeDef, const std::string& name)
-{
- uint32_t attribValue = 0u;
- ReadMandatoryNodeAttributeImpl(nodeDef, name, tensorflow::AttrValue::kI,
- [&attribValue](const tensorflow::AttrValue& attrValue)
- {
- attribValue = static_cast<uint32_t>(attrValue.i());
- });
- return attribValue;
-}
-
-std::string ReadMandatoryNodeStringAttribute(const tensorflow::NodeDef& nodeDef, const std::string& name)
-{
- std::string attribValue = "";
- ReadMandatoryNodeAttributeImpl(nodeDef, name, tensorflow::AttrValue::kS,
- [&attribValue](const tensorflow::AttrValue& attrValue)
- {
- attribValue = attrValue.s();
- });
- return attribValue;
-}
-
-std::vector<uint32_t> ReadMandatoryNodeUint32ListAttribute(const tensorflow::NodeDef& nodeDef,
- const std::string& name)
-{
- std::vector<uint32_t> attriList;
- ReadMandatoryNodeAttributeImpl(nodeDef, name, tensorflow::AttrValue::kList,
- [&attriList](const tensorflow::AttrValue& attrValue)
- {
- for (int attriNum = 0; attriNum < attrValue.list().i_size(); ++attriNum)
- {
- attriList.push_back(static_cast<uint32_t>(attrValue.list().i(attriNum)));
- }
- });
-
- return attriList;
-}
-
-std::vector<uint32_t> ReadOptionalNodeUint32ListAttribute(const tensorflow::NodeDef& nodeDef,
- const std::string& name)
-{
- std::vector<uint32_t> attriList;
- ReadOptionalNodeAttributeImpl(nodeDef, name, tensorflow::AttrValue::kList,
- [&attriList](const tensorflow::AttrValue& attrValue)
- {
- for (int attriNum = 0; attriNum < attrValue.list().i_size(); ++attriNum)
- {
- attriList.push_back(static_cast<uint32_t>(attrValue.list().i(attriNum)));
- }
- });
-
- return attriList;
-}
-
-std::string ReadOptionalNodeStringAttribute(const tensorflow::NodeDef& nodeDef,
- const std::string& name,
- const std::string& defaultValue = "")
-{
- std::string attribValue = defaultValue;
- ReadOptionalNodeAttributeImpl(nodeDef, name, tensorflow::AttrValue::kS,
- [&attribValue](const tensorflow::AttrValue& attrValue)
- {
- attribValue = attrValue.s();
- });
- return attribValue;
-}
-
-bool ReadOptionalNodeBoolAttribute(const tensorflow::NodeDef& nodeDef,
- const std::string& name,
- bool defaultValue = false)
-{
- bool attribValue = defaultValue;
- ReadOptionalNodeAttributeImpl(nodeDef, name, tensorflow::AttrValue::kB,
- [&attribValue](const tensorflow::AttrValue& attrValue)
- {
- attribValue = attrValue.b();
- });
- return attribValue;
-}
-
-tensorflow::DataType ReadMandatoryNodeTypeAttribute(const tensorflow::NodeDef& nodeDef, const std::string& name)
-{
- tensorflow::DataType attribValue = tensorflow::DT_INVALID;
- ReadMandatoryNodeAttributeImpl(nodeDef, name, tensorflow::AttrValue::kType,
- [&attribValue](const tensorflow::AttrValue& attrValue)
- {
- attribValue = attrValue.type();
- });
- return attribValue;
-}
-
-TensorInfo PrepareReshape(const TensorInfo& input, const std::vector<int32_t>& targetDims)
-{
- std::vector<unsigned int> outDims(targetDims.begin(), targetDims.end());
- const auto stretchDim = std::find(targetDims.begin(), targetDims.end(), -1);
-
- if (stretchDim != targetDims.end())
- {
- if (std::find(std::next(stretchDim), targetDims.end(), -1) != targetDims.end())
- {
- throw ParseException(
- fmt::format("At most one component of shape can be -1 {}",
- CHECK_LOCATION().AsString()));
- }
-
- auto targetNumElements =
- armnn::numeric_cast<unsigned int>(
- std::accumulate(targetDims.begin(), targetDims.end(), -1, std::multiplies<int32_t>()));
- auto stretchIndex = static_cast<size_t>(std::distance(targetDims.begin(), stretchDim));
- outDims[stretchIndex] = input.GetNumElements() / targetNumElements;
- }
-
- TensorInfo reshapeInfo = input;
- reshapeInfo.SetShape(TensorShape{ static_cast<unsigned int>(outDims.size()), outDims.data() });
-
- return reshapeInfo;
-}
-
-// We need the input0Slot to guide the reshape for input1Slot.
-IOutputSlot* AddBroadcastReshapeLayer(IOutputSlot* input0Slot, IOutputSlot* input1Slot, bool isNHWC,
- INetwork& m_Network, const tensorflow::NodeDef& nodeDef)
-{
- const TensorInfo& input1Info = input1Slot->GetTensorInfo();
- const TensorInfo inputTensorInfo = input0Slot->GetTensorInfo();
- const unsigned int matchDim = inputTensorInfo.GetNumDimensions() - (isNHWC ? 1 : 3);
- std::array<unsigned int, MaxNumOfTensorDimensions> reshapedDimensions;
- std::fill_n(reshapedDimensions.begin(), inputTensorInfo.GetNumDimensions(), 1);
- reshapedDimensions[matchDim] = input1Info.GetShape()[0];
-
- armnn::TensorInfo reshapedInfo = input1Info;
- reshapedInfo.SetShape(TensorShape{ inputTensorInfo.GetNumDimensions(), reshapedDimensions.data() });
-
- const std::string reshapeLayerName = "reshape_for-" + nodeDef.name();
- ReshapeDescriptor reshapeDesc;
- reshapeDesc.m_TargetShape = reshapedInfo.GetShape();
- IConnectableLayer* const reshapeLayer = m_Network.AddReshapeLayer(reshapeDesc, reshapeLayerName.c_str());
-
- input1Slot->Connect(reshapeLayer->GetInputSlot(0));
- reshapeLayer->GetOutputSlot(0).SetTensorInfo(reshapedInfo);
-
- input1Slot = &reshapeLayer->GetOutputSlot(0);
-
- return input1Slot;
-}
-
-OutputId ParseOutputId(const std::string & name)
-{
- unsigned int outputNum = 0;
- size_t colonPos = name.find_last_of(":");
- if (colonPos != std::string::npos)
- {
- int n = std::stoi(name.substr(colonPos+1));
- if (n<0 || n>100)
- {
- throw ParseException(
- fmt::format("Output tensor id is out of range for {} {}",
- name,
- CHECK_LOCATION().AsString()));
- }
- outputNum = static_cast<unsigned int>(n);
- }
- return OutputId(name.substr(0,colonPos),outputNum);
-}
-
-#define CHECK_DATA_FORMAT(NODE_DEF, FORMAT, NODE_TYPE) \
- if( FORMAT != "NHWC" && FORMAT != "NCHW" ) \
- { \
- throw ParseException( \
- fmt::format("Unsupported data format {} passed for {} node {}. " \
- "Only NHWC and NCHW supported {}", \
- FORMAT, \
- NODE_TYPE, \
- NODE_DEF.name(), \
- CHECK_LOCATION().AsString())); \
- }
-
-#define CHECK_PADDING_TYPE(NODE_DEF, PADDING) \
- if(PADDING != "SAME" && PADDING != "VALID" ) \
- { \
- throw ParseException( \
- fmt::format("Only 'SAME' and 'VALID' padding supported. Got {} for {} {}", \
- PADDING, \
- NODE_DEF.name(), \
- CHECK_LOCATION().AsString())); \
- } \
-
-} // namespace
-
-const std::map<std::string, ITfParser::TfParserImpl::OperationParsingFunction>
- ITfParser::TfParserImpl::ms_OperationNameToParsingFunctions = {
- { "Const", &TfParserImpl::ParseConst },
- { "Add", &TfParserImpl::ParseAdd },
- { "AddN", &TfParserImpl::ParseAddN },
- { "BiasAdd", &TfParserImpl::ParseBiasAdd },
- { "Identity", &TfParserImpl::ParseIdentity },
- { "Conv2D", &TfParserImpl::ParseConv2D },
- { "DepthwiseConv2dNative", &TfParserImpl::ParseDepthwiseConv2D },
- { "ExpandDims", &TfParserImpl::ParseExpandDims },
- { "FusedBatchNorm", &TfParserImpl::ParseFusedBatchNorm },
- { "Gather", &TfParserImpl::ParseGather},
- { "Greater", &TfParserImpl::ParseGreater},
- { "ConcatV2", &TfParserImpl::ParseConcat },
- { "LRN", &TfParserImpl::ParseLrn },
- { "MatMul", &TfParserImpl::ParseMatMul },
- { "Mean", &TfParserImpl::ParseMean },
- { "Mul", &TfParserImpl::ParseMul },
- { "Placeholder", &TfParserImpl::ParsePlaceholder },
- { "RealDiv", &TfParserImpl::ParseRealDiv },
- { "Relu", &TfParserImpl::ParseRelu },
- { "Relu6", &TfParserImpl::ParseRelu6 },
- { "Reshape", &TfParserImpl::ParseReshape },
- { "ResizeBilinear", &TfParserImpl::ParseResizeBilinear },
- { "Rsqrt", &TfParserImpl::ParseRsqrt },
- { "Shape", &TfParserImpl::ParseShape },
- { "Squeeze", &TfParserImpl::ParseSqueeze },
- { "Sigmoid", &TfParserImpl::ParseSigmoid },
- { "Softmax", &TfParserImpl::ParseSoftmax },
- { "Softplus", &TfParserImpl::ParseSoftplus },
- { "Split", &TfParserImpl::ParseSplit },
- { "StridedSlice", &TfParserImpl::ParseStridedSlice },
- { "Tanh", &TfParserImpl::ParseTanh },
- { "MaxPool", &TfParserImpl::ParseMaxPool },
- { "AvgPool", &TfParserImpl::ParseAvgPool },
- { "Maximum", &TfParserImpl::ParseMaximum },
- { "Minimum", &TfParserImpl::ParseMinimum },
- { "Equal", &TfParserImpl::ParseEqual },
- { "Pad", &TfParserImpl::ParsePad },
- { "Sub", &TfParserImpl::ParseSub },
- { "Pack" , &TfParserImpl::ParseStack },
- { "Stack", &TfParserImpl::ParseStack },
- { "Transpose", &TfParserImpl::ParseTranspose },
-};
-
-const std::list<std::string> ITfParser::TfParserImpl::m_ControlInputs = {
- "Assert"
-};
-
-void CalcPadding(uint32_t inputSize,
- uint32_t filterSize,
- uint32_t stride,
- uint32_t dilation,
- uint32_t& paddingFront,
- uint32_t& paddingBack,
- bool samePadding)
-{
- paddingFront = 0;
- paddingBack = 0;
- if (samePadding)
- {
- uint32_t outputSize = (inputSize + stride - 1) / stride;
- uint32_t dilatedSize = filterSize + (dilation - 1) * (filterSize - 1);
- uint32_t temp = (outputSize - 1) * stride + dilatedSize;
- if (temp > inputSize)
- {
- paddingFront = (temp - inputSize) / 2;
- paddingBack = (temp - inputSize) - paddingFront;
- }
- }
-}
-
-/// An Abstract base class which represents a single tensorflow operation (node)
-/// that has been (potentially partially) converted to Armnn.
-/// It may not yet have been fully converted into actual Armnn layers.
-class ParsedTfOperation
-{
-public:
- ParsedTfOperation(ITfParser::TfParserImpl* parser, const tensorflow::NodeDef& node)
- : m_Parser(parser)
- , m_Node(node)
- {
- }
-
- virtual ~ParsedTfOperation() {};
-
- const tensorflow::NodeDef& GetNode() const { return m_Node; }
-
- /// Gets the ArmNN IOutputSlot corresponding to the given output index of the Tensorflow operation.
- /// This may result in the creation of Armnn layers if this was deferred (e.g. see ParsedConstTfOperation).
- virtual IOutputSlot& ResolveArmnnOutputSlot(unsigned int tfOutputIndex) = 0;
-
- /// If this operation is an Identity then this will follow return the 'parent' operation (recursively).
- virtual ParsedTfOperation* ResolveIdentityOperations()
- {
- return this;
- }
-
-protected:
- ITfParser::TfParserImpl* m_Parser;
- const tensorflow::NodeDef& m_Node;
-};
-
-/// An ParsedTfOperation where the Armnn equivalent is a single layer,
-/// with output slots that correspond directly to the Tf node outputs.
-class SingleLayerParsedTfOperation : public ParsedTfOperation
-{
-public:
- SingleLayerParsedTfOperation(ITfParser::TfParserImpl* parser,
- const tensorflow::NodeDef& node,
- IConnectableLayer* layer)
- : ParsedTfOperation(parser, node)
- , m_Layer(layer)
- {
- }
-
- IOutputSlot& ResolveArmnnOutputSlot(unsigned int tfOutputIndex) override
- {
- ARMNN_ASSERT(m_Layer);
- // Assumes one-to-one mapping between Tf and armnn output slots.
- unsigned int armnnOutputSlotIdx = tfOutputIndex;
- if (armnnOutputSlotIdx >= m_Layer->GetNumOutputSlots())
- {
- throw ParseException(
- fmt::format("The requested output slot #{} "
- "for {} does not exist {}",
- armnnOutputSlotIdx,
- m_Layer->GetName(),
- CHECK_LOCATION().AsString()));
- }
- return m_Layer->GetOutputSlot(armnnOutputSlotIdx);
- }
-
-protected:
- IConnectableLayer* m_Layer;
-};
-
-/// A SingleLayerParsedTfOperation for deferred layer creation.
-class DeferredSingleLayerParsedTfOperation : public SingleLayerParsedTfOperation
-{
-public:
- DeferredSingleLayerParsedTfOperation(ITfParser::TfParserImpl* parser, const tensorflow::NodeDef& node)
- : SingleLayerParsedTfOperation(parser, node, nullptr)
- {
- }
-
- IOutputSlot& ResolveArmnnOutputSlot(unsigned int tfOutputIndex) override
- {
- if (!m_Layer)
- {
- CreateLayerDeferred();
- }
- return SingleLayerParsedTfOperation::ResolveArmnnOutputSlot(tfOutputIndex);
- }
-
-private:
- virtual void CreateLayerDeferred() = 0;
-};
-
-
-ITfParser::TfParserImpl::TfParserImpl()
- : m_Network(nullptr, nullptr)
-{
-}
-
-
-const tensorflow::NodeDef* ITfParser::TfParserImpl::ResolveIdentityNode(const tensorflow::NodeDef* nodeDef)
-{
- if (nodeDef->op() != "Identity")
- {
- return nodeDef;
- }
-
- if (nodeDef->input_size() != 1)
- {
- throw ParseException(
- fmt::format("Identity node should have a single input! {} has {} inputs {}",
- nodeDef->name(),
- nodeDef->input_size(),
- CHECK_LOCATION().AsString()));
- }
-
- auto it = m_NodesByName.find(nodeDef->input(0));
- if (it != m_NodesByName.end())
- {
- const tensorflow::NodeDef* inputNode = it->second;
- return ResolveIdentityNode(inputNode);
- }
- else
- {
- throw ParseException(
- fmt::format("Cannot find what the Identity node {} is linked to! {}",
- nodeDef->name(),
- CHECK_LOCATION().AsString()));
- }
-}
-
-std::vector<OutputOfConstNodeDef>
-ITfParser::TfParserImpl::GetTfInputNodes(const tensorflow::NodeDef& nodeDef) const
-{
- std::vector<OutputOfConstNodeDef> ret;
-
- if (nodeDef.op() == "Const")
- {
- // For some reason const node can have "Control Inputs". We ignore them for now.
- return ret;
- }
-
- ret.reserve(armnn::numeric_cast<size_t>(nodeDef.input_size()));
- for (int j = 0; j < nodeDef.input_size(); ++j)
- {
- OutputId outputId = ParseOutputId(nodeDef.input(j));
-
- if (nodeDef.input(j)[0] == '^') // I couldn't find a better test for control inputs.
- {
- // We currently allow Control Input from TensorFlow graph but we ignore them from ArmNN graph.
- continue;
- }
-
- auto inputIt = m_NodesByName.find(outputId.m_IndexedValue);
- if (inputIt == m_NodesByName.end())
- {
- throw ParseException(
- fmt::format("Can't find node '{}', which is listed as an input of '{}' {}",
- nodeDef.input(j),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
- ret.push_back(OutputOfConstNodeDef(inputIt->second,outputId.m_Index));
- }
-
- return ret;
-}
-
-std::vector<OutputOfParsedTfOperation>
-ITfParser::TfParserImpl::GetInputParsedTfOperationsChecked(const tensorflow::NodeDef& nodeDef,
- std::size_t expectedNumInputs)
-{
- // Fetches the tensorflow nodes connected as inputs and validate the size.
- std::vector<OutputOfConstNodeDef> nodes = GetTfInputNodes(nodeDef);
- const std::size_t numInputs = nodes.size();
- if (numInputs != expectedNumInputs)
- {
- throw ParseException(
- fmt::format("Unexpected number of inputs for node {}. Expected {}, found {} {}",
- nodeDef.name(),
- expectedNumInputs,
- numInputs,
- CHECK_LOCATION().AsString()));
- }
- // Fetches the corresponding ParsedTfOperation operations
- std::vector<OutputOfParsedTfOperation> result;
- for (auto&& node : nodes)
- {
- auto it = m_ParsedTfOperations.find(node.m_IndexedValue->name());
- if (it == m_ParsedTfOperations.end())
- {
- throw ParseException(
- fmt::format("Node with name '{}' has not been parsed {}",
- node.m_IndexedValue->name(),
- CHECK_LOCATION().AsString()));
- }
- ParsedTfOperation* parsedOp = it->second.get();
- // Transparently 'skip' any Identity operations. This simplifies the logic inside the ParseXXX() functions.
- parsedOp = parsedOp->ResolveIdentityOperations();
- result.push_back(OutputOfParsedTfOperation(parsedOp,node.m_Index));
- }
- return result;
-}
-
-IConnectableLayer* ITfParser::TfParserImpl::CreateAdditionLayer(
- const tensorflow::NodeDef& nodeDef,
- IOutputSlot* input0Slot,
- IOutputSlot* input1Slot,
- const std::string& layerName)
-{
- const TensorInfo& input0Info = input0Slot->GetTensorInfo();
- const TensorInfo& input1Info = input1Slot->GetTensorInfo();
-
- const unsigned int input0Dim = input0Info.GetNumDimensions();
- const unsigned int input1Dim = input1Info.GetNumDimensions();
- if (input0Dim != input1Dim)
- {
- // broadcasting where input0 and input1 have different number of dimensions
- // is only supported for 1D and 4D tensors pair
- if (input0Dim == 1 && input1Dim == 4)
- {
- input0Slot = AddBroadcastReshapeLayer(input1Slot, input0Slot, true, *m_Network, nodeDef);
- }
- else if (input0Dim == 4 && input1Dim == 1)
- {
- input1Slot = AddBroadcastReshapeLayer(input0Slot, input1Slot, true, *m_Network, nodeDef);
- }
- else
- {
- throw ParseException(
- fmt::format("Unsupported broadcast configuration for {} operation {} {}",
- layerName,
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
- }
- IConnectableLayer* const layer = m_Network->AddAdditionLayer(layerName.c_str());
-
- input0Slot->Connect(layer->GetInputSlot(0));
- input1Slot->Connect(layer->GetInputSlot(1));
-
- // Ensure the output tensor has the correct dimensions even if a broadcast has been done
- TensorInfo outputInfo = input0Slot->GetTensorInfo();
- std::vector<unsigned int> outputShape;
-
- const TensorShape& input0Shape = input0Slot->GetTensorInfo().GetShape();
- const TensorShape& input1Shape = input1Slot->GetTensorInfo().GetShape();
-
- for (unsigned int i = 0; i < input0Shape.GetNumDimensions(); i++)
- {
- outputShape.push_back(std::max(input0Shape[i], input1Shape[i]));
- }
-
- outputInfo.SetShape(TensorShape(input0Shape.GetNumDimensions(), outputShape.data()));
- layer->GetOutputSlot(0).SetTensorInfo(outputInfo);
-
- return layer;
-}
-
-IConnectableLayer* ITfParser::TfParserImpl::CreateAdditionLayer(
- const tensorflow::NodeDef& nodeDef,
- IConnectableLayer* layerOne,
- IConnectableLayer* layerTwo,
- unsigned int numberOfAddition,
- unsigned long numberOfLayersToConnect,
- bool isOdd)
-{
- IOutputSlot* input0Slot = &layerOne->GetOutputSlot(0);
- IOutputSlot* input1Slot = &layerTwo->GetOutputSlot(0);
- std::string layerName(nodeDef.name());
- if (isOdd || numberOfLayersToConnect != 2)
- {
- // we are not connecting the final layer
- layerName.append("_addN_").append(std::to_string(numberOfAddition));
- }
- return CreateAdditionLayer(nodeDef, input0Slot, input1Slot, layerName);
-}
-
-IConnectableLayer* ITfParser::TfParserImpl::CreateAdditionLayer(
- const tensorflow::NodeDef& nodeDef,
- const OutputOfParsedTfOperation& opOne,
- const OutputOfParsedTfOperation& opTwo,
- unsigned int numberOfAddition)
-{
- IOutputSlot* input0Slot = &opOne.m_IndexedValue->ResolveArmnnOutputSlot(opOne.m_Index);
- IOutputSlot* input1Slot = &opTwo.m_IndexedValue->ResolveArmnnOutputSlot(opTwo.m_Index);
- std::string layerName(nodeDef.name());
- layerName.append("_addN_").append(std::to_string(numberOfAddition));
- return CreateAdditionLayer(nodeDef, input0Slot, input1Slot, layerName);
-}
-
-IConnectableLayer* ITfParser::TfParserImpl::CreateAdditionLayer(
- const tensorflow::NodeDef& nodeDef,
- const OutputOfParsedTfOperation& op,
- IConnectableLayer* layer)
-{
- IOutputSlot* input0Slot = &op.m_IndexedValue->ResolveArmnnOutputSlot(op.m_Index);
- IOutputSlot* input1Slot = &layer->GetOutputSlot(0);
- return CreateAdditionLayer(nodeDef, input0Slot, input1Slot, nodeDef.name());
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseAddN(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- uint32_t numberOfInputs = ReadMandatoryNodeUint32Attribute(nodeDef, "N");
- if (numberOfInputs < 2)
- {
- // should never happen
- throw ParseException(
- fmt::format("AddN Node with name '{}' has less than two ({}) inputs {}",
- nodeDef.name(),
- std::to_string(numberOfInputs),
- CHECK_LOCATION().AsString()));
- }
- else if (numberOfInputs == 2)
- {
- //this is the same as a simple Add operation
- return AddAdditionLayer(nodeDef, false);
- }
- else
- {
- // build a binary tree of Add layers and return the final Add as the return from the function
- // if we have an odd number of inputs then the final Add will consist of a layer connecting to an
- // OutputOfParsedTfOperation, otherwise it will be two layers being added together
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, numberOfInputs);
- unsigned int numberOfAdditions = 0;
- std::vector<IConnectableLayer*> layers;
- // NOTE: at this point we will have a minimum of three inputs
- for (unsigned int i = 0; i < numberOfInputs; ++i)
- {
- // every time i is odd we have two inputs to process.
- bool onSecondItem = i % 2;
- if (onSecondItem)
- {
- ++numberOfAdditions;
- IConnectableLayer* newLayer = CreateAdditionLayer(
- nodeDef, inputs[ i - 1], inputs[i], numberOfAdditions);
- layers.push_back(newLayer);
- }
- }
-
- std::vector<IConnectableLayer*> layersToConnect(layers);
- unsigned long numberOfLayersToConnect = layersToConnect.size();
- bool isOdd = numberOfInputs % 2;
-
- while (numberOfLayersToConnect > 1)
- {
- layers.clear();
- for (unsigned long i = 0; i < numberOfLayersToConnect; ++i) {
- bool onSecondItem = i % 2;
- if (onSecondItem) {
- ++numberOfAdditions;
- IConnectableLayer* newLayer = CreateAdditionLayer(
- nodeDef,
- layersToConnect[i - 1],
- layersToConnect[i],
- numberOfAdditions,
- numberOfLayersToConnect,
- isOdd);
- layers.push_back(newLayer);
- }
- }
- //OK... need to go again... maybe
- layersToConnect = layers;
- numberOfLayersToConnect = layersToConnect.size();
- }
- IConnectableLayer* finalLayer = layersToConnect[0];
- // if we had an odd number of inputs we need to connect the final layer to the
- // last OutputOfParsedTfOperation in order to create the last Add layer we will
- // be handing back.
- if (isOdd)
- {
- // connect the final layer to the last op
- finalLayer = CreateAdditionLayer(nodeDef, inputs[numberOfInputs - 1], finalLayer);
- }
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, finalLayer);
- }
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseAdd(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 2);
-
- // If one of the inputs is a MatMul and the other is a const, then we handle both nodes
- // together as FullyConnected.
- if (inputs[0].m_IndexedValue->GetNode().op() == "MatMul" &&
- HasParsedConstTensor<float>(inputs[1].m_IndexedValue->GetNode().name()))
- {
- IConnectableLayer* layer =
- AddFullyConnectedLayer(inputs[0].m_IndexedValue->GetNode(),
- &nodeDef,nodeDef.name().c_str());
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
- }
- else if (HasParsedConstTensor<float>(inputs[0].m_IndexedValue->GetNode().name()) &&
- inputs[1].m_IndexedValue->GetNode().op() == "MatMul")
- {
- IConnectableLayer* layer =
- AddFullyConnectedLayer(inputs[1].m_IndexedValue->GetNode(),
- &nodeDef,nodeDef.name().c_str());
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
- }
- else
- {
- // Otherwise it's just a regular addition.
- return AddAdditionLayer(nodeDef);
- }
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseBiasAdd(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- return AddAdditionLayer(nodeDef, true);
-}
-
-/// An ParsedTfOperation which forwards to another (used for Identity nodes).
-class ParsedIdentityTfOperation : public ParsedTfOperation
-{
-public:
- ParsedIdentityTfOperation(ITfParser::TfParserImpl* parser,
- const tensorflow::NodeDef& node,
- ParsedTfOperation* representative)
- : ParsedTfOperation(parser, node)
- , m_Representative(representative)
- {
- }
-
- virtual IOutputSlot& ResolveArmnnOutputSlot(unsigned int tfOutputIndex) override
- {
- ARMNN_ASSERT(m_Representative);
- return m_Representative->ResolveArmnnOutputSlot(tfOutputIndex);
- }
-
- virtual ParsedTfOperation* ResolveIdentityOperations() override
- {
- return m_Representative->ResolveIdentityOperations();
- }
-
-private:
- ParsedTfOperation* m_Representative;
-};
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseIdentity(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 1);
- // Any requests for the output slots of this node should be forwarded to the node connected as input.
- return std::make_unique<ParsedIdentityTfOperation>(this, nodeDef, inputs[0].m_IndexedValue);
-}
-
-/// An ParsedTfOperation for a Const node.
-/// Creation of the armnn ConstLayer is deferred until it is actually needed, because Const nodes are mostly used
-/// for weight inputs to MatMul/Conv2D nodes and in these cases armnn doesn't need a ConstLayer.
-template <typename T>
-class ParsedConstTfOperation : public DeferredSingleLayerParsedTfOperation
-{
-public:
- ParsedConstTfOperation(ITfParser::TfParserImpl* parser, const tensorflow::NodeDef& node,
- const T* tensorData, const TensorInfo& tensorInfo)
- : DeferredSingleLayerParsedTfOperation(parser, node),
- m_Storage(tensorData, tensorData + tensorInfo.GetNumElements()),
- m_TensorInfo(tensorInfo)
- {
- ARMNN_ASSERT(GetDataTypeSize(tensorInfo.GetDataType()) == sizeof(T));
- }
-
- void CreateLayerDeferred() override
- {
- ARMNN_ASSERT(m_Layer == nullptr);
- m_Layer = m_Parser->m_Network->AddConstantLayer(ConstTensor(m_TensorInfo, m_Storage),
- m_Node.name().c_str());
- m_Layer->GetOutputSlot(0).SetTensorInfo(m_TensorInfo);
- }
-
- ConstTensor GetConstTensor(std::vector<T>& outputTensorData) const
- {
- outputTensorData.resize(m_TensorInfo.GetNumElements());
-
- memcpy(outputTensorData.data(), m_Storage.data(), m_TensorInfo.GetNumBytes());
-
- // Updates the result to point to the user provided storage.
- ConstTensor constTensor(m_TensorInfo, outputTensorData);
- return constTensor;
- }
-
- const T* GetStorage() const
- {
- return m_Storage.data();
- }
-
- const TensorInfo& GetTensorInfo() const
- {
- return m_TensorInfo;
- }
-
-private:
- ///< Manages the lifetime of the tensor data.
- std::vector<T> m_Storage;
- ///< Describes the layout of the tensor and points to the data in m_Storage.
- TensorInfo m_TensorInfo;
-};
-
-DataType ConvertTfTensorDataType(const tensorflow::DataType tfDataType,
- const tensorflow::NodeDef& nodeDef)
-{
- switch (tfDataType)
- {
- case tensorflow::DT_FLOAT:
- return DataType::Float32;
- break;
- case tensorflow::DT_INT32:
- return DataType::Signed32;
- break;
- default:
- throw ParseException(
- fmt::format("Unknown DataType {} for node {} {}",
- tensorflow::DataType_Name(tfDataType),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-}
-
-struct ParseTfTensorValueList
-{
- template<typename DataType>
- static void Parse(
- const tensorflow::TensorProto& tfTensor,
- unsigned int dstElements,
- std::vector<int8_t>& outputData);
-
- template <typename DataType>
- static void ReadData(const void* srcData, unsigned int numSrcElements,
- std::vector<int8_t>& dstData, unsigned int numDstElements)
- {
- // If there are no entries in the list, perform no action.
- if (numSrcElements == 0)
- {
- return;
- }
-
- // If no size was provided, use the length of the value list.
- if (numDstElements == 0)
- {
- numDstElements = numSrcElements;
- }
-
- // Allocates memory.
- dstData.resize(std::max(numSrcElements, numDstElements) * sizeof(DataType));
-
- const DataType* srcTensor = reinterpret_cast<const DataType*>(srcData);
- DataType* dstTensor = reinterpret_cast<DataType*>(dstData.data());
-
- // Copies the value list entries into the destination.
- std::copy(srcTensor, srcTensor + numSrcElements, dstTensor);
-
- if (numDstElements > numSrcElements)
- {
- // Uses the last element in the list to fill the remaining entries.
- std::fill(dstTensor + numSrcElements, dstTensor + numDstElements, srcTensor[numSrcElements - 1]);
- }
- }
-
-};
-
-template <>
-void ParseTfTensorValueList::Parse<float>(const tensorflow::TensorProto& tfTensor,
- unsigned int dstElements, std::vector<int8_t>& outputData)
-{
- ReadData<float>(tfTensor.float_val().data(), static_cast<unsigned int>(tfTensor.float_val_size()),
- outputData, dstElements);
-}
-
-template <>
-void ParseTfTensorValueList::Parse<int32_t>(const tensorflow::TensorProto& tfTensor,
- unsigned int dstElements, std::vector<int8_t>& outputData)
-{
- ReadData<int32_t>(tfTensor.int_val().data(), static_cast<unsigned int>(tfTensor.int_val_size()),
- outputData, dstElements);
-}
-
-template <template<typename> class OperatorType, typename T = int8_t>
-struct MakeTfOperation
-{
- template<typename DataType, class... Args>
- inline static std::unique_ptr<OperatorType<DataType>> Parse(ITfParser::TfParserImpl* parser,
- const tensorflow::NodeDef& node,
- Args&&... args)
- {
- return std::make_unique<OperatorType<DataType>>(parser, node, std::forward<Args>(args)...);
- }
-};
-
-template <>
-struct MakeTfOperation<ParsedConstTfOperation>
-{
- template<typename DataType, class... Args>
- inline static std::unique_ptr<ParsedConstTfOperation<DataType>> Parse(ITfParser::TfParserImpl* parser,
- const tensorflow::NodeDef& node, const std::vector<int8_t>& tensorData, const TensorInfo& tensorInfo)
- {
- return std::make_unique<ParsedConstTfOperation<DataType>>(parser, node,
- reinterpret_cast<const DataType*>(tensorData.data()), tensorInfo);
- }
-};
-
-template <class FuncType>
-struct InvokeParseFunction
-{
- template<class ResType, class... Args>
- inline static ResType Result(DataType dataType, Args&&... args)
- {
- if (dataType == DataType::Float32)
- {
- return FuncType::template Parse<float>(std::forward<Args>(args)...);
- }
- else if (dataType == DataType::Signed32)
- {
- return FuncType::template Parse<int32_t>(std::forward<Args>(args)...);
- }
-
- return ResType();
- }
-
- template<class... Args>
- inline static void Result(DataType dataType, Args&&... args)
- {
- if (dataType == DataType::Float32)
- {
- FuncType::template Parse<float>(std::forward<Args>(args)...);
- }
- else if (dataType == DataType::Signed32)
- {
- FuncType::template Parse<int32_t>(std::forward<Args>(args)...);
- }
- }
-};
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseConst(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- ARMNN_ASSERT(nodeDef.op() == "Const");
-
- if (nodeDef.attr().count("value") == 0)
- {
- throw ParseException(
- fmt::format("Value not found for Const node - {} {}",
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- const tensorflow::TensorProto& tfTensor = nodeDef.attr().at("value").tensor();
- const tensorflow::TensorShapeProto& tfTensorShape = tfTensor.tensor_shape();
- const tensorflow::DataType tfDataType = ReadMandatoryNodeTypeAttribute(nodeDef, "dtype");
-
- const auto GetDimensionSize = [](auto& d) { return d.size(); };
-
- std::vector<unsigned int> dimensionSizes;
- std::transform(tfTensorShape.dim().begin(), tfTensorShape.dim().end(),
- std::back_inserter(dimensionSizes), GetDimensionSize);
-
- // Calculates number of elements.
- const DataType dataType = ConvertTfTensorDataType(tfDataType, nodeDef);
- unsigned int numElements = 0U;
-
- if (!dimensionSizes.empty())
- {
- numElements = std::accumulate(dimensionSizes.begin(), dimensionSizes.end(),
- 1U, std::multiplies<unsigned int>());
- }
-
- std::vector<int8_t> tensorData;
-
- // Get tensor data from the list of values attribute.
- if (tfTensor.tensor_content().empty())
- {
- InvokeParseFunction<ParseTfTensorValueList>::Result<void>(dataType, tfTensor, numElements, tensorData);
-
- // If the tensor shape is not defined, but there is a value list, then interpret the data as a 1D
- // tensor of the provided number of elements.
- if (numElements == 0)
- {
- const unsigned int tfNumElements =
- static_cast<unsigned int>(tensorData.size()) / GetDataTypeSize(dataType);
- dimensionSizes.push_back(tfNumElements);
- }
- }
- // Gets tensor data from tensor content attribute.
- else
- {
- tensorData.assign(tfTensor.tensor_content().begin(), tfTensor.tensor_content().end());
-
- // Checks if a tensor shape is defined for the tensor content.
- if (numElements == 0)
- {
- throw ParseException(
- fmt::format("No tensor shape found for Const node - {} {}",
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
- }
-
- // Const node requires at least a list of values or a content attribute.
- if (tensorData.empty())
- {
- throw ParseException(
- fmt::format("No tensor data found for Const node - {} {}",
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- const TensorInfo tensorInfo(static_cast<unsigned int>(dimensionSizes.size()),
- dimensionSizes.data(),
- dataType);
-
- // If we have a list of values, then the length of the list must be
- // less than or equal to the number of elements implied by the shape argument.
- if (tensorData.size() > tensorInfo.GetNumBytes())
- {
- throw ParseException(
- fmt::format("Number of elements ({}) should be less than or equal "
- "to the number of elements implied by the shape argument ({}) for Const node - {} {}",
- (tensorData.size() / GetDataTypeSize(dataType)),
- tensorInfo.GetNumElements(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- return InvokeParseFunction<MakeTfOperation<ParsedConstTfOperation>>::Result<ParsedTfOperationPtr>(
- dataType, this, nodeDef, tensorData, tensorInfo);
-}
-
-template<typename Type>
-bool ITfParser::TfParserImpl::HasParsedConstTensor(const std::string & nodeName) const
-{
- auto it = m_ParsedTfOperations.find(nodeName);
- if (it == m_ParsedTfOperations.end())
- {
- return false;
- }
- return dynamic_cast<ParsedConstTfOperation<Type>*>(it->second.get()) != nullptr;
-}
-
-template<typename Type>
-bool ITfParser::TfParserImpl::HasParsedConstTensor(ParsedTfOperation* parsedTfOpPtr) const
-{
- return dynamic_cast<ParsedConstTfOperation<Type>*>(parsedTfOpPtr) != nullptr;
-}
-
-unsigned int ITfParser::TfParserImpl::GetConstInputIndex(const std::vector<OutputOfParsedTfOperation>& inputs)
-{
- for (unsigned int i = 0; i < inputs.size(); i++)
- {
- if (HasParsedConstTensor<int32_t>(inputs[i].m_IndexedValue->GetNode().name()))
- {
- return i;
- }
- }
- throw ParseException(
- fmt::format("ArmNN only supports operators with constant axis. {}",
- CHECK_LOCATION().AsString()));
-
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseConv2D(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 2);
- IOutputSlot& inputSlot = inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- TensorInfo inputTensorInfo = inputSlot.GetTensorInfo();
-
- if (!HasParsedConstTensor<float>(inputs[1].m_IndexedValue->GetNode().name()))
- {
- throw ParseException(
- fmt::format("ArmNN only supports Convolution layers with constant weights for {}, input {} {}",
- nodeDef.name(),
- inputs[1].m_IndexedValue->GetNode().name(),
- CHECK_LOCATION().AsString()));
- }
- ParsedConstTfOperation<float>* weightNode =
- PolymorphicDowncast<ParsedConstTfOperation<float> *>(inputs[1].m_IndexedValue);
-
- std::string paddingString = ReadMandatoryNodeStringAttribute(nodeDef, "padding");
- std::string dataFormat = ReadMandatoryNodeStringAttribute(nodeDef, "data_format");
- std::vector<uint32_t> strides = ReadMandatoryNodeUint32ListAttribute(nodeDef, "strides");
-
- Convolution2dDescriptor desc;
- desc.m_BiasEnabled = false;
-
- CHECK_DATA_FORMAT(nodeDef, dataFormat, "Conv2D");
-
- DataLayout dataLayout = dataFormat == "NHWC" ? DataLayout::NHWC : DataLayout::NCHW;
-
- desc.m_DataLayout = dataLayout;
-
- DataLayoutIndexed dataLayoutIndexed(dataLayout);
-
- desc.m_StrideX = strides[dataLayoutIndexed.GetWidthIndex()];
- desc.m_StrideY = strides[dataLayoutIndexed.GetHeightIndex()];
-
- std::vector<uint32_t> dilations = ReadOptionalNodeUint32ListAttribute(nodeDef, "dilations");
- if (!dilations.empty())
- {
- desc.m_DilationX = dilations[dataLayoutIndexed.GetWidthIndex()];
- desc.m_DilationY = dilations[dataLayoutIndexed.GetHeightIndex()];
- }
-
- uint32_t inputHeight = inputTensorInfo.GetShape()[dataLayoutIndexed.GetHeightIndex()];
- uint32_t inputWidth = inputTensorInfo.GetShape()[dataLayoutIndexed.GetWidthIndex()];
-
- // Mappings from TensorFlow filter tensors to the ArmNN filter tensors.
- // Tensorflow weights are [H, W, In, Out].
- // ArmNN weights have to be [Out, H, W, In] when the data layout is NHWC,
- // and [Out, In, H, W] when the data layout is NCHW.
- PermutationVector permutationVector =
- dataLayout == DataLayout::NHWC ?
- std::initializer_list<unsigned int>{ 1, 2, 3, 0 } : // NHWC: [H, W, In, Out] -> [Out, H, W, In]
- std::initializer_list<unsigned int>{ 2, 3, 1, 0 }; // NCHW: [H, W, In, Out] -> [Out, In, H, W]
-
- // Swizzle the tensor using the given permutation vector.
- const TensorInfo& weightTensorInfo = weightNode->GetTensorInfo();
- const TensorInfo weightTensorSwizzledInfo = armnnUtils::Permuted(weightTensorInfo, permutationVector);
-
- // Swizzles the content of the tensor's permanent storage into a local storage.
- std::vector<float> weightTensorSwizzledData(weightTensorInfo.GetNumElements());
- armnnUtils::Permute(weightTensorSwizzledInfo.GetShape(), permutationVector,
- weightNode->GetStorage(), weightTensorSwizzledData.data(), sizeof(float));
-
- // Create a weight tensor with the newly swizzled data.
- ConstTensor weightTensor(weightTensorSwizzledInfo, weightTensorSwizzledData);
-
- uint32_t weightHeight = weightTensor.GetShape()[dataLayoutIndexed.GetHeightIndex()];
- uint32_t weightWidth = weightTensor.GetShape()[dataLayoutIndexed.GetWidthIndex()];
-
- bool padding = false;
- TensorInfo outputInfo;
- unsigned int outputHeight = 0;
- unsigned int outputWidth = 0;
-
- CHECK_PADDING_TYPE(nodeDef, paddingString);
-
- if (paddingString == "SAME")
- {
- padding = true;
- }
- else if (paddingString == "VALID")
- {
- padding = false;
- }
-
- CalcPadding(inputHeight, weightHeight, desc.m_StrideY, desc.m_DilationY, desc.m_PadTop, desc.m_PadBottom, padding);
- CalcPadding(inputWidth, weightWidth, desc.m_StrideX, desc.m_DilationX, desc.m_PadLeft, desc.m_PadRight, padding);
-
- // Calculate output height and width
- unsigned int dilatedFilterWidth = weightWidth + (desc.m_DilationX - 1) * (weightWidth - 1);
- unsigned int readWidth = (inputWidth + desc.m_PadLeft + desc.m_PadRight) - dilatedFilterWidth;
- outputWidth = 1 + (readWidth / desc.m_StrideX);
-
- unsigned int dilatedFilterHeight = weightHeight + (desc.m_DilationY - 1) * (weightHeight - 1);
- unsigned int readHeight = (inputHeight + desc.m_PadTop + desc.m_PadBottom) - dilatedFilterHeight;
- outputHeight = 1 + (readHeight / desc.m_StrideY);
-
- switch (dataLayout)
- {
- case DataLayout::NHWC:
- outputInfo = TensorInfo({ inputTensorInfo.GetShape()[0],
- outputHeight,
- outputWidth,
- weightTensor.GetShape()[0] },
- DataType::Float32);
- break;
- case DataLayout::NCHW:
- default:
- outputInfo = TensorInfo({ inputTensorInfo.GetShape()[0],
- weightTensor.GetShape()[0],
- outputHeight,
- outputWidth },
- DataType::Float32);
- break;
- }
-
- IConnectableLayer* layer = m_Network->AddConvolution2dLayer(desc,
- weightTensor,
- EmptyOptional(),
- nodeDef.name().c_str());
- layer->GetOutputSlot(0).SetTensorInfo(outputInfo);
- inputSlot.Connect(layer->GetInputSlot(0));
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseDepthwiseConv2D(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 2);
- IOutputSlot& inputSlot = inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- TensorInfo inputTensorInfo = inputSlot.GetTensorInfo();
-
- if (!HasParsedConstTensor<float>(inputs[1].m_IndexedValue->GetNode().name()))
- {
- throw ParseException(
- fmt::format("ArmNN only supports Depthwise Convolution layer with constant weights. "
- "Non const input found {} for node {} {}",
- inputs[1].m_IndexedValue->GetNode().name(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- ParsedConstTfOperation<float>* weightNode =
- PolymorphicDowncast<ParsedConstTfOperation<float> *>(inputs[1].m_IndexedValue);
-
- std::string paddingString = ReadMandatoryNodeStringAttribute(nodeDef, "padding");
- std::string dataFormat = ReadMandatoryNodeStringAttribute(nodeDef, "data_format");
- std::vector<uint32_t> strides = ReadMandatoryNodeUint32ListAttribute(nodeDef, "strides");
-
- DepthwiseConvolution2dDescriptor desc;
- desc.m_BiasEnabled = false;
-
- CHECK_DATA_FORMAT(nodeDef, dataFormat, "DepthwiseConv2dNative");
-
- DataLayout dataLayout = dataFormat == "NHWC" ? DataLayout::NHWC : DataLayout::NCHW;
-
- desc.m_DataLayout = dataLayout;
-
- DataLayoutIndexed dataLayoutIndexed(dataLayout);
-
- desc.m_StrideX = strides[dataLayoutIndexed.GetWidthIndex()];
- desc.m_StrideY = strides[dataLayoutIndexed.GetHeightIndex()];
- std::vector<uint32_t> dilations = ReadOptionalNodeUint32ListAttribute(nodeDef, "dilations");
- if (!dilations.empty())
- {
- desc.m_DilationX = dilations[dataLayoutIndexed.GetWidthIndex()];
- desc.m_DilationY = dilations[dataLayoutIndexed.GetHeightIndex()];
- }
-
- uint32_t inputHeight = inputTensorInfo.GetShape()[dataLayoutIndexed.GetHeightIndex()];
- uint32_t inputWidth = inputTensorInfo.GetShape()[dataLayoutIndexed.GetWidthIndex()];
-
- // Mappings from TensorFlow filter tensors to the ArmNN filter tensors.
- // Tensorflow weights come in the format [H, W, I, M].
- // ArmNN weights have to be [M, I, H, W].
- PermutationVector permutationVector{ 2, 3, 1, 0 }; // [H, W, I, M] -> [M, I, H, W]
-
- // Swizzle the tensor using the given permutation vector.
- const TensorInfo& weightTensorInfo = weightNode->GetTensorInfo();
- const TensorInfo weightTensorSwizzledInfo = armnnUtils::Permuted(weightTensorInfo, permutationVector);
-
- // Swizzles the content of the tensor's permanent storage into a local storage.
- std::vector<float> weightTensorSwizzledData(weightTensorInfo.GetNumElements());
- armnnUtils::Permute(weightTensorSwizzledInfo.GetShape(), permutationVector,
- weightNode->GetStorage(), weightTensorSwizzledData.data(), sizeof(float));
-
- // Create a weight tensor with the newly swizzled data.
- ConstTensor weightTensor(weightTensorSwizzledInfo, weightTensorSwizzledData);
-
- uint32_t weightHeight = weightTensor.GetShape()[2];
- uint32_t weightWidth = weightTensor.GetShape()[3];
-
- bool padding = false;
- TensorInfo outputInfo;
- unsigned int outputHeight = 0;
- unsigned int outputWidth = 0;
-
- CHECK_PADDING_TYPE(nodeDef, paddingString);
-
- if (paddingString == "SAME")
- {
- padding = true;
- }
- else if (paddingString == "VALID")
- {
- padding = false;
- }
-
- CalcPadding(inputHeight, weightHeight, desc.m_StrideY, desc.m_DilationY, desc.m_PadTop, desc.m_PadBottom, padding);
- CalcPadding(inputWidth, weightWidth, desc.m_StrideX, desc.m_DilationX, desc.m_PadLeft, desc.m_PadRight, padding);
-
- // Calculate output height and width
- unsigned int dilatedFilterWidth = weightWidth + (desc.m_DilationX - 1) * (weightWidth - 1);
- unsigned int readWidth = (inputWidth + desc.m_PadLeft + desc.m_PadRight) - dilatedFilterWidth;
- outputWidth = 1 + (readWidth / desc.m_StrideX);
-
- unsigned int dilatedFilterHeight = weightHeight + (desc.m_DilationY - 1) * (weightHeight - 1);
- unsigned int readHeight = (inputHeight + desc.m_PadTop + desc.m_PadBottom) - dilatedFilterHeight;
- outputHeight = 1 + (readHeight / desc.m_StrideY);
-
- switch (dataLayout)
- {
- case DataLayout::NHWC:
- outputInfo = TensorInfo({ inputTensorInfo.GetShape()[0],
- outputHeight,
- outputWidth,
- weightTensor.GetShape()[0] * weightTensor.GetShape()[1]},
- DataType::Float32);
- break;
- case DataLayout::NCHW:
- default:
- outputInfo = TensorInfo({ inputTensorInfo.GetShape()[0],
- weightTensor.GetShape()[0] * weightTensor.GetShape()[1],
- outputHeight,
- outputWidth },
- DataType::Float32);
- break;
- }
-
- IConnectableLayer* layer = m_Network->AddDepthwiseConvolution2dLayer(desc,
- weightTensor,
- EmptyOptional(),
- nodeDef.name().c_str());
- layer->GetOutputSlot(0).SetTensorInfo(outputInfo);
- inputSlot.Connect(layer->GetInputSlot(0));
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-TensorInfo OutputShapeOfExpandDims(const tensorflow::NodeDef& nodeDef,
- TensorInfo inputTensorInfo,
- std::int32_t expandDim)
-{
- ARMNN_ASSERT(nodeDef.op() == "ExpandDims");
-
- if (inputTensorInfo.GetNumDimensions() > 4) {
- throw ParseException(
- fmt::format("Unsupported number of dimensions: {} for input shape for ExpandDims {} {}",
- inputTensorInfo.GetNumDimensions(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- std::int32_t inputDimSize = armnn::numeric_cast<int32_t>(inputTensorInfo.GetNumDimensions());
- std::vector<uint32_t> outputDims;
-
- // expandDim operation requires: -1-input.dims() <= dim <= input.dims()
- if (expandDim >= -1 - inputDimSize && expandDim <= inputDimSize)
- {
- // add current input shape to outputDims
- for (unsigned int i = 0; i < inputTensorInfo.GetNumDimensions(); ++i) {
- auto currentDimension = inputTensorInfo.GetShape()[i];
- outputDims.push_back(currentDimension);
- }
-
- // insert a dimension of 1 at index 'expandDim' of inputs shape
- if (expandDim >= 0)
- {
- auto getPosition = std::next(outputDims.begin() + 0, expandDim);
- outputDims.insert(getPosition, 1);
- }
-
- // if negative number for 'expandDim' then count backwards from the last element
- // and insert 1 dimension at index 'expandDim'
- if (expandDim < 0)
- {
- int outputDimSize = armnn::numeric_cast<int>(outputDims.size() + 1);
- auto getPosition = std::next(outputDims.begin() + outputDimSize, expandDim);
- outputDims.insert(getPosition, 1);
- }
- }
- else
- {
- throw InvalidArgumentException(
- fmt::format("Cannot expand dimension {} in input tensor with {} dimension {}",
- expandDim,
- inputDimSize,
- CHECK_LOCATION().AsString()));
- }
-
- if (outputDims.size() > 4)
- {
- throw ParseException(
- fmt::format("Unsupported number of dimensions: {} for output shape for ExpandDims {} {}",
- outputDims.size(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- TensorShape outShape = TensorShape(static_cast<unsigned int>(outputDims.size()),
- outputDims.data());
-
- TensorInfo outTensorInfo = inputTensorInfo;
- outTensorInfo.SetShape(outShape);
-
- return outTensorInfo;
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseExpandDims(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
-
- // Number of inputs can either
- // be 1 - that indicates that the axis parameter is passed as an attribute of the operation
- // or 2 - which means that the axis parameter is passed as a second input
- std::vector<OutputOfConstNodeDef> nodes = GetTfInputNodes(nodeDef);
- const std::size_t numInputs = nodes.size();
- std::vector<OutputOfParsedTfOperation> inputs;
- std::int32_t expandDim; // axis or dim parameter. Describes which dimension to expand.
- if (numInputs == 1)
- {
- inputs = GetInputParsedTfOperationsChecked(nodeDef, 1);
- expandDim = ReadMandatoryNodeInt32Attribute(nodeDef, "Tdim");
- }
- else
- {
- inputs = GetInputParsedTfOperationsChecked(nodeDef, 2);
-
- // make sure data type is int32
- IOutputSlot& prevLayerOutputSlot = inputs[1].m_IndexedValue->ResolveArmnnOutputSlot(inputs[1].m_Index);
- TensorInfo inputTensorInfo = prevLayerOutputSlot.GetTensorInfo();
-
- if (inputTensorInfo.GetDataType()!=armnn::DataType::Signed32)
- {
- throw ParseException(
- fmt::format("The axis parameter of ExpandDims operation given as second input is not of type int32."
- " Input {0} Node {1} {2}",
- inputs[1].m_IndexedValue->GetNode().name(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- // ensure the second input is a constant value
- if (!HasParsedConstTensor<int32_t>(inputs[1].m_IndexedValue->GetNode().name()))
- {
- throw ParseException(
- fmt::format("ArmNN only supports ExpandDims layers with constant axis/dim parameter. "
- "Input {0} Node {1} {2}",
- inputs[1].m_IndexedValue->GetNode().name(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- // make sure the second input is scalar or contains only a single value
- // (we don't support expand dims for multiple axis but we don't care what shape the
- // given tensor has as long as there is only a single value in it
- // e.g. a tensor like this [[[1]]] is completely fine)
- if (inputTensorInfo.GetNumElements() != 1)
- {
- throw ParseException(
- fmt::format("The axis parameter of ExpandDims operation given as second input is not "
- "allowed to hold more than one value. "
- "Input {0} Node {1} {2}",
- inputs[1].m_IndexedValue->GetNode().name(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- ParsedConstTfOperation<int32_t>* expandDimsNode =
- PolymorphicDowncast<ParsedConstTfOperation<int32_t>*>(inputs[1].m_IndexedValue);
-
- memcpy(&expandDim, expandDimsNode->GetStorage(), sizeof(expandDim));
- }
-
- // First input is the vector that should be expanded by another dimension
- IOutputSlot& prevLayerOutputSlot = inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- TensorInfo inputTensorInfo = prevLayerOutputSlot.GetTensorInfo();
-
- TensorInfo outputInfo;
- outputInfo = OutputShapeOfExpandDims(nodeDef, inputTensorInfo, expandDim);
-
- ReshapeDescriptor reshapeDesc;
- reshapeDesc.m_TargetShape = outputInfo.GetShape();
- IConnectableLayer* layer = m_Network->AddReshapeLayer(reshapeDesc, nodeDef.name().c_str());
- prevLayerOutputSlot.Connect(layer->GetInputSlot(0));
- layer->GetOutputSlot(0).SetTensorInfo(outputInfo);
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseFusedBatchNorm(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 5);
-
- if (!HasParsedConstTensor<float>(inputs[1].m_IndexedValue->GetNode().name()))
- {
- throw ParseException(
- fmt::format("ArmNN only supports FusedBatchNormalization layers with constant scale. "
- "Input {}. Node {} {}",
- inputs[1].m_IndexedValue->GetNode().name(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
- ParsedConstTfOperation<float>* scaleNode =
- PolymorphicDowncast<ParsedConstTfOperation<float> *>(inputs[1].m_IndexedValue);
-
- if (!HasParsedConstTensor<float>(inputs[2].m_IndexedValue->GetNode().name()))
- {
- throw ParseException(
- fmt::format("ArmNN only supports FusedBatchNormalization layers with constant offset. "
- "Input {}. Node {} {}",
- inputs[2].m_IndexedValue->GetNode().name(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
- ParsedConstTfOperation<float>* offsetNode =
- PolymorphicDowncast<ParsedConstTfOperation<float> *>(inputs[2].m_IndexedValue);
-
- if (!HasParsedConstTensor<float>(inputs[3].m_IndexedValue->GetNode().name()))
- {
- throw ParseException(
- fmt::format("ArmNN only supports FusedBatchNormalization layers with constant mean. "
- "Input {}. Node {} {}",
- inputs[3].m_IndexedValue->GetNode().name(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
- ParsedConstTfOperation<float>* meanNode =
- PolymorphicDowncast<ParsedConstTfOperation<float> *>(inputs[3].m_IndexedValue);
-
- if (!HasParsedConstTensor<float>(inputs[4].m_IndexedValue->GetNode().name()))
- {
- throw ParseException(
- fmt::format("ArmNN only supports FusedBatchNormalization layers with constant variance. "
- "Input {}. Node {} {}",
- inputs[4].m_IndexedValue->GetNode().name(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
- ParsedConstTfOperation<float>* varianceNode =
- PolymorphicDowncast<ParsedConstTfOperation<float> *>(inputs[4].m_IndexedValue);
-
- const std::string dataFormat = ReadOptionalNodeStringAttribute(nodeDef, "data_format", "NHWC");
- CHECK_DATA_FORMAT(nodeDef, dataFormat, "FusedBatchNorm");
-
- // The descriptor only has the epsilon attribute.
- BatchNormalizationDescriptor desc;
- desc.m_Eps = ReadMandatoryNodeFloatAttribute(nodeDef, "epsilon");
- desc.m_DataLayout = dataFormat == "NHWC" ? DataLayout::NHWC : DataLayout::NCHW;
-
- // Data for the parsed tensor args (scale, offset, mean, variance) must be stored
- // locally until the layer is added.
- std::vector<float> scaleTensorData;
- ConstTensor scaleTensor = scaleNode->GetConstTensor(scaleTensorData);
-
- std::vector<float> offsetTensorData;
- ConstTensor offsetTensor = offsetNode->GetConstTensor(offsetTensorData);
-
- std::vector<float> meanTensorData;
- ConstTensor meanTensor = meanNode->GetConstTensor(meanTensorData);
-
- std::vector<float> varianceTensorData;
- ConstTensor varianceTensor = varianceNode->GetConstTensor(varianceTensorData);
-
- IConnectableLayer* layer = m_Network->AddBatchNormalizationLayer(desc,
- meanTensor,
- varianceTensor,
- offsetTensor,
- scaleTensor,
- nodeDef.name().c_str());
-
- IOutputSlot& inputSlot = inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
-
- layer->GetOutputSlot(0).SetTensorInfo(inputSlot.GetTensorInfo());
- inputSlot.Connect(layer->GetInputSlot(0));
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-bool ITfParser::TfParserImpl::IsSupportedLeakyReluPattern(const tensorflow::NodeDef& mulNodeDef,
- size_t alphaLayerIndex,
- const OutputOfParsedTfOperation& otherOp,
- armnn::IOutputSlot** outputOfLeakyRelu,
- armnn::ActivationDescriptor & desc)
-{
- const tensorflow::NodeDef& otherNodeDef = otherOp.m_IndexedValue->GetNode();
-
- // Verifying all these assumptions hold:
- //
- // 1, the mulNodeDef is an elementwise multiplication node "Mul"
- // 2, the alphaLayerIndex selects a constant node from the inputs of the "Mul" node
- // 3, the inputLayerIndex selects a layer which has the same name as otherNodeDef
- //
-
- if (mulNodeDef.op() == "Mul")
- {
- size_t otherLayerIndex = (alphaLayerIndex == 0 ? 1 : 0);
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(mulNodeDef, 2);
-
- ARMNN_ASSERT(inputs.size() == 2);
- ARMNN_ASSERT((otherLayerIndex == 0 || alphaLayerIndex == 0));
- ARMNN_ASSERT((otherLayerIndex == 1 || alphaLayerIndex == 1));
- ARMNN_ASSERT(((otherLayerIndex + alphaLayerIndex) == 1));
-
- if (inputs[otherLayerIndex].m_IndexedValue->GetNode().name() == otherNodeDef.name())
- {
- if (HasParsedConstTensor<float>(inputs[alphaLayerIndex].m_IndexedValue->GetNode().name()))
- {
- ParsedConstTfOperation<float>* alpha =
- PolymorphicDowncast<ParsedConstTfOperation<float> *>(
- inputs[alphaLayerIndex].m_IndexedValue);
-
- std::vector<float> const_data;
- ConstTensor const_tensor = alpha->GetConstTensor(const_data);
-
- if (const_data.size() == 1)
- {
- desc.m_Function = ActivationFunction::LeakyReLu;
- desc.m_A = const_data[0];
-
- *outputOfLeakyRelu = &(otherOp.m_IndexedValue->ResolveArmnnOutputSlot(otherOp.m_Index));
- return true;
- }
- }
- }
- }
- return false;
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseMaximum(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 2);
- if (inputs.size() != 2)
- {
- throw ParseException(
- fmt::format("Maximum expects two inputs!. Got {} for Node {} {}",
- inputs.size(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- auto inputNode0 = inputs[0].m_IndexedValue->GetNode();
- auto inputNode1 = inputs[1].m_IndexedValue->GetNode();
- IOutputSlot* outputOfLeakyRelu = nullptr;
-
- ActivationDescriptor desc;
-
- // A max node may be part of a LeakyRelu, with one input as a multiplication with a scalar constant,
- // i.e. one of the four possible scenarios:
- // 1, max(mul(a, x), x)
- // 2, max(mul(x, a), x)
- // 3, max(x, mul(a, x))
- // 4, max(x, mul(x, a))
- // These are handled by an activation layer.
-
- if (IsSupportedLeakyReluPattern(inputNode0, 0, inputs[1], &outputOfLeakyRelu, desc) ||
- IsSupportedLeakyReluPattern(inputNode0, 1, inputs[1], &outputOfLeakyRelu, desc) ||
- IsSupportedLeakyReluPattern(inputNode1, 0, inputs[0], &outputOfLeakyRelu, desc) ||
- IsSupportedLeakyReluPattern(inputNode1, 1, inputs[0], &outputOfLeakyRelu, desc))
- {
- ARMNN_ASSERT(outputOfLeakyRelu != nullptr);
-
- IConnectableLayer* const layer = m_Network->AddActivationLayer(desc, nodeDef.name().c_str());
- outputOfLeakyRelu->Connect(layer->GetInputSlot(0));
- layer->GetOutputSlot(0).SetTensorInfo(outputOfLeakyRelu->GetTensorInfo());
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
- }
- else
- {
- // Anything else is just a maximum layer.
-
- return AddMaximumLayer(nodeDef);
- }
-}
-
-std::pair<armnn::IOutputSlot*, armnn::IOutputSlot*> ITfParser::TfParserImpl::ProcessElementwiseInputSlots(
- const tensorflow::NodeDef& nodeDef, const std::string& layerName)
-{
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 2);
-
- IOutputSlot* input0Slot = &inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- IOutputSlot* input1Slot = &inputs[1].m_IndexedValue->ResolveArmnnOutputSlot(inputs[1].m_Index);
- const unsigned int input0Dim = input0Slot->GetTensorInfo().GetNumDimensions();
- const unsigned int input1Dim = input1Slot->GetTensorInfo().GetNumDimensions();
-
- if (input0Dim != input1Dim)
- {
- // broadcasting where input0 and input1 have different number of dimensions
- // is only supported for 1D and 4D tensors pair
- if (input0Dim == 1 && input1Dim == 4)
- {
- input0Slot = AddBroadcastReshapeLayer(input1Slot, input0Slot, true, *m_Network, nodeDef);
- }
- else if (input0Dim == 4 && input1Dim == 1)
- {
- input1Slot = AddBroadcastReshapeLayer(input0Slot, input1Slot, true, *m_Network, nodeDef);
- }
- else
- {
- throw ParseException(
- fmt::format("Unsupported broadcast configuration for {} operation {} {}",
- layerName,
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
- }
- return {input0Slot, input1Slot};
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ProcessComparisonLayer(
- IOutputSlot* input0Slot,
- IOutputSlot* input1Slot,
- IConnectableLayer* const layer,
- const tensorflow::NodeDef& nodeDef)
-{
- input0Slot->Connect(layer->GetInputSlot(0));
- input1Slot->Connect(layer->GetInputSlot(1));
-
- TensorInfo outputInfo = input0Slot->GetTensorInfo();
- outputInfo.SetDataType(DataType::Boolean);
- std::vector<unsigned int> outputShape;
-
- const TensorShape& input0Shape = input0Slot->GetTensorInfo().GetShape();
- const TensorShape& input1Shape = input1Slot->GetTensorInfo().GetShape();
-
- for (unsigned int i = 0; i < input0Shape.GetNumDimensions(); i++)
- {
- outputShape.push_back(std::max(input0Shape[i], input1Shape[i]));
- }
-
- outputInfo.SetShape(TensorShape(input0Shape.GetNumDimensions(), outputShape.data()));
- layer->GetOutputSlot(0).SetTensorInfo(outputInfo);
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ProcessElementwiseLayer(
- IOutputSlot* input0Slot,
- IOutputSlot* input1Slot,
- IConnectableLayer* const layer,
- const tensorflow::NodeDef& nodeDef)
-{
- input0Slot->Connect(layer->GetInputSlot(0));
- input1Slot->Connect(layer->GetInputSlot(1));
-
- TensorInfo outputInfo = input0Slot->GetTensorInfo();
- std::vector<unsigned int> outputShape;
-
- const TensorShape& input0Shape = input0Slot->GetTensorInfo().GetShape();
- const TensorShape& input1Shape = input1Slot->GetTensorInfo().GetShape();
-
- for (unsigned int i = 0; i < input0Shape.GetNumDimensions(); i++)
- {
- outputShape.push_back(std::max(input0Shape[i], input1Shape[i]));
- }
-
- outputInfo.SetShape(TensorShape(input0Shape.GetNumDimensions(), outputShape.data()));
- layer->GetOutputSlot(0).SetTensorInfo(outputInfo);
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseGather(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 2);
- IOutputSlot& params = inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- IOutputSlot& indices = inputs[1].m_IndexedValue->ResolveArmnnOutputSlot(inputs[1].m_Index);
- GatherDescriptor descriptor;
- descriptor.m_Axis = ReadMandatoryNodeInt32Attribute(nodeDef, "axis");
-
- // Infer shape of output tensor
- unsigned int paramsDim = params.GetTensorInfo().GetNumDimensions();
- unsigned int indicesDim = indices.GetTensorInfo().GetNumDimensions();
- unsigned int outputDim = paramsDim - 1 + indicesDim;
-
- std::vector<unsigned int> dimSizes;
-
- for (unsigned int i = 0; i < indicesDim; ++i)
- {
- dimSizes.push_back(indices.GetTensorInfo().GetShape()[i]);
- }
- for (unsigned int i = 1; i < paramsDim; ++i)
- {
- dimSizes.push_back(params.GetTensorInfo().GetShape()[i]);
- }
-
- const TensorShape& inferredShape = TensorShape(outputDim, dimSizes.data());
-
- const TensorInfo inferredOutputInfo(inferredShape, params.GetTensorInfo().GetDataType());
-
- IConnectableLayer* const layer = m_Network->AddGatherLayer(descriptor, nodeDef.name().c_str());
- layer->GetOutputSlot(0).SetTensorInfo(inferredOutputInfo);
-
- params.Connect(layer->GetInputSlot(0));
- indices.Connect(layer->GetInputSlot(1));
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseGreater(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::pair<armnn::IOutputSlot*, armnn::IOutputSlot*> inputLayers = ProcessElementwiseInputSlots(nodeDef, "Greater");
- IOutputSlot* input0Slot = inputLayers.first;
- IOutputSlot* input1Slot = inputLayers.second;
-
- ComparisonDescriptor descriptor(ComparisonOperation::Greater);
- IConnectableLayer* const layer = m_Network->AddComparisonLayer(descriptor, nodeDef.name().c_str());
-
- return ProcessComparisonLayer(input0Slot, input1Slot, layer, nodeDef);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseEqual(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::pair<armnn::IOutputSlot*, armnn::IOutputSlot*> inputLayers = ProcessElementwiseInputSlots(nodeDef, "Equal");
- IOutputSlot* input0Slot = inputLayers.first;
- IOutputSlot* input1Slot = inputLayers.second;
-
- ComparisonDescriptor descriptor(ComparisonOperation::Equal);
- IConnectableLayer* const layer = m_Network->AddComparisonLayer(descriptor, nodeDef.name().c_str());
-
- return ProcessComparisonLayer(input0Slot, input1Slot, layer, nodeDef);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseMinimum(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::pair<armnn::IOutputSlot*, armnn::IOutputSlot*> inputLayers = ProcessElementwiseInputSlots(nodeDef, "Minimum");
- IOutputSlot* input0Slot = inputLayers.first;
- IOutputSlot* input1Slot = inputLayers.second;
-
- IConnectableLayer* const layer = m_Network->AddMinimumLayer(nodeDef.name().c_str());
-
- return ProcessElementwiseLayer(input0Slot, input1Slot, layer, nodeDef);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseSub(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 2);
-
- IOutputSlot* input0Slot = &inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- IOutputSlot* input1Slot = &inputs[1].m_IndexedValue->ResolveArmnnOutputSlot(inputs[1].m_Index);
-
- const TensorInfo& input0Info = input0Slot->GetTensorInfo();
- const TensorInfo& input1Info = input1Slot->GetTensorInfo();
-
- if (input0Info.GetNumDimensions() == 1)
- {
- const bool isNHWC = true;
- input0Slot = AddBroadcastReshapeLayer(input1Slot, input0Slot, isNHWC, *m_Network, nodeDef);
- }
-
- if (input1Info.GetNumDimensions() == 1)
- {
- const bool isNHWC = true;
- input1Slot = AddBroadcastReshapeLayer(input0Slot, input1Slot, isNHWC, *m_Network, nodeDef);
- }
-
- IConnectableLayer* const layer = m_Network->AddSubtractionLayer(nodeDef.name().c_str());
-
- input0Slot->Connect(layer->GetInputSlot(0));
- input1Slot->Connect(layer->GetInputSlot(1));
-
- if (input0Info.GetNumDimensions() == 1)
- {
- layer->GetOutputSlot(0).SetTensorInfo(input1Slot->GetTensorInfo());
- }
- else
- {
- layer->GetOutputSlot(0).SetTensorInfo(input0Slot->GetTensorInfo());
- }
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseStack(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::vector<OutputOfConstNodeDef> nodes = GetTfInputNodes(nodeDef);
-
- unsigned int numInputs = static_cast<unsigned int>(nodes.size());
- if (numInputs < 1)
- {
- throw ParseException(
- fmt::format("Pack/Stack expects at least one input. Got {} for Node {} {}",
- numInputs,
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, numInputs);
- // Use the tensor shape of the first input as the "correct" input shape in the descriptor
- IOutputSlot* input0Slot = &inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- const TensorInfo& inputTensorInfo = input0Slot->GetTensorInfo();
- auto numDimensions = inputTensorInfo.GetShape().GetNumDimensions();
-
- // validate axis
- int32_t axis = ReadMandatoryNodeInt32Attribute(nodeDef, "axis");
- const int sNumDimensions = (static_cast<int>(numDimensions) + 1);
- if (!(axis < sNumDimensions && axis >= -sNumDimensions))
- {
- throw ParseException(
- fmt::format("Axis index is not in range. Got {} for Node {} {}",
- axis,
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- if (axis < 0)
- {
- axis = static_cast<int32_t>(numDimensions) + axis + 1;
- }
-
- StackDescriptor stackDescriptor;
- stackDescriptor.m_Axis = static_cast<uint32_t>(axis);
- stackDescriptor.m_NumInputs = static_cast<uint32_t>(numInputs);
- stackDescriptor.m_InputShape = inputTensorInfo.GetShape();
-
- const unsigned int supportedNumDims = 4;
- for (unsigned int viewIndex = 0; viewIndex < numInputs; ++viewIndex)
- {
- IOutputSlot& inputSlot = inputs[viewIndex].m_IndexedValue->ResolveArmnnOutputSlot(inputs[viewIndex].m_Index);
- TensorInfo inputTensorInfo = inputSlot.GetTensorInfo();
-
- // Double check dimensions of the tensors
- if (inputTensorInfo.GetNumDimensions() >= supportedNumDims)
- {
- throw armnn::ParseException(
- fmt::format("The number of dimensions: {} for input tensors of the "
- "Pack/Stack op. Number of dimensions should be less than {} {}",
- inputTensorInfo.GetNumDimensions(),
- supportedNumDims,
- CHECK_LOCATION().AsString()));
- }
- }
-
- std::vector<unsigned int> outputDimensions;
- for (unsigned int i = 0; i < stackDescriptor.m_InputShape.GetNumDimensions(); ++i)
- {
- outputDimensions.push_back(stackDescriptor.m_InputShape[i]);
- }
- outputDimensions.insert(outputDimensions.begin() + axis, numInputs);
-
- // add Stack Layer
- IConnectableLayer* const layer = m_Network->AddStackLayer(stackDescriptor, nodeDef.name().c_str());
-
- for (unsigned int viewIndex = 0; viewIndex < numInputs; ++viewIndex)
- {
- IOutputSlot& inputSlot = inputs[viewIndex].m_IndexedValue->ResolveArmnnOutputSlot(inputs[viewIndex].m_Index);
- inputSlot.Connect(layer->GetInputSlot(viewIndex));
- }
-
- layer->GetOutputSlot(0).SetTensorInfo(
- armnn::TensorInfo(static_cast<uint32_t>(outputDimensions.size()),
- outputDimensions.data(),
- inputTensorInfo.GetDataType()));
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseTranspose(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
-
- auto inputs = GetInputParsedTfOperationsChecked(nodeDef, 2);
- const auto inputCount = inputs.size();
-
- if (inputCount != 2)
- {
- throw ParseException(
- fmt::format("The number of given input is {}. It should be two for Transpose op."
- "Node {} {}",
- inputCount,
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- auto* input0Slot = &inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
-
- const auto constInput = inputs[GetConstInputIndex(inputs)];
- auto* permuteVectorInput =
- PolymorphicDowncast<ParsedConstTfOperation<int32_t>*>(constInput.m_IndexedValue);
- const auto& permuteVectorInfo = permuteVectorInput->GetTensorInfo();
-
- std::vector<int32_t> permuteVectorData;
- permuteVectorInput->GetConstTensor(permuteVectorData);
-
- std::vector<unsigned int> armnnPermuteVectorData(permuteVectorData.begin(), permuteVectorData.end());
-
- const auto permutationVector = PermutationVector(armnnPermuteVectorData.data(), permuteVectorInfo.GetNumElements());
- const auto desc = TransposeDescriptor(permutationVector);
-
- auto* layer = m_Network->AddTransposeLayer(desc, nodeDef.name().c_str());
- ARMNN_ASSERT(layer);
-
- input0Slot->Connect(layer->GetInputSlot(0));
-
- const auto& input0Info = input0Slot->GetTensorInfo();
- armnn::TensorInfo outputInfo {input0Info};
- outputInfo.SetShape(armnnUtils::TransposeTensorShape(input0Info.GetShape(), desc.m_DimMappings));
- layer->GetOutputSlot(0).SetTensorInfo(outputInfo);
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-unsigned int CheckPaddingTensor(const ConstTensor& paddingTensor,
- const TensorInfo& inputTensorInfo,
- const std::string& nodeName)
-{
- unsigned int rank = paddingTensor.GetShape()[0];
- unsigned int expectedRank = inputTensorInfo.GetNumDimensions();
- if (rank != expectedRank)
- {
- throw ParseException(
- fmt::format("Expected the padding tensor to be of rank {} not {} on Node {} {}.",
- expectedRank,
- rank,
- nodeName,
- CHECK_LOCATION().AsString()));
- }
- unsigned int second = paddingTensor.GetShape()[1];
- if (second != 2)
- {
- throw ParseException(
- fmt::format("Expected the padding tensor to be of dimensions "
- "[{1}, 2] not [{1}, {2}] on Node {3} {4}.",
- rank,
- second,
- nodeName,
- CHECK_LOCATION().AsString()));
- }
- return rank;
-}
-
-TensorInfo CalculatePaddedOutputTensorInfo(const TensorInfo& inputTensorInfo,
- const std::vector<std::pair<unsigned int, unsigned int>>& padList)
-{
- unsigned int numDims = inputTensorInfo.GetNumDimensions();
- std::vector<unsigned int> outDims;
- for (unsigned int i = 0; i < numDims; ++i)
- {
- unsigned int dimSize = inputTensorInfo.GetShape()[i];
- const std::pair<unsigned int, unsigned int>& dimPadding = padList[i];
- dimSize += dimPadding.first;
- dimSize += dimPadding.second;
- outDims.push_back(dimSize);
- }
- TensorInfo paddedTensorInfo = inputTensorInfo;
- unsigned int outDimsSize = static_cast<unsigned int>(outDims.size());
- paddedTensorInfo.SetShape(TensorShape{ outDimsSize, outDims.data() });
- return paddedTensorInfo;
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParsePad(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- // input consists of:
- // input[0] the tensor which will be padded
- // input[1] the tensor holding the padding values
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 2);
- IOutputSlot& previousLayerOutputSlot = inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- TensorInfo inputTensorInfo = previousLayerOutputSlot.GetTensorInfo();
- if (!HasParsedConstTensor<int32_t>(inputs[1].m_IndexedValue))
- {
- throw ParseException(
- fmt::format("ArmNN only supports Pad with constant padding. "
- "Input {}. Node {} {}",
- inputs[1].m_IndexedValue->GetNode().name(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
-
- }
- ParsedConstTfOperation<int32_t>* paddingTensorOp =
- PolymorphicDowncast<ParsedConstTfOperation<int32_t>*>(inputs[1].m_IndexedValue);
-
- std::vector<int32_t> paddingTensorData;
- ConstTensor paddingTensor = paddingTensorOp->GetConstTensor(paddingTensorData);
- // paddings is an integer tensor with shape [n, 2], where n is the rank of tensor
- // and should match the rank of the input tensor that is being padded.
- // For each dimension D of input, paddings[D, 0] indicates how many values to add
- // before the contents of tensor in that dimension, and paddings[D, 1] indicates how
- // many values to add after the contents of tensor in that dimension
- // This needs to be translated into a padList for ACL
- std::vector<std::pair<unsigned int, unsigned int>> padList;
- unsigned int rank = CheckPaddingTensor(paddingTensor, inputTensorInfo, nodeDef.name());
- for (unsigned int i = 0; i < rank; ++i)
- {
- std::pair<unsigned int, unsigned int> paddingForDim;
- for (unsigned int j = 0; j < 2; j++)
- {
- unsigned int index = (i * 2) + j;
- int paddingAmount = paddingTensorData[index];
- // make sure we can cast to an unsigned value
- if (paddingAmount < 0)
- {
- throw ParseException(
- fmt::format("Negative amount {} specified at [{}, {}] of padding tensor on Node {} {}.",
- paddingAmount,
- i,
- j,
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
- if (j == 0)
- {
- paddingForDim.first = static_cast<unsigned int>(paddingAmount);
- }
- else
- {
- paddingForDim.second = static_cast<unsigned int>(paddingAmount);
- }
- }
- padList.push_back(paddingForDim);
- }
- PadDescriptor padDescriptor(padList);
- IConnectableLayer* layer = m_Network->AddPadLayer(padDescriptor, nodeDef.name().c_str());
- previousLayerOutputSlot.Connect(layer->GetInputSlot(0));
- // Use the padding to calculate the new output tensor shape
- TensorInfo outputTensorInfo = CalculatePaddedOutputTensorInfo(inputTensorInfo, padList);
- layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseConcat(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::vector<OutputOfConstNodeDef> nodes = GetTfInputNodes(nodeDef);
-
- // In tensorflow, we have the last input of the Concat layer as the axis for concatenation.
- unsigned int numInputs = static_cast<unsigned int>(nodes.size());
-
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, numInputs);
-
- // Constant tensor index
- unsigned int index = GetConstInputIndex(inputs);
- // Get the axis tensor data
- ParsedConstTfOperation<int32_t>* shapeNode =
- PolymorphicDowncast<ParsedConstTfOperation<int32_t>*>(inputs[index].m_IndexedValue);
-
- std::vector<int32_t> axisTensorData;
- shapeNode->GetConstTensor(axisTensorData);
-
- // This concatDim indicates the data format: 3 is the NHWC, 1 is the NCHW.
- const unsigned int concatDim = static_cast<unsigned int>(axisTensorData[0]);
-
- // Armnn supports concatenation along the channel dimension for data formats NHWC and NCHW.
- if (concatDim == 0 || concatDim == 2)
- {
- throw ParseException(
- fmt::format("Dimension {} for concatenation is not supported by Armnn. "
- "Node {} {}",
- concatDim,
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- const unsigned int supportedNumDims = 4;
- unsigned int numConcatViews = numInputs - 1;
- OriginsDescriptor concatDescriptor(static_cast<uint32_t>(numConcatViews), supportedNumDims);
- concatDescriptor.SetConcatAxis(concatDim);
- TensorShape mergeDims(supportedNumDims);
- unsigned int mergeDim = 0;
- for (unsigned int viewIndex = 0; viewIndex < numConcatViews; ++viewIndex)
- {
- // Need to double check whether it should be
- IOutputSlot& inputSlot = inputs[viewIndex].m_IndexedValue->ResolveArmnnOutputSlot(inputs[viewIndex].m_Index);
- TensorInfo inputTensorInfo = inputSlot.GetTensorInfo();
-
- // Double check dimensions of the tensors
- if (inputTensorInfo.GetNumDimensions() != supportedNumDims)
- {
- throw armnn::ParseException(
- fmt::format("The number of dimensions: {} for input tensors of the "
- "concatenation op should be {} {}",
- inputTensorInfo.GetNumDimensions(),
- supportedNumDims,
- CHECK_LOCATION().AsString()));
- }
-
- // Copy the input tensor shape to mergeDimSizes and initialize the view origin coordinates for the current input
- mergeDims = inputTensorInfo.GetShape();
- unsigned int* viewOrigin = const_cast<unsigned int*>(concatDescriptor.GetViewOrigin(viewIndex));
- std::fill(viewOrigin, viewOrigin + supportedNumDims, 0);
-
- // Update the view origin coordinates and the merge dimension value
- concatDescriptor.SetViewOriginCoord(viewIndex, concatDim, mergeDim);
- mergeDim += mergeDims[concatDim];
- }
-
- // Update the output shape
- mergeDims[concatDim] = mergeDim;
- armnn::IConnectableLayer *layer = m_Network->AddConcatLayer(concatDescriptor, nodeDef.name().c_str());
-
- layer->GetOutputSlot(0).SetTensorInfo(armnn::TensorInfo(mergeDims, DataType::Float32));
-
- for (unsigned int viewIndex = 0; viewIndex < numConcatViews; ++viewIndex)
- {
- IOutputSlot& inputSlot = inputs[viewIndex].m_IndexedValue->ResolveArmnnOutputSlot(inputs[viewIndex].m_Index);
- inputSlot.Connect(layer->GetInputSlot(viewIndex));
- }
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseShape(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- // Note: the Shape layer is handled in a special way, because:
- // 1. ARMNN doesn't support int32 tensors which it outputs.
- // 2. ARMNN works with statically shaped tensors which are known at parse time.
- // 3. because of 1. and 2. we treat the output of Shape as a temporary const int32
- // tensor which may be used as an input to other ops, most likely a Reshape.
-
- const tensorflow::DataType tfDataType = ReadMandatoryNodeTypeAttribute(nodeDef, "out_type");
- if (tfDataType != tensorflow::DT_INT32)
- {
- throw ParseException(
- fmt::format("Armnn only supports DT_INT32 as out_type. Got {} for Node {} {}",
- tensorflow::DataType_Name(tfDataType),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- const std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 1);
- IOutputSlot& prevLayerOutputSlot = inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- const TensorInfo& prevLayerTensorInfo = prevLayerOutputSlot.GetTensorInfo();
- unsigned int prevLayerDimensions = prevLayerTensorInfo.GetNumDimensions();
-
- std::vector<int32_t> shapeTensorData;
- shapeTensorData.reserve(prevLayerDimensions);
-
- for (unsigned int i=0; i<prevLayerDimensions; ++i)
- {
- shapeTensorData.push_back(static_cast<int32_t>(prevLayerTensorInfo.GetShape()[i]));
- }
-
- TensorInfo shapeTensorInfo(1, &prevLayerDimensions, DataType::Signed32);
-
- return std::make_unique<ParsedConstTfOperation<int32_t>>(this,
- nodeDef,
- &shapeTensorData[0],
- shapeTensorInfo);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseReshape(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 2);
- ParsedTfOperation* inputNode = inputs[0].m_IndexedValue;
-
- if (!HasParsedConstTensor<int32_t>(inputs[1].m_IndexedValue->GetNode().name()))
- {
- throw ParseException(
- fmt::format("ArmNN only supports Reshape layers with constant shapes. "
- "Input {} Node {} {}",
- inputs[1].m_IndexedValue->GetNode().name(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
- ParsedConstTfOperation<int32_t>* shapeNode =
- PolymorphicDowncast<ParsedConstTfOperation<int32_t>*>(inputs[1].m_IndexedValue);
-
- armnn::IOutputSlot& prevLayerOutputSlot = inputNode->ResolveArmnnOutputSlot(inputs[0].m_Index);
- TensorInfo inputTensorInfo = prevLayerOutputSlot.GetTensorInfo();
-
- std::vector<int32_t> shapeTensorData;
- ConstTensor shapeTensor = shapeNode->GetConstTensor(shapeTensorData);
- const TensorInfo outputTensorInfo = PrepareReshape(inputTensorInfo, shapeTensorData);
-
- TensorShape targetShape = outputTensorInfo.GetShape();
- ReshapeDescriptor reshapeDesc;
- reshapeDesc.m_TargetShape = targetShape;
-
- IConnectableLayer* layer = m_Network->AddReshapeLayer(reshapeDesc, nodeDef.name().c_str());
- prevLayerOutputSlot.Connect(layer->GetInputSlot(0));
- layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseResizeBilinear(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 2);
-
- if (!HasParsedConstTensor<int32_t>(inputs[1].m_IndexedValue->GetNode().name()))
- {
- throw ParseException(
- fmt::format("ArmNN only supports ResizeBilinear layers with constant sizes. "
- "Input {}. Node {} {}",
- inputs[1].m_IndexedValue->GetNode().name(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
- ParsedConstTfOperation<int32_t>* sizeNode =
- PolymorphicDowncast<ParsedConstTfOperation<int32_t>*>(inputs[1].m_IndexedValue);
-
- // Checks the align_corners attribute is not set.
- if (ReadOptionalNodeBoolAttribute(nodeDef, "align_corners", false))
- {
- throw ParseException(
- fmt::format("ArmNN only supports ResizeBilinear layers with align_corners set to false. "
- "Node {} {}",
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- // Data for the parsed tensor args (size) must be stored locally.
- std::vector<int32_t> sizeTensorData;
- ConstTensor sizeTensor = sizeNode->GetConstTensor(sizeTensorData);
-
- // The descriptor only has target height and width attributes, which we get from the size tensor.
- ResizeDescriptor desc;
- desc.m_Method = armnn::ResizeMethod::Bilinear;
- desc.m_TargetHeight = static_cast<uint32_t> (sizeTensorData[0]);
- desc.m_TargetWidth = static_cast<uint32_t> (sizeTensorData[1]);
- desc.m_DataLayout = armnn::DataLayout::NHWC;
-
- IConnectableLayer* layer = m_Network->AddResizeLayer(desc, nodeDef.name().c_str());
-
- IOutputSlot& inputSlot = inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- TensorInfo inputTensorInfo = inputSlot.GetTensorInfo();
- // The input shape is always in BHWC format, this will be swizzled below; for now,
- // get the batch and channels to make up the ArmNN output shape with the target size.
- unsigned int outBatch = inputTensorInfo.GetShape()[0];
- unsigned int outChannels = inputTensorInfo.GetShape()[3];
- unsigned int outHeight = desc.m_TargetHeight;
- unsigned int outWidth = desc.m_TargetWidth;
- TensorShape outShape({outBatch, outHeight, outWidth, outChannels });
- // The output DataType is always Float32, regardless of the input DataType.
- const TensorInfo outputTensorInfo(outShape, armnn::DataType::Float32);
- layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
-
- inputSlot.Connect(layer->GetInputSlot(0));
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-TensorInfo OutputShapeOfSqueeze(const tensorflow::NodeDef& nodeDef, TensorInfo inputTensorInfo)
-{
- ARMNN_ASSERT(nodeDef.op() == "Squeeze");
- tensorflow::DataType tfDataType = ReadMandatoryNodeTypeAttribute(nodeDef, "T");
-
- DataType type;
- if (tfDataType == tensorflow::DT_FLOAT)
- {
- type = DataType::Float32;
- }
- else if (tfDataType == tensorflow::DT_INT32)
- {
- type = DataType::Signed32;
- }
- else
- {
- throw ParseException(
- fmt::format("Unsupported DataType {} for Squeeze operation {} {}",
- tensorflow::DataType_Name(tfDataType),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
-
- if (inputTensorInfo.GetNumDimensions() > 4)
- {
- throw ParseException(
- fmt::format("Unsupported number of dimensions: {} for input shape for Squeeze {} {}",
- inputTensorInfo.GetNumDimensions(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- std::vector<uint32_t> squeezeDims = ReadOptionalNodeUint32ListAttribute(nodeDef, "squeeze_dims");
- static const uint32_t dimensionSequence[] = { 0, 1, 2, 3 };
-
- if (squeezeDims.empty())
- {
- squeezeDims.assign(dimensionSequence,
- dimensionSequence+inputTensorInfo.GetNumDimensions());
- }
-
- std::vector<uint32_t> outputDims;
- for(unsigned int i = 0; i < inputTensorInfo.GetNumDimensions(); i++)
- {
- bool skipSqueeze = (std::find(squeezeDims.begin(), squeezeDims.end(), i) == squeezeDims.end());
- auto currentDimension = inputTensorInfo.GetShape()[i];
- if (skipSqueeze || currentDimension != 1)
- {
- outputDims.push_back(currentDimension);
- }
- }
-
- if (outputDims.size() > 4)
- {
- throw ParseException(
- fmt::format("Unsupported number of dimensions: {} for output shape for Squeeze {} {}",
- outputDims.size(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- TensorShape outShape = TensorShape(static_cast<unsigned int>(outputDims.size()),
- outputDims.data());
-
- TensorInfo outTensorInfo = inputTensorInfo;
- outTensorInfo.SetShape(outShape);
- outTensorInfo.SetDataType(type);
-
- return outTensorInfo;
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseSqueeze(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 1);
-
- IOutputSlot& prevLayerOutputSlot = inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- TensorInfo inputTensorInfo = prevLayerOutputSlot.GetTensorInfo();
-
- TensorInfo outputInfo;
- outputInfo = OutputShapeOfSqueeze(nodeDef, inputTensorInfo);
-
- ReshapeDescriptor reshapeDesc;
- reshapeDesc.m_TargetShape = outputInfo.GetShape();
- IConnectableLayer* layer = m_Network->AddReshapeLayer(reshapeDesc, nodeDef.name().c_str());
- prevLayerOutputSlot.Connect(layer->GetInputSlot(0));
- layer->GetOutputSlot(0).SetTensorInfo(outputInfo);
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseLrn(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 1);
-
- NormalizationDescriptor normalizationDescriptor;
- normalizationDescriptor.m_NormMethodType = NormalizationAlgorithmMethod::LocalBrightness;
- normalizationDescriptor.m_NormChannelType = NormalizationAlgorithmChannel::Across;
- normalizationDescriptor.m_Alpha = ReadMandatoryNodeFloatAttribute(nodeDef, "alpha");
- normalizationDescriptor.m_Beta = ReadMandatoryNodeFloatAttribute(nodeDef, "beta");
- normalizationDescriptor.m_K = ReadMandatoryNodeFloatAttribute(nodeDef, "bias");
- normalizationDescriptor.m_NormSize = ReadMandatoryNodeUint32Attribute(nodeDef, "depth_radius");
- normalizationDescriptor.m_DataLayout = armnn::DataLayout::NHWC;
-
- // The window size must be an odd value. For a window size of (2 * n + 1), TensorFlow defines depth_radius = n.
- normalizationDescriptor.m_NormSize = normalizationDescriptor.m_NormSize * 2 + 1;
-
- IOutputSlot& prevLayerOutputSlot = inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- IConnectableLayer* layer = m_Network->AddNormalizationLayer(normalizationDescriptor,
- nodeDef.name().c_str());
- prevLayerOutputSlot.Connect(layer->GetInputSlot(0));
- layer->GetOutputSlot(0).SetTensorInfo(prevLayerOutputSlot.GetTensorInfo());
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-/// An ParsedTfOperation for a MatMul node.
-/// Creation of the armnn FullyConnected layer is deferred until it is actually needed, because
-/// MatMul nodes are often used for the first part of a biased FullyConnected (MatMul followed
-/// by Add) and in these cases armnn doesn't need a separate layer for the MatMul.
-///
-class ParsedMatMulTfOperation : public DeferredSingleLayerParsedTfOperation
-{
-public:
- ParsedMatMulTfOperation(ITfParser::TfParserImpl* parser, const tensorflow::NodeDef& node)
- : DeferredSingleLayerParsedTfOperation(parser, node)
- {
- }
-
- void CreateLayerDeferred() override
- {
- ARMNN_ASSERT(m_Layer == nullptr);
- m_Layer = m_Parser->AddFullyConnectedLayer(m_Node, nullptr, m_Node.name().c_str());
- }
-};
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseMatMul(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
-
- // Defers the creation of the layer (see ParsedMatMulTfOperation).
- return std::make_unique<ParsedMatMulTfOperation>(this, nodeDef);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseMean(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 2);
- IOutputSlot& inputSlot = inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- TensorInfo inputTensorInfo = inputSlot.GetTensorInfo();
-
- if (inputs.size() != 2)
- {
- throw ParseException(
- fmt::format("Mean expects two inputs!. Got {} for Node {} {}",
- inputs.size(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- bool keepDims = ReadMandatoryNodeBoolAttribute(nodeDef, "keep_dims");
-
- ParsedConstTfOperation<int32_t>* axisNode =
- PolymorphicDowncast<ParsedConstTfOperation<int32_t>*>(inputs[1].m_IndexedValue);
-
- const TensorInfo& axisTensorInfo = axisNode->GetTensorInfo();
-
- ConstTensor axisTensor(axisTensorInfo, axisNode->GetStorage());
- const int* axisData = static_cast<const int*>(axisTensor.GetMemoryArea());
-
- TensorInfo outputTensorInfo;
- MeanDescriptor meanDescriptor;
- meanDescriptor.m_KeepDims = keepDims;
-
- // Negative axis values are supported so that the process requires
- // to convert them into the corresponding positive ones.
- // Duplicate values are also removed.
- std::vector<int> rawAxisVector(axisData, axisData + axisTensorInfo.GetNumElements());
- std::set<unsigned int> positiveAxisSet;
- int rank = static_cast<int>(inputTensorInfo.GetNumDimensions());
-
- std::transform(rawAxisVector.begin(), rawAxisVector.end(),
- std::inserter(positiveAxisSet, positiveAxisSet.begin()),
- [rank](int i) -> unsigned int { return static_cast<unsigned int>((i + rank) % rank); });
-
- CalculateReducedOutputTensoInfo(inputTensorInfo, positiveAxisSet, keepDims, outputTensorInfo);
-
- if (inputTensorInfo.GetNumDimensions() > positiveAxisSet.size())
- {
- meanDescriptor.m_Axis.assign(positiveAxisSet.begin(), positiveAxisSet.end());
- }
-
- IConnectableLayer* layer = m_Network->AddMeanLayer(meanDescriptor, nodeDef.name().c_str());
- layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
- inputSlot.Connect(layer->GetInputSlot(0));
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-/// An ParsedTfOperation for a Mul node.
-/// Creation of the armnn Mul layer is deferred until it is actually needed, because Mul nodes
-/// are also used for the first part of a leaky relu activation function (Mul followed by Maximum)
-/// and in these cases armnn doesn't need a separate layer for the Mul.
-///
-class ParsedMulTfOperation : public DeferredSingleLayerParsedTfOperation
-{
-public:
- ParsedMulTfOperation(ITfParser::TfParserImpl* parser, const tensorflow::NodeDef& node)
- : DeferredSingleLayerParsedTfOperation(parser, node)
- {
- }
-
- void CreateLayerDeferred() override
- {
- ARMNN_ASSERT(m_Layer == nullptr);
- m_Layer = m_Parser->AddMultiplicationLayer(m_Node);
- }
-};
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseMul(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
-
- return std::make_unique<ParsedMulTfOperation>(this, nodeDef);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParsePlaceholder(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
-
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 0);
-
- const LayerBindingId layerId = armnn::numeric_cast<LayerBindingId>(m_NetworkInputsBindingInfo.size());
-
- auto it = m_InputShapes.find(nodeDef.name());
- if (it == m_InputShapes.end())
- {
- throw ParseException(
- fmt::format("Missing input shape for Placeholder '{}' {}",
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
- TensorInfo tensorInfo(it->second, DataType::Float32);
-
- IConnectableLayer* const layer = m_Network->AddInputLayer(layerId, nodeDef.name().c_str());
-
- layer->GetOutputSlot(0).SetTensorInfo(tensorInfo);
-
- TrackInputBinding(layer, layerId, tensorInfo);
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseRealDiv(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
- return AddRealDivLayer(nodeDef);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseRelu(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
-
- ActivationDescriptor activationDesc;
- activationDesc.m_Function = ActivationFunction::ReLu;
- return AddActivationLayer(nodeDef, activationDesc);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseRelu6(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
-
- ActivationDescriptor activationDesc;
- activationDesc.m_Function = ActivationFunction::BoundedReLu;
- activationDesc.m_A = 6.0f;
- activationDesc.m_B = 0.0f;
-
- return AddActivationLayer(nodeDef, activationDesc);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseSigmoid(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
-
- ActivationDescriptor activationDesc;
- activationDesc.m_Function = ActivationFunction::Sigmoid;
-
- return AddActivationLayer(nodeDef, activationDesc);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseRsqrt(const tensorflow::NodeDef &nodeDef,
- const tensorflow::GraphDef &graphDef)
-{
- IgnoreUnused(graphDef);
-
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 1);
-
- ElementwiseUnaryDescriptor descriptor(UnaryOperation::Rsqrt);
- IConnectableLayer* const layer = m_Network->AddElementwiseUnaryLayer(descriptor, nodeDef.name().c_str());
-
- IOutputSlot& prevLayerOutputSlot = inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- prevLayerOutputSlot.Connect(layer->GetInputSlot(0));
- layer->GetOutputSlot(0).SetTensorInfo(prevLayerOutputSlot.GetTensorInfo());
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseSoftmax(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
-
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 1);
-
- SoftmaxDescriptor softmaxDescriptor;
- IConnectableLayer* const layer = m_Network->AddSoftmaxLayer(softmaxDescriptor, nodeDef.name().c_str());
-
- IOutputSlot& prevLayerSlot = inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- prevLayerSlot.Connect(layer->GetInputSlot(0));
- layer->GetOutputSlot(0).SetTensorInfo(prevLayerSlot.GetTensorInfo());
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseSplit(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
-
- std::vector<OutputOfConstNodeDef> nodes = GetTfInputNodes(nodeDef);
- unsigned int numInputs = static_cast<unsigned int>(nodes.size());
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, numInputs);
-
- // Constant tensor index
- unsigned int index = GetConstInputIndex(inputs);
- // Get the axis tensor data
- ParsedConstTfOperation<int32_t>* shapeNode =
- PolymorphicDowncast<ParsedConstTfOperation<int32_t>*>(inputs[index].m_IndexedValue);
-
- std::vector<int32_t> axisTensorData;
- shapeNode->GetConstTensor(axisTensorData);
-
- // This splitDim indicates the data format: 3 is the NHWC, 1 is the NCHW.
- const unsigned int splitDim = static_cast<unsigned int>(axisTensorData[0]);
-
- // Armnn supports split along the channel dimension for data formats NHWC and NCHW.
- if (splitDim == 0 || splitDim == 2)
- {
- throw armnn::ParseException(
- fmt::format("Dimension {} for split is not supported by Armnn. "
- "Node {} {}",
- splitDim,
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- // As Armnn only supports splitter outputs of the same shape, therefore num_split will be limited to an integer.
- uint32_t num_split = ReadMandatoryNodeUint32Attribute(nodeDef, "num_split");
-
- IOutputSlot& inputSlot = inputs[1 - index].m_IndexedValue->ResolveArmnnOutputSlot(inputs[1 - index].m_Index);
- TensorInfo inputTensorInfo = inputSlot.GetTensorInfo();
-
- const unsigned int supportedNumDims = 4;
- auto inputDimSize = inputTensorInfo.GetNumDimensions();
-
- if (inputDimSize != supportedNumDims)
- {
- throw armnn::ParseException(
- fmt::format("The number of dimensions: {} for input tensors of the "
- "split op should be {} {}",
- inputTensorInfo.GetNumDimensions(),
- supportedNumDims,
- CHECK_LOCATION().AsString()));
- }
-
- std::vector<unsigned int> splitterDimSizes(inputDimSize);
-
- // Add current input shape to splitterDimSizes
- for (unsigned int i = 0; i < inputDimSize; ++i)
- {
- splitterDimSizes[i] = inputTensorInfo.GetShape()[i];
- }
-
- if (splitterDimSizes[splitDim] % num_split != 0)
- {
- throw ParseException("Number of splits must evenly divide the dimension");
- }
- splitterDimSizes[splitDim] /= num_split;
-
- SplitterDescriptor splitDesc(num_split);
- for (unsigned int g = 0; g < num_split; ++g)
- {
- // Set the size of the views.
- for (unsigned int dimIdx = 0; dimIdx < splitterDimSizes.size(); ++dimIdx)
- {
- splitDesc.SetViewSize(g, dimIdx, splitterDimSizes[dimIdx]);
- }
- splitDesc.SetViewOriginCoord(g, splitDim, splitterDimSizes[splitDim] * g);
- }
-
- IConnectableLayer *layer = m_Network->AddSplitterLayer(splitDesc, nodeDef.name().c_str());
-
- inputSlot.Connect(layer->GetInputSlot(0));
-
- TensorShape outShape = TensorShape(static_cast<unsigned int>(splitterDimSizes.size()),
- splitterDimSizes.data());
-
- for (unsigned int i = 0; i < layer->GetNumOutputSlots(); ++i)
- {
- layer->GetOutputSlot(i).SetTensorInfo(armnn::TensorInfo(outShape, inputTensorInfo.GetDataType()));
- }
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseSoftplus(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
-
- ActivationDescriptor activationDesc;
- activationDesc.m_Function = ActivationFunction::SoftReLu;
-
- return AddActivationLayer(nodeDef, activationDesc);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseStridedSlice(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
-
- std::vector<OutputOfConstNodeDef> nodes = GetTfInputNodes(nodeDef);
- unsigned int numInputs = static_cast<unsigned int>(nodes.size());
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, numInputs);
-
- ParsedConstTfOperation<int32_t>* beginNode =
- PolymorphicDowncast<ParsedConstTfOperation<int32_t> *>(inputs[1].m_IndexedValue);
- std::vector<int32_t> beginTensorData;
- beginNode->GetConstTensor(beginTensorData);
-
- ParsedConstTfOperation<int32_t>* endNode =
- PolymorphicDowncast<ParsedConstTfOperation<int32_t> *>(inputs[2].m_IndexedValue);
- std::vector<int32_t> endTensorData;
- endNode->GetConstTensor(endTensorData);
-
- ParsedConstTfOperation<int32_t>* stridesNode =
- PolymorphicDowncast<ParsedConstTfOperation<int32_t> *>(inputs[3].m_IndexedValue);
- std::vector<int32_t> stridesTensorData;
- stridesNode->GetConstTensor(stridesTensorData);
-
- StridedSliceDescriptor desc;
- desc.m_Begin = beginTensorData;
- desc.m_End = endTensorData;
- desc.m_Stride = stridesTensorData;
- desc.m_BeginMask = ReadMandatoryNodeInt32Attribute(nodeDef, "begin_mask");
- desc.m_EndMask = ReadMandatoryNodeInt32Attribute(nodeDef, "end_mask");
- desc.m_EllipsisMask = ReadMandatoryNodeInt32Attribute(nodeDef, "ellipsis_mask");
- desc.m_NewAxisMask = ReadMandatoryNodeInt32Attribute(nodeDef, "new_axis_mask");
- desc.m_ShrinkAxisMask = ReadMandatoryNodeInt32Attribute(nodeDef, "shrink_axis_mask");
- desc.m_DataLayout = armnn::DataLayout::NHWC;
- IConnectableLayer* const layer = m_Network->AddStridedSliceLayer(desc, nodeDef.name().c_str());
-
- IOutputSlot& prevLayerSlot = inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- TensorInfo inputTensorInfo = prevLayerSlot.GetTensorInfo();
-
- TensorInfo outputTensorInfo;
- CalculateStridedSliceOutputTensorInfo(inputTensorInfo, desc, outputTensorInfo);
-
- prevLayerSlot.Connect(layer->GetInputSlot(0));
- layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo);
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseTanh(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- IgnoreUnused(graphDef);
-
- ActivationDescriptor activationDesc;
- activationDesc.m_Function = ActivationFunction::TanH;
- activationDesc.m_A = 1.0f;
- activationDesc.m_B = 1.0f;
-
- return AddActivationLayer(nodeDef, activationDesc);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::AddActivationLayer(const tensorflow::NodeDef& nodeDef,
- ActivationDescriptor& activationDesc)
-{
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 1);
-
- IConnectableLayer* const layer = m_Network->AddActivationLayer(activationDesc, nodeDef.name().c_str());
-
- IOutputSlot& prevLayerOutputSlot = inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- prevLayerOutputSlot.Connect(layer->GetInputSlot(0));
- layer->GetOutputSlot(0).SetTensorInfo(prevLayerOutputSlot.GetTensorInfo());
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseMaxPool(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- return ParsePooling2d(nodeDef, graphDef, PoolingAlgorithm::Max);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParseAvgPool(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef)
-{
- return ParsePooling2d(nodeDef, graphDef, PoolingAlgorithm::Average);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::ParsePooling2d(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef, PoolingAlgorithm pooltype)
-{
- IgnoreUnused(graphDef);
-
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 1);
- IOutputSlot& inputSlot = inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- TensorInfo inputTensorInfo = inputSlot.GetTensorInfo();
-
- if (inputs.size() != 1)
- {
- throw ParseException(
- fmt::format("2D Pooling expects one input!. Got {} for Node {} {}",
- inputs.size(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- std::string paddingString = ReadMandatoryNodeStringAttribute(nodeDef, "padding");
- std::string dataFormat = ReadMandatoryNodeStringAttribute(nodeDef, "data_format");
- std::vector<uint32_t> strides = ReadMandatoryNodeUint32ListAttribute(nodeDef, "strides");
- std::vector<uint32_t> ksize = ReadMandatoryNodeUint32ListAttribute(nodeDef, "ksize"); // size of pool windows
-
- Pooling2dDescriptor pooling2dDescriptor;
- pooling2dDescriptor.m_PoolType = pooltype;
- pooling2dDescriptor.m_PaddingMethod = PaddingMethod::Exclude;
- pooling2dDescriptor.m_OutputShapeRounding = OutputShapeRounding::Floor;
-
- CHECK_DATA_FORMAT(nodeDef, dataFormat, "Pooling2D");
- DataLayout dataLayout = dataFormat == "NHWC" ? DataLayout::NHWC : DataLayout::NCHW;
- pooling2dDescriptor.m_DataLayout = dataLayout;
- DataLayoutIndexed dataLayoutIndexed(dataLayout);
-
- pooling2dDescriptor.m_StrideX = strides[dataLayoutIndexed.GetWidthIndex()];
- pooling2dDescriptor.m_StrideY = strides[dataLayoutIndexed.GetHeightIndex()];
- pooling2dDescriptor.m_PoolWidth = ksize[dataLayoutIndexed.GetWidthIndex()];
- pooling2dDescriptor.m_PoolHeight = ksize[dataLayoutIndexed.GetHeightIndex()];
-
- uint32_t inputHeight = inputTensorInfo.GetShape()[dataLayoutIndexed.GetHeightIndex()];
- uint32_t inputWidth = inputTensorInfo.GetShape()[dataLayoutIndexed.GetWidthIndex()];
-
- bool padding = false;
- TensorInfo outputInfo;
- unsigned int outputHeight = 0;
- unsigned int outputWidth = 0;
-
- CHECK_PADDING_TYPE(nodeDef, paddingString);
-
- if (paddingString == "SAME")
- {
- padding = true;
-
- outputHeight = static_cast<uint32_t>(ceil(static_cast<float>(inputHeight) /
- static_cast<float>(pooling2dDescriptor.m_StrideY)));
- outputWidth = static_cast<uint32_t>(ceil(static_cast<float>(inputWidth) /
- static_cast<float>(pooling2dDescriptor.m_StrideX)));
- }
- else if (paddingString == "VALID")
- {
- padding = false;
-
- outputHeight = static_cast<uint32_t>(ceil(
- static_cast<float>(inputHeight - pooling2dDescriptor.m_PoolHeight + 1) /
- static_cast<float>(pooling2dDescriptor.m_StrideY)));
- outputWidth = static_cast<uint32_t>(ceil(
- static_cast<float>(inputWidth - pooling2dDescriptor.m_PoolWidth + 1) /
- static_cast<float>(pooling2dDescriptor.m_StrideX)));
- }
-
- switch (dataLayout)
- {
- case DataLayout::NHWC:
- outputInfo = TensorInfo({ inputTensorInfo.GetShape()[0],
- outputHeight,
- outputWidth,
- inputTensorInfo.GetShape()[3] },
- DataType::Float32);
- break;
- case DataLayout::NCHW:
- outputInfo = TensorInfo({ inputTensorInfo.GetShape()[0],
- inputTensorInfo.GetShape()[1],
- outputHeight,
- outputWidth },
- DataType::Float32);
- break;
- }
-
- CalcPadding(inputWidth, pooling2dDescriptor.m_PoolWidth, pooling2dDescriptor.m_StrideX, 1u,
- pooling2dDescriptor.m_PadLeft, pooling2dDescriptor.m_PadRight, padding);
- CalcPadding(inputHeight, pooling2dDescriptor.m_PoolHeight, pooling2dDescriptor.m_StrideY, 1u,
- pooling2dDescriptor.m_PadTop, pooling2dDescriptor.m_PadBottom, padding);
-
-
- IConnectableLayer* layer = m_Network->AddPooling2dLayer(pooling2dDescriptor, nodeDef.name().c_str());
- if (layer == nullptr)
- {
- throw ParseException(
- fmt::format("Failed to add pooling2d layer for {} {}",
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- layer->GetOutputSlot(0).SetTensorInfo(outputInfo);
-
- inputSlot.Connect(layer->GetInputSlot(0));
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::AddAdditionLayer(const tensorflow::NodeDef& nodeDef, bool isBiasAdd)
-{
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 2);
-
- IOutputSlot* input0Slot = &inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- IOutputSlot* input1Slot = &inputs[1].m_IndexedValue->ResolveArmnnOutputSlot(inputs[1].m_Index);
-
- const TensorInfo& input0Info = input0Slot->GetTensorInfo();
- const TensorInfo& input1Info = input1Slot->GetTensorInfo();
-
- if (isBiasAdd)
- {
- // BiasAdd takes bias as a 1D tensor. We need to add a reshape layer to create a 4D tensor
- // with the same data in the correct dimension for broadcast in addition.
- if(input1Info.GetNumDimensions() != 1)
- {
- throw ParseException(
- fmt::format("Unsupported bias for BiasAdd. It should be a 1D vector. "
- "Got {} dimensions for input {}. Node {} {}",
- input1Info.GetNumDimensions(),
- inputs[1].m_IndexedValue->GetNode().name(),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- const std::string dataFormat = ReadMandatoryNodeStringAttribute(nodeDef, "data_format");
-
- CHECK_DATA_FORMAT(nodeDef, dataFormat, "BiasAdd");
- input1Slot = AddBroadcastReshapeLayer(input0Slot, input1Slot, dataFormat == "NHWC", *m_Network, nodeDef);
- }
- else
- {
- if (input0Info.GetNumDimensions() == 1)
- {
- const bool isNHWC = true;
- input0Slot = AddBroadcastReshapeLayer(input1Slot, input0Slot, isNHWC, *m_Network, nodeDef);
- }
-
- if (input1Info.GetNumDimensions() == 1)
- {
- const bool isNHWC = true;
- input1Slot = AddBroadcastReshapeLayer(input0Slot, input1Slot, isNHWC, *m_Network, nodeDef);
- }
- }
-
- IConnectableLayer* const layer = m_Network->AddAdditionLayer(nodeDef.name().c_str());
-
- input0Slot->Connect(layer->GetInputSlot(0));
- input1Slot->Connect(layer->GetInputSlot(1));
-
- if (input0Info.GetNumDimensions() == input1Info.GetNumDimensions())
- {
- const TensorShape& input0Shape = input0Info.GetShape();
- const TensorShape& input1Shape = input1Info.GetShape();
-
- std::vector<unsigned int> outputShape;
- outputShape.reserve(input0Shape.GetNumDimensions());
- TensorInfo outputInfo(input0Info);
-
- for (unsigned int i = 0; i < input0Shape.GetNumDimensions(); i++)
- {
- outputShape.push_back(std::max(input0Shape[i], input1Shape[i]));
- }
-
- outputInfo.SetShape(TensorShape(input0Shape.GetNumDimensions(), outputShape.data()));
-
- layer->GetOutputSlot(0).SetTensorInfo(outputInfo);
- }
- else if (input0Info.GetNumDimensions() == 1 && isBiasAdd == false)
- {
- layer->GetOutputSlot(0).SetTensorInfo(input1Slot->GetTensorInfo());
- }
- else
- {
- layer->GetOutputSlot(0).SetTensorInfo(input0Slot->GetTensorInfo());
- }
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::AddRealDivLayer(const tensorflow::NodeDef& nodeDef)
-{
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 2);
-
- IConnectableLayer* const layer = m_Network->AddDivisionLayer(nodeDef.name().c_str());
- IOutputSlot* input0Slot = &inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- IOutputSlot* input1Slot = &inputs[1].m_IndexedValue->ResolveArmnnOutputSlot(inputs[1].m_Index);
-
- auto const input0NumDims = input0Slot->GetTensorInfo().GetNumDimensions();
- auto const input1NumDims = input1Slot->GetTensorInfo().GetNumDimensions();
-
-
- if (input0NumDims < input1NumDims)
- {
- const bool isNHWC = true;
- input0Slot = AddBroadcastReshapeLayer(input1Slot, input0Slot, isNHWC, *m_Network, nodeDef);
- }
- if (input1NumDims < input0NumDims)
- {
- const bool isNHWC = true;
- input1Slot = AddBroadcastReshapeLayer(input0Slot, input1Slot, isNHWC, *m_Network, nodeDef);
- }
-
- input0Slot->Connect(layer->GetInputSlot(0));
- input1Slot->Connect(layer->GetInputSlot(1));
-
- if (input0NumDims < input1NumDims)
- {
- layer->GetOutputSlot(0).SetTensorInfo(input1Slot->GetTensorInfo());
- }
- else
- {
- layer->GetOutputSlot(0).SetTensorInfo(input0Slot->GetTensorInfo());
-
- }
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-ParsedTfOperationPtr ITfParser::TfParserImpl::AddMaximumLayer(const tensorflow::NodeDef& nodeDef)
-{
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 2);
-
- IOutputSlot* input0Slot = &inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- IOutputSlot* input1Slot = &inputs[1].m_IndexedValue->ResolveArmnnOutputSlot(inputs[1].m_Index);
-
- auto const input0NumDims = input0Slot->GetTensorInfo().GetNumDimensions();
- auto const input1NumDims = input1Slot->GetTensorInfo().GetNumDimensions();
-
- if (input0NumDims < input1NumDims)
- {
- const bool isNHWC = true;
- input0Slot = AddBroadcastReshapeLayer(input1Slot, input0Slot, isNHWC, *m_Network, nodeDef);
- }
- if (input1NumDims < input0NumDims)
- {
- const bool isNHWC = true;
- input1Slot = AddBroadcastReshapeLayer(input0Slot, input1Slot, isNHWC, *m_Network, nodeDef);
- }
-
- IConnectableLayer* const layer = m_Network->AddMaximumLayer(nodeDef.name().c_str());
-
- input0Slot->Connect(layer->GetInputSlot(0));
- input1Slot->Connect(layer->GetInputSlot(1));
-
- TensorInfo outputInfo = input0Slot->GetTensorInfo();
- std::vector<unsigned int> outputShape;
-
- const TensorShape& input0Shape = input0Slot->GetTensorInfo().GetShape();
- const TensorShape& input1Shape = input1Slot->GetTensorInfo().GetShape();
-
- for (unsigned int i = 0; i < input0Shape.GetNumDimensions(); i++)
- {
- outputShape.push_back(std::max(input0Shape[i], input1Shape[i]));
- }
-
- outputInfo.SetShape(TensorShape(input0Shape.GetNumDimensions(), outputShape.data()));
- layer->GetOutputSlot(0).SetTensorInfo(outputInfo);
-
- return std::make_unique<SingleLayerParsedTfOperation>(this, nodeDef, layer);
-}
-
-IConnectableLayer* ITfParser::TfParserImpl::AddMultiplicationLayer(const tensorflow::NodeDef& nodeDef)
-{
- std::vector<OutputOfParsedTfOperation> inputs = GetInputParsedTfOperationsChecked(nodeDef, 2);
-
- IConnectableLayer* const layer = m_Network->AddMultiplicationLayer(nodeDef.name().c_str());
- IOutputSlot* input0Slot = &inputs[0].m_IndexedValue->ResolveArmnnOutputSlot(inputs[0].m_Index);
- IOutputSlot* input1Slot = &inputs[1].m_IndexedValue->ResolveArmnnOutputSlot(inputs[1].m_Index);
-
- auto const input0NumDims = input0Slot->GetTensorInfo().GetNumDimensions();
- auto const input1NumDims = input1Slot->GetTensorInfo().GetNumDimensions();
-
- if (input0NumDims < input1NumDims)
- {
- const bool isNHWC = true;
- input0Slot = AddBroadcastReshapeLayer(input1Slot, input0Slot, isNHWC, *m_Network, nodeDef);
- }
- if (input1NumDims < input0NumDims)
- {
- const bool isNHWC = true;
- input1Slot = AddBroadcastReshapeLayer(input0Slot, input1Slot, isNHWC, *m_Network, nodeDef);
- }
-
- input0Slot->Connect(layer->GetInputSlot(0));
- input1Slot->Connect(layer->GetInputSlot(1));
-
- if (input0NumDims < input1NumDims)
- {
- layer->GetOutputSlot(0).SetTensorInfo(input1Slot->GetTensorInfo());
- }
- else
- {
- layer->GetOutputSlot(0).SetTensorInfo(input0Slot->GetTensorInfo());
- }
- return layer;
-}
-
-IConnectableLayer* ITfParser::TfParserImpl::AddFullyConnectedLayer(const tensorflow::NodeDef& matMulNodeDef,
- const tensorflow::NodeDef* addNodeDef, const char* armnnLayerName)
-{
- // Finds bias const (if applicable).
- ParsedConstTfOperation<float>* biasNode = nullptr;
- if (addNodeDef != nullptr)
- {
- std::vector<OutputOfParsedTfOperation> addInputs = GetInputParsedTfOperationsChecked(*addNodeDef, 2);
- // Finds our inputs.
- if (HasParsedConstTensor<float>(addInputs[0].m_IndexedValue->GetNode().name()))
- {
- biasNode = PolymorphicDowncast<ParsedConstTfOperation<float>*>(addInputs[0].m_IndexedValue);
- }
- else if (HasParsedConstTensor<float>(addInputs[1].m_IndexedValue->GetNode().name()))
- {
- biasNode = PolymorphicDowncast<ParsedConstTfOperation<float>*>(addInputs[1].m_IndexedValue);
- }
- else
- {
- throw ParseException(
- fmt::format("ArmNN only supports fully connected layers with constant bias. "
- "Inputs {} and {}. AddNode {}. MatMulNode {} {}",
- addInputs[0].m_IndexedValue->GetNode().name(),
- addInputs[1].m_IndexedValue->GetNode().name(),
- addNodeDef->name(),
- matMulNodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
- }
-
- // Finds matmul inputs.
- ParsedConstTfOperation<float>* weightNode = nullptr;
- ParsedTfOperation* inputNode = nullptr;
- unsigned int inputIdx = 0;
- std::vector<OutputOfParsedTfOperation> mulInputs = GetInputParsedTfOperationsChecked(matMulNodeDef, 2);
- if (HasParsedConstTensor<float>(mulInputs[0].m_IndexedValue->GetNode().name()))
- {
- weightNode = PolymorphicDowncast<ParsedConstTfOperation<float>*>(mulInputs[0].m_IndexedValue);
- inputNode = mulInputs[1].m_IndexedValue;
- inputIdx = mulInputs[1].m_Index;
- }
- else if (HasParsedConstTensor<float>(mulInputs[1].m_IndexedValue->GetNode().name()))
- {
- weightNode = PolymorphicDowncast<ParsedConstTfOperation<float>*>(mulInputs[1].m_IndexedValue);
- inputNode = mulInputs[0].m_IndexedValue;
- inputIdx = mulInputs[0].m_Index;
- }
- else
- {
- throw ParseException(
- fmt::format("ArmNN only supports fully connected layers with constant weights. "
- "Inputs {} and {}. MatMulNode {} {}",
- mulInputs[0].m_IndexedValue->GetNode().name(),
- mulInputs[1].m_IndexedValue->GetNode().name(),
- matMulNodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- std::vector<float> weightTensorData;
- // Handles weight.
- ConstTensor weights = weightNode->GetConstTensor(weightTensorData);
-
- FullyConnectedDescriptor desc;
- desc.m_BiasEnabled = addNodeDef != nullptr;
-
- IConnectableLayer* layer = nullptr;
- Optional<ConstTensor> optionalBiases;
- std::vector<float> biasTensorData;
- // Makes the layer.
- if (addNodeDef != nullptr)
- {
- ConstTensor biases = biasNode->GetConstTensor(biasTensorData);
-
- if (weights.GetShape()[1] != biases.GetShape()[0])
- {
- throw ParseException(
- fmt::format("Shape of matmul weights and bias do not match. "
- "AddNode {}. MatMulNode {} {}",
- addNodeDef->name(),
- matMulNodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- optionalBiases = Optional<ConstTensor>(biases);
- }
- layer = m_Network->AddFullyConnectedLayer(desc, weights, optionalBiases, armnnLayerName);
-
- ARMNN_ASSERT(layer != nullptr);
-
- inputNode->ResolveArmnnOutputSlot(inputIdx).Connect(layer->GetInputSlot(0));
- unsigned int batches = inputNode->ResolveArmnnOutputSlot(inputIdx).GetTensorInfo().GetShape()[0];
-
- // Handles output.
- TensorInfo outputInfo({ batches, weights.GetShape()[1] }, DataType::Float32);
- layer->GetOutputSlot(0).SetTensorInfo(outputInfo);
- return layer;
-}
-
-void ITfParser::TfParserImpl::LoadNodeDef(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef)
-{
- // Gets the type of the node (assume float).
- tensorflow::DataType type = tensorflow::DT_FLOAT;
- if (nodeDef.attr().count("T") != 0)
- {
- auto attr = nodeDef.attr().at("T");
- type = attr.type();
- }
- else if (nodeDef.attr().count("dtype") != 0)
- {
- auto attr = nodeDef.attr().at("dtype");
- type = attr.type();
- }
-
- if ((type != tensorflow::DT_FLOAT && type != tensorflow::DT_INT32) && nodeDef.op() != "Const")
- {
- throw ParseException(
- fmt::format("Currently only FLOAT and INT32 are supported for tensorflow nodes (apart from Const). "
- "Got {} for Node {} {}",
- tensorflow::DataType_Name(type),
- nodeDef.name(),
- CHECK_LOCATION().AsString()));
- }
-
- const std::string& operation = nodeDef.op();
- auto itControlInput = std::find(m_ControlInputs.begin(), m_ControlInputs.end(), operation);
- if (itControlInput != m_ControlInputs.end())
- {
- // We currently allow Control Input from TensorFlow graph but we ignore them from ArmNN graph.
- return;
- }
- auto it = ms_OperationNameToParsingFunctions.find(operation);
- if (it != ms_OperationNameToParsingFunctions.end())
- {
- auto func = it->second;
- ParsedTfOperationPtr parsedTfOperation = (this->*func)(nodeDef, graphDef);
- ParsedTfOperation* parsedTfOperationRaw = parsedTfOperation.get();
-
- // Stores the parsed operation so that dependent layers can connect to it.
- auto it = m_ParsedTfOperations.find(nodeDef.name());
- if (it != m_ParsedTfOperations.end())
- {
- throw ParseException(fmt::format("Name {} used by more than one node", nodeDef.name()));
- }
- m_ParsedTfOperations[nodeDef.name()] = std::move(parsedTfOperation);
-
- // If this node was requested as an output from the network, then adds an ArmNN output layer.
- if (std::find(m_RequestedOutputs.begin(), m_RequestedOutputs.end(), nodeDef.name()) !=
- m_RequestedOutputs.end())
- {
- auto outId = ParseOutputId(nodeDef.name());
- const LayerBindingId layerId = armnn::numeric_cast<LayerBindingId>(m_NetworkOutputsBindingInfo.size());
- IOutputSlot& prevSlot = parsedTfOperationRaw->ResolveArmnnOutputSlot(outId.m_Index);
-
- TensorInfo tensorInfo = prevSlot.GetTensorInfo();
-
- IConnectableLayer* outputLayer = m_Network->AddOutputLayer(layerId, nodeDef.name().c_str());
-
- prevSlot.Connect(outputLayer->GetInputSlot(0));
-
- TrackOutputBinding(outputLayer, layerId, tensorInfo);
- }
- }
- else
- {
- throw ParseException(
- fmt::format("Unsupported operation {} in tensorflow::GraphDef {}",
- operation,
- CHECK_LOCATION().AsString()));
- }
-}
-
-void ITfParser::TfParserImpl::LoadGraphDef(const tensorflow::GraphDef& graphDef)
-{
- // Adds all nodes to our map.
- m_NodesByName.clear();
- m_NetworkInputsBindingInfo.clear();
- m_NetworkOutputsBindingInfo.clear();
-
- for (int i = 0; i < graphDef.node_size(); ++i)
- {
- const tensorflow::NodeDef& node = graphDef.node(i);
- m_NodesByName[node.name()] = &node;
- }
-
- // Checks that the input nodes the user has requested exist.
- for (const auto& pair : m_InputShapes)
- {
- const std::string& requestedInputName = pair.first;
- auto nodeIt = m_NodesByName.find(requestedInputName);
- if (nodeIt == m_NodesByName.end())
- {
- throw ParseException(
- fmt::format("Couldn't find requested input node '{}' in graph {}",
- requestedInputName,
- CHECK_LOCATION().AsString()));
- }
- }
-
- // Finds the output nodes the user requested.
- std::vector<const tensorflow::NodeDef*> targetNodes;
- for (const std::string& requestedOutputName : m_RequestedOutputs)
- {
- auto nodeIt = m_NodesByName.find(requestedOutputName);
- if (nodeIt == m_NodesByName.end())
- {
- throw ParseException(
- fmt::format("Couldn't find requested output node '{}' in graph {}",
- requestedOutputName,
- CHECK_LOCATION().AsString()));
- }
- targetNodes.push_back(nodeIt->second);
- }
-
- // Sorts them into a linear ordering such that all inputs of a node are before the node itself.
- std::vector<const tensorflow::NodeDef*> sortedNodes;
- if (!armnnUtils::GraphTopologicalSort<const tensorflow::NodeDef*>(
- targetNodes,
- [this](const tensorflow::NodeDef* node)
- {
- auto outputs = GetTfInputNodes(*node);
- std::vector<const tensorflow::NodeDef*> nodesOnly;
- for (const auto & o : outputs) {
- nodesOnly.push_back(o.m_IndexedValue);
- }
- return nodesOnly;
- },
- sortedNodes))
- {
- throw ParseException(
- fmt::format("Cycle detected in graph {}",
- CHECK_LOCATION().AsString()));
- }
-
- // Parses each node in order, knowing that all inputs of a node will be processed before the node itself.
- for (const auto& it : sortedNodes)
- {
- const tensorflow::NodeDef& currentNode = *it;
- LoadNodeDef(currentNode, graphDef);
- }
-}
-
-INetworkPtr ITfParser::TfParserImpl::CreateNetworkFromTextFile(const char* graphFile,
- const std::map<std::string, TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs)
-{
- FILE* fd = fopen(graphFile, "r");
-
- if (fd == nullptr)
- {
- throw FileNotFoundException(
- fmt::format("Graph file {} failed to open {}",
- graphFile,
- CHECK_LOCATION().AsString()));
- }
-
- // Parses the file into a message.
- tensorflow::GraphDef graphDef;
- auto input = new google::protobuf::io::FileInputStream(fileno(fd));
- bool success = google::protobuf::TextFormat::Parse(input, &graphDef);
- delete input;
- fclose(fd);
-
- if (!success)
- {
- throw ParseException(
- fmt::format("Failed to parse graph file {}",
- CHECK_LOCATION().AsString()));
- }
-
- return CreateNetworkFromGraphDef(graphDef, inputShapes, requestedOutputs);
-}
-
-INetworkPtr ITfParser::TfParserImpl::CreateNetworkFromString(const char* protoText,
- const std::map<std::string, TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs)
-{
- // Parses the string into a message.
- tensorflow::GraphDef graphDef;
- bool success = google::protobuf::TextFormat::ParseFromString(protoText, &graphDef);
-
- if (!success)
- {
- throw ParseException(
- fmt::format("Failed to parse graph file {}",
- CHECK_LOCATION().AsString()));
- }
-
- return CreateNetworkFromGraphDef(graphDef, inputShapes, requestedOutputs);
-}
-
-INetworkPtr ITfParser::TfParserImpl::CreateNetworkFromBinaryFile(const char* graphFile,
- const std::map<std::string, TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs)
-{
- FILE* fd = fopen(graphFile, "rb");
-
- if (fd == nullptr)
- {
- throw FileNotFoundException(
- fmt::format("Graph file {} failed to open {}",
- graphFile,
- CHECK_LOCATION().AsString()));
- }
-
- // Parses the file into a message.
- tensorflow::GraphDef graphDef;
-
- google::protobuf::io::FileInputStream inStream(fileno(fd));
- google::protobuf::io::CodedInputStream codedStream(&inStream);
- codedStream.SetTotalBytesLimit(INT_MAX);
- bool success = graphDef.ParseFromCodedStream(&codedStream);
- fclose(fd);
-
- if (!success)
- {
- throw ParseException(
- fmt::format("Failed to parse protobuf file {} {}",
- graphFile,
- CHECK_LOCATION().AsString()));
- }
-
- return CreateNetworkFromGraphDef(graphDef, inputShapes, requestedOutputs);
-}
-
-INetworkPtr ITfParser::TfParserImpl::CreateNetworkFromGraphDef(const tensorflow::GraphDef& graphDef,
- const std::map<std::string, TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs)
-{
- m_Network = INetwork::Create();
-
- m_InputShapes = inputShapes;
- if (requestedOutputs.size() == 0)
- {
- throw ParseException(
- fmt::format("requestedOutputs must have at least one entry {}",
- CHECK_LOCATION().AsString()));
- }
- m_RequestedOutputs = requestedOutputs;
-
- try
- {
- LoadGraphDef(graphDef);
- }
- catch (const ParseException& e)
- {
- Cleanup();
- throw e;
- }
-
- Cleanup();
-
- return std::move(m_Network);
-}
-
-void ITfParser::TfParserImpl::Cleanup()
-{
- // Cleanup, in case we reuse this parser.
- m_InputShapes.clear();
- m_RequestedOutputs.clear();
- m_NodesByName.clear();
- m_ParsedTfOperations.clear();
-}
-
-BindingPointInfo ITfParser::TfParserImpl::GetNetworkInputBindingInfo(const std::string& name) const
-{
- return GetBindingInfo(name, "input", m_NetworkInputsBindingInfo);
-}
-
-BindingPointInfo ITfParser::TfParserImpl::GetNetworkOutputBindingInfo(const std::string& name) const
-{
- return GetBindingInfo(name, "output", m_NetworkOutputsBindingInfo);
-}
-
-std::pair<LayerBindingId, TensorInfo> ITfParser::TfParserImpl::GetBindingInfo(const std::string& layerName,
- const char* bindingPointDesc,
- const std::unordered_map<std::string, BindingPointInfo>& nameToBindingInfo)
-{
- auto it = nameToBindingInfo.find(layerName);
- if (it == nameToBindingInfo.end())
- {
- throw InvalidArgumentException(
- fmt::format("Unknown {} '{}' {}",
- bindingPointDesc,
- layerName,
- CHECK_LOCATION().AsString()));
- }
- return it->second;
-}
-
-void ITfParser::TfParserImpl::TrackInputBinding(IConnectableLayer* layer,
- LayerBindingId id,
- const TensorInfo& tensorInfo)
-{
- return TrackBindingPoint(layer, id, tensorInfo, "input", m_NetworkInputsBindingInfo);
-}
-
-void ITfParser::TfParserImpl::TrackOutputBinding(IConnectableLayer* layer,
- LayerBindingId id,
- const TensorInfo& tensorInfo)
-{
- return TrackBindingPoint(layer, id, tensorInfo, "output", m_NetworkOutputsBindingInfo);
-}
-
-void ITfParser::TfParserImpl::TrackBindingPoint(IConnectableLayer* layer,
- LayerBindingId id,
- const TensorInfo& tensorInfo,
- const char* bindingPointDesc,
- std::unordered_map<std::string, BindingPointInfo>& nameToBindingInfo)
-{
- const std::string layerName = layer->GetName();
- auto it = nameToBindingInfo.find(layerName);
- if (it == nameToBindingInfo.end())
- {
- nameToBindingInfo[layerName] = std::make_pair(id, tensorInfo);
- }
- else
- {
- throw ParseException(
- fmt::format("Id {} used by more than one {} layer {}",
- id,
- bindingPointDesc,
- CHECK_LOCATION().AsString()));
- }
-}
-
-const std::string ITfParser::TfParserImpl::GetVersion()
-{
- return TF_PARSER_VERSION;
-}
-
-} // namespace armnnTfParser
diff --git a/src/armnnTfParser/TfParser.hpp b/src/armnnTfParser/TfParser.hpp
deleted file mode 100644
index 31e074de93..0000000000
--- a/src/armnnTfParser/TfParser.hpp
+++ /dev/null
@@ -1,276 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-#pragma once
-
-#include "armnnTfParser/ITfParser.hpp"
-
-#include "armnn/Types.hpp"
-#include "armnn/Tensor.hpp"
-#include "armnn/INetwork.hpp"
-
-#include <list>
-#include <map>
-#include <memory>
-#include <unordered_map>
-#include <utility>
-#include <vector>
-
-namespace armnn
-{
-class TensorInfo;
-}
-
-namespace tensorflow
-{
-class GraphDef;
-class NodeDef;
-}
-
-namespace armnnTfParser
-{
-
-class ParsedTfOperation;
-using ParsedTfOperationPtr = std::unique_ptr<ParsedTfOperation>;
-
-///
-/// WithOutputTensorIndex wraps a value and an index. The purpose of
-/// this template is to signify that, in Tensorflow, the input name of
-/// a layer has the convention of 'inputTensorName:#index', where the
-/// #index can be omitted and it implicitly means the 0 output of
-/// the referenced layer. By supporting this notation we can handle
-/// layers with multiple outputs, such as Split.
-///
-template <typename T>
-struct WithOutputTensorIndex
-{
- T m_IndexedValue;
- unsigned int m_Index;
-
- WithOutputTensorIndex(const T & value, unsigned int index)
- : m_IndexedValue{value}
- , m_Index{index} {}
-
- WithOutputTensorIndex(T && value, unsigned int index)
- : m_IndexedValue{value}
- , m_Index{index} {}
-};
-
-using OutputOfParsedTfOperation = WithOutputTensorIndex<ParsedTfOperation *>;
-using OutputOfConstNodeDef = WithOutputTensorIndex<const tensorflow::NodeDef*>;
-using OutputId = WithOutputTensorIndex<std::string>;
-
-struct ITfParser::TfParserImpl
-{
-public:
- /// Creates the network from a protobuf text file on the disk.
- armnn::INetworkPtr CreateNetworkFromTextFile(
- const char* graphFile,
- const std::map<std::string, armnn::TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs);
-
- /// Creates the network from a protobuf binary file on the disk.
- armnn::INetworkPtr CreateNetworkFromBinaryFile(
- const char* graphFile,
- const std::map<std::string, armnn::TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs);
-
- /// Creates the network directly from protobuf text in a string. Useful for debugging/testing.
- armnn::INetworkPtr CreateNetworkFromString(
- const char* protoText,
- const std::map<std::string, armnn::TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs);
-
- /// Retrieves binding info (layer id and tensor info) for the network input identified by the given layer name.
- BindingPointInfo GetNetworkInputBindingInfo(const std::string& name) const;
-
- /// Retrieves binding info (layer id and tensor info) for the network output identified by the given layer name.
- BindingPointInfo GetNetworkOutputBindingInfo(const std::string& name) const;
-
- /// Retrieve version in X.Y.Z form
- static const std::string GetVersion();
-
- TfParserImpl();
- ~TfParserImpl() = default;
-
- TfParserImpl(const TfParserImpl&) = delete;
- TfParserImpl& operator=(const TfParserImpl&) = delete;
-
- /// Parses a GraphDef loaded into memory from one of the other CreateNetwork*.
- armnn::INetworkPtr CreateNetworkFromGraphDef(const tensorflow::GraphDef& graphDef,
- const std::map<std::string, armnn::TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs);
-
- /// Sets up variables and then performs BFS to parse all nodes.
- void LoadGraphDef(const tensorflow::GraphDef& graphDef);
-
- /// Parses a given node, assuming nodes before it in the graph have been done.
- void LoadNodeDef(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
-
- /// Handling identity layers as the input for Conv2D layer.
- const tensorflow::NodeDef* ResolveIdentityNode(const tensorflow::NodeDef* nodeDef);
- /// Finds the nodes connected as inputs of the given node in the graph.
- std::vector<OutputOfConstNodeDef> GetTfInputNodes(const tensorflow::NodeDef& nodeDef) const;
- /// Finds the IParsedTfOperations for the nodes connected as inputs of the given node in the graph,
- /// and throws an exception if the number of inputs does not match the expected one.
- /// This will automatically resolve any identity nodes. The result vector contains the parsed operation
- /// together with the output tensor index to make the connection unambiguous.
- std::vector<OutputOfParsedTfOperation> GetInputParsedTfOperationsChecked(const tensorflow::NodeDef& nodeDef,
- std::size_t expectedNumInputs);
-
- ParsedTfOperationPtr ParseConst(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
-
- /// Checks if there is a pre-parsed const tensor available with the given name and Type.
- template<typename Type>
- bool HasParsedConstTensor(const std::string & nodeName) const;
- template<typename Type>
- bool HasParsedConstTensor(ParsedTfOperation* parsedTfOpPtr) const;
-
- unsigned int GetConstInputIndex(const std::vector<OutputOfParsedTfOperation>& inputs);
-
- ParsedTfOperationPtr ParseAdd(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseAddN(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseBiasAdd(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseConv2D(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseDepthwiseConv2D(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseExpandDims(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseFusedBatchNorm(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseConcat(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseIdentity(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseLrn(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseMatMul(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseMean(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseMul(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParsePlaceholder(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseRealDiv(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseRelu(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseRelu6(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseReshape(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseResizeBilinear(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseRsqrt(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseShape(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseSqueeze(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseSigmoid(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseSoftmax(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseSoftplus(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseSplit(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseStridedSlice(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseTanh(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseMaxPool(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseAvgPool(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParsePooling2d(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef,
- armnn::PoolingAlgorithm pooltype);
- ParsedTfOperationPtr ParseEqual(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseMaximum(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseMinimum(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseGather(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseGreater(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParsePad(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseSub(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseStack(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr ParseTranspose(const tensorflow::NodeDef& nodeDef, const tensorflow::GraphDef& graphDef);
- ParsedTfOperationPtr AddActivationLayer(const tensorflow::NodeDef& nodeDef, armnn::ActivationDescriptor& desc);
- ParsedTfOperationPtr AddAdditionLayer(const tensorflow::NodeDef& nodeDef, bool isBiasAdd = false);
- ParsedTfOperationPtr AddRealDivLayer(const tensorflow::NodeDef& nodeDef);
- ParsedTfOperationPtr AddMaximumLayer(const tensorflow::NodeDef& nodeDef);
-
- armnn::IConnectableLayer* AddMultiplicationLayer(const tensorflow::NodeDef& nodeDef);
-
- armnn::IConnectableLayer* AddFullyConnectedLayer(const tensorflow::NodeDef& matMulNodeDef,
- const tensorflow::NodeDef* addNodeDef, const char* armnnLayerName);
-
- bool IsSupportedLeakyReluPattern(const tensorflow::NodeDef& mulNodeDef,
- size_t alphaLayerIndex,
- const OutputOfParsedTfOperation& otherOp,
- armnn::IOutputSlot** outputOfLeakyRelu,
- armnn::ActivationDescriptor & desc);
-
- std::pair<armnn::IOutputSlot*, armnn::IOutputSlot*> ProcessElementwiseInputSlots(
- const tensorflow::NodeDef& nodeDef, const std::string& layerName);
-
- ParsedTfOperationPtr ProcessComparisonLayer(
- armnn::IOutputSlot* input0Slot,
- armnn::IOutputSlot* input1Slot,
- armnn::IConnectableLayer* const layer,
- const tensorflow::NodeDef& nodeDef);
-
- ParsedTfOperationPtr ProcessElementwiseLayer(
- armnn::IOutputSlot* input0Slot,
- armnn::IOutputSlot* input1Slot,
- armnn::IConnectableLayer* const layer,
- const tensorflow::NodeDef& nodeDef);
-
- armnn::IConnectableLayer* CreateAdditionLayer(
- const tensorflow::NodeDef& nodeDef,
- armnn::IOutputSlot* input0Slot,
- armnn::IOutputSlot* input1Slot,
- const std::string& layerName);
-
- armnn::IConnectableLayer* CreateAdditionLayer(
- const tensorflow::NodeDef& nodeDef,
- const OutputOfParsedTfOperation& opOne,
- const OutputOfParsedTfOperation& opTwo,
- unsigned int numberOfAddition);
-
- armnn::IConnectableLayer* CreateAdditionLayer(
- const tensorflow::NodeDef& nodeDef,
- armnn::IConnectableLayer* layerOne,
- armnn::IConnectableLayer* layerTwo,
- unsigned int numberOfAddition,
- unsigned long numberOfLayersToConnect,
- bool isOdd);
-
- armnn::IConnectableLayer* CreateAdditionLayer(
- const tensorflow::NodeDef& nodeDef,
- const OutputOfParsedTfOperation& op,
- armnn::IConnectableLayer* layer);
-
- static std::pair<armnn::LayerBindingId, armnn::TensorInfo> GetBindingInfo(const std::string& layerName,
- const char* bindingPointDesc,
- const std::unordered_map<std::string, BindingPointInfo>& nameToBindingInfo);
-
- void TrackInputBinding(armnn::IConnectableLayer* layer,
- armnn::LayerBindingId id,
- const armnn::TensorInfo& tensorInfo);
-
- void TrackOutputBinding(armnn::IConnectableLayer* layer,
- armnn::LayerBindingId id,
- const armnn::TensorInfo& tensorInfo);
-
- static void TrackBindingPoint(armnn::IConnectableLayer* layer, armnn::LayerBindingId id,
- const armnn::TensorInfo& tensorInfo,
- const char* bindingPointDesc,
- std::unordered_map<std::string, BindingPointInfo>& nameToBindingInfo);
-
- void Cleanup();
-
- /// The network we're building. Gets cleared after it is passed to the user.
- armnn::INetworkPtr m_Network;
-
- using OperationParsingFunction = ParsedTfOperationPtr(TfParserImpl::*)(const tensorflow::NodeDef& nodeDef,
- const tensorflow::GraphDef& graphDef);
-
- /// Map of TensorFlow operation names to parsing member functions.
- static const std::map<std::string, OperationParsingFunction> ms_OperationNameToParsingFunctions;
-
- static const std::list<std::string> m_ControlInputs;
-
- std::map<std::string, armnn::TensorShape> m_InputShapes;
- std::vector<std::string> m_RequestedOutputs;
-
- /// Map of nodes extracted from the GraphDef to speed up parsing.
- std::unordered_map<std::string, const tensorflow::NodeDef*> m_NodesByName;
-
- std::unordered_map<std::string, ParsedTfOperationPtr> m_ParsedTfOperations;
-
- /// Maps input layer names to their corresponding ids and tensor info.
- std::unordered_map<std::string, BindingPointInfo> m_NetworkInputsBindingInfo;
-
- /// Maps output layer names to their corresponding ids and tensor info.
- std::unordered_map<std::string, BindingPointInfo> m_NetworkOutputsBindingInfo;
-};
-
-}
diff --git a/src/armnnTfParser/test/Activations.cpp b/src/armnnTfParser/test/Activations.cpp
deleted file mode 100644
index d5ebb24787..0000000000
--- a/src/armnnTfParser/test/Activations.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct ActivationFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- explicit ActivationFixture(const char* activationFunction)
- {
- m_Prototext = "node {\n"
- " name: \"Placeholder\"\n"
- " op: \"Placeholder\"\n"
- " attr {\n"
- " key: \"dtype\"\n"
- " value {\n"
- " type: DT_FLOAT\n"
- " }\n"
- " }\n"
- " attr {\n"
- " key: \"shape\"\n"
- " value {\n"
- " shape {\n"
- " unknown_rank: true\n"
- " }\n"
- " }\n"
- " }\n"
- "}\n"
- "node {\n"
- " name: \"";
- m_Prototext.append(activationFunction);
- m_Prototext.append("\"\n"
- " op: \"");
- m_Prototext.append(activationFunction);
- m_Prototext.append("\"\n"
- " input: \"Placeholder\"\n"
- " attr {\n"
- " key: \"T\"\n"
- " value {\n"
- " type: DT_FLOAT\n"
- " }\n"
- " }\n"
- "}\n");
-
- SetupSingleInputSingleOutput({ 1, 7 }, "Placeholder", activationFunction);
- }
-};
-
-
-struct ReLuFixture : ActivationFixture
-{
- ReLuFixture() : ActivationFixture("Relu") {}
-};
-BOOST_FIXTURE_TEST_CASE(ParseReLu, ReLuFixture)
-{
- RunTest<2>({ -1.0f, -0.5f, 1.25f, -3.0f, 0.0f, 0.5f, -0.75f },
- { 0.0f, 0.0f, 1.25f, 0.0f, 0.0f, 0.5f, 0.0f });
-}
-
-
-struct ReLu6Fixture : ActivationFixture
-{
- ReLu6Fixture() : ActivationFixture("Relu6") {}
-};
-BOOST_FIXTURE_TEST_CASE(ParseReLu6, ReLu6Fixture)
-{
- RunTest<2>({ -1.0f, -0.5f, 7.25f, -3.0f, 0.0f, 0.5f, -0.75f },
- { 0.0f, 0.0f, 6.0f, 0.0f, 0.0f, 0.5f, 0.0f });
-}
-
-
-struct SigmoidFixture : ActivationFixture
-{
- SigmoidFixture() : ActivationFixture("Sigmoid") {}
-};
-BOOST_FIXTURE_TEST_CASE(ParseSigmoid, SigmoidFixture)
-{
- RunTest<2>({ -0.1f, -0.2f, -0.3f, -0.4f, 0.1f, 0.2f, 0.3f },
- { 0.4750208f, 0.45016602f, 0.42555749f, 0.40131235f, 0.52497917f, 0.54983395f, 0.57444251f });
-}
-
-
-struct SoftplusFixture : ActivationFixture
-{
- SoftplusFixture() : ActivationFixture("Softplus") {}
-};
-BOOST_FIXTURE_TEST_CASE(ParseSoftplus, SoftplusFixture)
-{
- RunTest<2>({ -0.1f, -0.2f, -0.3f, -0.4f, 0.1f, 0.2f, 0.3f },
- { 0.64439666f, 0.59813893f, 0.55435526f, 0.51301527f, 0.74439669f, 0.7981388f, 0.85435522f });
-}
-
-
-struct TanhFixture : ActivationFixture
-{
- TanhFixture() : ActivationFixture("Tanh") {}
-};
-BOOST_FIXTURE_TEST_CASE(ParseTanh, TanhFixture)
-{
- RunTest<2>({ -0.1f, -0.2f, -0.3f, -0.4f, 0.1f, 0.2f, 0.3f },
- { -0.09966799f, -0.19737528f, -0.29131261f, -0.379949f, 0.09966799f, 0.19737528f, 0.29131261f });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/AddN.cpp b/src/armnnTfParser/test/AddN.cpp
deleted file mode 100644
index 16b1124e24..0000000000
--- a/src/armnnTfParser/test/AddN.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <armnn/utility/Assert.hpp>
-#include <boost/test/unit_test.hpp>
-
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-#include <map>
-#include <string>
-
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct AddNFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- AddNFixture(const std::vector<armnn::TensorShape> inputShapes, unsigned int numberOfInputs)
- {
- ARMNN_ASSERT(inputShapes.size() == numberOfInputs);
- m_Prototext = "";
- for (unsigned int i = 0; i < numberOfInputs; i++)
- {
- m_Prototext.append("node { \n");
- m_Prototext.append(" name: \"input").append(std::to_string(i)).append("\"\n");
- m_Prototext += R"( op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
-}
-)";
- }
- m_Prototext += R"(node {
- name: "output"
- op: "AddN"
-)";
- for (unsigned int i = 0; i < numberOfInputs; i++)
- {
- m_Prototext.append(" input: \"input").append(std::to_string(i)).append("\"\n");
- }
- m_Prototext += R"( attr {
- key: "N"
- value {
-)";
- m_Prototext.append(" i: ").append(std::to_string(numberOfInputs)).append("\n");
- m_Prototext += R"( }
- }
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-})";
-
- std::map<std::string, armnn::TensorShape> inputs;
- for (unsigned int i = 0; i < numberOfInputs; i++)
- {
- std::string name("input");
- name.append(std::to_string(i));
- inputs.emplace(std::make_pair(name, inputShapes[i]));
- }
- Setup(inputs, {"output"});
- }
-
-};
-
-// try with 2, 3, 5 and 8 inputs
-struct FiveTwoDimInputsFixture : AddNFixture
-{
- FiveTwoDimInputsFixture() : AddNFixture({ { 2, 2 }, { 2, 2 }, { 2, 2 }, { 2, 2 }, { 2, 2 } }, 5) {}
-};
-
-
-BOOST_FIXTURE_TEST_CASE(FiveTwoDimInputs, FiveTwoDimInputsFixture)
-{
- RunTest<2>({ { "input0", { 1.0, 2.0, 3.0, 4.0 } },
- { "input1", { 1.0, 5.0, 2.0, 2.0 } },
- { "input2", { 1.0, 1.0, 2.0, 2.0 } },
- { "input3", { 3.0, 7.0, 1.0, 2.0 } },
- { "input4", { 8.0, 0.0, -2.0, -3.0 } } },
- { { "output", { 14.0, 15.0, 6.0, 7.0 } } });
-}
-
-struct TwoTwoDimInputsFixture : AddNFixture
-{
- TwoTwoDimInputsFixture() : AddNFixture({ { 2, 2 }, { 2, 2 } }, 2) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(TwoTwoDimInputs, TwoTwoDimInputsFixture)
-{
- RunTest<2>({ { "input0", { 1.0, 2.0, 3.0, 4.0 } },
- { "input1", { 1.0, 5.0, 2.0, 2.0 } } },
- { { "output", { 2.0, 7.0, 5.0, 6.0 } } });
-}
-
-struct ThreeTwoDimInputsFixture : AddNFixture
-{
- ThreeTwoDimInputsFixture() : AddNFixture({ { 2, 2 }, { 2, 2 }, { 2, 2 } }, 3) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ThreeTwoDimInputs, ThreeTwoDimInputsFixture)
-{
- RunTest<2>({ { "input0", { 1.0, 2.0, 3.0, 4.0 } },
- { "input1", { 1.0, 5.0, 2.0, 2.0 } },
- { "input2", { 1.0, 1.0, 2.0, 2.0 } } },
- { { "output", { 3.0, 8.0, 7.0, 8.0 } } });
-}
-
-struct EightTwoDimInputsFixture : AddNFixture
-{
- EightTwoDimInputsFixture() : AddNFixture({ { 2, 2 }, { 2, 2 }, { 2, 2 }, { 2, 2 },
- { 2, 2 }, { 2, 2 }, { 2, 2 }, { 2, 2 } }, 8) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(EightTwoDimInputs, EightTwoDimInputsFixture)
-{
- RunTest<2>({ { "input0", { 1.0, 2.0, 3.0, 4.0 } },
- { "input1", { 1.0, 5.0, 2.0, 2.0 } },
- { "input2", { 1.0, 1.0, 2.0, 2.0 } },
- { "input3", { 3.0, 7.0, 1.0, 2.0 } },
- { "input4", { 8.0, 0.0, -2.0, -3.0 } },
- { "input5", {-3.0, 2.0, -1.0, -5.0 } },
- { "input6", { 1.0, 6.0, 2.0, 2.0 } },
- { "input7", {-19.0, 7.0, 1.0, -10.0 } } },
- { { "output", {-7.0, 30.0, 8.0, -6.0 } } });
-}
-
-struct ThreeInputBroadcast1D4D4DInputsFixture : AddNFixture
-{
- ThreeInputBroadcast1D4D4DInputsFixture() : AddNFixture({ { 1 }, { 1, 1, 2, 2 }, { 1, 1, 2, 2 } }, 3) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ThreeInputBroadcast1D4D4DInputs, ThreeInputBroadcast1D4D4DInputsFixture)
-{
- RunTest<4>({ { "input0", { 1.0 } },
- { "input1", { 1.0, 5.0, 2.0, 2.0 } },
- { "input2", { 1.0, 1.0, 2.0, 2.0 } } },
- { { "output", { 3.0, 7.0, 5.0, 5.0 } } });
-}
-
-struct ThreeInputBroadcast4D1D4DInputsFixture : AddNFixture
-{
- ThreeInputBroadcast4D1D4DInputsFixture() : AddNFixture({ { 1, 1, 2, 2 }, { 1 }, { 1, 1, 2, 2 } }, 3) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ThreeInputBroadcast4D1D4DInputs, ThreeInputBroadcast4D1D4DInputsFixture)
-{
- RunTest<4>({ { "input0", { 1.0, 3.0, 9.0, 4.0 } },
- { "input1", {-2.0 } },
- { "input2", { 1.0, 1.0, 2.0, 2.0 } } },
- { { "output", { 0.0, 2.0, 9.0, 4.0 } } });
-}
-
-struct ThreeInputBroadcast4D4D1DInputsFixture : AddNFixture
-{
- ThreeInputBroadcast4D4D1DInputsFixture() : AddNFixture({ { 1, 1, 2, 2 }, { 1, 1, 2, 2 }, { 1 } }, 3) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ThreeInputBroadcast4D4D1DInputs, ThreeInputBroadcast4D4D1DInputsFixture)
-{
- RunTest<4>({ { "input0", { 1.0, 5.0, 2.0, 2.0 } },
- { "input1", { 1.0, 1.0, 2.0, 2.0 } },
- { "input2", { 1.0 } } },
- { { "output", { 3.0, 7.0, 5.0, 5.0 } } });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Addition.cpp b/src/armnnTfParser/test/Addition.cpp
deleted file mode 100644
index f5c51dc602..0000000000
--- a/src/armnnTfParser/test/Addition.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct AdditionFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- AdditionFixture()
- {
- m_Prototext = "node { \n"
- " name: \"graphInput\" \n"
- " op: \"Placeholder\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"shape\" \n"
- " value { \n"
- " shape { \n"
- " } \n"
- " } \n"
- " } \n"
- " } \n"
- " node { \n"
- " name: \"softmax1\" \n"
- " op: \"Softmax\" \n"
- " input: \"graphInput\" \n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " }\n"
- " node {\n"
- " name: \"softmax2\"\n"
- " op : \"Softmax\"\n"
- " input: \"graphInput\"\n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " }\n"
- " node {\n"
- " name: \"addition\"\n"
- " op : \"Add\"\n"
- " input: \"softmax1\"\n"
- " input: \"softmax2\"\n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " }\n";
-
- SetupSingleInputSingleOutput({ 1, 7 }, "graphInput", "addition");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseAddition, AdditionFixture)
-{
- RunTest<2>({ 0, 0, 10000, 0, 0, 0, 0 }, { 0, 0, 2, 0, 0, 0, 0 });
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Assert.cpp b/src/armnnTfParser/test/Assert.cpp
deleted file mode 100644
index 0665be7c7e..0000000000
--- a/src/armnnTfParser/test/Assert.cpp
+++ /dev/null
@@ -1,299 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-#include "test/GraphUtils.hpp"
-
-#include <armnn/utility/PolymorphicDowncast.hpp>
-
-#include <boost/test/unit_test.hpp>
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct AssertSimpleFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- AssertSimpleFixture()
- {
- // Placeholder AssertInput
- // | \ /
- // Add ------ Assert
-
- m_Prototext = R"(
- node {
- name: "Placeholder"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- unknown_rank: true
- }
- }
- }
- }
- node {
- name: "AssertInput"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- dim {
- size: 1
- }
- }
- float_val: 17.0
- }
- }
- }
- }
- node {
- name: "Assert"
- op: "Assert"
- input: "Placeholder"
- input: "AssertInput"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "Add"
- op: "Add"
- input: "Placeholder"
- input: "Placeholder"
- input: "^Assert"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- })";
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(AssertSimpleTest, AssertSimpleFixture)
-{
- SetupSingleInputSingleOutput({ 1, 1, 1, 4 }, "Placeholder", "Add");
- RunTest<4>({ 1.0f, 2.0f, 3.0f, 4.0f }, { 2.0f, 4.0f, 6.0f, 8.0f });
-}
-
-BOOST_FIXTURE_TEST_CASE(AssertSimpleGraphStructureTest, AssertSimpleFixture)
-{
- auto optimized = SetupOptimizedNetwork({ { "Placeholder", { 1, 1, 1, 4 } } }, { "Add" });
-
- armnn::Graph& graph = GetGraphForTesting(optimized.get());
-
- BOOST_TEST((graph.GetNumInputs() == 1));
- BOOST_TEST((graph.GetNumOutputs() == 1));
- BOOST_TEST((graph.GetNumLayers() == 3));
-
- armnn::Layer* inputLayer = GetFirstLayerWithName(graph, "Placeholder");
- BOOST_TEST((inputLayer->GetType() == armnn::LayerType::Input));
- BOOST_TEST(CheckNumberOfInputSlot(inputLayer, 0));
- BOOST_TEST(CheckNumberOfOutputSlot(inputLayer, 1));
-
- armnn::Layer* addLayer = GetFirstLayerWithName(graph, "Add");
- BOOST_TEST((addLayer->GetType() == armnn::LayerType::Addition));
- BOOST_TEST(CheckNumberOfInputSlot(addLayer, 2));
- BOOST_TEST(CheckNumberOfOutputSlot(addLayer, 1));
-
- armnn::TensorInfo tensorInfo(armnn::TensorShape({1, 1, 1, 4}), armnn::DataType::Float32);
- BOOST_TEST(IsConnected(inputLayer, addLayer, 0, 0, tensorInfo));
- BOOST_TEST(IsConnected(inputLayer, addLayer, 0, 1, tensorInfo));
-
- for (auto&& outputLayer : graph.GetOutputLayers())
- {
- BOOST_TEST(IsConnected(addLayer, const_cast<armnn::OutputLayer*>(outputLayer), 0, 0, tensorInfo));
- }
-}
-
-struct AssertFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- AssertFixture()
- {
- // Input0 Input1 Input2
- // | \ / |
- // | Sub ------ Assert
- // \ / /
- // Output -------
-
- m_Prototext = R"(
- node {
- name: "Input0"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- unknown_rank: true
- }
- }
- }
- }
- node {
- name: "Input1"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- unknown_rank: true
- }
- }
- }
- }
- node {
- name: "Sub"
- op: "Sub"
- input: "Input0"
- input: "Input1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "Input2"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- unknown_rank: true
- }
- }
- }
- }
- node {
- name: "Assert"
- op: "Assert"
- input: "Input2"
- input: "Sub"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "Output"
- op: "Add"
- input: "Input0"
- input: "Sub"
- input: "^Assert"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- })";
-
-
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(AssertTest, AssertFixture)
-{
- Setup({ { "Input0", { 1, 1, 2, 2 } },
- { "Input1", { 1, 1, 2, 2 } } },
- { "Output" });
-
- RunTest<4>({ { "Input0", { 4.0f, 3.0f,
- 2.0f, 1.0f } },
-
- { "Input1", { 1.0f, 2.0f,
- 3.0f, 4.0f } } },
-
- { { "Output", { 7.0f, 4.0f,
- 1.0f, -2.0f } } });
-}
-
-BOOST_FIXTURE_TEST_CASE(AssertGraphStructureTest, AssertFixture)
-{
- auto optimized = SetupOptimizedNetwork({ { "Input0", { 1, 1, 2, 2 } },
- { "Input1", { 1, 1, 2, 2 } } },
- { "Output" });
-
- armnn::Graph& graph = GetGraphForTesting(optimized.get());
-
- BOOST_TEST((graph.GetNumInputs() == 2));
- BOOST_TEST((graph.GetNumOutputs() == 1));
- BOOST_TEST((graph.GetNumLayers() == 5));
-
- armnn::Layer* inputLayer0 = GetFirstLayerWithName(graph, "Input0");
- BOOST_TEST((inputLayer0->GetType() == armnn::LayerType::Input));
- BOOST_TEST(CheckNumberOfInputSlot(inputLayer0, 0));
- BOOST_TEST(CheckNumberOfOutputSlot(inputLayer0, 1));
-
- armnn::Layer* inputLayer1 = GetFirstLayerWithName(graph, "Input1");
- BOOST_TEST((inputLayer1->GetType() == armnn::LayerType::Input));
- BOOST_TEST(CheckNumberOfInputSlot(inputLayer1, 0));
- BOOST_TEST(CheckNumberOfOutputSlot(inputLayer1, 1));
-
- armnn::Layer* subLayer = GetFirstLayerWithName(graph, "Sub");
- BOOST_TEST((subLayer->GetType() == armnn::LayerType::Subtraction));
- BOOST_TEST(CheckNumberOfInputSlot(subLayer, 2));
- BOOST_TEST(CheckNumberOfOutputSlot(subLayer, 1));
-
- armnn::Layer* addLayer = GetFirstLayerWithName(graph, "Output");
- BOOST_TEST((addLayer->GetType() == armnn::LayerType::Addition));
- BOOST_TEST(CheckNumberOfInputSlot(addLayer, 2));
- BOOST_TEST(CheckNumberOfOutputSlot(addLayer, 1));
-
- armnn::TensorInfo tensorInfo(armnn::TensorShape({1, 1, 2, 2}), armnn::DataType::Float32);
- BOOST_TEST(IsConnected(inputLayer0, subLayer, 0, 0, tensorInfo));
- BOOST_TEST(IsConnected(inputLayer1, subLayer, 0, 1, tensorInfo));
- BOOST_TEST(IsConnected(inputLayer0, addLayer, 0, 0, tensorInfo));
- BOOST_TEST(IsConnected(subLayer, addLayer, 0, 1, tensorInfo));
-
- for (auto&& outputLayer : graph.GetOutputLayers())
- {
- BOOST_TEST(IsConnected(addLayer, const_cast<armnn::OutputLayer*>(outputLayer), 0, 0, tensorInfo));
- }
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/BiasAdd.cpp b/src/armnnTfParser/test/BiasAdd.cpp
deleted file mode 100644
index 81dcad4cda..0000000000
--- a/src/armnnTfParser/test/BiasAdd.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct BiasAddFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- explicit BiasAddFixture(const std::string& dataFormat)
- {
- m_Prototext = R"(
-node {
- name: "graphInput"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
-}
-node {
- name: "bias"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- dim {
- size: 3
- }
- }
- float_val: 1
- float_val: 2
- float_val: 3
- }
- }
- }
-}
-node {
- name: "biasAdd"
- op : "BiasAdd"
- input: "graphInput"
- input: "bias"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "data_format"
- value {
- s: ")" + dataFormat + R"("
- }
- }
-}
-)";
-
- SetupSingleInputSingleOutput({ 1, 3, 1, 3 }, "graphInput", "biasAdd");
- }
-};
-
-struct BiasAddFixtureNCHW : BiasAddFixture
-{
- BiasAddFixtureNCHW() : BiasAddFixture("NCHW") {}
-};
-
-struct BiasAddFixtureNHWC : BiasAddFixture
-{
- BiasAddFixtureNHWC() : BiasAddFixture("NHWC") {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseBiasAddNCHW, BiasAddFixtureNCHW)
-{
- RunTest<4>(std::vector<float>(9), { 1, 1, 1, 2, 2, 2, 3, 3, 3 });
-}
-
-BOOST_FIXTURE_TEST_CASE(ParseBiasAddNHWC, BiasAddFixtureNHWC)
-{
- RunTest<4>(std::vector<float>(9), { 1, 2, 3, 1, 2, 3, 1, 2, 3 });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/BroadcastForAdd.cpp b/src/armnnTfParser/test/BroadcastForAdd.cpp
deleted file mode 100644
index 36cba9df4e..0000000000
--- a/src/armnnTfParser/test/BroadcastForAdd.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-// This is a special case for add, which supports broadcasting.
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct BroadcastForAddFixtureSlot1 : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- BroadcastForAddFixtureSlot1()
- {
- m_Prototext = R"(
- node {
- name: "graphInput"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "Const_1"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- }
- float_val: 4.0
- float_val: 5.0
- }
- }
- }
- }
- node {
- name: "Add"
- op: "Add"
- input: "graphInput"
- input: "Const_1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- )";
-
- SetupSingleInputSingleOutput({ 1, 2, 2, 2 }, "graphInput", "Add");
- }
-};
-
-struct BroadcastForAddFixtureSlot0 : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- BroadcastForAddFixtureSlot0()
- {
- m_Prototext = R"(
- node {
- name: "graphInput"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "Const_1"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- }
- float_val: 4.0
- float_val: 5.0
- }
- }
- }
- }
- node {
- name: "Add"
- op: "Add"
- input: "Const_1"
- input: "graphInput"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- )";
-
- SetupSingleInputSingleOutput({ 1, 2, 2, 2 }, "graphInput", "Add");
- }
-};
-
-
-BOOST_FIXTURE_TEST_CASE(ParseBroadcastForAddition1, BroadcastForAddFixtureSlot1)
-{
- RunTest<4>({ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 }, { 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0 });
-}
-
-BOOST_FIXTURE_TEST_CASE(ParseBroadcastForAddition0, BroadcastForAddFixtureSlot0)
-{
- RunTest<4>({ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 }, { 5.0, 6.0, 6.0, 7.0, 7.0, 8.0, 8.0, 9.0 });
-}
-
-
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Concat.cpp b/src/armnnTfParser/test/Concat.cpp
deleted file mode 100644
index 2d4a95ba0a..0000000000
--- a/src/armnnTfParser/test/Concat.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct ConcatFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- explicit ConcatFixture(const armnn::TensorShape& inputShape0, const armnn::TensorShape& inputShape1,
- unsigned int concatDim)
- {
- m_Prototext = R"(
- node {
- name: "graphInput0"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "graphInput1"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "concat/axis"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_INT32
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_INT32
- tensor_shape {
- }
- int_val: )";
-
- m_Prototext += std::to_string(concatDim);
-
- m_Prototext += R"(
- }
- }
- }
- }
- node {
- name: "concat"
- op: "ConcatV2"
- input: "graphInput0"
- input: "graphInput1"
- input: "concat/axis"
- attr {
- key: "N"
- value {
- i: 2
- }
- }
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "Tidx"
- value {
- type: DT_FLOAT
- }
- }
- }
- )";
-
- Setup({{"graphInput0", inputShape0 },
- {"graphInput1", inputShape1 }}, {"concat"});
- }
-};
-
-struct ConcatFixtureNCHW : ConcatFixture
-{
- ConcatFixtureNCHW() : ConcatFixture({ 1, 1, 2, 2 }, { 1, 1, 2, 2 }, 1 ) {}
-};
-
-struct ConcatFixtureNHWC : ConcatFixture
-{
- ConcatFixtureNHWC() : ConcatFixture({ 1, 1, 2, 2 }, { 1, 1, 2, 2 }, 3 ) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseConcatNCHW, ConcatFixtureNCHW)
-{
- RunTest<4>({{"graphInput0", {0.0, 1.0, 2.0, 3.0}},
- {"graphInput1", {4.0, 5.0, 6.0, 7.0}}},
- {{"concat", { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 }}});
-}
-
-BOOST_FIXTURE_TEST_CASE(ParseConcatNHWC, ConcatFixtureNHWC)
-{
- RunTest<4>({{"graphInput0", {0.0, 1.0, 2.0, 3.0}},
- {"graphInput1", {4.0, 5.0, 6.0, 7.0}}},
- {{"concat", { 0.0, 1.0, 4.0, 5.0, 2.0, 3.0, 6.0, 7.0 }}});
-}
-
-struct ConcatFixtureDim1 : ConcatFixture
-{
- ConcatFixtureDim1() : ConcatFixture({ 1, 2, 3, 4 }, { 1, 2, 3, 4 }, 1) {}
-};
-
-struct ConcatFixtureDim3 : ConcatFixture
-{
- ConcatFixtureDim3() : ConcatFixture({ 1, 2, 3, 4 }, { 1, 2, 3, 4 }, 3) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseConcatDim1, ConcatFixtureDim1)
-{
- RunTest<4>({ { "graphInput0", { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0,
- 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0 } },
- { "graphInput1", { 50.0, 51.0, 52.0, 53.0, 54.0, 55.0, 56.0, 57.0, 58.0, 59.0, 60.0, 61.0,
- 62.0, 63.0, 64.0, 65.0, 66.0, 67.0, 68.0, 69.0, 70.0, 71.0, 72.0, 73.0 } } },
- { { "concat", { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0,
- 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0,
- 50.0, 51.0, 52.0, 53.0, 54.0, 55.0, 56.0, 57.0, 58.0, 59.0, 60.0, 61.0,
- 62.0, 63.0, 64.0, 65.0, 66.0, 67.0, 68.0, 69.0, 70.0, 71.0, 72.0, 73.0 } } });
-}
-
-BOOST_FIXTURE_TEST_CASE(ParseConcatDim3, ConcatFixtureDim3)
-{
- RunTest<4>({ { "graphInput0", { 0.0, 1.0, 2.0, 3.0,
- 4.0, 5.0, 6.0, 7.0,
- 8.0, 9.0, 10.0, 11.0,
- 12.0, 13.0, 14.0, 15.0,
- 16.0, 17.0, 18.0, 19.0,
- 20.0, 21.0, 22.0, 23.0 } },
- { "graphInput1", { 50.0, 51.0, 52.0, 53.0,
- 54.0, 55.0, 56.0, 57.0,
- 58.0, 59.0, 60.0, 61.0,
- 62.0, 63.0, 64.0, 65.0,
- 66.0, 67.0, 68.0, 69.0,
- 70.0, 71.0, 72.0, 73.0 } } },
- { { "concat", { 0.0, 1.0, 2.0, 3.0,
- 50.0, 51.0, 52.0, 53.0,
- 4.0, 5.0, 6.0, 7.0,
- 54.0, 55.0, 56.0, 57.0,
- 8.0, 9.0, 10.0, 11.0,
- 58.0, 59.0, 60.0, 61.0,
- 12.0, 13.0, 14.0, 15.0,
- 62.0, 63.0, 64.0, 65.0,
- 16.0, 17.0, 18.0, 19.0,
- 66.0, 67.0, 68.0, 69.0,
- 20.0, 21.0, 22.0, 23.0,
- 70.0, 71.0, 72.0, 73.0 } } });
-}
-
-BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file
diff --git a/src/armnnTfParser/test/ConcatOfConcats.cpp b/src/armnnTfParser/test/ConcatOfConcats.cpp
deleted file mode 100644
index b038698c01..0000000000
--- a/src/armnnTfParser/test/ConcatOfConcats.cpp
+++ /dev/null
@@ -1,316 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct ConcatOfConcatsFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- explicit ConcatOfConcatsFixture(const armnn::TensorShape& inputShape0, const armnn::TensorShape& inputShape1,
- const armnn::TensorShape& inputShape2, const armnn::TensorShape& inputShape3,
- unsigned int concatDim)
- {
- m_Prototext = R"(
- node {
- name: "graphInput0"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "graphInput1"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "graphInput2"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "graphInput3"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "Relu"
- op: "Relu"
- input: "graphInput0"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "Relu_1"
- op: "Relu"
- input: "graphInput1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "Relu_2"
- op: "Relu"
- input: "graphInput2"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "Relu_3"
- op: "Relu"
- input: "graphInput3"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "concat/axis"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_INT32
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_INT32
- tensor_shape {
- }
- int_val: )";
- m_Prototext += std::to_string(concatDim);
- m_Prototext += R"(
- }
- }
- }
- }
- node {
- name: "concat"
- op: "ConcatV2"
- input: "Relu"
- input: "Relu_1"
- input: "concat/axis"
- attr {
- key: "N"
- value {
- i: 2
- }
- }
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "Tidx"
- value {
- type: DT_INT32
- }
- }
- }
- node {
- name: "concat_1/axis"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_INT32
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_INT32
- tensor_shape {
- }
- int_val: )";
- m_Prototext += std::to_string(concatDim);
- m_Prototext += R"(
- }
- }
- }
- }
- node {
- name: "concat_1"
- op: "ConcatV2"
- input: "Relu_2"
- input: "Relu_3"
- input: "concat_1/axis"
- attr {
- key: "N"
- value {
- i: 2
- }
- }
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "Tidx"
- value {
- type: DT_INT32
- }
- }
- }
- node {
- name: "concat_2/axis"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_INT32
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_INT32
- tensor_shape {
- }
- int_val: )";
- m_Prototext += std::to_string(concatDim);
- m_Prototext += R"(
- }
- }
- }
- }
- node {
- name: "concat_2"
- op: "ConcatV2"
- input: "concat"
- input: "concat_1"
- input: "concat_2/axis"
- attr {
- key: "N"
- value {
- i: 2
- }
- }
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "Tidx"
- value {
- type: DT_INT32
- }
- }
- }
- )";
-
- Setup({{ "graphInput0", inputShape0 },
- { "graphInput1", inputShape1 },
- { "graphInput2", inputShape2 },
- { "graphInput3", inputShape3}}, {"concat_2"});
- }
-};
-
-struct ConcatOfConcatsFixtureNCHW : ConcatOfConcatsFixture
-{
- ConcatOfConcatsFixtureNCHW() : ConcatOfConcatsFixture({ 1, 1, 2, 2 }, { 1, 1, 2, 2 }, { 1, 1, 2, 2 },
- { 1, 1, 2, 2 }, 1 ) {}
-};
-
-struct ConcatOfConcatsFixtureNHWC : ConcatOfConcatsFixture
-{
- ConcatOfConcatsFixtureNHWC() : ConcatOfConcatsFixture({ 1, 1, 2, 2 }, { 1, 1, 2, 2 }, { 1, 1, 2, 2 },
- { 1, 1, 2, 2 }, 3 ) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseConcatOfConcatsNCHW, ConcatOfConcatsFixtureNCHW)
-{
- RunTest<4>({{"graphInput0", {0.0, 1.0, 2.0, 3.0}},
- {"graphInput1", {4.0, 5.0, 6.0, 7.0}},
- {"graphInput2", {8.0, 9.0, 10.0, 11.0}},
- {"graphInput3", {12.0, 13.0, 14.0, 15.0}}},
- {{"concat_2", { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0,
- 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0 }}});
-}
-
-BOOST_FIXTURE_TEST_CASE(ParseConcatOfConcatsNHWC, ConcatOfConcatsFixtureNHWC)
-{
- RunTest<4>({{"graphInput0", {0.0, 1.0, 2.0, 3.0}},
- {"graphInput1", {4.0, 5.0, 6.0, 7.0}},
- {"graphInput2", {8.0, 9.0, 10.0, 11.0}},
- {"graphInput3", {12.0, 13.0, 14.0, 15.0}}},
- {{"concat_2", { 0.0, 1.0, 4.0, 5.0, 8.0, 9.0, 12.0, 13.0,
- 2.0, 3.0, 6.0, 7.0, 10.0, 11.0, 14.0, 15.0 }}});
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Constant.cpp b/src/armnnTfParser/test/Constant.cpp
deleted file mode 100644
index 5c06d8c876..0000000000
--- a/src/armnnTfParser/test/Constant.cpp
+++ /dev/null
@@ -1,321 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-
-#include "armnnTfParser/ITfParser.hpp"
-
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-// Tests that a Const node in Tensorflow can be converted to a ConstLayer in armnn (as opposed to most
-// Const nodes which are used as weight inputs for convolutions etc. and are therefore not converted to
-// armnn ConstLayers).
-struct ConstantFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- ConstantFixture()
- {
- // Input = tf.placeholder(tf.float32, name = "input")
- // Const = tf.constant([17], tf.float32, [1])
- // Output = tf.add(input, const, name = "output")
- m_Prototext =
- R"(
-node {
- name: "input"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- unknown_rank: true
- }
- }
- }
-}
-node {
- name: "Const"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- dim {
- size: 1
- }
- }
- float_val: 17.0
- }
- }
- }
-}
-node {
- name: "output"
- op: "Add"
- input: "input"
- input: "Const"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
- )";
- SetupSingleInputSingleOutput({ 1 }, "input", "output");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(Constant, ConstantFixture)
-{
- RunTest<1>({1}, {18});
-}
-
-
-// Tests that a single Const node in Tensorflow can be used twice by a dependant node. This should result in only
-// a single armnn ConstLayer being created.
-struct ConstantReusedFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- ConstantReusedFixture()
- {
- // Const = tf.constant([17], tf.float32, [1])
- // Output = tf.add(const, const, name = "output")
- m_Prototext =
- R"(
-node {
- name: "Const"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- dim {
- size: 1
- }
- }
- float_val: 17.0
- }
- }
- }
-}
-node {
- name: "output"
- op: "Add"
- input: "Const"
- input: "Const"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
- )";
- Setup({}, { "output" });
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(ConstantReused, ConstantReusedFixture)
-{
- RunTest<1>({}, { { "output", { 34 } } });
-}
-
-template <int ListSize>
-struct ConstantValueListFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- ConstantValueListFixture()
- {
- m_Prototext =
- R"(
-node {
- name: "output"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- dim {
- size: 2
- }
- dim {
- size: 3
- }
- })";
-
- double value = 0.75;
- for (int i = 0; i < ListSize; i++, value += 0.25)
- {
- m_Prototext += std::string("float_val : ") + std::to_string(value) + "\n";
- }
-
- m_Prototext +=
- R"(
- }
- }
- }
-}
- )";
- Setup({}, { "output" });
- }
-};
-
-using ConstantSingleValueListFixture = ConstantValueListFixture<1>;
-using ConstantMultipleValueListFixture = ConstantValueListFixture<4>;
-using ConstantMaxValueListFixture = ConstantValueListFixture<6>;
-
-BOOST_FIXTURE_TEST_CASE(ConstantSingleValueList, ConstantSingleValueListFixture)
-{
- RunTest<2>({}, { { "output", { 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f } } });
-}
-BOOST_FIXTURE_TEST_CASE(ConstantMultipleValueList, ConstantMultipleValueListFixture)
-{
- RunTest<2>({}, { { "output", { 0.75f, 1.f, 1.25f, 1.5f, 1.5f, 1.5f } } });
-}
-BOOST_FIXTURE_TEST_CASE(ConstantMaxValueList, ConstantMaxValueListFixture)
-{
- RunTest<2>({}, { { "output", { 0.75f, 1.f, 1.25f, 1.50f, 1.75f, 2.f } } });
-}
-
-template <bool WithShape, bool WithContent, bool WithValueList>
-struct ConstantCreateFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- ConstantCreateFixture()
- {
- m_Prototext =
- R"(
-node {
- name: "output"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- )";
-
- if (WithShape)
- {
- m_Prototext +=
- R"(
-tensor_shape {
- dim {
- size: 2
- }
- dim {
- size: 2
- }
-}
- )";
- }
- else
- {
- m_Prototext +=
- R"(
-tensor_shape {
-}
- )";
- }
-
- if (WithContent)
- {
- m_Prototext +=
- R"(
-tensor_content: "\000\000\200?\000\000\200?\000\000\200?\000\000\200?\000\000\200?"
- )";
- }
-
- if (WithValueList)
- {
- m_Prototext +=
- R"(
-float_val: 1.0
-float_val: 1.0
-float_val: 1.0
-float_val: 1.0
-float_val: 1.0
- )";
- }
-
- m_Prototext +=
- R"(
- }
- }
- }
-}
- )";
- }
-};
-
-using ConstantCreateNoValueListFixture = ConstantCreateFixture<true, false, true>;
-using ConstantCreateNoValueList2Fixture = ConstantCreateFixture<true, false, false>;
-using ConstantCreateNoContentFixture = ConstantCreateFixture<true, true, false>;
-using ConstantCreateNoContent2Fixture = ConstantCreateFixture<true, false, false>;
-using ConstantCreateNoShapeFixture = ConstantCreateFixture<false, false, false>;
-using ConstantCreateNoShape2Fixture = ConstantCreateFixture<false, true, false>;
-using ConstantCreateNoShape3Fixture = ConstantCreateFixture<false, false, true>;
-
-BOOST_FIXTURE_TEST_CASE(ConstantCreateInvalidValueList, ConstantCreateNoValueListFixture)
-{
- BOOST_REQUIRE_THROW(Setup({}, { "output" }), armnn::ParseException);
-}
-BOOST_FIXTURE_TEST_CASE(ConstantCreateInvalidValueList2, ConstantCreateNoValueList2Fixture)
-{
- BOOST_REQUIRE_THROW(Setup({}, { "output" }), armnn::ParseException);
-}
-BOOST_FIXTURE_TEST_CASE(ConstantCreateInvalidContent, ConstantCreateNoContentFixture)
-{
- BOOST_REQUIRE_THROW(Setup({}, { "output" }), armnn::ParseException);
-}
-BOOST_FIXTURE_TEST_CASE(ConstantCreateInvalidShape, ConstantCreateNoShapeFixture)
-{
- BOOST_REQUIRE_THROW(Setup({}, { "output" }), armnn::ParseException);
-}
-BOOST_FIXTURE_TEST_CASE(ConstantCreateNoShape2, ConstantCreateNoShape2Fixture)
-{
- BOOST_REQUIRE_THROW(Setup({}, { "output" }), armnn::ParseException);
-}
-BOOST_FIXTURE_TEST_CASE(ConstantCreateNoShape3, ConstantCreateNoShape3Fixture)
-{
- Setup({}, { "output" });
- RunTest<1>({}, { { "output", { 1.f, 1.f, 1.f, 1.f, 1.f } } });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Convolution2d.cpp b/src/armnnTfParser/test/Convolution2d.cpp
deleted file mode 100644
index c58615f990..0000000000
--- a/src/armnnTfParser/test/Convolution2d.cpp
+++ /dev/null
@@ -1,444 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-#include <array>
-#include <string>
-#include <iostream>
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct Convolution2dFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- explicit Convolution2dFixture(const std::string& dataLayout, const std::string& paddingType)
- : Convolution2dFixture(dataLayout, paddingType, 1)
- {}
-
- // Dilation: 0 - dilations attribute is not included;
- // Dilation: >0 - dilations attribute set to [1,v,v,1], where v is the value of the dilation arg
- explicit Convolution2dFixture(const std::string& dataLayout, const std::string& paddingType,
- int stride, int dilation = 0)
- {
- std::string strideString (" i: 1 \n"
- " i: 1 \n");
- if (dataLayout == "NHWC")
- {
- strideString.append(" i: " + std::to_string(stride) + " \n"
- " i: 1 \n");
- }
- else // dataLayout == "NCHW"
- {
- strideString.append(" i: 1 \n"
- " i: " + std::to_string(stride) + " \n");
- }
-
- std::string dilationString;
- if (dataLayout == "NHWC")
- {
- dilationString.append(" i: 1 \n"
- " i: " + std::to_string(dilation) + " \n"
- " i: " + std::to_string(dilation) + " \n"
- " i: 1 \n");
- }
- else // dataLayout == "NCHW"
- {
- dilationString.append(" i: 1 \n"
- " i: 1 \n"
- " i: " + std::to_string(dilation) + " \n"
- " i: " + std::to_string(dilation) + " \n");
- }
-
- m_Prototext = "node { \n"
- " name: \"graphInput\" \n"
- " op: \"Placeholder\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"shape\" \n"
- " value { \n"
- " shape { \n"
- " } \n"
- " } \n"
- " } \n"
- " } \n"
- " node { \n"
- " name: \"Const_1\" \n"
- " op: \"Const\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"value\" \n"
- " value { \n"
- " tensor { \n"
- " dtype: DT_FLOAT \n"
- " tensor_shape { \n"
- " dim { \n"
- " size: 1 \n"
- " } \n"
- " dim { \n"
- " size: 3 \n"
- " } \n"
- " dim { \n"
- " size: 1 \n"
- " } \n"
- " dim { \n"
- " size: 1 \n"
- " } \n"
- " } \n"
- " tensor_content: \"\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?\" \n"
- " } \n"
- " } \n"
- " } \n"
- "} \n"
- "node { \n"
- " name: \"potato\" \n"
- " op: \"Conv2D\" \n"
- " input: \"graphInput\" \n"
- " input: \"Const_1\" \n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"data_format\" \n"
- " value { \n"
- " s: \"";
- m_Prototext.append(dataLayout);
- m_Prototext.append("\"\n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"padding\" \n"
- " value { \n"
- " s: \"");
- m_Prototext.append(paddingType);
- m_Prototext.append("\"\n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"strides\" \n"
- " value { \n"
- " list { \n");
- m_Prototext.append(strideString);
-
- m_Prototext.append(" } \n"
- " } \n"
- " } \n");
-
- if (dilation > 0)
- {
- m_Prototext.append(" attr { \n"
- " key: \"dilations\" \n"
- " value { \n"
- " list { \n");
- m_Prototext.append(dilationString);
-
- m_Prototext.append(" } \n"
- " } \n"
- " } \n");
- }
- m_Prototext.append(" attr { \n"
- " key: \"use_cudnn_on_gpu\" \n"
- " value { \n"
- " b: false \n"
- " } \n"
- " } \n"
- "} \n");
-
- // Manual height computation based on stride parameter.
- ARMNN_ASSERT_MSG(stride == 1 || stride == 2, "Add support for strides other than 1 or 2.");
- std::array<unsigned int, 4> dims;
- if (dataLayout == "NHWC")
- {
- dims = { 1u, (stride == 2 ? 3u : 2u), 3u, 1u };
- }
- else // dataLayout == "NCHW"
- {
- dims = { 1u, 1u, (stride == 2 ? 3u : 2u), 3u };
- }
-
- SetupSingleInputSingleOutput(armnn::TensorShape(4, dims.data()), "graphInput", "potato");
- }
-};
-
-struct Convolution2dNhwcSameFixture : Convolution2dFixture
-{
- Convolution2dNhwcSameFixture() : Convolution2dFixture("NHWC", "SAME", 1){}
-};
-BOOST_FIXTURE_TEST_CASE(ParseConv2dNhwcSame, Convolution2dNhwcSameFixture)
-{
- RunTest<4>({1, 2, 3, 4, 5, 6}, {2, 4, 4, 6.5f, 10 , 8.5f});
-}
-
-struct Convolution2dNchwSameFixture : Convolution2dFixture
-{
- Convolution2dNchwSameFixture() : Convolution2dFixture("NCHW", "SAME", 1){}
-};
-BOOST_FIXTURE_TEST_CASE(ParseConv2dNchwSame, Convolution2dNchwSameFixture)
-{
- RunTest<4>({1, 2, 3, 4, 5, 6}, {2, 4, 4, 6.5f, 10 , 8.5f});
-}
-
-
-struct Convolution2dNhwcValidFixture : Convolution2dFixture
-{
- Convolution2dNhwcValidFixture() : Convolution2dFixture("NHWC", "VALID", 1){}
-};
-BOOST_FIXTURE_TEST_CASE(ParseConv2dNhwcValid, Convolution2dNhwcValidFixture)
-{
- RunTest<4>({1, 2, 3, 4, 5, 6}, {4, 10});
-}
-
-struct Convolution2dNchwValidFixture : Convolution2dFixture
-{
- Convolution2dNchwValidFixture() : Convolution2dFixture("NCHW", "VALID", 1){}
-};
-BOOST_FIXTURE_TEST_CASE(ParseConv2dNchwValid, Convolution2dNchwValidFixture)
-{
- RunTest<4>({1, 2, 3, 4, 5, 6}, {4, 10});
-}
-
-
-struct Convolution2dStride2NhwcSameFixture : Convolution2dFixture
-{
- Convolution2dStride2NhwcSameFixture() : Convolution2dFixture("NHWC", "SAME", 2){}
-};
-BOOST_FIXTURE_TEST_CASE(ParseConv2dStride2NhwcSame, Convolution2dStride2NhwcSameFixture)
-{
- RunTest<4>({1, 2, 3, 4, 5, 6, 7, 8, 9}, {2, 4, 6.5, 8.5, 11, 13});
-}
-
-struct Convolution2dStride2NchwSameFixture : Convolution2dFixture
-{
- Convolution2dStride2NchwSameFixture() : Convolution2dFixture("NCHW", "SAME", 2){}
-};
-BOOST_FIXTURE_TEST_CASE(ParseConv2dStride2NchwSame, Convolution2dStride2NchwSameFixture)
-{
- RunTest<4>({1, 2, 3, 4, 5, 6, 7, 8, 9}, {2, 4, 6.5, 8.5, 11, 13});
-}
-
-
-struct Convolution2dStride2NhwcValidFixture : Convolution2dFixture
-{
- Convolution2dStride2NhwcValidFixture() : Convolution2dFixture("NHWC", "VALID", 2){}
-};
-BOOST_FIXTURE_TEST_CASE(ParseConv2dStride2NhwcValid, Convolution2dStride2NhwcValidFixture)
-{
- RunTest<4>({1, 2, 3, 4, 5, 6, 7, 8, 9}, {4, 10, 16});
-}
-
-struct Convolution2dStride2NchwValidFixture : Convolution2dFixture
-{
- Convolution2dStride2NchwValidFixture() : Convolution2dFixture("NCHW", "VALID", 2){}
-};
-BOOST_FIXTURE_TEST_CASE(ParseConv2dStride2NchwValid, Convolution2dStride2NchwValidFixture)
-{
- RunTest<4>({1, 2, 3, 4, 5, 6, 7, 8, 9}, {4, 10, 16});
-}
-
-
-struct Convolution2dDilation1NhwcFixture : Convolution2dFixture
-{
- Convolution2dDilation1NhwcFixture() : Convolution2dFixture("NHWC", "SAME", 1, 1){}
-};
-BOOST_FIXTURE_TEST_CASE(ParseConv2dDilation1Nhwc, Convolution2dDilation1NhwcFixture)
-{
- RunTest<4>({1, 2, 3, 4, 5, 6}, {2, 4, 4, 6.5f, 10 , 8.5f});
-}
-
-struct Convolution2dDilation1NchwFixture : Convolution2dFixture
-{
- Convolution2dDilation1NchwFixture() : Convolution2dFixture("NCHW", "SAME", 1, 1){}
-};
-BOOST_FIXTURE_TEST_CASE(ParseConv2dDilation1Nchw, Convolution2dDilation1NchwFixture)
-{
- RunTest<4>({1, 2, 3, 4, 5, 6}, {2, 4, 4, 6.5f, 10 , 8.5f});
-}
-
-struct Convolution2dDilationFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- explicit Convolution2dDilationFixture(const std::string& dataLayout, const std::string& paddingType)
- : Convolution2dDilationFixture(dataLayout, paddingType, 1)
- {}
-
- explicit Convolution2dDilationFixture(const std::string& dataLayout, const std::string& paddingType,
- int stride, int dilation = 0)
- {
- std::string strideString;
- if (dataLayout == "NHWC")
- {
- strideString.append(" i: 1 \n"
- " i: " + std::to_string(stride) + " \n"
- " i: " + std::to_string(stride) + " \n"
- " i: 1 \n");
- }
- else // dataLayout == "NCHW"
- {
- strideString.append(" i: 1 \n"
- " i: 1 \n"
- " i: " + std::to_string(stride) + " \n"
- " i: " + std::to_string(stride) + " \n");
- }
-
- std::string dilationString;
- if (dataLayout == "NHWC")
- {
- dilationString.append(" i: 1 \n"
- " i: " + std::to_string(dilation) + " \n"
- " i: " + std::to_string(dilation) + " \n"
- " i: 1 \n");
- }
- else // dataLayout == "NCHW"
- {
- dilationString.append(" i: 1 \n"
- " i: 1 \n"
- " i: " + std::to_string(dilation) + " \n"
- " i: " + std::to_string(dilation) + " \n");
- }
-
- m_Prototext = "node { \n"
- " name: \"graphInput\" \n"
- " op: \"Placeholder\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"shape\" \n"
- " value { \n"
- " shape { \n"
- " } \n"
- " } \n"
- " } \n"
- " } \n"
- " node { \n"
- " name: \"Const_1\" \n"
- " op: \"Const\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"value\" \n"
- " value { \n"
- " tensor { \n"
- " dtype: DT_FLOAT \n"
- " tensor_shape { \n"
- " dim { \n"
- " size: 3 \n"
- " } \n"
- " dim { \n"
- " size: 1 \n"
- " } \n"
- " dim { \n"
- " size: 1 \n"
- " } \n"
- " dim { \n"
- " size: 1 \n"
- " } \n"
- " } \n"
- " tensor_content: \"\\001\\000\\000?\\000\\000\\000?\\001\\000\\000?\" \n"
- " } \n"
- " } \n"
- " } \n"
- "} \n"
- "node { \n"
- " name: \"potato\" \n"
- " op: \"Conv2D\" \n"
- " input: \"graphInput\" \n"
- " input: \"Const_1\" \n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"data_format\" \n"
- " value { \n"
- " s: \"";
- m_Prototext.append(dataLayout);
- m_Prototext.append("\"\n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"padding\" \n"
- " value { \n"
- " s: \"");
- m_Prototext.append(paddingType);
- m_Prototext.append("\"\n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"strides\" \n"
- " value { \n"
- " list { \n");
- m_Prototext.append(strideString);
-
- m_Prototext.append(" } \n"
- " } \n"
- " } \n");
-
- if (dilation > 0)
- {
- m_Prototext.append(" attr { \n"
- " key: \"dilations\" \n"
- " value { \n"
- " list { \n");
- m_Prototext.append(dilationString);
-
- m_Prototext.append(" } \n"
- " } \n"
- " } \n");
- }
- m_Prototext.append(" attr { \n"
- " key: \"use_cudnn_on_gpu\" \n"
- " value { \n"
- " b: false \n"
- " } \n"
- " } \n"
- "} \n");
-
- // Manual height computation based on stride parameter.
- std::array<unsigned int, 4> dims = { 1u, 1u, 6u, 6u };;
-
- SetupSingleInputSingleOutput(armnn::TensorShape(4, dims.data()), "graphInput", "potato");
- }
-};
-
-struct Convolution2dDilation2NchwValidFixture : Convolution2dDilationFixture
-{
- Convolution2dDilation2NchwValidFixture() : Convolution2dDilationFixture("NCHW", "VALID", 1, 2){}
-};
-BOOST_FIXTURE_TEST_CASE(ParseConv2dDilation2NchwValid, Convolution2dDilation2NchwValidFixture)
-{
- RunTest<4>({1.0, 2.0, 3.0, 4.0, 5.0, 6.0,
- 7.0, 8.0, 9.0, 10.0, 11.0, 12.0,
- 1.0, 2.0, 3.0, 4.0, 5.0, 6.0,
- 7.0, 8.0, 9.0, 10.0, 11.0, 12.0,
- 1.0, 2.0, 3.0, 4.0, 5.0, 6.0,
- 7.0, 8.0, 9.0, 10.0, 11.0, 12.0},
- {1.5f, 3.0f, 4.5f, 6.0f, 7.5f, 9.0f, 10.5f, 12.f, 13.5f, 15.0f, 16.5f, 18.0f});
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/DepthwiseConvolution2d.cpp b/src/armnnTfParser/test/DepthwiseConvolution2d.cpp
deleted file mode 100644
index 43a7ebc28e..0000000000
--- a/src/armnnTfParser/test/DepthwiseConvolution2d.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "ParserPrototxtFixture.hpp"
-
-#include "armnnTfParser/ITfParser.hpp"
-
-#include <armnnUtils/Permute.hpp>
-
-#include <boost/test/unit_test.hpp>
-
-#include <string>
-#include <iostream>
-
-using namespace armnnUtils;
-using namespace armnn;
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct DepthwiseConvolution2dFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- explicit DepthwiseConvolution2dFixture(const std::string& dataLayout, const char* paddingType)
- {
- m_Prototext = "node { \n"
- " name: \"graphInput\" \n"
- " op: \"Placeholder\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"shape\" \n"
- " value { \n"
- " shape { \n"
- " } \n"
- " } \n"
- " } \n"
- " } \n"
- " node { \n"
- " name: \"Const_1\" \n"
- " op: \"Const\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"value\" \n"
- " value { \n"
- " tensor { \n"
- " dtype: DT_FLOAT \n"
- " tensor_shape { \n"
- " dim { \n"
- " size: 1 \n"
- " } \n"
- " dim { \n"
- " size: 3 \n"
- " } \n"
- " dim { \n"
- " size: 3 \n"
- " } \n"
- " dim { \n"
- " size: 3 \n"
- " } \n"
- " } \n"
- " tensor_content: \"\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?"
- "\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?"
- "\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?"
- "\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?"
- "\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?"
- "\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?"
- "\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?"
- "\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?"
- "\\000\\000\\000?\\000\\000\\200?\\000\\000\\000?\" \n"
- " } \n"
- " } \n"
- " } \n"
- "} \n"
- "node { \n"
- " name: \"potato\" \n"
- " op: \"DepthwiseConv2dNative\" \n"
- " input: \"graphInput\" \n"
- " input: \"Const_1\" \n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"data_format\" \n"
- " value { \n"
- " s: \"";
- m_Prototext.append(dataLayout);
- m_Prototext.append("\"\n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"padding\" \n"
- " value { \n"
- " s: \"");
- m_Prototext.append(paddingType);
- m_Prototext.append("\"\n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"strides\" \n"
- " value { \n"
- " list { \n"
- " i: 1 \n"
- " i: 1 \n"
- " i: 1 \n"
- " i: 1 \n"
- " } \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"use_cudnn_on_gpu\" \n"
- " value { \n"
- " b: false \n"
- " } \n"
- " } \n"
- "} \n");
-
- if(dataLayout == "NHWC")
- {
- SetupSingleInputSingleOutput({ 1u, 1u, 3u, 3u }, "graphInput", "potato");
- }
- else
- {
- SetupSingleInputSingleOutput({ 1u, 3u, 1u, 3u }, "graphInput", "potato");
- }
- }
-};
-
-struct DepthwiseConvolution2dNhwcSameFixture : DepthwiseConvolution2dFixture
-{
- DepthwiseConvolution2dNhwcSameFixture() : DepthwiseConvolution2dFixture("NHWC", "SAME") { }
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseDepthwiseConv2DNhwcSame, DepthwiseConvolution2dNhwcSameFixture)
-{
- RunTest<4>({ 1, 2, 3, 4, 5, 6, 7, 8, 9 },
- { 2.5f, 5.f, 2.5f, 3.5f, 7.f, 3.5f, 4.5f, 9.f, 4.5f,
- 6.f, 12.f, 6.f, 7.5f, 15.f, 7.5f, 9.f, 18.f, 9.f,
- 5.5f, 11.f, 5.5f, 6.5f, 13.f, 6.5f, 7.5f, 15.f, 7.5f });
-}
-
-struct DepthwiseConvolution2dNchwSameFixture : DepthwiseConvolution2dFixture
-{
- DepthwiseConvolution2dNchwSameFixture() : DepthwiseConvolution2dFixture("NCHW", "SAME") { }
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseDepthwiseConv2DNchwSame, DepthwiseConvolution2dNchwSameFixture)
-{
- RunTest<4>({ 1, 4, 7, 2, 5, 8, 3, 6, 9 },
- { 2.5f, 6.f, 5.5f, 5.f, 12.f, 11.f, 2.5f, 6.f, 5.5f,
- 3.5f, 7.5f, 6.5f, 7.f, 15.f, 13.f, 3.5f, 7.5f, 6.5f,
- 4.5f, 9.f, 7.5f, 9.f, 18.f, 15.f, 4.5f, 9.f, 7.5f });
-}
-
-struct DepthwiseConvolution2dNhwcValidFixture : DepthwiseConvolution2dFixture
-{
- DepthwiseConvolution2dNhwcValidFixture() : DepthwiseConvolution2dFixture("NHWC", "VALID") { }
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseDepthwiseConv2DNhwcValid, DepthwiseConvolution2dNhwcValidFixture)
-{
- RunTest<4>({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, // input data
- { 6.f, 12.f, 6.f, 7.5f, 15.f, 7.5f, 9.f, 18.f, 9.f }); // output expected data
-}
-
-struct DepthwiseConvolution2dNchwValidFixture : DepthwiseConvolution2dFixture
-{
- DepthwiseConvolution2dNchwValidFixture() : DepthwiseConvolution2dFixture("NCHW", "VALID") { }
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseDepthwiseConv2DNchwValid, DepthwiseConvolution2dNchwValidFixture)
-{
- RunTest<4>({ 1, 4, 7, 2, 5, 8, 3, 6, 9 },
- { 6.f, 12.f, 6.f, 7.5f, 15.f, 7.5f, 9.f, 18.f, 9.f });
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Equal.cpp b/src/armnnTfParser/test/Equal.cpp
deleted file mode 100644
index 2dce822b0f..0000000000
--- a/src/armnnTfParser/test/Equal.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
- struct EqualFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
- {
- EqualFixture()
- {
- m_Prototext = R"(
-node {
- name: "input0"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
-}
-node {
- name: "input1"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
-}
-node {
- name: "output"
- op: "Equal"
- input: "input0"
- input: "input1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
- )";
- }
- };
-
-BOOST_FIXTURE_TEST_CASE(ParseEqualUnsupportedBroadcast, EqualFixture)
-{
- BOOST_REQUIRE_THROW(Setup({ { "input0", {2, 3} },
- { "input1", {1, 2, 2, 3} } },
- { "output" }),
- armnn::ParseException);
-}
-
-struct EqualFixtureAutoSetup : public EqualFixture
-{
- EqualFixtureAutoSetup(const armnn::TensorShape& input0Shape,
- const armnn::TensorShape& input1Shape)
- : EqualFixture()
- {
- Setup({ { "input0", input0Shape },
- { "input1", input1Shape } },
- { "output" });
- }
-};
-
-struct EqualTwoByTwo : public EqualFixtureAutoSetup
-{
- EqualTwoByTwo() : EqualFixtureAutoSetup({2,2}, {2,2}) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseEqualTwoByTwo, EqualTwoByTwo)
-{
- RunComparisonTest<2>({ { "input0", { 1.0f, 2.0f, 3.0f, 2.0f } },
- { "input1", { 1.0f, 5.0f, 2.0f, 2.0f } } },
- { { "output", { 1, 0, 0, 1 } } });
-}
-
-struct EqualBroadcast1DAnd4D : public EqualFixtureAutoSetup
-{
- EqualBroadcast1DAnd4D() : EqualFixtureAutoSetup({1}, {1,1,2,2}) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseEqualBroadcast1DToTwoByTwo, EqualBroadcast1DAnd4D)
-{
- RunComparisonTest<4>({ { "input0", { 2.0f } },
- { "input1", { 1.0f, 2.0f, 3.0f, 2.0f } } },
- { { "output", { 0, 1, 0, 1 } } });
-}
-
-struct EqualBroadcast4DAnd1D : public EqualFixtureAutoSetup
-{
- EqualBroadcast4DAnd1D() : EqualFixtureAutoSetup({1,1,2,2}, {1}) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseEqualBroadcast4DAnd1D, EqualBroadcast4DAnd1D)
-{
- RunComparisonTest<4>({ { "input0", { 1.0f, 2.0f, 3.0f, 2.0f } },
- { "input1", { 3.0f } } },
- { { "output", { 0, 0, 1, 0 } } });
-}
-
-struct EqualMultiDimBroadcast : public EqualFixtureAutoSetup
-{
- EqualMultiDimBroadcast() : EqualFixtureAutoSetup({1,1,2,1}, {1,2,1,3}) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseEqualMultiDimBroadcast, EqualMultiDimBroadcast)
-{
- RunComparisonTest<4>({ { "input0", { 1.0f, 2.0f } },
- { "input1", { 1.0f, 2.0f, 3.0f,
- 3.0f, 2.0f, 2.0f } } },
- { { "output", { 1, 0, 0,
- 0, 1, 0,
- 0, 0, 0,
- 0, 1, 1 } } });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/ExpandDims.cpp b/src/armnnTfParser/test/ExpandDims.cpp
deleted file mode 100644
index ad95641cd1..0000000000
--- a/src/armnnTfParser/test/ExpandDims.cpp
+++ /dev/null
@@ -1,313 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct ExpandDimsFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- ExpandDimsFixture(const std::string& expandDim)
- {
- m_Prototext =
- "node { \n"
- " name: \"graphInput\" \n"
- " op: \"Placeholder\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"shape\" \n"
- " value { \n"
- " shape { \n"
- " } \n"
- " } \n"
- " } \n"
- " } \n"
- "node { \n"
- " name: \"ExpandDims\" \n"
- " op: \"ExpandDims\" \n"
- " input: \"graphInput\" \n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"Tdim\" \n"
- " value { \n";
- m_Prototext += "i:" + expandDim;
- m_Prototext +=
- " } \n"
- " } \n"
- "} \n";
-
- SetupSingleInputSingleOutput({ 2, 3, 5 }, "graphInput", "ExpandDims");
- }
-};
-
-struct ExpandZeroDim : ExpandDimsFixture
-{
- ExpandZeroDim() : ExpandDimsFixture("0") {}
-};
-
-struct ExpandTwoDim : ExpandDimsFixture
-{
- ExpandTwoDim() : ExpandDimsFixture("2") {}
-};
-
-struct ExpandThreeDim : ExpandDimsFixture
-{
- ExpandThreeDim() : ExpandDimsFixture("3") {}
-};
-
-struct ExpandMinusOneDim : ExpandDimsFixture
-{
- ExpandMinusOneDim() : ExpandDimsFixture("-1") {}
-};
-
-struct ExpandMinusThreeDim : ExpandDimsFixture
-{
- ExpandMinusThreeDim() : ExpandDimsFixture("-3") {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseExpandZeroDim, ExpandZeroDim)
-{
- BOOST_TEST((m_Parser->GetNetworkOutputBindingInfo("ExpandDims").second.GetShape() ==
- armnn::TensorShape({1, 2, 3, 5})));
-}
-
-BOOST_FIXTURE_TEST_CASE(ParseExpandTwoDim, ExpandTwoDim)
-{
- BOOST_TEST((m_Parser->GetNetworkOutputBindingInfo("ExpandDims").second.GetShape() ==
- armnn::TensorShape({2, 3, 1, 5})));
-}
-
-BOOST_FIXTURE_TEST_CASE(ParseExpandThreeDim, ExpandThreeDim)
-{
- BOOST_TEST((m_Parser->GetNetworkOutputBindingInfo("ExpandDims").second.GetShape() ==
- armnn::TensorShape({2, 3, 5, 1})));
-}
-
-BOOST_FIXTURE_TEST_CASE(ParseExpandMinusOneDim, ExpandMinusOneDim)
-{
- BOOST_TEST((m_Parser->GetNetworkOutputBindingInfo("ExpandDims").second.GetShape() ==
- armnn::TensorShape({2, 3, 5, 1})));
-}
-
-BOOST_FIXTURE_TEST_CASE(ParseExpandMinusThreeDim, ExpandMinusThreeDim)
-{
- BOOST_TEST((m_Parser->GetNetworkOutputBindingInfo("ExpandDims").second.GetShape() ==
- armnn::TensorShape({2, 1, 3, 5})));
-}
-
-struct ExpandDimsAsInputFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- ExpandDimsAsInputFixture(const std::string& expandDim,
- const bool wrongDataType = false,
- const std::string& numElements = "1")
- {
- std::string dataType = (wrongDataType) ? "DT_FLOAT" : "DT_INT32";
- std::string val = (wrongDataType) ? ("float_val: " + expandDim + ".0") : ("int_val: "+ expandDim);
-
- m_Prototext = R"(
- node {
- name: "a"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- dim {
- size: 1
- }
- dim {
- size: 4
- }
- }
- }
- }
- }
- node {
- name: "b"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: )" + dataType + R"(
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: )" + dataType + R"(
- tensor_shape {
- dim {
- size: )" + numElements + R"(
- }
- }
- )" + val + R"(
- }
- }
- }
- }
- node {
- name: "ExpandDims"
- op: "ExpandDims"
- input: "a"
- input: "b"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "Tdim"
- value {
- type: DT_INT32
- }
- }
- }
- versions {
- producer: 134
- })";
- }
-};
-
-struct ExpandDimAsInput : ExpandDimsAsInputFixture
-{
- ExpandDimAsInput() : ExpandDimsAsInputFixture("0")
- {
- Setup({{"a", {1,4}} ,{"b",{1,1}}}, { "ExpandDims" });
- }
-};
-
-
-BOOST_FIXTURE_TEST_CASE(ParseExpandDimAsInput, ExpandDimAsInput)
-{
- // Axis parameter that describes which axis/dim should be expanded is passed as a second input
- BOOST_TEST((m_Parser->GetNetworkOutputBindingInfo("ExpandDims").second.GetShape() ==
- armnn::TensorShape({1, 1, 4})));
-}
-
-struct ExpandDimAsInputWrongDataType : ExpandDimsAsInputFixture
-{
- ExpandDimAsInputWrongDataType() : ExpandDimsAsInputFixture("0", true, "1") {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseExpandDimAsInputWrongDataType, ExpandDimAsInputWrongDataType)
-{
- // Axis parameter that describes which axis/dim should be expanded is passed as a second input
- // Axis parameter is of wrong data type (float instead of int32)
- BOOST_REQUIRE_THROW(Setup({{"a", {1,4}} ,{"b",{1,1}}}, { "ExpandDims" }), armnn::ParseException);
-}
-
-struct ExpandDimAsInputWrongShape : ExpandDimsAsInputFixture
-{
- ExpandDimAsInputWrongShape() : ExpandDimsAsInputFixture("0", false, "2") {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseExpandDimAsInputWrongShape, ExpandDimAsInputWrongShape)
-{
- // Axis parameter that describes which axis/dim should be expanded is passed as a second input
- // Axis parameter is of wrong shape
- BOOST_REQUIRE_THROW(Setup({{"a", {1,4}} ,{"b",{1,1}}}, { "ExpandDims" }), armnn::ParseException);
-}
-
-struct ExpandDimsAsNotConstInputFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- ExpandDimsAsNotConstInputFixture()
- {
- m_Prototext = R"(
- node {
- name: "a"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- dim {
- size: 1
- }
- dim {
- size: 4
- }
- }
- }
- }
- }
- node {
- name: "b"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_INT32
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- dim {
- size: 1
- }
- }
- }
- }
- }
- node {
- name: "ExpandDims"
- op: "ExpandDims"
- input: "a"
- input: "b"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "Tdim"
- value {
- type: DT_INT32
- }
- }
- }
- versions {
- producer: 134
- })";
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseExpandDimAsNotConstInput, ExpandDimsAsNotConstInputFixture)
-{
- // Axis parameter that describes which axis/dim should be expanded is passed as a second input.
- // But is not a constant tensor --> not supported
- BOOST_REQUIRE_THROW(Setup({{"a", {1,4}} ,{"b",{1,1}}}, { "ExpandDims" }),
- armnn::ParseException);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/FullyConnected.cpp b/src/armnnTfParser/test/FullyConnected.cpp
deleted file mode 100644
index 14561c43cd..0000000000
--- a/src/armnnTfParser/test/FullyConnected.cpp
+++ /dev/null
@@ -1,579 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-#include "Runtime.hpp"
-#include "Network.hpp"
-#include "Graph.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-// In Tensorflow fully connected layers are expressed as a MatMul followed by an Add.
-// The TfParser must detect this case and convert them to a FullyConnected layer.
-struct FullyConnectedFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- FullyConnectedFixture()
- {
- // Input = tf.placeholder(tf.float32, [1, 1], "input")
- // Weights = tf.constant([2], tf.float32, [1, 1])
- // Matmul = tf.matmul(input, weights)
- // Bias = tf.constant([1], tf.float32)
- // Output = tf.add(matmul, bias, name="output")
- m_Prototext = R"(
-node {
- name: "input"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- dim {
- size: 1
- }
- dim {
- size: 1
- }
- }
- }
- }
-}
-node {
- name: "Const"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- dim {
- size: 1
- }
- dim {
- size: 1
- }
- }
- float_val: 2.0
- }
- }
- }
-}
-node {
- name: "MatMul"
- op: "MatMul"
- input: "input"
- input: "Const"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "transpose_a"
- value {
- b: false
- }
- }
- attr {
- key: "transpose_b"
- value {
- b: false
- }
- }
-}
-node {
- name: "Const_1"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- dim {
- size: 1
- }
- }
- float_val: 1.0
- }
- }
- }
-}
-node {
- name: "output"
- op: "Add"
- input: "MatMul"
- input: "Const_1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
- )";
- SetupSingleInputSingleOutput({ 1, 1 }, "input", "output");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(FullyConnected, FullyConnectedFixture)
-{
- RunTest<1>({ 3 }, { 7 });
-}
-
-// Similar to FullyConnectedFixture, but this time the MatMul's output is used by two Adds. This should result
-// in two FullyConnected layers being created.
-// I
-// |
-// M -- C
-// / \'
-// C-- A A -- C
-// \ /
-// A
-struct MatMulUsedInTwoFcFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- MatMulUsedInTwoFcFixture()
- {
- m_Prototext = R"(
-node {
- name: "input"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- dim {
- size: 1
- }
- dim {
- size: 1
- }
- }
- }
- }
-}
-node {
- name: "Const"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- dim {
- size: 1
- }
- dim {
- size: 1
- }
- }
- float_val: 2.0
- }
- }
- }
-}
-node {
- name: "MatMul"
- op: "MatMul"
- input: "input"
- input: "Const"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "transpose_a"
- value {
- b: false
- }
- }
- attr {
- key: "transpose_b"
- value {
- b: false
- }
- }
-}
-node {
- name: "Const_1"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- dim {
- size: 1
- }
- }
- float_val: 5.0
- }
- }
- }
-}
-node {
- name: "Const_2"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- dim {
- size: 1
- }
- }
- float_val: 15.0
- }
- }
- }
-}
-node {
- name: "Add"
- op: "Add"
- input: "MatMul"
- input: "Const_1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
-node {
- name: "Add_1"
- op: "Add"
- input: "MatMul"
- input: "Const_2"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
-node {
- name: "output"
- op: "Add"
- input: "Add"
- input: "Add_1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
- )";
- SetupSingleInputSingleOutput({ 1, 1 }, "input", "output");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(MatMulUsedInTwoFc, MatMulUsedInTwoFcFixture)
-{
- RunTest<1>({ 3 }, { 32 });
- // Ideally we would check here that the armnn network has 5 layers:
- // Input, 2 x FullyConnected (biased), Add and Output.
- // This would make sure the parser hasn't incorrectly added some unconnected layers corresponding to the MatMul.
-}
-
-// Similar to MatMulUsedInTwoFc, but this time the Adds are 'staggered' (see diagram), which means that only one
-// FullyConnected layer can be created (the other should just be an Add).
-// I
-// |
-// M -- C1
-// / \'
-// C2 -- A |
-// \ /
-// A
-struct MatMulUsedInTwoFcStaggeredFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- MatMulUsedInTwoFcStaggeredFixture()
- {
- // Input = tf.placeholder(tf.float32, shape=[1,1], name = "input")
- // Const1 = tf.constant([17], tf.float32, [1,1])
- // Mul = tf.matmul(input, const1)
- // Monst2 = tf.constant([7], tf.float32, [1])
- // Fc = tf.add(mul, const2)
- // Output = tf.add(mul, fc, name="output")
- m_Prototext = R"(
-node {
- name: "input"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- dim {
- size: 1
- }
- dim {
- size: 1
- }
- }
- }
- }
-}
-node {
- name: "Const"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- dim {
- size: 1
- }
- dim {
- size: 1
- }
- }
- float_val: 17.0
- }
- }
- }
-}
-node {
- name: "MatMul"
- op: "MatMul"
- input: "input"
- input: "Const"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "transpose_a"
- value {
- b: false
- }
- }
- attr {
- key: "transpose_b"
- value {
- b: false
- }
- }
-}
-node {
- name: "Const_1"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- dim {
- size: 1
- }
- }
- float_val: 7.0
- }
- }
- }
-}
-node {
- name: "Add"
- op: "Add"
- input: "MatMul"
- input: "Const_1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
-node {
- name: "output"
- op: "Add"
- input: "MatMul"
- input: "Add"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
- )";
- SetupSingleInputSingleOutput({ 1, 1 }, "input", "output");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(MatMulUsedInTwoFcStaggered, MatMulUsedInTwoFcStaggeredFixture)
-{
- RunTest<1>({ 2 }, { 75 });
- // Ideally we would check here that the armnn network has 5 layers:
- // Input, FullyConnected (biased), FullyConnected (non biased), Add and Output.
-}
-
-// A MatMul in isolation, not connected to an add. Should result in a non-biased FullyConnected layer.
-struct MatMulFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- MatMulFixture()
- {
- // Input = tf.placeholder(tf.float32, shape = [1, 1], name = "input")
- // Const = tf.constant([17], tf.float32, [1, 1])
- // Output = tf.matmul(input, const, name = "output")
- m_Prototext = R"(
-node {
- name: "input"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- dim {
- size: 1
- }
- dim {
- size: 1
- }
- }
- }
- }
-}
-node {
- name: "Const"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- dim {
- size: 1
- }
- dim {
- size: 1
- }
- }
- float_val: 17.0
- }
- }
- }
-}
-node {
- name: "output"
- op: "MatMul"
- input: "input"
- input: "Const"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "transpose_a"
- value {
- b: false
- }
- }
- attr {
- key: "transpose_b"
- value {
- b: false
- }
- }
-}
- )";
- SetupSingleInputSingleOutput({ 1, 1 }, "input", "output");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(MatMul, MatMulFixture)
-{
- RunTest<1>({ 2 }, { 34 });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/FusedBatchNorm.cpp b/src/armnnTfParser/test/FusedBatchNorm.cpp
deleted file mode 100644
index b93a4728d0..0000000000
--- a/src/armnnTfParser/test/FusedBatchNorm.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-#include <array>
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct FusedBatchNormFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- explicit FusedBatchNormFixture(const std::string& dataLayout)
- {
- m_Prototext = "node { \n"
- " name: \"graphInput\" \n"
- " op: \"Placeholder\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"shape\" \n"
- " value { \n"
- " shape { \n"
- " } \n"
- " } \n"
- " } \n"
- "} \n"
- "node { \n"
- " name: \"Const_1\" \n"
- " op: \"Const\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"value\" \n"
- " value { \n"
- " tensor { \n"
- " dtype: DT_FLOAT \n"
- " tensor_shape { \n"
- " dim { \n"
- " size: 1 \n"
- " } \n"
- " } \n"
- " float_val: 1.0 \n"
- " } \n"
- " } \n"
- " } \n"
- "} \n"
- "node { \n"
- " name: \"Const_2\" \n"
- " op: \"Const\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"value\" \n"
- " value { \n"
- " tensor { \n"
- " dtype: DT_FLOAT \n"
- " tensor_shape { \n"
- " dim { \n"
- " size: 1 \n"
- " } \n"
- " } \n"
- " float_val: 0.0 \n"
- " } \n"
- " } \n"
- " } \n"
- "} \n"
- "node { \n"
- " name: \"FusedBatchNormLayer/mean\" \n"
- " op: \"Const\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"value\" \n"
- " value { \n"
- " tensor { \n"
- " dtype: DT_FLOAT \n"
- " tensor_shape { \n"
- " dim { \n"
- " size: 1 \n"
- " } \n"
- " } \n"
- " float_val: 5.0 \n"
- " } \n"
- " } \n"
- " } \n"
- "} \n"
- "node { \n"
- " name: \"FusedBatchNormLayer/variance\" \n"
- " op: \"Const\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"value\" \n"
- " value { \n"
- " tensor { \n"
- " dtype: DT_FLOAT \n"
- " tensor_shape { \n"
- " dim { \n"
- " size: 1 \n"
- " } \n"
- " } \n"
- " float_val: 2.0 \n"
- " } \n"
- " } \n"
- " } \n"
- "} \n"
- "node { \n"
- " name: \"output\" \n"
- " op: \"FusedBatchNorm\" \n"
- " input: \"graphInput\" \n"
- " input: \"Const_1\" \n"
- " input: \"Const_2\" \n"
- " input: \"FusedBatchNormLayer/mean\" \n"
- " input: \"FusedBatchNormLayer/variance\" \n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n";
-
- // NOTE: we only explicitly set data_format when it is not the default NHWC
- if (dataLayout != "NHWC")
- {
- m_Prototext.append(" attr { \n"
- " key: \"data_format\" \n"
- " value { \n"
- " s: \"");
- m_Prototext.append(dataLayout);
- m_Prototext.append("\" \n"
- " } \n"
- " } \n");
- }
-
- m_Prototext.append(" attr { \n"
- " key: \"epsilon\" \n"
- " value { \n"
- " f: 0.0010000000475 \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"is_training\" \n"
- " value { \n"
- " b: false \n"
- " } \n"
- " } \n"
- "} \n");
-
- // Set the input shape according to the data layout
- std::array<unsigned int, 4> dims;
- if (dataLayout == "NHWC")
- {
- dims = { 1u, 3u, 3u, 1u };
- }
- else // dataLayout == "NCHW"
- {
- dims = { 1u, 1u, 3u, 3u };
- }
-
- SetupSingleInputSingleOutput(armnn::TensorShape(4, dims.data()), "graphInput", "output");
- }
-};
-
-struct FusedBatchNormNhwcFixture : FusedBatchNormFixture
-{
- FusedBatchNormNhwcFixture() : FusedBatchNormFixture("NHWC"){}
-};
-BOOST_FIXTURE_TEST_CASE(ParseFusedBatchNormNhwc, FusedBatchNormNhwcFixture)
-{
- RunTest<4>({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, // Input data.
- { -2.8277204f, -2.12079024f, -1.4138602f,
- -0.7069301f, 0.0f, 0.7069301f,
- 1.4138602f, 2.12079024f, 2.8277204f }); // Expected output data.
-}
-
-struct FusedBatchNormNchwFixture : FusedBatchNormFixture
-{
- FusedBatchNormNchwFixture() : FusedBatchNormFixture("NCHW"){}
-};
-BOOST_FIXTURE_TEST_CASE(ParseFusedBatchNormNchw, FusedBatchNormNchwFixture)
-{
- RunTest<4>({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, // Input data.
- { -2.8277204f, -2.12079024f, -1.4138602f,
- -0.7069301f, 0.0f, 0.7069301f,
- 1.4138602f, 2.12079024f, 2.8277204f }); // Expected output data.
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Gather.cpp b/src/armnnTfParser/test/Gather.cpp
deleted file mode 100644
index ab5fb7104d..0000000000
--- a/src/armnnTfParser/test/Gather.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd and Contributors. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "armnnTfParser/ITfParser.hpp"
-
-#include "ParserPrototxtFixture.hpp"
-#include <PrototxtConversions.hpp>
-
-#include <boost/test/unit_test.hpp>
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-namespace {
-// helper for setting the dimensions in prototxt
-void dimsHelper(const std::vector<int>& dims, std::string& text){
- for(unsigned int i = 0; i < dims.size(); ++i) {
- text.append(R"(dim {
- size: )");
- text.append(std::to_string(dims[i]));
- text.append(R"(
- })");
- }
-}
-
-// helper for converting from integer to octal representation
-void octalHelper(const std::vector<int>& indicesContent, std::string& text){
- for(unsigned int i = 0; i < indicesContent.size(); ++i) {
- text.append(armnnUtils::ConvertInt32ToOctalString(static_cast<int>(indicesContent[i])));
- }
-}
-} // namespace
-
-struct GatherFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- GatherFixture(const armnn::TensorShape& inputShape0,
- const armnn::TensorShape& inputShape1,
- const std::vector<int>& input1Content,
- const std::vector<int>& input0Dims,
- const std::vector<int>& input1Dims,
- int axis = 0)
- {
- m_Prototext = R"(
-node {
- name: "input0"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
-)";
- dimsHelper(input0Dims, m_Prototext);
-
- m_Prototext.append(R"(
- }
- }
- }
-}
-node {
- name: "input1"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_INT32
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_INT32
- tensor_shape {
-)");
- dimsHelper(input1Dims, m_Prototext);
-
- m_Prototext.append(R"(
- }
- tensor_content: ")");
- octalHelper(input1Content, m_Prototext);
- m_Prototext.append(R"("
- }
- }
- }
-}
-node {
- name: "output"
- op: "Gather"
- input: "input0"
- input: "input1"
- attr {
- key: "Tindices"
- value {
- type: DT_INT32
- }
- }
- attr {
- key: "Tparams"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "axis"
- value {
- i: )");
- m_Prototext += std::to_string(axis);
-
- m_Prototext.append(R"(
- }
- }
-}
- )");
-
- Setup({ { "input0", inputShape0 },
- { "input1", inputShape1 } },
- { "output" });
-
- }
-};
-
-
-struct GatherFixture1DParams1DIndices : public GatherFixture
-{
- GatherFixture1DParams1DIndices() : GatherFixture(
- { 4, 1, 1, 1 },
- { 4, 0, 0, 0 },
- { 0, 2, 1, 3 },
- { 4 },
- { 4 },
- 0) {}
-};
-
-struct GatherFixture1DParamsMultiDimIndices : public GatherFixture
-{
- GatherFixture1DParamsMultiDimIndices() : GatherFixture(
- { 4, 1, 1 },
- { 2, 2, 1, 1 },
- { 0, 1, 1, 3 },
- { 4 },
- { 2, 2 },
- 0) {}
-};
-
-struct GatherFixtureMultiDimParamMultiDimIndices : public GatherFixture
-{
- GatherFixtureMultiDimParamMultiDimIndices() : GatherFixture(
- { 5, 2, 1 },
- { 2, 1, 4 },
- { 1, 3, 0, 2 },
- { 5, 2 },
- { 2, 2 },
- 0) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseGather1DParams1DIndices, GatherFixture1DParams1DIndices)
-{
- RunTest<4>({ { "input0", { 1, 2, 3, 4 } } },
-
- { { "output", { 1, 3, 2, 4 } } });
-}
-
-BOOST_FIXTURE_TEST_CASE(ParseGather1DParamsMultiDimIndices, GatherFixture1DParamsMultiDimIndices)
-{
- RunTest<4>({ { "input0", { 1, 2, 3, 4 } } },
-
- { { "output", { 1, 2, 2, 4 } } });
-}
-
-BOOST_FIXTURE_TEST_CASE(ParseGatherMultiDimParamMultiDimIndices, GatherFixtureMultiDimParamMultiDimIndices)
-{
- RunTest<4>({ { "input0", { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } } },
-
- { { "output", { 3, 4, 7, 8, 1, 2, 5, 6} } });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Greater.cpp b/src/armnnTfParser/test/Greater.cpp
deleted file mode 100644
index d1e793987b..0000000000
--- a/src/armnnTfParser/test/Greater.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct GreaterFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- GreaterFixture()
- {
- m_Prototext = R"(
-node {
- name: "input0"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
-}
-node {
- name: "input1"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
-}
-node {
- name: "output"
- op: "Greater"
- input: "input0"
- input: "input1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
- )";
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseGreaterUnsupportedBroadcast, GreaterFixture)
-{
- BOOST_REQUIRE_THROW(Setup({ { "input0", {2, 3} },
- { "input1", {1, 2, 2, 3} } },
- { "output" }),
- armnn::ParseException);
-}
-
-struct GreaterFixtureAutoSetup : public GreaterFixture
-{
- GreaterFixtureAutoSetup(const armnn::TensorShape& input0Shape,
- const armnn::TensorShape& input1Shape)
- : GreaterFixture()
- {
- Setup({ { "input0", input0Shape },
- { "input1", input1Shape } },
- { "output" });
- }
-};
-
-struct GreaterFixtureTwoByTwo : public GreaterFixtureAutoSetup
-{
- GreaterFixtureTwoByTwo() : GreaterFixtureAutoSetup({2, 2}, {2, 2}) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseGreaterTwoByTwo, GreaterFixtureTwoByTwo)
-{
- RunComparisonTest<2>({ { "input0", { 1.0f, 2.0f, 3.0f, 4.0f} },
- { "input1", { 1.0f, 5.0f, 2.0f, 2.0f} } },
- { { "output", { 0, 0, 1, 1} } });
-}
-
-struct GreaterBroadcast1DAnd4D : public GreaterFixtureAutoSetup
-{
- GreaterBroadcast1DAnd4D() : GreaterFixtureAutoSetup({1}, {1,1,2,2}) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseGreaterBroadcast1DToTwoByTwo, GreaterBroadcast1DAnd4D)
-{
- RunComparisonTest<4>({ { "input0", { 2.0f } },
- { "input1", { 1.0f, 2.0f, 3.0f, 2.0f } } },
- { { "output", { 1, 0, 0, 0 } } });
-}
-
-struct GreaterBroadcast4DAnd1D : public GreaterFixtureAutoSetup
-{
- GreaterBroadcast4DAnd1D() : GreaterFixtureAutoSetup({1,1,2,2}, {1}) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseGreaterBroadcast4DAnd1D, GreaterBroadcast4DAnd1D)
-{
- RunComparisonTest<4>({ { "input0", { 1.0f, 2.0f, 3.0f, 2.0f } },
- { "input1", { 3.0f } } },
- { { "output", { 0, 0, 0, 0 } } });
-}
-
-struct GreaterMultiDimBroadcast : public GreaterFixtureAutoSetup
-{
- GreaterMultiDimBroadcast() : GreaterFixtureAutoSetup({1,1,2,1}, {1,2,1,3}) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseGreaterMultiDimBroadcast, GreaterMultiDimBroadcast)
-{
- RunComparisonTest<4>({ { "input0", { 1.0f, 2.0f } },
- { "input1", { 1.0f, 2.0f, 3.0f,
- 3.0f, 2.0f, 2.0f } } },
- { { "output", { 0, 0, 0,
- 1, 0, 0,
- 0, 0, 0,
- 0, 0, 0 } } });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Identity.cpp b/src/armnnTfParser/test/Identity.cpp
deleted file mode 100644
index 5b04d42b67..0000000000
--- a/src/armnnTfParser/test/Identity.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct IdentitySimpleFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- IdentitySimpleFixture()
- {
- m_Prototext = "node{ "
- " name: \"Placeholder\""
- " op: \"Placeholder\""
- " attr {"
- " key: \"dtype\""
- " value {"
- " type: DT_FLOAT"
- " }"
- " }"
- " attr {"
- " key: \"shape\""
- " value {"
- " shape {"
- " unknown_rank: true"
- " }"
- " }"
- " }"
- "}"
- "node {"
- " name: \"Identity\""
- " op: \"Identity\""
- " input: \"Placeholder\""
- " attr {"
- " key: \"T\""
- " value {"
- " type: DT_FLOAT"
- " }"
- " }"
- "}";
- SetupSingleInputSingleOutput({ 4 }, "Placeholder", "Identity");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(IdentitySimple, IdentitySimpleFixture)
-{
- RunTest<1>({ 1.0f, 2.0f, 3.0f, 4.0f }, { 1.0f, 2.0f, 3.0f, 4.0f });
-}
-
-struct IdentityFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- IdentityFixture()
- {
- m_Prototext = "node{ "
- " name: \"Placeholder\""
- " op: \"Placeholder\""
- " attr {"
- " key: \"dtype\""
- " value {"
- " type: DT_FLOAT"
- " }"
- " }"
- " attr {"
- " key: \"shape\""
- " value {"
- " shape {"
- " unknown_rank: true"
- " }"
- " }"
- " }"
- "}"
- "node {"
- " name: \"Identity\""
- " op: \"Identity\""
- " input: \"Placeholder\""
- " attr {"
- " key: \"T\""
- " value {"
- " type: DT_FLOAT"
- " }"
- " }"
- "}"
- "node {"
- " name: \"Add\""
- " op: \"Add\""
- " input: \"Identity\""
- " input: \"Identity\""
- " attr {"
- " key: \"T\""
- " value {"
- " type: DT_FLOAT"
- " }"
- " }"
- "}";
- SetupSingleInputSingleOutput({ 4 }, "Placeholder", "Add");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseIdentity, IdentityFixture)
-{
- RunTest<1>({ 1.0f, 2.0f, 3.0f, 4.0f }, { 2.0f, 4.0f, 6.0f, 8.0f });
-}
-
-struct IdentityChainFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- IdentityChainFixture()
- {
- m_Prototext = "node{ "
- " name: \"Placeholder\""
- " op: \"Placeholder\""
- " attr {"
- " key: \"dtype\""
- " value {"
- " type: DT_FLOAT"
- " }"
- " }"
- " attr {"
- " key: \"shape\""
- " value {"
- " shape {"
- " unknown_rank: true"
- " }"
- " }"
- " }"
- "}"
- "node {"
- " name: \"Identity\""
- " op: \"Identity\""
- " input: \"Placeholder\""
- " attr {"
- " key: \"T\""
- " value {"
- " type: DT_FLOAT"
- " }"
- " }"
- "}"
- "node {"
- " name: \"Identity2\""
- " op: \"Identity\""
- " input: \"Identity\""
- " attr {"
- " key: \"T\""
- " value {"
- " type: DT_FLOAT"
- " }"
- " }"
- "}";
- SetupSingleInputSingleOutput({ 4 }, "Placeholder", "Identity2");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(IdentityChain, IdentityChainFixture)
-{
- RunTest<1>({ 1.0f, 2.0f, 3.0f, 4.0f }, { 1.0f, 2.0f, 3.0f, 4.0f });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/LocalResponseNormalization.cpp b/src/armnnTfParser/test/LocalResponseNormalization.cpp
deleted file mode 100644
index 7a364daac2..0000000000
--- a/src/armnnTfParser/test/LocalResponseNormalization.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct LocalResponseNormalizationBaseFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- explicit LocalResponseNormalizationBaseFixture(float alpha, float beta, float bias)
- {
- std::string alphaString = std::to_string(alpha);
- std::string betaString = std::to_string(beta);
- std::string biasString = std::to_string(bias);
-
- m_Prototext = "node {"
- " name: \"Placeholder\""
- " op: \"Placeholder\""
- " attr {"
- " key: \"dtype\""
- " value {"
- " type: DT_FLOAT"
- " }"
- " }"
- " attr {"
- " key: \"shape\""
- " value {"
- " shape {"
- " unknown_rank: true"
- " }"
- " }"
- " }"
- "}"
- "node {"
- " name: \"LRN\""
- " op: \"LRN\""
- " input: \"Placeholder\""
- " attr {"
- " key: \"T\""
- " value {"
- " type: DT_FLOAT"
- " }"
- " }"
- " attr {"
- " key: \"alpha\""
- " value {"
- " f: ";
- m_Prototext.append(alphaString);
- m_Prototext.append("\n"
- " }"
- " }"
- " attr {"
- " key: \"beta\""
- " value {"
- " f: ");
- m_Prototext.append(betaString);
- m_Prototext.append("\n"
- " }"
- " }"
- " attr {"
- " key: \"bias\""
- " value {"
- " f: ");
- m_Prototext.append(biasString);
- m_Prototext.append("\n"
- " }"
- " }"
- " attr {"
- " key: \"depth_radius\""
- " value {"
- " i: 1"
- " }"
- " }"
- "}");
- }
-};
-
-
-struct LocalResponseNormalizationFixtureSimple : public LocalResponseNormalizationBaseFixture
-{
- explicit LocalResponseNormalizationFixtureSimple()
- : LocalResponseNormalizationBaseFixture(1.0f, 1.0f, 1.0f)
- {
- SetupSingleInputSingleOutput({ 2, 2, 2, 1 }, "Placeholder", "LRN");
- }
-};
-BOOST_FIXTURE_TEST_CASE(ParseSimpleLocalResponseNormalization, LocalResponseNormalizationFixtureSimple)
-{
- RunTest<4>({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f },
- { 0.5f, 0.4f, 0.3f, 0.23529412f, 0.1923077f, 0.16216217f, 0.14f, 0.12307692f });
-}
-
-
-struct LocalResponseNormalizationFixture : public LocalResponseNormalizationBaseFixture
-{
- explicit LocalResponseNormalizationFixture()
- : LocalResponseNormalizationBaseFixture(0.5f, 1.0f, 0.5f)
- {
- SetupSingleInputSingleOutput({1, 3, 3, 2}, "Placeholder", "LRN");
- }
-};
-BOOST_FIXTURE_TEST_CASE(ParseLocalResponseNormalization, LocalResponseNormalizationFixture)
-{
- RunTest<4>({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f,
- 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f,
- 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f},
-
- {0.333333340f, 0.66666670f, 0.230769250f, 0.307692320f, 0.161290320f, 0.19354838f,
- 0.122807020f, 0.14035088f, 0.098901100f, 0.109890110f, 0.082706770f, 0.09022556f,
- 0.071038246f, 0.07650273f, 0.062240668f, 0.066390045f, 0.055374593f, 0.05863192f});
-}
-
-
-
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Maximum.cpp b/src/armnnTfParser/test/Maximum.cpp
deleted file mode 100644
index 8b87b76296..0000000000
--- a/src/armnnTfParser/test/Maximum.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct MaximumFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- MaximumFixture(const armnn::TensorShape& inputShape0, const armnn::TensorShape& inputShape1)
- {
- m_Prototext = R"(
-node {
- name: "input0"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
-}
-node {
- name: "input1"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
-}
-node {
- name: "output"
- op: "Maximum"
- input: "input0"
- input: "input1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
- )";
-
- Setup({ { "input0", inputShape0 },
- { "input1", inputShape1 } },
- { "output" });
- }
-};
-
-struct MaximumFixture4D4D : public MaximumFixture
-{
- MaximumFixture4D4D() : MaximumFixture({ 1, 2, 2, 3 }, { 1, 2, 2, 3 }) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseMaximum4D4D, MaximumFixture4D4D)
-{
- RunTest<4>({ { "input0", { 0.0f, 1.0f, 2.0f,
- 3.0f, 4.0f, 5.0f,
- 6.0f, 7.0f, 8.0f,
- 9.0f, 10.0f, 11.0f } },
- { "input1", { 5.0f, 1.0f, 3.0f,
- 4.0f, 5.5f, 1.0f,
- 2.0f, 17.0f, 18.0f,
- 19.0f, 1.0f, 3.0f } } },
- { { "output", { 5.0f, 1.0f, 3.0f,
- 4.0f, 5.5f, 5.0f,
- 6.0f, 17.0f, 18.0f,
- 19.0f, 10.0f, 11.0f } } });
-}
-
-struct MaximumBroadcastFixture4D4D : public MaximumFixture
-{
- MaximumBroadcastFixture4D4D() : MaximumFixture({ 1, 1, 2, 1 }, { 1, 2, 1, 3 }) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseMaximumBroadcast4D4D, MaximumBroadcastFixture4D4D)
-{
- RunTest<4>({ { "input0", { 2.0f, 4.0f } },
- { "input1", { 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f } } },
- { { "output", { 2.0f, 2.0f, 3.0f,
- 4.0f, 4.0f, 4.0f,
- 4.0f, 5.0f, 6.0f,
- 4.0f, 5.0f, 6.0f } } });
-}
-
-struct MaximumBroadcastFixture4D1D : public MaximumFixture
-{
- MaximumBroadcastFixture4D1D() : MaximumFixture({ 1, 2, 2, 3 }, { 1 }) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseMaximumBroadcast4D1D, MaximumBroadcastFixture4D1D)
-{
- RunTest<4>({ { "input0", { 0.0f, 1.0f, 2.0f,
- 3.0f, 4.0f, 5.0f,
- 6.0f, 7.0f, 8.0f,
- 9.0f, 10.0f, 11.0f } },
- { "input1", { 5.0f } } },
- { { "output", { 5.0f, 5.0f, 5.0f,
- 5.0f, 5.0f, 5.0f,
- 6.0f, 7.0f, 8.0f,
- 9.0f, 10.0f, 11.0f } } });
-}
-
-struct MaximumBroadcastFixture1D4D : public MaximumFixture
-{
- MaximumBroadcastFixture1D4D() : MaximumFixture({ 1 }, { 1, 2, 2, 3 }) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseMaximumBroadcast1D4D, MaximumBroadcastFixture1D4D)
-{
- RunTest<4>({ { "input0", { 3.0f } },
- { "input1", { 0.0f, 1.0f, 2.0f,
- 3.0f, 4.0f, 5.0f,
- 6.0f, 7.0f, 8.0f,
- 9.0f, 10.0f, 11.0f } } },
- { { "output", { 3.0f, 3.0f, 3.0f,
- 3.0f, 4.0f, 5.0f,
- 6.0f, 7.0f, 8.0f,
- 9.0f, 10.0f, 11.0f } } });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/MaximumForLeakyRelu.cpp b/src/armnnTfParser/test/MaximumForLeakyRelu.cpp
deleted file mode 100644
index 05c5003399..0000000000
--- a/src/armnnTfParser/test/MaximumForLeakyRelu.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct UnsupportedMaximumFixture
- : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- UnsupportedMaximumFixture()
- {
- m_Prototext = R"(
- node {
- name: "graphInput"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "Maximum"
- op: "Maximum"
- input: "graphInput"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- }
- )";
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(UnsupportedMaximum, UnsupportedMaximumFixture)
-{
- BOOST_CHECK_THROW(
- SetupSingleInputSingleOutput({ 1, 1 }, "graphInput", "Maximum"),
- armnn::ParseException);
-}
-
-struct SupportedMaximumFixture
- : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- SupportedMaximumFixture(const std::string & maxInput0,
- const std::string & maxInput1,
- const std::string & mulInput0,
- const std::string & mulInput1)
- {
- m_Prototext = R"(
- node {
- name: "graphInput"
- op: "Placeholder"
- attr {
- key: "dtype"
- value { type: DT_FLOAT }
- }
- attr {
- key: "shape"
- value { shape { } }
- }
- }
- node {
- name: "Alpha"
- op: "Const"
- attr {
- key: "dtype"
- value { type: DT_FLOAT }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- dim { size: 1 }
- }
- float_val: 0.1
- }
- }
- }
- }
- node {
- name: "Mul"
- op: "Mul"
- input: ")" + mulInput0 + R"("
- input: ")" + mulInput1 + R"("
- attr {
- key: "T"
- value { type: DT_FLOAT }
- }
- }
- node {
- name: "Maximum"
- op: "Maximum"
- input: ")" + maxInput0 + R"("
- input: ")" + maxInput1 + R"("
- attr {
- key: "T"
- value { type: DT_FLOAT }
- }
- }
- )";
- SetupSingleInputSingleOutput({ 1, 2 }, "graphInput", "Maximum");
- }
-};
-
-struct LeakyRelu_Max_MulAT_T_Fixture : public SupportedMaximumFixture
-{
- LeakyRelu_Max_MulAT_T_Fixture()
- : SupportedMaximumFixture("Mul","graphInput","Alpha","graphInput") {}
-};
-
-BOOST_FIXTURE_TEST_CASE(LeakyRelu_Max_MulAT_T, LeakyRelu_Max_MulAT_T_Fixture)
-{
- RunTest<2>(std::vector<float>({-5.0, 3.0}), {-0.5, 3.0});
-}
-
-struct LeakyRelu_Max_T_MulAT_Fixture : public SupportedMaximumFixture
-{
- LeakyRelu_Max_T_MulAT_Fixture()
- : SupportedMaximumFixture("graphInput","Mul","Alpha","graphInput") {}
-};
-
-
-BOOST_FIXTURE_TEST_CASE(LeakyRelu_Max_T_MulAT, LeakyRelu_Max_T_MulAT_Fixture)
-{
- RunTest<2>(std::vector<float>({-10.0, 3.0}), {-1.0, 3.0});
-}
-
-struct LeakyRelu_Max_MulTA_T_Fixture : public SupportedMaximumFixture
-{
- LeakyRelu_Max_MulTA_T_Fixture()
- : SupportedMaximumFixture("Mul", "graphInput","graphInput","Alpha") {}
-};
-
-BOOST_FIXTURE_TEST_CASE(LeakyRelu_Max_MulTA_T, LeakyRelu_Max_MulTA_T_Fixture)
-{
- RunTest<2>(std::vector<float>({-5.0, 3.0}), {-0.5, 3.0});
-}
-
-struct LeakyRelu_Max_T_MulTA_Fixture : public SupportedMaximumFixture
-{
- LeakyRelu_Max_T_MulTA_Fixture()
- : SupportedMaximumFixture("graphInput", "Mul", "graphInput", "Alpha") {}
-};
-
-BOOST_FIXTURE_TEST_CASE(LeakyRelu_Max_T_MulTA, LeakyRelu_Max_T_MulTA_Fixture)
-{
- RunTest<2>(std::vector<float>({-10.0, 13.0}), {-1.0, 13.0});
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Mean.cpp b/src/armnnTfParser/test/Mean.cpp
deleted file mode 100644
index d73682961f..0000000000
--- a/src/armnnTfParser/test/Mean.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "armnnTfParser/ITfParser.hpp"
-
-#include <ParserPrototxtFixture.hpp>
-#include <PrototxtConversions.hpp>
-
-#include <boost/test/unit_test.hpp>
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct MeanFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- explicit MeanFixture(const armnn::TensorShape& inputShape, const armnn::TensorShape& outputShape,
- const std::vector<unsigned int>& axis, bool keepDims)
- {
- std::string protobufAxisString;
- std::vector<unsigned int> protobufAxis(axis);
-
- // If no axis range is specified, the reduction is applied to
- // all dimensions of the input tensor
- if (protobufAxis.size() == 0)
- {
- for (unsigned int i = 0; i < inputShape.GetNumDimensions(); ++i)
- {
- protobufAxis.push_back(i);
- }
- }
-
- for (unsigned int i = 0; i < protobufAxis.size(); ++i)
- {
- protobufAxisString.append(armnnUtils::ConvertInt32ToOctalString(static_cast<int>(protobufAxis[i])));
- }
-
- m_Prototext = R"(node {
- name: "input"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "Const"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_INT32
- }
- }
- attr {
- key: "value"
- value { )";
-
- if (axis.size() == 1)
- {
- m_Prototext.append(R"( tensor {
- dtype: DT_INT32
- tensor_shape {
- }
- int_val: )").append(std::to_string(protobufAxis[0])).append(R"(
- } )");
- }
- else
- {
- m_Prototext.append(R"( tensor {
- dtype: DT_INT32
- tensor_shape {
- dim {
- size: 2
- }
- }
- tensor_content: ")").append(protobufAxisString).append(R"("
- } )");
- }
-
- m_Prototext.append(R"( }
- }
- }
- node {
- name: "output"
- op: "Mean"
- input: "input"
- input: "Const"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "Tidx"
- value {
- type: DT_INT32
- }
- }
- attr {
- key: "keep_dims"
- value {
- b: )").append(keepDims ? "true" : "false").append(R"(
- }
- }
- })");
-
- SetupSingleInputSingleOutput(inputShape, outputShape, "input", "output");
- }
-};
-
-struct MeanNoAxisNoKeepDimsFixture: MeanFixture
-{
- MeanNoAxisNoKeepDimsFixture() : MeanFixture({ 2, 3 }, { 1 }, {}, false) {}
-};
-
-struct MeanWithAxis0NoKeepDimsFixture: MeanFixture
-{
- MeanWithAxis0NoKeepDimsFixture() : MeanFixture({ 2, 3 }, { 3 }, { 0 }, false) {}
-};
-
-struct MeanWithAxis1NoKeepDimsFixture: MeanFixture
-{
- MeanWithAxis1NoKeepDimsFixture() : MeanFixture({ 2, 3 }, { 2 }, { 1 }, false) {}
-};
-
-struct MeanWithAxis0KeepDimsFixture: MeanFixture
-{
- MeanWithAxis0KeepDimsFixture() : MeanFixture({ 2, 3 }, { 1, 3 }, { 0 }, true) {}
-};
-
-struct MeanWithAxis1KeepDimsFixture: MeanFixture
-{
- MeanWithAxis1KeepDimsFixture() : MeanFixture({ 2, 3 }, { 2, 1 }, { 1 }, true) {}
-};
-
-
-BOOST_FIXTURE_TEST_CASE(MeanNoAxisNoKeepDims, MeanNoAxisNoKeepDimsFixture)
-{
- RunTest<1>({ { "input", { 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f } } },
- { { "output", { 1.5f } } });
-}
-
-BOOST_FIXTURE_TEST_CASE(MeanWithAxis0NoKeepDims, MeanWithAxis0NoKeepDimsFixture)
-{
- RunTest<1>({ { "input", { 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f } } },
- { { "output", { 1.5f, 1.5f, 1.5f } } });
-}
-
-BOOST_FIXTURE_TEST_CASE(MeanWithAxis1NoKeepDims, MeanWithAxis1NoKeepDimsFixture)
-{
- RunTest<1>({ { "input", { 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f } } },
- { { "output", { 1.f, 2.f } } });
-}
-
-BOOST_FIXTURE_TEST_CASE(MeanWithAxis0KeepDims, MeanWithAxis0KeepDimsFixture)
-{
- RunTest<2>({ { "input", { 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f } } },
- { { "output", { 1.5f, 1.5f, 1.5f } } });
-}
-
-BOOST_FIXTURE_TEST_CASE(MeanWithAxis1KeepDims, MeanWithAxis1KeepDimsFixture)
-{
- RunTest<2>({ { "input", { 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f } } },
- { { "output", { 1.f, 2.f } } });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Minimum.cpp b/src/armnnTfParser/test/Minimum.cpp
deleted file mode 100644
index feb86a17d6..0000000000
--- a/src/armnnTfParser/test/Minimum.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct MinimumFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- MinimumFixture()
- {
- m_Prototext = R"(
- node {
- name: "input0"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "input1"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "output"
- op: "Minimum"
- input: "input0"
- input: "input1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- )";
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseMininumUnsupportedBroadcast, MinimumFixture)
-{
- BOOST_REQUIRE_THROW(Setup({ { "input0", {2, 3} },
- { "input1", {1, 2, 2, 3} } },
- { "output" }),
- armnn::ParseException);
-}
-
-struct MinimumFixtureAutoSetup : public MinimumFixture
-{
- MinimumFixtureAutoSetup(const armnn::TensorShape& input0Shape,
- const armnn::TensorShape& input1Shape)
- : MinimumFixture()
- {
- Setup({ { "input0", input0Shape },
- { "input1", input1Shape } },
- { "output" });
- }
-};
-
-struct MinimumFixture4D : public MinimumFixtureAutoSetup
-{
- MinimumFixture4D()
- : MinimumFixtureAutoSetup({1, 2, 2, 3}, {1, 2, 2, 3}) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseMinimum4D, MinimumFixture4D)
-{
- RunTest<4>({ { "input0", { 0.0f, 1.0f, 2.0f,
- 3.0f, 4.0f, 5.0f,
- 6.0f, 7.0f, 8.0f,
- 9.0f, 10.0f, 11.0f } },
- { "input1", { 0.0f, 0.0f, 0.0f,
- 5.0f, 5.0f, 5.0f,
- 7.0f, 7.0f, 7.0f,
- 9.0f, 9.0f, 9.0f } } },
- { { "output", { 0.0f, 0.0f, 0.0f,
- 3.0f, 4.0f, 5.0f,
- 6.0f, 7.0f, 7.0f,
- 9.0f, 9.0f, 9.0f } } });
-}
-
-struct MinimumBroadcastFixture4D : public MinimumFixtureAutoSetup
-{
- MinimumBroadcastFixture4D()
- : MinimumFixtureAutoSetup({1, 1, 2, 1}, {1, 2, 1, 3}) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseMinimumBroadcast4D, MinimumBroadcastFixture4D)
-{
- RunTest<4>({ { "input0", { 2.0f,
- 4.0f } },
- { "input1", { 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f } } },
- { { "output", { 1.0f, 2.0f, 2.0f,
- 1.0f, 2.0f, 3.0f,
- 2.0f, 2.0f, 2.0f,
- 4.0f, 4.0f, 4.0f } } });
-}
-
-struct MinimumBroadcastFixture4D1D : public MinimumFixtureAutoSetup
-{
- MinimumBroadcastFixture4D1D()
- : MinimumFixtureAutoSetup({1, 2, 2, 3}, {1}) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseMinimumBroadcast4D1D, MinimumBroadcastFixture4D1D)
-{
- RunTest<4>({ { "input0", { 0.0f, 1.0f, 2.0f,
- 3.0f, 4.0f, 5.0f,
- 6.0f, 7.0f, 8.0f,
- 9.0f, 10.0f, 11.0f } },
- { "input1", { 5.0f } } },
- { { "output", { 0.0f, 1.0f, 2.0f,
- 3.0f, 4.0f, 5.0f,
- 5.0f, 5.0f, 5.0f,
- 5.0f, 5.0f, 5.0f } } });
-}
-
-struct MinimumBroadcastFixture1D4D : public MinimumFixtureAutoSetup
-{
- MinimumBroadcastFixture1D4D()
- : MinimumFixtureAutoSetup({3}, {1, 2, 2, 3}) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseMinimumBroadcast1D4D, MinimumBroadcastFixture1D4D)
-{
- RunTest<4>({ { "input0", { 5.0f, 6.0f, 7.0f } },
- { "input1", { 0.0f, 1.0f, 2.0f,
- 3.0f, 4.0f, 5.0f,
- 6.0f, 7.0f, 8.0f,
- 9.0f, 10.0f, 11.0f } } },
- { { "output", { 0.0f, 1.0f, 2.0f,
- 3.0f, 4.0f, 5.0f,
- 5.0f, 6.0f, 7.0f,
- 5.0f, 6.0f, 7.0f } } });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/MultiOutput.cpp b/src/armnnTfParser/test/MultiOutput.cpp
deleted file mode 100644
index 15879c2bed..0000000000
--- a/src/armnnTfParser/test/MultiOutput.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct MultiOutMatchFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- MultiOutMatchFixture()
- {
- m_Prototext = R"(
-node {
- name: "input"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
-}
-node {
- name: "softmax1"
- op: "Softmax"
- input: "input:0"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
- )";
- SetupSingleInputSingleOutput({ 1, 7 }, "input", "softmax1");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(MultiOutMatch, MultiOutMatchFixture)
-{
- // Note that the point of this test is to verify the parsing went well.
- // Here we make sure the softmax has really connected to the input layer.
- RunTest<2>({ 0, 0, 10000, 0, 0, 0, 0 }, { 0, 0, 1, 0, 0, 0, 0 });
-}
-
-struct MultiOutFailFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- MultiOutFailFixture()
- {
- m_Prototext = R"(
-node {
- name: "input"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
-}
-node {
- name: "softmax1"
- op: "Softmax"
- input: "input:1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
- )";
- BOOST_CHECK_THROW(SetupSingleInputSingleOutput({ 1, 7 }, "input", "softmax1"), armnn::ParseException);
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(MultiOutFail, MultiOutFailFixture)
-{
- // Not running the graph because this is expected to throw an exception during parsing.
-}
-
-struct MultiOutInvalidFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- MultiOutInvalidFixture()
- {
- m_Prototext = R"(
-node {
- name: "input"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
-}
-node {
- name: "softmax1"
- op: "Softmax"
- input: "input:-1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
- )";
- BOOST_CHECK_THROW(SetupSingleInputSingleOutput({ 1, 7 }, "input", "softmax1"), armnn::ParseException);
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(MultiOutInvalid, MultiOutInvalidFixture)
-{
- // Not running the graph because this is expected to throw an exception during parsing.
-}
-
-
-BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file
diff --git a/src/armnnTfParser/test/Multiplication.cpp b/src/armnnTfParser/test/Multiplication.cpp
deleted file mode 100644
index 01a7c79b6c..0000000000
--- a/src/armnnTfParser/test/Multiplication.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct MultiplicationFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- MultiplicationFixture()
- {
- m_Prototext = "node { \n"
- " name: \"graphInput\" \n"
- " op: \"Placeholder\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"shape\" \n"
- " value { \n"
- " shape { \n"
- " } \n"
- " } \n"
- " } \n"
- " } \n"
- " node { \n"
- " name: \"softmax1\" \n"
- " op: \"Softmax\" \n"
- " input: \"graphInput\" \n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " }\n"
- " node {\n"
- " name: \"softmax2\"\n"
- " op : \"Softmax\"\n"
- " input: \"graphInput\"\n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " }\n"
- " node {\n"
- " name: \"multiplication\"\n"
- " op : \"Mul\"\n"
- " input: \"softmax1\"\n"
- " input: \"softmax2\"\n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " }\n";
-
- SetupSingleInputSingleOutput({ 1, 7 }, "graphInput", "multiplication");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseMultiplication, MultiplicationFixture)
-{
- RunTest<2>({ 0, 0, 10000, 0, 0, 0, 0 }, { 0, 0, 1, 0, 0, 0, 0 });
-}
-
-struct MultiplicationBroadcastFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- MultiplicationBroadcastFixture(const armnn::TensorShape& inputShape0, const armnn::TensorShape& inputShape1)
- {
- m_Prototext = R"(
-node {
- name: "input0"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
-}
-node {
- name: "input1"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
-}
-node {
- name: "output"
- op: "Mul"
- input: "input0"
- input: "input1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
- )";
-
- Setup({ { "input0", inputShape0 },
- { "input1", inputShape1 } },
- { "output" });
- }
-};
-
-struct MultiplicationBroadcastFixture4D1D : public MultiplicationBroadcastFixture
-{
- MultiplicationBroadcastFixture4D1D() : MultiplicationBroadcastFixture({ 1, 2, 2, 3 }, { 1 }) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseMultiplicationBroadcast4D1D, MultiplicationBroadcastFixture4D1D)
-{
- RunTest<4>({ { "input0", { 0.0f, 1.0f, 2.0f,
- 3.0f, 4.0f, 5.0f,
- 6.0f, 7.0f, 8.0f,
- 9.0f, 10.0f, 11.0f } },
- { "input1", { 5.0f } } },
- { { "output", { 0.0f, 5.0f, 10.0f,
- 15.0f, 20.0f, 25.0f,
- 30.0f, 35.0f, 40.0f,
- 45.0f, 50.0f, 55.0f } } });
-}
-
-struct MultiplicationBroadcastFixture1D4D : public MultiplicationBroadcastFixture
-{
- MultiplicationBroadcastFixture1D4D() : MultiplicationBroadcastFixture({ 1 }, { 1, 2, 2, 3 }) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseMultiplicationBroadcast1D4D, MultiplicationBroadcastFixture1D4D)
-{
- RunTest<4>({ { "input0", { 3.0f } },
- { "input1", { 0.0f, 1.0f, 2.0f,
- 3.0f, 4.0f, 5.0f,
- 6.0f, 7.0f, 8.0f,
- 9.0f, 10.0f, 11.0f } } },
- { { "output", { 0.0f, 3.0f, 6.0f,
- 9.0f, 12.0f, 15.0f,
- 18.0f, 21.0f, 24.0f,
- 27.0f, 30.0f, 33.0f } } });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Pad.cpp b/src/armnnTfParser/test/Pad.cpp
deleted file mode 100644
index 8bfe970dfa..0000000000
--- a/src/armnnTfParser/test/Pad.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct PadFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- PadFixture() {
- m_Prototext = "node {\n"
- " name: \"input\"\n"
- " op: \"Placeholder\"\n"
- " attr {\n"
- " key: \"dtype\"\n"
- " value {\n"
- " type: DT_FLOAT\n"
- " }\n"
- " }\n"
- " attr {\n"
- " key: \"shape\"\n"
- " value {\n"
- " shape {\n"
- " dim {\n"
- " size: -1\n"
- " }\n"
- " dim {\n"
- " size: 2\n"
- " }\n"
- " dim {\n"
- " size: 2\n"
- " }\n"
- " dim {\n"
- " size: 2\n"
- " }\n"
- " }\n"
- " }\n"
- " }\n"
- "}\n"
- "node {\n"
- " name: \"Pad/paddings\"\n"
- " op: \"Const\"\n"
- " attr {\n"
- " key: \"dtype\"\n"
- " value {\n"
- " type: DT_INT32\n"
- " }\n"
- " }\n"
- " attr {\n"
- " key: \"value\"\n"
- " value {\n"
- " tensor {\n"
- " dtype: DT_INT32\n"
- " tensor_shape {\n"
- " dim {\n"
- " size: 4\n"
- " }\n"
- " dim {\n"
- " size: 2\n"
- " }\n"
- " }\n"
- " tensor_content: \"\\000\\000\\000\\000\\000\\000\\000\\000"
- "\\001\\000\\000\\000\\001\\000\\000\\000"
- "\\001\\000\\000\\000\\001\\000\\000\\000"
- "\\000\\000\\000\\000\\000\\000\\000\\000\"\n"
- " }\n"
- " }\n"
- " }\n"
- "}\n"
- "node {\n"
- " name: \"Pad\"\n"
- " op: \"Pad\"\n"
- " input: \"input\"\n"
- " input: \"Pad/paddings\"\n"
- " attr {\n"
- " key: \"T\"\n"
- " value {\n"
- " type: DT_FLOAT\n"
- " }\n"
- " }\n"
- " attr {\n"
- " key: \"Tpaddings\"\n"
- " value {\n"
- " type: DT_INT32\n"
- " }\n"
- " }\n"
- "}";
-
- SetupSingleInputSingleOutput({1, 2, 2, 2}, "input", "Pad");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(ParsePad, PadFixture)
-{
- RunTest<4>({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f },
- { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 5.0f, 6.0f, 7.0f, 8.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
- });
-}
-
-BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file
diff --git a/src/armnnTfParser/test/PassThru.cpp b/src/armnnTfParser/test/PassThru.cpp
deleted file mode 100644
index 736e13c1ad..0000000000
--- a/src/armnnTfParser/test/PassThru.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct PassThruFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- PassThruFixture()
- {
- m_Prototext = "node {\n"
- " name: \"Placeholder\"\n"
- " op: \"Placeholder\"\n"
- " attr {\n"
- " key: \"dtype\"\n"
- " value {\n"
- " type: DT_FLOAT\n"
- " }\n"
- " }\n"
- " attr {\n"
- " key: \"shape\"\n"
- " value {\n"
- " shape {\n"
- " }\n"
- " }\n"
- " }\n"
- "}\n";
- SetupSingleInputSingleOutput({ 1, 7 }, "Placeholder", "Placeholder");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(ValidateOutput, PassThruFixture)
-{
- BOOST_TEST(m_Parser->GetNetworkOutputBindingInfo("Placeholder").second.GetNumDimensions() == 2);
- BOOST_TEST(m_Parser->GetNetworkOutputBindingInfo("Placeholder").second.GetShape()[0] == 1);
- BOOST_TEST(m_Parser->GetNetworkOutputBindingInfo("Placeholder").second.GetShape()[1] == 7);
-}
-
-BOOST_FIXTURE_TEST_CASE(RunGraph, PassThruFixture)
-{
- armnn::TensorInfo inputTensorInfo = m_Parser->GetNetworkInputBindingInfo("Placeholder").second;
- auto input = MakeRandomTensor<float, 2>(inputTensorInfo, 378346);
- std::vector<float> inputVec;
- inputVec.assign(input.data(), input.data() + input.num_elements());
- RunTest<2>(inputVec, inputVec); // The passthru network should output the same as the input.
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Pooling.cpp b/src/armnnTfParser/test/Pooling.cpp
deleted file mode 100644
index f6de44c95f..0000000000
--- a/src/armnnTfParser/test/Pooling.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct Pooling2dFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- explicit Pooling2dFixture(const char* poolingtype, std::string dataLayout, std::string paddingOption)
- {
- m_Prototext = "node {\n"
- " name: \"Placeholder\"\n"
- " op: \"Placeholder\"\n"
- " attr {\n"
- " key: \"dtype\"\n"
- " value {\n"
- " type: DT_FLOAT\n"
- " }\n"
- " }\n"
- " attr {\n"
- " key: \"value\"\n"
- " value {\n"
- " tensor {\n"
- " dtype: DT_FLOAT\n"
- " tensor_shape {\n"
- " }\n"
- " }\n"
- " }\n"
- " }\n"
- " }\n"
- "node {\n"
- " name: \"";
- m_Prototext.append(poolingtype);
- m_Prototext.append("\"\n"
- " op: \"");
- m_Prototext.append(poolingtype);
- m_Prototext.append("\"\n"
- " input: \"Placeholder\"\n"
- " attr {\n"
- " key: \"T\"\n"
- " value {\n"
- " type: DT_FLOAT\n"
- " }\n"
- " }\n"
- " attr {\n"
- " key: \"data_format\"\n"
- " value {\n"
- " s: \"");
- m_Prototext.append(dataLayout);
- m_Prototext.append("\"\n"
- " }\n"
- " }\n"
- " attr {\n"
- " key: \"ksize\"\n"
- " value {\n"
- " list {\n"
-
- " i: 1\n");
- if(dataLayout == "NHWC")
- {
- m_Prototext.append(" i: 2\n"
- " i: 2\n"
- " i: 1\n");
- }
- else
- {
- m_Prototext.append(" i: 1\n"
- " i: 2\n"
- " i: 2\n");
- }
- m_Prototext.append(
- " }\n"
- " }\n"
- " }\n"
- " attr {\n"
- " key: \"padding\"\n"
- " value {\n"
- " s: \"");
- m_Prototext.append(paddingOption);
- m_Prototext.append(
- "\"\n"
- " }\n"
- " }\n"
- " attr {\n"
- " key: \"strides\"\n"
- " value {\n"
- " list {\n"
- " i: 1\n"
- " i: 1\n"
- " i: 1\n"
- " i: 1\n"
- " }\n"
- " }\n"
- " }\n"
- "}\n");
-
- if(dataLayout == "NHWC")
- {
- SetupSingleInputSingleOutput({ 1, 2, 2, 1 }, "Placeholder", poolingtype);
- }
- else
- {
- SetupSingleInputSingleOutput({ 1, 1, 2, 2 }, "Placeholder", poolingtype);
- }
- }
-};
-
-
-struct MaxPoolFixtureNhwcValid : Pooling2dFixture
-{
- MaxPoolFixtureNhwcValid() : Pooling2dFixture("MaxPool", "NHWC", "VALID") {}
-};
-BOOST_FIXTURE_TEST_CASE(ParseMaxPoolNhwcValid, MaxPoolFixtureNhwcValid)
-{
- RunTest<4>({1.0f, 2.0f, 3.0f, -4.0f}, {3.0f});
-}
-
-struct MaxPoolFixtureNchwValid : Pooling2dFixture
-{
- MaxPoolFixtureNchwValid() : Pooling2dFixture("MaxPool", "NCHW", "VALID") {}
-};
-BOOST_FIXTURE_TEST_CASE(ParseMaxPoolNchwValid, MaxPoolFixtureNchwValid)
-{
- RunTest<4>({1.0f, 2.0f, 3.0f, -4.0f}, {3.0f});
-}
-
-struct MaxPoolFixtureNhwcSame : Pooling2dFixture
-{
- MaxPoolFixtureNhwcSame() : Pooling2dFixture("MaxPool", "NHWC", "SAME") {}
-};
-BOOST_FIXTURE_TEST_CASE(ParseMaxPoolNhwcSame, MaxPoolFixtureNhwcSame)
-{
- RunTest<4>({1.0f, 2.0f, 3.0f, -4.0f}, {3.0f, 2.0f, 3.0f, -4.0f});
-}
-
-struct MaxPoolFixtureNchwSame : Pooling2dFixture
-{
- MaxPoolFixtureNchwSame() : Pooling2dFixture("MaxPool", "NCHW", "SAME") {}
-};
-BOOST_FIXTURE_TEST_CASE(ParseMaxPoolNchwSame, MaxPoolFixtureNchwSame)
-{
- RunTest<4>({1.0f, 2.0f, 3.0f, -4.0f}, {3.0f, 2.0f, 3.0f, -4.0f});
-}
-
-struct AvgPoolFixtureNhwcValid : Pooling2dFixture
-{
- AvgPoolFixtureNhwcValid() : Pooling2dFixture("AvgPool", "NHWC", "VALID") {}
-};
-BOOST_FIXTURE_TEST_CASE(ParseAvgPoolNhwcValid, AvgPoolFixtureNhwcValid)
-{
- RunTest<4>({1.0f, 2.0f, 3.0f, 4.0f}, {2.5f});
-}
-
-struct AvgPoolFixtureNchwValid : Pooling2dFixture
-{
- AvgPoolFixtureNchwValid() : Pooling2dFixture("AvgPool", "NCHW", "VALID") {}
-};
-BOOST_FIXTURE_TEST_CASE(ParseAvgPoolNchwValid, AvgPoolFixtureNchwValid)
-{
- RunTest<4>({1.0f, 2.0f, 3.0f, 4.0f}, {2.5f});
-}
-
-struct AvgPoolFixtureNhwcSame : Pooling2dFixture
-{
- AvgPoolFixtureNhwcSame() : Pooling2dFixture("AvgPool", "NHWC", "SAME") {}
-};
-BOOST_FIXTURE_TEST_CASE(ParseAvgPoolNhwcSame, AvgPoolFixtureNhwcSame)
-{
- RunTest<4>({1.0f, 2.0f, 3.0f, 4.0f}, {2.5f, 3.0f, 3.5f, 4.0f});
-}
-
-struct AvgPoolFixtureNchwSame : Pooling2dFixture
-{
- AvgPoolFixtureNchwSame() : Pooling2dFixture("AvgPool", "NCHW", "SAME") {}
-};
-BOOST_FIXTURE_TEST_CASE(ParseAvgPoolNchwSame, AvgPoolFixtureNchwSame)
-{
- RunTest<4>({1.0f, 2.0f, 3.0f, 4.0f}, {2.5f, 3.0f, 3.5f, 4.0f});
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/RealDiv.cpp b/src/armnnTfParser/test/RealDiv.cpp
deleted file mode 100644
index 952590e001..0000000000
--- a/src/armnnTfParser/test/RealDiv.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct DivisionFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- DivisionFixture()
- {
- m_Prototext = "node { \n"
- " name: \"graphInput\" \n"
- " op: \"Placeholder\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"shape\" \n"
- " value { \n"
- " shape { \n"
- " } \n"
- " } \n"
- " } \n"
- " } \n"
- " node { \n"
- " name: \"softmax1\" \n"
- " op: \"Softmax\" \n"
- " input: \"graphInput\" \n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " }\n"
- " node {\n"
- " name: \"softmax2\"\n"
- " op : \"Softmax\"\n"
- " input: \"graphInput\"\n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " }\n"
- " node {\n"
- " name: \"division\"\n"
- " op : \"RealDiv\"\n"
- " input: \"softmax1\"\n"
- " input: \"softmax2\"\n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " }\n";
-
- SetupSingleInputSingleOutput({ 4, 1 }, "graphInput", "division");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseDivision, DivisionFixture)
-{
- RunTest<2>({ 2, 1.0f, 3, 1 }, { 1, 1.0f, 1, 1});
-}
-
-struct DivisionBroadcastFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- DivisionBroadcastFixture(const armnn::TensorShape& inputShape0, const armnn::TensorShape& inputShape1)
- {
- m_Prototext = R"(
- node {
- name: "input0"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "input1"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "output"
- op: "RealDiv"
- input: "input0"
- input: "input1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- )";
-
- Setup({ { "input0", inputShape0 },
- { "input1", inputShape1 } },
- { "output" });
- }
-};
-struct DivisionBroadcastFixture4D1D : public DivisionBroadcastFixture
-{
- DivisionBroadcastFixture4D1D() : DivisionBroadcastFixture({ 1, 2, 2, 3 }, { 1 }) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseDivisionBroadcast4D1D, DivisionBroadcastFixture4D1D)
-{
- RunTest<4>({ { "input0", { 0.0f, 100.0f, 2.0f,
- 3.0f, 250.0f, 15.0f,
- 33.0f, 60.0f, 5.0f,
- 35.0f, 10.0f, 55.0f } },
- { "input1", { 5.0f } } },
- { { "output", { 0, 20.0f, 0.4f,
- 0.6f, 50.0f, 3.0f,
- 6.6f, 12.0f, 1.0f,
- 7.0f, 2.0f, 11.0f } } });
-}
-
-BOOST_FIXTURE_TEST_CASE(ParseDivideByZeroBroadcast4D1D, DivisionBroadcastFixture4D1D)
-{
- float Inf = std::numeric_limits<float>::infinity();
- float NaN = std::numeric_limits<float>::quiet_NaN();
-
- RunTest<4>({ { "input0", { 0.0f, -100.0f, 2.0f,
- 3.0f, -250.0f, 15.0f,
- 33.0f, -0, 5.0f,
- 35.0f, -10.0f, 55.0f } },
- { "input1", { 0 } } },
- { { "output", { NaN, -Inf, Inf,
- Inf, -Inf, Inf,
- Inf, NaN, Inf,
- Inf, -Inf, Inf } } });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Reshape.cpp b/src/armnnTfParser/test/Reshape.cpp
deleted file mode 100644
index cbb3a75011..0000000000
--- a/src/armnnTfParser/test/Reshape.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct ReshapeFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- ReshapeFixture()
- {
- m_Prototext = "node { \n"
- " name: \"graphInput\" \n"
- " op: \"Placeholder\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"shape\" \n"
- " value { \n"
- " shape { \n"
- " } \n"
- " } \n"
- " } \n"
- " } \n"
- "node { \n"
- " name: \"Reshape/shape\" \n"
- " op: \"Const\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_INT32 \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"value\" \n"
- " value { \n"
- " tensor { \n"
- " dtype: DT_INT32 \n"
- " tensor_shape { \n"
- " dim { \n"
- " size: 2 \n"
- " } \n"
- " } \n"
- " tensor_content: \"\\002\\000\\000\\000\\002\\000\\000\\000\" \n"
- " } \n"
- " } \n"
- " } \n"
- "} \n"
- "node { \n"
- " name: \"Reshape\" \n"
- " op: \"Reshape\" \n"
- " input: \"graphInput\" \n"
- " input: \"Reshape/shape\" \n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"Tshape\" \n"
- " value { \n"
- " type: DT_INT32 \n"
- " } \n"
- " } \n"
- "} \n";
-
- SetupSingleInputSingleOutput({1, 4}, "graphInput", "Reshape");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseReshape, ReshapeFixture)
-{
- RunTest<2>({ 0.0f, 1.0f, 2.0f, 3.0f }, { 0.0f, 1.0f, 2.0f, 3.0f });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/ResizeBilinear.cpp b/src/armnnTfParser/test/ResizeBilinear.cpp
deleted file mode 100644
index d9741ee784..0000000000
--- a/src/armnnTfParser/test/ResizeBilinear.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct ResizeBilinearFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- ResizeBilinearFixture()
- {
- m_Prototext = R"(
-node {
- name: "graphInput"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- dim {
- size: 1
- }
- dim {
- size: 3
- }
- dim {
- size: 3
- }
- dim {
- size: 1
- }
- }
- tensor_content:
-"\000\000\000\000\000\000\200?\000\000\000@\000\000@@\000\000\200@\000\000\240@\000\000\300@\000\000\340@\000\000\000A"
- }
- }
- }
-}
-node {
- name: "resizeBilinearLayer/size"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_INT32
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_INT32
- tensor_shape {
- dim {
- size: 2
- }
- }
- tensor_content: "\005\000\000\000\005\000\000\000"
- }
- }
- }
-}
-node {
- name: "resizeBilinearLayer"
- op: "ResizeBilinear"
- input: "graphInput"
- input: "resizeBilinearLayer/size"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "align_corners"
- value {
- b: false
- }
- }
-}
- )";
-
- SetupSingleInputSingleOutput({ 1, 3, 3, 1 }, "graphInput", "resizeBilinearLayer");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseResizeBilinear, ResizeBilinearFixture)
-{
- RunTest<4>(// Input data.
- { 0.0f, 1.0f, 2.0f,
- 3.0f, 4.0f, 5.0f,
- 6.0f, 7.0f, 8.0f },
- // Expected output data.
- { 0.0f, 0.6f, 1.2f, 1.8f, 2.0f,
- 1.8f, 2.4f, 3.0f, 3.6f, 3.8f,
- 3.6f, 4.2f, 4.8f, 5.4f, 5.6f,
- 5.4f, 6.0f, 6.6f, 7.2f, 7.4f,
- 6.0f, 6.6f, 7.2f, 7.8f, 8.0f });
-
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Rsqrt.cpp b/src/armnnTfParser/test/Rsqrt.cpp
deleted file mode 100644
index 6924c060a6..0000000000
--- a/src/armnnTfParser/test/Rsqrt.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct RsqrtFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- RsqrtFixture()
- {
- m_Prototext = "node {\n"
- " name: \"input\"\n"
- " op: \"Placeholder\"\n"
- " attr {\n"
- " key: \"dtype\"\n"
- " value {\n"
- " type: DT_FLOAT\n"
- " }\n"
- " }\n"
- " attr {\n"
- " key: \"shape\"\n"
- " value {\n"
- " shape {\n"
- " }\n"
- " }\n"
- " }\n"
- "}\n"
- "node {\n"
- " name: \"Rsqrt\"\n"
- " op: \"Rsqrt\"\n"
- " input: \"input\"\n"
- " attr {\n"
- " key: \"T\"\n"
- " value {\n"
- " type: DT_FLOAT\n"
- " }\n"
- " }\n"
- "}\n";
-
- SetupSingleInputSingleOutput({ 2, 2 }, "input", "Rsqrt");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseRsqrt, RsqrtFixture)
-{
- RunTest<2>({ 1.f, 4.f, 16.f, 25.f }, { 1.f, 0.5f, 0.25f, 0.2f });
-}
-
-BOOST_FIXTURE_TEST_CASE(ParseRsqrtZeroNegative, RsqrtFixture)
-{
- RunTest<2>({ 0.f, -0.f, -25.f, -16.f }, { INFINITY, -INFINITY, -NAN, -NAN });
-}
-
-BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file
diff --git a/src/armnnTfParser/test/Shape.cpp b/src/armnnTfParser/test/Shape.cpp
deleted file mode 100644
index 52fe9c8951..0000000000
--- a/src/armnnTfParser/test/Shape.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct ShapeFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- ShapeFixture()
- {
- m_Prototext =
- "node { \n"
- " name: \"Placeholder\" \n"
- " op: \"Placeholder\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"shape\" \n"
- " value { \n"
- " shape { \n"
- " dim { \n"
- " size: 1 \n"
- " } \n"
- " dim { \n"
- " size: 1 \n"
- " } \n"
- " dim { \n"
- " size: 1 \n"
- " } \n"
- " dim { \n"
- " size: 4 \n"
- " } \n"
- " } \n"
- " } \n"
- " } \n"
- "} \n"
- "node { \n"
- " name: \"shapeTest\" \n"
- " op: \"Shape\" \n"
- " input: \"Placeholder\" \n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"out_type\" \n"
- " value { \n"
- " type: DT_INT32 \n"
- " } \n"
- " } \n"
- "} \n"
- "node { \n"
- " name: \"Reshape\" \n"
- " op: \"Reshape\" \n"
- " input: \"Placeholder\" \n"
- " input: \"shapeTest\" \n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"Tshape\" \n"
- " value { \n"
- " type: DT_INT32 \n"
- " } \n"
- " } \n"
- "} \n";
-
- SetupSingleInputSingleOutput({1, 4}, "Placeholder", "Reshape");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseShape, ShapeFixture)
-{
- // Note: the test's output cannot be an int32 const layer, because ARMNN only supports u8 and float layers.
- // For that reason I added a reshape layer which reshapes the input to its original dimensions.
- RunTest<2>({ 0.0f, 1.0f, 2.0f, 3.0f }, { 0.0f, 1.0f, 2.0f, 3.0f });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Softmax.cpp b/src/armnnTfParser/test/Softmax.cpp
deleted file mode 100644
index df304b6880..0000000000
--- a/src/armnnTfParser/test/Softmax.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct SoftmaxFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- SoftmaxFixture()
- {
- m_Prototext = "node {\n"
- " name: \"blah\"\n"
- " op: \"Placeholder\"\n"
- " attr {\n"
- " key: \"dtype\"\n"
- " value {\n"
- " type: DT_FLOAT\n"
- " }\n"
- " }\n"
- " attr {\n"
- " key: \"shape\"\n"
- " value {\n"
- " shape {\n"
- " }\n"
- " }\n"
- " }\n"
- "}\n"
- "node {\n"
- " name: \"blah2\"\n"
- " op: \"Softmax\"\n"
- " input: \"blah\"\n"
- " attr {\n"
- " key: \"T\"\n"
- " value {\n"
- " type: DT_FLOAT\n"
- " }\n"
- " }\n"
- "}\n";
-
- SetupSingleInputSingleOutput({ 1, 7 }, "blah", "blah2");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseSoftmax, SoftmaxFixture)
-{
- RunTest<2>({ 0, 0, 10000, 0, 0, 0, 0 }, { 0, 0, 1, 0, 0, 0, 0 });
-}
-
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Split.cpp b/src/armnnTfParser/test/Split.cpp
deleted file mode 100644
index eeef90a625..0000000000
--- a/src/armnnTfParser/test/Split.cpp
+++ /dev/null
@@ -1,398 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-#include <armnn/utility/IgnoreUnused.hpp>
-
-#include <boost/test/unit_test.hpp>
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct SplitFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- SplitFixture(bool withDimZero=false) {
- m_Prototext = R"(
- node {
- name: "graphInput"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "graphInput2"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "multiplication"
- op : "Mul"
- input: "graphInput"
- input: "graphInput2"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "SplitInput"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_INT32
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_INT32
- tensor_shape {
- }
- int_val: )";
-
- if(withDimZero)
- {
- m_Prototext += std::to_string(3);
- }
- else
- {
- m_Prototext += std::to_string(1);
- }
-
- m_Prototext += R"(
- }
- }
- }
- }
- node {
- name: "Split"
- op: "Split" )";
- if(withDimZero)
- {
- m_Prototext += "input: \"SplitInput\"\n";
- m_Prototext += "input: \"multiplication\"\n";
- }
- else
- {
- m_Prototext += "input: \"graphInput\"\n";
- m_Prototext += "input: \"SplitInput\"\n";
- }
- m_Prototext += R"(
- attr {
- key: "num_split"
- value {
- i: 2
- }
- }
- }
- node {
- name: "Relu_1"
- op: "Relu"
- input: "Split:0"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "Relu_2"
- op: "Relu"
- input:"Split:1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- } )";
-
- Setup( { { "graphInput", { 1, 2, 2 , 2} } , { "graphInput2", { 1, 2, 2 , 2} }},
- { "Relu_1", "Relu_2" });
- }
-};
-
-struct InputFirstSplitFixture : SplitFixture
-{
- InputFirstSplitFixture() : SplitFixture(true) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseAxisOneSplitTwo, SplitFixture)
-{
- BOOST_TEST(
- (m_Parser->GetNetworkOutputBindingInfo("Relu_1").second.GetShape() == armnn::TensorShape({ 1, 1, 2, 2 })));
-
- BOOST_TEST(
- (m_Parser->GetNetworkOutputBindingInfo("Relu_2").second.GetShape() == armnn::TensorShape({ 1, 1, 2, 2 })));
-
- RunTest<4>({ { "graphInput", { -1.0f, -0.5f, 1.25f, -3.0f, 0.0f, 0.5f, -0.75f, 1.75f } } },
- { { "Relu_1", { 0.0f, 0.0f, 1.25f, 0.0f } },
- { "Relu_2", { 0.0f, 0.5f, 0.0f, 1.75f } } });
-}
-
-BOOST_FIXTURE_TEST_CASE(ParseSplit, InputFirstSplitFixture)
-{
-
- BOOST_TEST(
- (m_Parser->GetNetworkOutputBindingInfo("Relu_1").second.GetShape() == armnn::TensorShape({ 1, 2, 2, 1 })));
-
- BOOST_TEST(
- (m_Parser->GetNetworkOutputBindingInfo("Relu_2").second.GetShape() == armnn::TensorShape({ 1, 2, 2, 1 })));
-
- RunTest<4>({ { "graphInput", { -1.0f, -0.5f, 1.25f, -3.0f, 0.0f, 0.5f, -0.75f , 1.75f } } ,
- { "graphInput2", { -1.0f, -0.5f, 1.25f, -3.0f, 0.0f, 0.5f, -0.75f , 1.75f } } },
- { { "Relu_1", { 1.0f, 1.5625f, 0, 0.5625f } },
- { "Relu_2", { 0.25, 9.0f, 0.25f, 3.0625f } } });
-}
-
-struct SplitLastDimFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- SplitLastDimFixture(bool withDimZero=false) {
- armnn::IgnoreUnused(withDimZero);
- m_Prototext = R"(
- node {
- name: "Placeholder"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- dim {
- size: 1
- }
- dim {
- size: 2
- }
- dim {
- size: 2
- }
- dim {
- size: 3
- }
- }
- }
- }
- }
- node {
- name: "Const"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_INT32
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_INT32
- tensor_shape {
- }
- int_val: 3
- }
- }
- }
- }
- node {
- name: "split/split_dim"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_INT32
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_INT32
- tensor_shape {
- }
- int_val: 3
- }
- }
- }
- }
- node {
- name: "split"
- op: "Split"
- input: "split/split_dim"
- input: "Placeholder"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "num_split"
- value {
- i: 3
- }
- }
- }
- node {
- name: "sub0/y"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- }
- float_val: 3.0
- }
- }
- }
- }
- node {
- name: "sub0"
- op: "Sub"
- input: "split"
- input: "sub0/y"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "sub1/y"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- }
- float_val: 2.0
- }
- }
- }
- }
- node {
- name: "sub1"
- op: "Sub"
- input: "split:1"
- input: "sub1/y"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "sub2/y"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_FLOAT
- tensor_shape {
- }
- float_val: 1.0
- }
- }
- }
- }
- node {
- name: "sub2"
- op: "Sub"
- input: "split:2"
- input: "sub2/y"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- versions {
- producer: 27
- } )";
-
- Setup( { { "Placeholder", { 1, 2, 2 , 3} } },
- { "sub0", "sub1", "sub2" });
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(SplitLastDimTest, SplitLastDimFixture)
-{
- BOOST_TEST(
- (m_Parser->GetNetworkOutputBindingInfo("sub0").second.GetShape() == armnn::TensorShape({ 1, 2, 2, 1 })));
-
- BOOST_TEST(
- (m_Parser->GetNetworkOutputBindingInfo("sub1").second.GetShape() == armnn::TensorShape({ 1, 2, 2, 1 })));
-
- BOOST_TEST(
- (m_Parser->GetNetworkOutputBindingInfo("sub2").second.GetShape() == armnn::TensorShape({ 1, 2, 2, 1 })));
-
- RunTest<4>({ { "Placeholder", { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f } } },
- { { "sub0", { -2.0f, 1.0f, 4.0f, 7.0f } },
- { "sub1", { 0.0f, 3.0f, 6.0f, 9.0f } },
- { "sub2", { 2.0f, 5.0f, 8.0f, 11.0f } } });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Squeeze.cpp b/src/armnnTfParser/test/Squeeze.cpp
deleted file mode 100644
index e02a5947a5..0000000000
--- a/src/armnnTfParser/test/Squeeze.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-template <bool withDimZero, bool withDimOne>
-struct SqueezeFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- SqueezeFixture()
- {
- m_Prototext =
- "node { \n"
- " name: \"graphInput\" \n"
- " op: \"Placeholder\" \n"
- " attr { \n"
- " key: \"dtype\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"shape\" \n"
- " value { \n"
- " shape { \n"
- " } \n"
- " } \n"
- " } \n"
- " } \n"
- "node { \n"
- " name: \"Squeeze\" \n"
- " op: \"Squeeze\" \n"
- " input: \"graphInput\" \n"
- " attr { \n"
- " key: \"T\" \n"
- " value { \n"
- " type: DT_FLOAT \n"
- " } \n"
- " } \n"
- " attr { \n"
- " key: \"squeeze_dims\" \n"
- " value { \n"
- " list {\n";
-
- if (withDimZero)
- {
- m_Prototext += "i:0\n";
- }
-
- if (withDimOne)
- {
- m_Prototext += "i:1\n";
- }
-
- m_Prototext +=
- " } \n"
- " } \n"
- " } \n"
- "} \n";
-
- SetupSingleInputSingleOutput({ 1, 1, 2, 2 }, "graphInput", "Squeeze");
- }
-};
-
-typedef SqueezeFixture<false, false> ImpliedDimensionsSqueezeFixture;
-typedef SqueezeFixture<true, false> ExplicitDimensionZeroSqueezeFixture;
-typedef SqueezeFixture<false, true> ExplicitDimensionOneSqueezeFixture;
-typedef SqueezeFixture<true, true> ExplicitDimensionsSqueezeFixture;
-
-BOOST_FIXTURE_TEST_CASE(ParseImplicitSqueeze, ImpliedDimensionsSqueezeFixture)
-{
- BOOST_TEST((m_Parser->GetNetworkOutputBindingInfo("Squeeze").second.GetShape() ==
- armnn::TensorShape({2,2})));
- RunTest<2>({ 1.0f, 2.0f, 3.0f, 4.0f },
- { 1.0f, 2.0f, 3.0f, 4.0f });
-}
-
-BOOST_FIXTURE_TEST_CASE(ParseDimensionZeroSqueeze, ExplicitDimensionZeroSqueezeFixture)
-{
- BOOST_TEST((m_Parser->GetNetworkOutputBindingInfo("Squeeze").second.GetShape() ==
- armnn::TensorShape({1,2,2})));
- RunTest<3>({ 1.0f, 2.0f, 3.0f, 4.0f },
- { 1.0f, 2.0f, 3.0f, 4.0f });
-}
-
-BOOST_FIXTURE_TEST_CASE(ParseDimensionOneSqueeze, ExplicitDimensionOneSqueezeFixture)
-{
- BOOST_TEST((m_Parser->GetNetworkOutputBindingInfo("Squeeze").second.GetShape() ==
- armnn::TensorShape({1,2,2})));
- RunTest<3>({ 1.0f, 2.0f, 3.0f, 4.0f },
- { 1.0f, 2.0f, 3.0f, 4.0f });
-}
-
-BOOST_FIXTURE_TEST_CASE(ParseExplicitDimensionsSqueeze, ExplicitDimensionsSqueezeFixture)
-{
- BOOST_TEST((m_Parser->GetNetworkOutputBindingInfo("Squeeze").second.GetShape() ==
- armnn::TensorShape({2,2})));
- RunTest<2>({ 1.0f, 2.0f, 3.0f, 4.0f },
- { 1.0f, 2.0f, 3.0f, 4.0f });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Stack.cpp b/src/armnnTfParser/test/Stack.cpp
deleted file mode 100644
index b28991713d..0000000000
--- a/src/armnnTfParser/test/Stack.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-//
-// Copyright © 2020 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-#include <PrototxtConversions.hpp>
-
-#include <boost/test/unit_test.hpp>
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct StackFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- explicit StackFixture(const armnn::TensorShape& inputShape0,
- const armnn::TensorShape& inputShape1,
- int axis = 0)
- {
- m_Prototext = R"(
- node {
- name: "input0"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "input1"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
- }
- node {
- name: "output"
- op: "Stack"
- input: "input0"
- input: "input1"
- attr {
- key: "axis"
- value {
- i: )";
- m_Prototext += std::to_string(axis);
- m_Prototext += R"(
- }
- }
- })";
-
- Setup({{"input0", inputShape0 },
- {"input1", inputShape1 }}, {"output"});
- }
-};
-
-struct Stack3DFixture : StackFixture
-{
- Stack3DFixture() : StackFixture({ 3, 2, 3 }, { 3, 2, 3 }, 3 ) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(Stack3D, Stack3DFixture)
-{
-
- RunTest<4>({ { "input0", { 1, 2, 3,
- 4, 5, 6,
-
- 7, 8, 9,
- 10, 11, 12,
-
- 13, 14, 15,
- 16, 17, 18 } },
- { "input1", { 19, 20, 21,
- 22, 23, 24,
-
- 25, 26, 27,
- 28, 29, 30,
-
- 31, 32, 33,
- 34, 35, 36 } } },
- { { "output", { 1, 19,
- 2, 20,
- 3, 21,
-
- 4, 22,
- 5, 23,
- 6, 24,
-
- 7, 25,
- 8, 26,
- 9, 27,
-
- 10, 28,
- 11, 29,
- 12, 30,
-
- 13, 31,
- 14, 32,
- 15, 33,
-
- 16, 34,
- 17, 35,
- 18, 36 } } });
-}
-
-struct Stack3DNegativeAxisFixture : StackFixture
-{
- Stack3DNegativeAxisFixture() : StackFixture({ 3, 2, 3 }, { 3, 2, 3 }, -1 ) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(Stack3DNegativeAxis, Stack3DNegativeAxisFixture)
-{
-
- RunTest<4>({ { "input0", { 1, 2, 3,
- 4, 5, 6,
-
- 7, 8, 9,
- 10, 11, 12,
-
- 13, 14, 15,
- 16, 17, 18 } },
- { "input1", { 19, 20, 21,
- 22, 23, 24,
-
- 25, 26, 27,
- 28, 29, 30,
-
- 31, 32, 33,
- 34, 35, 36 } } },
- { { "output", { 1, 19,
- 2, 20,
- 3, 21,
-
- 4, 22,
- 5, 23,
- 6, 24,
-
- 7, 25,
- 8, 26,
- 9, 27,
-
- 10, 28,
- 11, 29,
- 12, 30,
-
- 13, 31,
- 14, 32,
- 15, 33,
-
- 16, 34,
- 17, 35,
- 18, 36 } } });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/StridedSlice.cpp b/src/armnnTfParser/test/StridedSlice.cpp
deleted file mode 100644
index 340f3a49ff..0000000000
--- a/src/armnnTfParser/test/StridedSlice.cpp
+++ /dev/null
@@ -1,283 +0,0 @@
-//
-// Copyright © 2020 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "armnnTfParser/ITfParser.hpp"
-
-#include "ParserPrototxtFixture.hpp"
-#include <PrototxtConversions.hpp>
-
-#include <boost/test/unit_test.hpp>
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-namespace {
-// helper for setting the dimensions in prototxt
-void shapeHelper(const armnn::TensorShape& shape, std::string& text){
- for(unsigned int i = 0; i < shape.GetNumDimensions(); ++i) {
- text.append(R"(dim {
- size: )");
- text.append(std::to_string(shape[i]));
- text.append(R"(
- })");
- }
-}
-
-// helper for converting from integer to octal representation
-void octalHelper(const std::vector<int>& content, std::string& text){
- for (unsigned int i = 0; i < content.size(); ++i)
- {
- text.append(armnnUtils::ConvertInt32ToOctalString(static_cast<int>(content[i])));
- }
-}
-} // namespace
-
-struct StridedSliceFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- StridedSliceFixture(const armnn::TensorShape& inputShape,
- const std::vector<int>& beginData,
- const std::vector<int>& endData,
- const std::vector<int>& stridesData,
- int beginMask = 0,
- int endMask = 0,
- int ellipsisMask = 0,
- int newAxisMask = 0,
- int shrinkAxisMask = 0)
- {
- m_Prototext = R"(
- node {
- name: "input"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {)";
- shapeHelper(inputShape, m_Prototext);
- m_Prototext.append(R"(
- }
- }
- }
- }
- node {
- name: "begin"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_INT32
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_INT32
- tensor_shape {
- dim {
- size: )");
- m_Prototext += std::to_string(beginData.size());
- m_Prototext.append(R"(
- }
- }
- tensor_content: ")");
- octalHelper(beginData, m_Prototext);
- m_Prototext.append(R"("
- }
- }
- }
- }
- node {
- name: "end"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_INT32
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_INT32
- tensor_shape {
- dim {
- size: )");
- m_Prototext += std::to_string(endData.size());
- m_Prototext.append(R"(
- }
- }
- tensor_content: ")");
- octalHelper(endData, m_Prototext);
- m_Prototext.append(R"("
- }
- }
- }
- }
- node {
- name: "strides"
- op: "Const"
- attr {
- key: "dtype"
- value {
- type: DT_INT32
- }
- }
- attr {
- key: "value"
- value {
- tensor {
- dtype: DT_INT32
- tensor_shape {
- dim {
- size: )");
- m_Prototext += std::to_string(stridesData.size());
- m_Prototext.append(R"(
- }
- }
- tensor_content: ")");
- octalHelper(stridesData, m_Prototext);
- m_Prototext.append(R"("
- }
- }
- }
- }
- node {
- name: "output"
- op: "StridedSlice"
- input: "input"
- input: "begin"
- input: "end"
- input: "strides"
- attr {
- key: "begin_mask"
- value {
- i: )");
- m_Prototext += std::to_string(beginMask);
- m_Prototext.append(R"(
- }
- }
- attr {
- key: "end_mask"
- value {
- i: )");
- m_Prototext += std::to_string(endMask);
- m_Prototext.append(R"(
- }
- }
- attr {
- key: "ellipsis_mask"
- value {
- i: )");
- m_Prototext += std::to_string(ellipsisMask);
- m_Prototext.append(R"(
- }
- }
- attr {
- key: "new_axis_mask"
- value {
- i: )");
- m_Prototext += std::to_string(newAxisMask);
- m_Prototext.append(R"(
- }
- }
- attr {
- key: "shrink_axis_mask"
- value {
- i: )");
- m_Prototext += std::to_string(shrinkAxisMask);
- m_Prototext.append(R"(
- }
- }
- })");
-
- Setup({ { "input", inputShape } }, { "output" });
- }
-};
-
-struct StridedSlice4DFixture : StridedSliceFixture
-{
- StridedSlice4DFixture() : StridedSliceFixture({ 3, 2, 3, 1 }, // inputShape
- { 1, 0, 0, 0 }, // beginData
- { 2, 2, 3, 1 }, // endData
- { 1, 1, 1, 1 } // stridesData
- ) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(StridedSlice4D, StridedSlice4DFixture)
-{
- RunTest<4>(
- {{"input", { 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f,
- 3.0f, 3.0f, 3.0f, 4.0f, 4.0f, 4.0f,
- 5.0f, 5.0f, 5.0f, 6.0f, 6.0f, 6.0f }}},
- {{"output", { 3.0f, 3.0f, 3.0f, 4.0f, 4.0f, 4.0f }}});
-}
-
-struct StridedSlice4DReverseFixture : StridedSliceFixture
-{
-
- StridedSlice4DReverseFixture() : StridedSliceFixture({ 3, 2, 3, 1 }, // inputShape
- { 1, -1, 0, 0 }, // beginData
- { 2, -3, 3, 1 }, // endData
- { 1, -1, 1, 1 } // stridesData
- ) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(StridedSlice4DReverse, StridedSlice4DReverseFixture)
-{
- RunTest<4>(
- {{"input", { 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f,
- 3.0f, 3.0f, 3.0f, 4.0f, 4.0f, 4.0f,
- 5.0f, 5.0f, 5.0f, 6.0f, 6.0f, 6.0f }}},
- {{"output", { 4.0f, 4.0f, 4.0f, 3.0f, 3.0f, 3.0f }}});
-}
-
-struct StridedSliceSimpleStrideFixture : StridedSliceFixture
-{
- StridedSliceSimpleStrideFixture() : StridedSliceFixture({ 3, 2, 3, 1 }, // inputShape
- { 0, 0, 0, 0 }, // beginData
- { 3, 2, 3, 1 }, // endData
- { 2, 2, 2, 1 } // stridesData
- ) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(StridedSliceSimpleStride, StridedSliceSimpleStrideFixture)
-{
- RunTest<4>(
- {{"input", { 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f,
- 3.0f, 3.0f, 3.0f, 4.0f, 4.0f, 4.0f,
- 5.0f, 5.0f, 5.0f, 6.0f, 6.0f, 6.0f }}},
- {{"output", { 1.0f, 1.0f,
- 5.0f, 5.0f }}});
-}
-
-struct StridedSliceSimpleRangeMaskFixture : StridedSliceFixture
-{
- StridedSliceSimpleRangeMaskFixture() : StridedSliceFixture({ 3, 2, 3, 1 }, // inputShape
- { 1, 1, 1, 1 }, // beginData
- { 1, 1, 1, 1 }, // endData
- { 1, 1, 1, 1 }, // stridesData
- (1 << 4) - 1, // beginMask
- (1 << 4) - 1 // endMask
- ) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(StridedSliceSimpleRangeMask, StridedSliceSimpleRangeMaskFixture)
-{
- RunTest<4>(
- {{"input", { 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f,
- 3.0f, 3.0f, 3.0f, 4.0f, 4.0f, 4.0f,
- 5.0f, 5.0f, 5.0f, 6.0f, 6.0f, 6.0f }}},
- {{"output", { 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f,
- 3.0f, 3.0f, 3.0f, 4.0f, 4.0f, 4.0f,
- 5.0f, 5.0f, 5.0f, 6.0f, 6.0f, 6.0f }}});
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Sub.cpp b/src/armnnTfParser/test/Sub.cpp
deleted file mode 100644
index 2b3cbe65d8..0000000000
--- a/src/armnnTfParser/test/Sub.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct SubFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- SubFixture(const armnn::TensorShape& inputShape0, const armnn::TensorShape& inputShape1)
- {
- m_Prototext = R"(
-node {
- name: "input0"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
-}
-node {
- name: "input1"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
-}
-node {
- name: "output"
- op: "Sub"
- input: "input0"
- input: "input1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
- )";
- Setup({ { "input0", inputShape0 },
- { "input1", inputShape1 } },
- { "output" });
-
- }
-};
-
-struct SubFixture4D4D : public SubFixture
-{
- SubFixture4D4D() : SubFixture({ 1, 2, 2, 3 }, { 1, 2, 2, 3 }) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseSub, SubFixture4D4D)
-{
- RunTest<4>({ { "input0", { 5.0f, 1.0f, 2.0f,
- 3.0f, 4.0f, 5.0f,
- 6.0f, 7.0f, 8.0f,
- 29.0f, 10.0f, 11.0f } },
-
- { "input1", { 0.0f, 1.0f, 3.0f,
- 4.0f, 5.5f, 1.0f,
- 2.0f, 17.0f, 18.0f,
- 19.0f, 1.0f, 3.0f } } },
-
- { { "output", { 5.0f, 0.0f, -1.0f,
- -1.0f, -1.5f, 4.0f,
- 4.0f, -10.0f, -10.0f,
- 10.0f, 9.0f, 8.0f } } });
-}
-
-struct SubBroadcastFixture4D1D : public SubFixture
-{
- SubBroadcastFixture4D1D() : SubFixture({ 1, 2, 2, 3 }, { 1 }) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseSubBroadcast4D1D, SubBroadcastFixture4D1D)
-{
- RunTest<4>({ { "input0", { 0.0f, 1.0f, 2.0f,
- 3.0f, 4.0f, 5.0f,
- 6.0f, 7.0f, 8.0f,
- 9.0f, 10.0f, 11.0f } },
-
- { "input1", { 5.0f } } },
-
- { { "output", { -5.0f, -4.0f, -3.0f,
- -2.0f, -1.0f, 0.0f,
- 1.0f, 2.0f, 3.0f,
- 4.0f, 5.0f, 6.0f } } });
-}
-
-struct SubBroadcastFixture1D4D : public SubFixture
-{
- SubBroadcastFixture1D4D() : SubFixture({ 1 }, { 1, 2, 2, 3 }) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(ParseSubBroadcast1D4D, SubBroadcastFixture1D4D)
-{
- RunTest<4>({ { "input0", { 3.0f } },
-
- { "input1", { 0.0f, 1.0f, 2.0f,
- 3.0f, 4.0f, 5.0f,
- 6.0f, 7.0f, 8.0f,
- 9.0f, 10.0f, 11.0f } } },
-
- { { "output", { 3.0f, 2.0f, 1.0f,
- 0.0f, -1.0f, -2.0f,
- -3.0f, -4.0f, -5.0f,
- -6.0f, -7.0f, -8.0f } } });
-}
-
-
-BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file
diff --git a/src/armnnTfParser/test/TestDependencies.cpp b/src/armnnTfParser/test/TestDependencies.cpp
deleted file mode 100644
index f373e5669d..0000000000
--- a/src/armnnTfParser/test/TestDependencies.cpp
+++ /dev/null
@@ -1,296 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-// Graph which tests that nodes are re-ordered in the queue when they are encountered a second time.
-// In this case R0 will be encountered first via R1 and then via R2. At that time
-// we need to make sure that R0 (and the I on which it is dependent) is moved to the front again
-// so that it is before both R1 and R2.
-// I
-// |
-// R0
-// / \'
-// R1 R2
-// \ |
-// \ R3
-// \|
-// O
-struct RediscoveredDependenciesFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- RediscoveredDependenciesFixture()
- {
- // Input = tf.placeholder(tf.float32, 1, "input")
- // Relu0 = tf.nn.relu(input, "relu0")
- // Relu1 = tf.nn.relu(relu0, "relu1")
- // Relu2 = tf.nn.relu(relu0, "relu2")
- // Relu3 = tf.nn.relu(relu2, "relu3")
- // Output = tf.add(relu1, relu3, "output")
- m_Prototext = R"(
- node {
- name: "input"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- dim {
- size: 1
- }
- }
- }
- }
- }
- node {
- name: "relu0"
- op: "Relu"
- input: "input"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "relu1"
- op: "Relu"
- input: "relu0"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "relu2"
- op: "Relu"
- input: "relu0"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "relu3"
- op: "Relu"
- input: "relu2"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "output"
- op: "Add"
- input: "relu1"
- input: "relu3"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- )";
- SetupSingleInputSingleOutput({ 1 }, "input", "output");
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(RediscoveredDependencies, RediscoveredDependenciesFixture)
-{
- RunTest<1>({1}, {2});
-}
-
-// Tests that a simple cycle in the tensorflow graph will be detected and an exception thrown, rather than the TfParser
-// getting stuck in an infinite loop.
-BOOST_AUTO_TEST_CASE(SimpleCycle)
-{
- const char* prototext = R"(
-node {
- name: "r1"
- op: "Relu"
- input: "r2"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
-node {
- name: "r2"
- op: "Relu"
- input: "r1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
- )";
- armnnTfParser::ITfParserPtr parser = armnnTfParser::ITfParser::Create();
- BOOST_CHECK_THROW(parser->CreateNetworkFromString(prototext, {}, { "r2" }), armnn::ParseException);
-}
-
-// Similar to the above SimpleCycle test, but has a single node which connects to itself.
-BOOST_AUTO_TEST_CASE(SingleNodeCycle)
-{
- const char* prototext = R"(
-node {
- name: "r1"
- op: "Relu"
- input: "r1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
- )";
- armnnTfParser::ITfParserPtr parser = armnnTfParser::ITfParser::Create();
- BOOST_CHECK_THROW(parser->CreateNetworkFromString(prototext, {}, { "r1" }), armnn::ParseException);
-}
-
-// Similar to the above SimpleCycle test, but with a more complicated graph.
-// I
-// |
-// A2---<---<-
-// / \' |
-// R1 R2 |
-// \ | |
-// \ R3 |
-// \| |
-// A1-->--->|
-//
-BOOST_AUTO_TEST_CASE(ComplexCycle)
-{
- // Input = tf.placeholder(tf.float32, 1, "input")
- // Add2 = tf.nn.relu(input, add1, "add2") // This line won't actually run in TF, because add1 is not yet defined
- // Relu1 = tf.nn.relu(relu0, "relu1")
- // Relu2 = tf.nn.relu(relu0, "relu2")
- // Relu3 = tf.nn.relu(relu2, "relu3")
- // Add1 = tf.add(relu1, relu3, "add1")
- const char* prototext = R"(
- node {
- name: "input"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- dim {
- size: 1
- }
- }
- }
- }
- }
- node {
- name: "add2"
- op: "Add"
- input: "input"
- input: "add1"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "relu1"
- op: "Relu"
- input: "add2"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "relu2"
- op: "Relu"
- input: "add2"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "relu3"
- op: "Relu"
- input: "relu2"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- node {
- name: "add1"
- op: "Add"
- input: "relu1"
- input: "relu3"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
- }
- )";
- armnnTfParser::ITfParserPtr parser = armnnTfParser::ITfParser::Create();
- BOOST_CHECK_THROW(parser->CreateNetworkFromString(prototext, {}, { "add1" }), armnn::ParseException);
-}
-
-// Tests that a graph with an input that is not present throws a ParseException.
-BOOST_AUTO_TEST_CASE(InvalidInput)
-{
- const char* prototext = R"(
-node {
- name: "r1"
- op: "Relu"
- input: "a-node-that-does-not-exist"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
- )";
- armnnTfParser::ITfParserPtr parser = armnnTfParser::ITfParser::Create();
- BOOST_CHECK_THROW(parser->CreateNetworkFromString(prototext, {}, { "r1" }), armnn::ParseException);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/TestMultiInputsOutputs.cpp b/src/armnnTfParser/test/TestMultiInputsOutputs.cpp
deleted file mode 100644
index a6d18b374c..0000000000
--- a/src/armnnTfParser/test/TestMultiInputsOutputs.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include <boost/test/unit_test.hpp>
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-struct MultiInputsOutputsFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- MultiInputsOutputsFixture()
- {
- // Input1 = tf.placeholder(tf.float32, shape=[], name = "input1")
- // Input2 = tf.placeholder(tf.float32, shape = [], name = "input2")
- // Add1 = tf.add(input1, input2, name = "add1")
- // Add2 = tf.add(input1, input2, name = "add2")
- m_Prototext = R"(
-node {
- name: "input1"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
-}
-node {
- name: "input2"
- op: "Placeholder"
- attr {
- key: "dtype"
- value {
- type: DT_FLOAT
- }
- }
- attr {
- key: "shape"
- value {
- shape {
- }
- }
- }
-}
-node {
- name: "add1"
- op: "Add"
- input: "input1"
- input: "input2"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
-node {
- name: "add2"
- op: "Add"
- input: "input1"
- input: "input2"
- attr {
- key: "T"
- value {
- type: DT_FLOAT
- }
- }
-}
- )";
- Setup({ { "input1", { 1 } },
- { "input2", { 1 } } },
- { "add1", "add2" });
- }
-};
-
-BOOST_FIXTURE_TEST_CASE(MultiInputsOutputs, MultiInputsOutputsFixture)
-{
- RunTest<1>({ { "input1", {12.0f} }, { "input2", { 13.0f } } },
- { { "add1", { 25.0f } }, { "add2", { 25.0f } } });
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/armnnTfParser/test/Transpose.cpp b/src/armnnTfParser/test/Transpose.cpp
deleted file mode 100644
index dd73bd90a2..0000000000
--- a/src/armnnTfParser/test/Transpose.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-//
-// Copyright © 2020 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#include "armnnTfParser/ITfParser.hpp"
-#include "ParserPrototxtFixture.hpp"
-
-#include <boost/test/unit_test.hpp>
-#include <PrototxtConversions.hpp>
-
-BOOST_AUTO_TEST_SUITE(TensorflowParser)
-
-namespace
-{
- std::string ConvertInt32VectorToOctalString(const std::vector<unsigned int>& data)
- {
- std::stringstream ss;
- ss << "\"";
- std::for_each(data.begin(), data.end(), [&ss](unsigned int d) {
- ss << armnnUtils::ConvertInt32ToOctalString(static_cast<int>(d));
- });
- ss << "\"";
- return ss.str();
- }
-} // namespace
-
-struct TransposeFixture : public armnnUtils::ParserPrototxtFixture<armnnTfParser::ITfParser>
-{
- TransposeFixture(const armnn::TensorShape& inputShape,
- const std::vector<unsigned int>& permuteVectorData)
- {
- using armnnUtils::ConvertTensorShapeToString;
- armnn::TensorShape permuteVectorShape({static_cast<unsigned int>(permuteVectorData.size())});
-
- m_Prototext = "node {\n"
-" name: \"input\"\n"
-" op: \"Placeholder\"\n"
-" attr {\n"
-" key: \"dtype\"\n"
-" value {\n"
-" type: DT_FLOAT\n"
-" }\n"
-" }\n"
-" attr {\n"
-" key: \"shape\"\n"
-" value {\n"
-" shape {\n";
- m_Prototext.append(ConvertTensorShapeToString(inputShape));
- m_Prototext.append(
-" }\n"
-" }\n"
-" }\n"
-"}\n"
-"node {\n"
-" name: \"transpose/perm\"\n"
-" op: \"Const\"\n"
-" attr {\n"
-" key: \"dtype\"\n"
-" value {\n"
-" type: DT_INT32\n"
-" }\n"
-" }\n"
-" attr {\n"
-" key: \"value\"\n"
-" value {\n"
-" tensor {\n"
-" dtype: DT_INT32\n"
-" tensor_shape {\n"
- );
- m_Prototext.append(ConvertTensorShapeToString(permuteVectorShape));
- m_Prototext.append(
-" }\n"
-" tensor_content: "
- );
- m_Prototext.append(ConvertInt32VectorToOctalString(permuteVectorData) + "\n");
- m_Prototext.append(
-" }\n"
-" }\n"
-" }\n"
-"}\n"
- );
- m_Prototext.append(
-"node {\n"
-" name: \"output\"\n"
-" op: \"Transpose\"\n"
-" input: \"input\"\n"
-" input: \"transpose/perm\"\n"
-" attr {\n"
-" key: \"T\"\n"
-" value {\n"
-" type: DT_FLOAT\n"
-" }\n"
-" }\n"
-" attr {\n"
-" key: \"Tperm\"\n"
-" value {\n"
-" type: DT_INT32\n"
-" }\n"
-" }\n"
-"}\n"
- );
- Setup({{"input", inputShape}}, {"output"});
- }
-};
-
-struct TransposeFixtureWithPermuteData : TransposeFixture
-{
- TransposeFixtureWithPermuteData()
- : TransposeFixture({2, 2, 3, 4},
- std::vector<unsigned int>({1, 3, 2, 0})) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(TransposeWithPermuteData, TransposeFixtureWithPermuteData)
-{
- RunTest<4>(
- {{"input", {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47}}},
- {{"output", {0, 24, 4, 28, 8, 32, 1, 25, 5, 29, 9, 33, 2, 26, 6,
- 30, 10, 34, 3, 27, 7, 31, 11, 35, 12, 36, 16, 40, 20, 44, 13, 37,
- 17, 41, 21, 45, 14, 38, 18, 42, 22, 46, 15, 39, 19, 43, 23, 47}}});
-
- BOOST_TEST((m_Parser->GetNetworkOutputBindingInfo("output").second.GetShape()
- == armnn::TensorShape({2, 4, 3, 2})));
-}
-
-struct TransposeFixtureWithoutPermuteData : TransposeFixture
-{
- // In case permute data is not given, it assumes (n-1,...,0) is given
- // where n is the rank of input tensor.
- TransposeFixtureWithoutPermuteData()
- : TransposeFixture({2, 2, 3, 4},
- std::vector<unsigned int>({3, 2, 1, 0})) {}
-};
-
-BOOST_FIXTURE_TEST_CASE(TransposeWithoutPermuteData, TransposeFixtureWithoutPermuteData)
-{
- RunTest<4>(
- {{"input", {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47}}},
- {{"output", {0, 24, 12, 36, 4, 28, 16, 40, 8, 32, 20, 44, 1, 25,
- 13, 37, 5, 29, 17, 41, 9, 33, 21, 45, 2, 26, 14, 38, 6, 30, 18,
- 42,10, 34, 22, 46, 3, 27, 15, 39, 7, 31, 19, 43, 11, 35, 23, 47}}});
-
- BOOST_TEST((m_Parser->GetNetworkOutputBindingInfo("output").second.GetShape()
- == armnn::TensorShape({4, 3, 2, 2})));
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 0b26384612..1531fd5f24 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -16,50 +16,6 @@ target_include_directories(inferenceTest PRIVATE ../src/armnnUtils)
target_include_directories(inferenceTest PRIVATE ../src/backends)
target_include_directories(inferenceTest PRIVATE ../third-party/stb)
-if(BUILD_TF_PARSER)
- macro(TfParserTest testName sources)
- add_executable_ex(${testName} ${sources})
- target_include_directories(${testName} PRIVATE ../src/armnnUtils)
- target_include_directories(${testName} PRIVATE ../src/backends)
-
- target_link_libraries(${testName} inferenceTest)
- target_link_libraries(${testName} armnnTfParser)
- target_link_libraries(${testName} armnn)
- target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT})
- addDllCopyCommands(${testName})
- endmacro()
-
- set(TfMnist-Armnn_sources
- TfMnist-Armnn/TfMnist-Armnn.cpp
- MnistDatabase.hpp
- MnistDatabase.cpp)
- TfParserTest(TfMnist-Armnn "${TfMnist-Armnn_sources}")
-
- set(TfCifar10-Armnn_sources
- TfCifar10-Armnn/TfCifar10-Armnn.cpp
- Cifar10Database.hpp
- Cifar10Database.cpp)
- TfParserTest(TfCifar10-Armnn "${TfCifar10-Armnn_sources}")
-
- set(TfMobileNet-Armnn_sources
- TfMobileNet-Armnn/TfMobileNet-Armnn.cpp
- ImagePreprocessor.hpp
- ImagePreprocessor.cpp)
- TfParserTest(TfMobileNet-Armnn "${TfMobileNet-Armnn_sources}")
-
- set(TfInceptionV3-Armnn_sources
- TfInceptionV3-Armnn/TfInceptionV3-Armnn.cpp
- ImagePreprocessor.hpp
- ImagePreprocessor.cpp)
- TfParserTest(TfInceptionV3-Armnn "${TfInceptionV3-Armnn_sources}")
-
- set(TfResNext-Armnn_sources
- TfResNext_Quantized-Armnn/TfResNext_Quantized-Armnn.cpp
- ImagePreprocessor.hpp
- ImagePreprocessor.cpp)
- TfParserTest(TfResNext-Armnn "${TfResNext-Armnn_sources}")
-endif()
-
if (BUILD_TF_LITE_PARSER)
macro(TfLiteParserTest testName sources)
add_executable_ex(${testName} ${sources})
@@ -146,6 +102,9 @@ if (BUILD_TF_LITE_PARSER)
ImagePreprocessor.hpp
ImagePreprocessor.cpp)
TfLiteParserTest(TfLiteYoloV3Big-Armnn "${TfLiteYoloV3Big-Armnn_sources}")
+
+
+
endif()
if (BUILD_ONNX_PARSER)
@@ -193,9 +152,6 @@ if (BUILD_ARMNN_SERIALIZER OR BUILD_TF_PARSER OR BUILD_TF_LITE_PARSER OR BUILD_O
if (BUILD_ARMNN_SERIALIZER)
target_link_libraries(ExecuteNetwork armnnSerializer)
endif()
- if (BUILD_TF_PARSER)
- target_link_libraries(ExecuteNetwork armnnTfParser)
- endif()
if (BUILD_TF_LITE_PARSER)
target_link_libraries(ExecuteNetwork armnnTfLiteParser)
@@ -218,9 +174,6 @@ if(BUILD_ACCURACY_TOOL)
if (BUILD_ARMNN_SERIALIZER)
target_link_libraries(${executorName} armnnSerializer)
endif()
- if (BUILD_TF_PARSER)
- target_link_libraries(${executorName} armnnTfParser)
- endif()
if (BUILD_TF_LITE_PARSER)
target_link_libraries(${executorName} armnnTfLiteParser)
endif()
diff --git a/tests/ExecuteNetwork/ExecuteNetwork.cpp b/tests/ExecuteNetwork/ExecuteNetwork.cpp
index 8ab286b16b..60e4ec3401 100644
--- a/tests/ExecuteNetwork/ExecuteNetwork.cpp
+++ b/tests/ExecuteNetwork/ExecuteNetwork.cpp
@@ -13,9 +13,6 @@
#if defined(ARMNN_SERIALIZER)
#include "armnnDeserializer/IDeserializer.hpp"
#endif
-#if defined(ARMNN_TF_PARSER)
-#include "armnnTfParser/ITfParser.hpp"
-#endif
#if defined(ARMNN_TF_LITE_PARSER)
#include "armnnTfLiteParser/ITfLiteParser.hpp"
#endif
@@ -478,15 +475,6 @@ int main(int argc, const char* argv[])
return EXIT_FAILURE;
#endif
}
- else if (modelFormat.find("tensorflow") != std::string::npos)
- {
- #if defined(ARMNN_TF_PARSER)
- return MainImpl<armnnTfParser::ITfParser, float>(ProgramOptions.m_ExNetParams, runtime);
- #else
- ARMNN_LOG(fatal) << "Not built with Tensorflow parser support.";
- return EXIT_FAILURE;
- #endif
- }
else if(modelFormat.find("tflite") != std::string::npos)
{
if (ProgramOptions.m_ExNetParams.m_TfLiteExecutor == ExecuteNetworkParams::TfLiteExecutor::ArmNNTfLiteParser)
@@ -514,7 +502,7 @@ int main(int argc, const char* argv[])
else
{
ARMNN_LOG(fatal) << "Unknown model format: '" << modelFormat
- << "'. Please include 'tensorflow', 'tflite' or 'onnx'";
+ << "'. Please include 'tflite' or 'onnx'";
return EXIT_FAILURE;
}
}
diff --git a/tests/ExecuteNetwork/ExecuteNetworkProgramOptions.cpp b/tests/ExecuteNetwork/ExecuteNetworkProgramOptions.cpp
index 7c1db61841..286c970d72 100644
--- a/tests/ExecuteNetwork/ExecuteNetworkProgramOptions.cpp
+++ b/tests/ExecuteNetwork/ExecuteNetworkProgramOptions.cpp
@@ -173,8 +173,7 @@ ProgramOptions::ProgramOptions() : m_CxxOptions{"ExecuteNetwork",
cxxopts::value<std::vector<std::string>>())
("f,model-format",
- "armnn-binary, onnx-binary, onnx-text, tflite-binary, tensorflow-binary or "
- "tensorflow-text.",
+ "armnn-binary, onnx-binary, onnx-text, tflite-binary",
cxxopts::value<std::string>())
("m,model-path",
diff --git a/tests/ImageTensorGenerator/ImageTensorGenerator.hpp b/tests/ImageTensorGenerator/ImageTensorGenerator.hpp
index f2ee470a7a..5aa2ca8124 100644
--- a/tests/ImageTensorGenerator/ImageTensorGenerator.hpp
+++ b/tests/ImageTensorGenerator/ImageTensorGenerator.hpp
@@ -24,8 +24,7 @@ struct NormalizationParameters
enum class SupportedFrontend
{
- TensorFlow = 0,
- TFLite = 1,
+ TFLite = 0,
};
/** Get normalization parameters.
@@ -45,7 +44,6 @@ NormalizationParameters GetNormalizationParameters(const SupportedFrontend& mode
normParams.stddev = { 1.0, 1.0, 1.0 };
switch (modelFormat)
{
- case SupportedFrontend::TensorFlow:
case SupportedFrontend::TFLite:
default:
switch (outputType)
diff --git a/tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp b/tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp
index 345a0fed98..e1a637a2d1 100644
--- a/tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp
+++ b/tests/ModelAccuracyTool-Armnn/ModelAccuracyTool-Armnn.cpp
@@ -76,7 +76,7 @@ int main(int argc, char* argv[])
"Path to armnn format model file",
cxxopts::value<std::string>(modelPath))
("f,model-format",
- "The model format. Supported values: tensorflow, tflite",
+ "The model format. Supported values: tflite",
cxxopts::value<std::string>(modelFormat))
("i,input-name",
"Identifier of the input tensors in the network separated by comma with no space.",
@@ -312,11 +312,7 @@ int main(int argc, char* argv[])
const unsigned int batchSize = 1;
// Get normalisation parameters
SupportedFrontend modelFrontend;
- if (modelFormat == "tensorflow")
- {
- modelFrontend = SupportedFrontend::TensorFlow;
- }
- else if (modelFormat == "tflite")
+ if (modelFormat == "tflite")
{
modelFrontend = SupportedFrontend::TFLite;
}
diff --git a/tests/MultipleNetworksCifar10/MultipleNetworksCifar10.cpp b/tests/MultipleNetworksCifar10/MultipleNetworksCifar10.cpp
index 9c51d3f0a7..133b8d885f 100644
--- a/tests/MultipleNetworksCifar10/MultipleNetworksCifar10.cpp
+++ b/tests/MultipleNetworksCifar10/MultipleNetworksCifar10.cpp
@@ -6,7 +6,7 @@
#include "armnn/ArmNN.hpp"
#include "armnn/Utils.hpp"
#include "armnn/INetwork.hpp"
-#include "armnnTfParser/TfParser.hpp"
+#include "armnnTfLiteParser/TfLiteParser.hpp"
#include "../Cifar10Database.hpp"
#include "../InferenceTest.hpp"
#include "../InferenceModel.hpp"
@@ -123,7 +123,7 @@ int main(int argc, char* argv[])
};
std::vector<Net> networks;
- armnnTfParser::ITfParserPtr parser(armnnTfParser::ITfParser::Create());
+ armnnTfLiteParser::ITfLiteParserPtr parser(armnnTfLiteParser::ITfLiteParserPtr::Create());
const int networksCount = 4;
for (int i = 0; i < networksCount; ++i)
diff --git a/tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp b/tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp
index 74c878304d..e5da1491b6 100644
--- a/tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp
+++ b/tests/NetworkExecutionUtils/NetworkExecutionUtils.cpp
@@ -12,9 +12,6 @@
#if defined(ARMNN_SERIALIZER)
#include "armnnDeserializer/IDeserializer.hpp"
#endif
-#if defined(ARMNN_TF_PARSER)
-#include "armnnTfParser/ITfParser.hpp"
-#endif
#if defined(ARMNN_TF_LITE_PARSER)
#include "armnnTfLiteParser/ITfLiteParser.hpp"
#endif
diff --git a/tests/TfCifar10-Armnn/TfCifar10-Armnn.cpp b/tests/TfCifar10-Armnn/TfCifar10-Armnn.cpp
deleted file mode 100644
index 6a88af29a6..0000000000
--- a/tests/TfCifar10-Armnn/TfCifar10-Armnn.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-#include "../InferenceTest.hpp"
-#include "../Cifar10Database.hpp"
-#include "armnnTfParser/ITfParser.hpp"
-
-int main(int argc, char* argv[])
-{
- armnn::TensorShape inputTensorShape({ 1, 32, 32, 3 });
-
- int retVal = EXIT_FAILURE;
- try
- {
- using DataType = float;
- using DatabaseType = Cifar10Database;
- using ParserType = armnnTfParser::ITfParser;
- using ModelType = InferenceModel<ParserType, DataType>;
-
- // Coverity fix: ClassifierInferenceTestMain() may throw uncaught exceptions.
- retVal = armnn::test::ClassifierInferenceTestMain<DatabaseType, ParserType>(
- argc, argv, "cifar10_tf.prototxt", false,
- "data", "prob", { 0, 1, 2, 4, 7 },
- [](const char* dataDir, const ModelType&) {
- return DatabaseType(dataDir, true);
- }, &inputTensorShape);
- }
- catch (const std::exception& e)
- {
- // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
- // exception of type std::length_error.
- // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
- std::cerr << "WARNING: TfCifar10-Armnn: An error has occurred when running "
- "the classifier inference tests: " << e.what() << std::endl;
- }
- return retVal;
-}
diff --git a/tests/TfCifar10-Armnn/Validation.txt b/tests/TfCifar10-Armnn/Validation.txt
deleted file mode 100644
index a7b59465eb..0000000000
--- a/tests/TfCifar10-Armnn/Validation.txt
+++ /dev/null
@@ -1,1000 +0,0 @@
-3
-8
-8
-8
-6
-8
-5
-6
-3
-8
-0
-9
-5
-7
-9
-8
-5
-7
-8
-6
-7
-0
-8
-9
-4
-3
-3
-0
-9
-6
-6
-5
-8
-3
-9
-3
-7
-9
-9
-5
-0
-6
-7
-3
-0
-9
-3
-8
-7
-2
-9
-8
-5
-5
-8
-8
-7
-5
-5
-3
-7
-5
-2
-3
-6
-7
-8
-0
-3
-7
-0
-3
-8
-8
-0
-2
-0
-8
-5
-8
-8
-0
-1
-7
-3
-0
-3
-3
-8
-9
-0
-2
-8
-6
-7
-3
-6
-0
-0
-7
-8
-5
-6
-3
-1
-1
-3
-6
-8
-7
-5
-0
-2
-3
-0
-3
-0
-3
-7
-5
-8
-0
-1
-2
-8
-8
-8
-3
-6
-0
-4
-1
-8
-9
-1
-0
-9
-4
-2
-8
-3
-5
-6
-5
-8
-0
-6
-5
-5
-5
-8
-9
-5
-0
-0
-5
-0
-9
-5
-4
-0
-0
-0
-6
-0
-0
-8
-8
-5
-8
-9
-0
-8
-8
-9
-9
-3
-7
-5
-0
-0
-5
-2
-8
-0
-8
-5
-3
-3
-8
-5
-8
-0
-1
-7
-3
-8
-8
-7
-8
-5
-0
-8
-0
-1
-3
-8
-5
-7
-8
-7
-0
-5
-8
-8
-0
-7
-9
-8
-2
-7
-5
-8
-5
-5
-9
-8
-0
-3
-6
-5
-1
-7
-8
-8
-0
-4
-0
-5
-3
-1
-1
-8
-3
-0
-8
-1
-8
-2
-0
-5
-5
-9
-9
-2
-8
-3
-0
-8
-9
-8
-8
-3
-3
-0
-8
-8
-4
-7
-0
-0
-3
-6
-3
-8
-0
-0
-3
-2
-5
-9
-0
-6
-1
-0
-9
-8
-8
-7
-9
-8
-2
-6
-9
-3
-0
-6
-0
-0
-6
-6
-3
-3
-8
-8
-8
-8
-3
-1
-0
-8
-6
-0
-0
-8
-0
-7
-7
-5
-5
-3
-3
-2
-0
-5
-0
-7
-7
-3
-6
-1
-9
-3
-6
-6
-9
-3
-8
-0
-7
-0
-6
-2
-5
-8
-5
-7
-6
-8
-9
-9
-1
-8
-2
-3
-7
-5
-2
-8
-0
-9
-5
-8
-8
-9
-4
-0
-5
-8
-0
-0
-7
-9
-3
-2
-7
-3
-7
-8
-6
-6
-9
-0
-8
-5
-0
-7
-3
-5
-5
-1
-2
-6
-2
-3
-6
-2
-3
-0
-8
-9
-8
-7
-8
-8
-4
-0
-8
-8
-3
-5
-8
-3
-8
-1
-9
-0
-5
-5
-7
-4
-7
-8
-0
-0
-9
-3
-7
-0
-6
-3
-3
-8
-7
-3
-7
-8
-5
-3
-8
-1
-3
-9
-8
-8
-7
-3
-0
-0
-0
-2
-9
-7
-0
-8
-3
-4
-5
-3
-8
-5
-6
-8
-7
-3
-8
-4
-3
-7
-8
-5
-7
-8
-8
-3
-7
-4
-0
-5
-4
-3
-6
-0
-8
-5
-8
-9
-9
-8
-0
-0
-0
-0
-1
-8
-8
-0
-5
-2
-0
-4
-0
-5
-2
-9
-4
-7
-9
-0
-4
-5
-6
-8
-9
-5
-5
-8
-9
-3
-8
-5
-7
-0
-7
-0
-5
-0
-0
-0
-6
-8
-8
-9
-5
-6
-3
-6
-3
-9
-8
-1
-7
-0
-7
-5
-9
-0
-6
-5
-5
-3
-3
-8
-3
-9
-8
-6
-4
-3
-2
-0
-7
-6
-0
-2
-3
-9
-5
-8
-0
-6
-7
-8
-3
-6
-8
-8
-8
-7
-5
-4
-0
-8
-4
-0
-8
-3
-5
-8
-9
-6
-9
-2
-3
-0
-0
-7
-8
-8
-3
-8
-5
-0
-2
-1
-6
-3
-4
-3
-9
-6
-9
-8
-8
-5
-8
-6
-3
-2
-1
-7
-7
-1
-2
-7
-9
-9
-4
-4
-0
-8
-3
-2
-8
-7
-0
-8
-3
-0
-3
-3
-8
-0
-7
-9
-1
-8
-0
-4
-5
-3
-9
-3
-0
-8
-0
-1
-5
-4
-1
-8
-0
-7
-6
-3
-0
-9
-0
-8
-2
-6
-3
-2
-3
-0
-0
-3
-8
-0
-3
-9
-6
-8
-0
-9
-2
-8
-2
-3
-0
-3
-2
-2
-7
-8
-3
-8
-0
-7
-5
-7
-0
-4
-8
-7
-4
-8
-3
-8
-8
-6
-0
-8
-7
-4
-3
-3
-8
-4
-8
-7
-8
-8
-9
-8
-8
-1
-3
-3
-5
-5
-0
-7
-9
-8
-0
-8
-4
-1
-3
-5
-7
-8
-7
-8
-7
-4
-6
-2
-5
-8
-0
-8
-1
-2
-0
-6
-8
-2
-1
-3
-5
-6
-0
-1
-2
-0
-8
-3
-0
-5
-0
-6
-8
-0
-2
-7
-6
-0
-6
-9
-1
-7
-8
-7
-0
-3
-9
-7
-8
-0
-0
-3
-3
-7
-5
-4
-8
-8
-8
-7
-1
-2
-7
-4
-4
-8
-4
-7
-7
-3
-2
-7
-2
-0
-8
-8
-5
-8
-0
-8
-2
-0
-8
-7
-5
-0
-8
-5
-0
-0
-8
-2
-2
-2
-8
-9
-2
-7
-2
-7
-0
-7
-2
-1
-0
-0
-0
-8
-4
-7
-9
-8
-0
-0
-7
-7
-0
-7
-8
-4
-4
-3
-5
-0
-1
-3
-7
-0
-1
-8
-1
-4
-2
-3
-8
-4
-5
-0
-7
-8
-8
-3
-0
-8
-8
-8
-8
-8
-4
-3
-6
-7
-3
-1
-8
-3
-7
-7
-5
-5
-6
-6
-5
-8
-8
-1
-6
-8
-8
-3
-3
-3
-2
-0
-1
-8
-8
-8
-0
-0
-9
-9
-3
-3
-5
-8
-3
-0
-0
-4
-2
-3
-3
-7
-3
-0
-5
-8
-8
-9
-8
-5
-4
-8
-3
-0
-8
-7
-8
-3
-9
-2
-8
-4
-7
-8
-3
-7
-8
-8
-8
-8
-3
-6
-3
-3
-8
-1
-9
-9
-4
-6
-8
-0
-0
-0
-8
-8
-9
-2
-8
-8
-8
-7
-8
-3
-1
-7
-0
-1
-5
-8
-3
-3
-3
-8
-9
-3
-8
diff --git a/tests/TfInceptionV3-Armnn/TfInceptionV3-Armnn.cpp b/tests/TfInceptionV3-Armnn/TfInceptionV3-Armnn.cpp
deleted file mode 100644
index 7208872204..0000000000
--- a/tests/TfInceptionV3-Armnn/TfInceptionV3-Armnn.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-#include "../InferenceTest.hpp"
-#include "../ImagePreprocessor.hpp"
-#include "armnnTfParser/ITfParser.hpp"
-
-int main(int argc, char* argv[])
-{
- int retVal = EXIT_FAILURE;
- try
- {
- // Coverity fix: The following code may throw an exception of type std::length_error.
- std::vector<ImageSet> imageSet =
- {
- { "Dog.jpg", 208 },
- // Top five predictions in tensorflow:
- // -----------------------------------
- // 208:golden retriever 0.57466376
- // 209:Labrador retriever 0.30202731
- // 853:tennis ball 0.0060001756
- // 223:kuvasz 0.0053707925
- // 160:Rhodesian ridgeback 0.0018179063
-
- { "Cat.jpg", 283 },
- // Top five predictions in tensorflow:
- // -----------------------------------
- // 283:tiger cat 0.4667799
- // 282:tabby, tabby cat 0.32511184
- // 286:Egyptian cat 0.1038616
- // 288:lynx, catamount 0.0017019814
- // 284:Persian cat 0.0011340436
-
- { "shark.jpg", 3 },
- // Top five predictions in tensorflow:
- // -----------------------------------
- // 3:great white shark, white shark, ... 0.98808634
- // 148:grey whale, gray whale, ... 0.00070245547
- // 234:Bouvier des Flandres, ... 0.00024639888
- // 149:killer whale, killer, ... 0.00014115588
- // 95:hummingbird 0.00011129203
- };
-
- armnn::TensorShape inputTensorShape({ 1, 299, 299, 3 });
-
- using DataType = float;
- using DatabaseType = ImagePreprocessor<float>;
- using ParserType = armnnTfParser::ITfParser;
- using ModelType = InferenceModel<ParserType, DataType>;
-
- // Coverity fix: InferenceTestMain() may throw uncaught exceptions.
- retVal = armnn::test::ClassifierInferenceTestMain<DatabaseType, ParserType>(
- argc, argv, "inception_v3_2016_08_28_frozen.pb", true,
- "input", "InceptionV3/Predictions/Reshape_1", { 0, 1, 2, },
- [&imageSet](const char* dataDir, const ModelType&) {
- return DatabaseType(dataDir, 299, 299, imageSet);
- },
- &inputTensorShape);
- }
- catch (const std::exception& e)
- {
- // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
- // exception of type std::length_error.
- // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
- std::cerr << "WARNING: TfInceptionV3-Armnn: An error has occurred when running "
- "the classifier inference tests: " << e.what() << std::endl;
- }
- return retVal;
-}
diff --git a/tests/TfInceptionV3-Armnn/Validation.txt b/tests/TfInceptionV3-Armnn/Validation.txt
deleted file mode 100644
index 81b64dd7c5..0000000000
--- a/tests/TfInceptionV3-Armnn/Validation.txt
+++ /dev/null
@@ -1,201 +0,0 @@
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
-208
-283
-3
diff --git a/tests/TfMnist-Armnn/TfMnist-Armnn.cpp b/tests/TfMnist-Armnn/TfMnist-Armnn.cpp
deleted file mode 100644
index d2b83061a1..0000000000
--- a/tests/TfMnist-Armnn/TfMnist-Armnn.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-#include "../InferenceTest.hpp"
-#include "../MnistDatabase.hpp"
-#include "armnnTfParser/ITfParser.hpp"
-
-int main(int argc, char* argv[])
-{
- armnn::TensorShape inputTensorShape({ 1, 784, 1, 1 });
-
- int retVal = EXIT_FAILURE;
- try
- {
- using DataType = float;
- using DatabaseType = MnistDatabase;
- using ParserType = armnnTfParser::ITfParser;
- using ModelType = InferenceModel<ParserType, DataType>;
-
- // Coverity fix: ClassifierInferenceTestMain() may throw uncaught exceptions.
- retVal = armnn::test::ClassifierInferenceTestMain<DatabaseType, ParserType>(
- argc, argv, "simple_mnist_tf.prototxt", false,
- "Placeholder", "Softmax", { 0, 1, 2, 3, 4 },
- [](const char* dataDir, const ModelType&) {
- return DatabaseType(dataDir, true);
- },
- &inputTensorShape);
- }
- catch (const std::exception& e)
- {
- // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
- // exception of type std::length_error.
- // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
- std::cerr << "WARNING: TfMnist-Armnn: An error has occurred when running "
- "the classifier inference tests: " << e.what() << std::endl;
- }
- return retVal;
-}
diff --git a/tests/TfMnist-Armnn/Validation.txt b/tests/TfMnist-Armnn/Validation.txt
deleted file mode 100644
index 175778ff07..0000000000
--- a/tests/TfMnist-Armnn/Validation.txt
+++ /dev/null
@@ -1,1000 +0,0 @@
-7
-2
-1
-0
-4
-1
-4
-9
-6
-9
-0
-6
-9
-0
-1
-5
-9
-7
-3
-4
-9
-6
-6
-5
-4
-0
-7
-4
-0
-1
-3
-1
-3
-6
-7
-2
-7
-1
-2
-1
-1
-9
-9
-2
-3
-5
-3
-2
-4
-4
-6
-3
-5
-5
-6
-0
-4
-1
-9
-5
-7
-8
-9
-2
-3
-4
-3
-4
-3
-0
-7
-0
-2
-9
-1
-7
-3
-2
-9
-7
-9
-6
-2
-7
-8
-4
-7
-3
-6
-1
-3
-6
-9
-3
-1
-4
-1
-7
-6
-9
-6
-0
-5
-4
-9
-9
-2
-1
-9
-4
-8
-1
-3
-9
-7
-9
-4
-4
-9
-2
-5
-9
-7
-6
-9
-9
-0
-5
-8
-5
-6
-6
-5
-7
-8
-1
-0
-1
-6
-9
-6
-7
-3
-1
-9
-1
-8
-2
-0
-9
-9
-9
-5
-5
-1
-5
-6
-0
-3
-9
-4
-6
-5
-4
-6
-5
-4
-5
-1
-4
-4
-7
-2
-3
-2
-7
-1
-8
-1
-8
-1
-8
-5
-0
-8
-9
-2
-5
-0
-1
-1
-1
-0
-3
-0
-5
-1
-6
-4
-2
-3
-6
-1
-1
-1
-3
-9
-5
-2
-9
-4
-5
-9
-3
-9
-0
-3
-6
-5
-5
-7
-2
-2
-7
-2
-2
-8
-4
-1
-7
-3
-3
-8
-9
-7
-9
-2
-2
-4
-1
-5
-5
-8
-7
-2
-5
-0
-2
-4
-2
-4
-5
-9
-5
-7
-7
-2
-2
-2
-0
-8
-5
-7
-7
-9
-1
-8
-1
-8
-0
-3
-0
-1
-9
-9
-4
-1
-8
-2
-1
-2
-9
-2
-5
-9
-2
-6
-4
-1
-5
-4
-2
-9
-2
-0
-4
-0
-0
-2
-8
-4
-7
-1
-2
-4
-0
-2
-9
-4
-3
-3
-0
-0
-5
-1
-9
-6
-5
-2
-5
-7
-7
-9
-3
-0
-9
-2
-0
-7
-1
-1
-2
-1
-5
-3
-2
-9
-7
-8
-6
-3
-6
-1
-3
-5
-1
-0
-5
-1
-3
-1
-5
-0
-6
-2
-8
-5
-1
-9
-9
-4
-6
-7
-2
-5
-0
-6
-5
-6
-3
-7
-2
-0
-8
-8
-5
-9
-1
-1
-4
-0
-3
-3
-7
-6
-1
-6
-2
-1
-9
-2
-8
-6
-1
-9
-5
-2
-5
-4
-4
-2
-8
-3
-9
-2
-4
-5
-0
-3
-1
-7
-7
-3
-7
-9
-7
-1
-9
-2
-1
-4
-2
-9
-2
-0
-2
-9
-1
-9
-8
-1
-8
-4
-5
-9
-7
-8
-3
-7
-6
-0
-0
-3
-0
-8
-0
-6
-9
-9
-5
-3
-3
-2
-3
-9
-1
-2
-6
-8
-0
-9
-6
-6
-6
-3
-8
-8
-2
-9
-5
-8
-9
-6
-1
-8
-4
-1
-2
-8
-3
-1
-9
-7
-5
-4
-0
-8
-9
-9
-1
-0
-5
-2
-3
-7
-2
-9
-4
-0
-6
-3
-9
-3
-2
-1
-3
-1
-5
-6
-5
-2
-8
-2
-2
-6
-2
-6
-6
-5
-4
-8
-9
-3
-1
-3
-0
-3
-8
-2
-1
-9
-6
-9
-4
-6
-4
-1
-1
-8
-2
-5
-4
-2
-3
-4
-0
-0
-2
-3
-2
-7
-1
-0
-8
-7
-4
-4
-7
-9
-6
-9
-0
-9
-8
-0
-9
-6
-0
-6
-4
-5
-9
-9
-3
-3
-9
-3
-3
-2
-7
-8
-0
-2
-2
-1
-7
-0
-6
-5
-4
-3
-2
-0
-9
-6
-3
-8
-0
-9
-9
-6
-8
-6
-8
-5
-9
-5
-6
-0
-2
-9
-0
-2
-8
-3
-1
-9
-7
-5
-1
-0
-8
-4
-6
-2
-6
-7
-9
-3
-6
-9
-8
-2
-2
-9
-2
-7
-3
-5
-9
-1
-8
-0
-2
-0
-5
-2
-1
-3
-7
-6
-7
-1
-2
-5
-8
-0
-3
-9
-9
-4
-0
-9
-1
-8
-6
-9
-7
-4
-3
-4
-9
-1
-9
-5
-1
-7
-3
-9
-7
-6
-9
-1
-3
-2
-8
-3
-3
-6
-9
-2
-4
-7
-8
-5
-1
-3
-4
-4
-3
-1
-0
-7
-7
-0
-7
-9
-9
-4
-8
-5
-5
-9
-0
-5
-2
-1
-6
-8
-4
-8
-0
-4
-0
-6
-1
-7
-3
-8
-6
-7
-2
-6
-9
-3
-1
-4
-6
-2
-5
-9
-2
-0
-6
-2
-1
-7
-3
-9
-1
-0
-5
-9
-3
-1
-1
-7
-4
-9
-9
-9
-8
-4
-0
-2
-4
-5
-1
-1
-6
-4
-7
-1
-9
-4
-2
-4
-1
-5
-5
-3
-5
-3
-1
-4
-5
-6
-8
-9
-4
-1
-9
-3
-8
-0
-3
-2
-5
-1
-2
-9
-3
-4
-4
-0
-8
-8
-3
-3
-1
-3
-3
-5
-9
-6
-3
-2
-6
-1
-3
-6
-0
-7
-2
-1
-7
-1
-4
-2
-8
-2
-1
-9
-9
-6
-1
-1
-2
-4
-3
-1
-7
-7
-4
-7
-0
-7
-3
-1
-3
-1
-0
-7
-7
-0
-3
-5
-3
-2
-9
-6
-6
-9
-2
-8
-3
-4
-2
-2
-5
-6
-0
-9
-2
-9
-2
-8
-2
-8
-8
-7
-9
-9
-3
-0
-6
-6
-3
-2
-1
-5
-2
-2
-9
-3
-0
-5
-5
-2
-8
-1
-4
-4
-6
-0
-2
-9
-1
-4
-7
-4
-7
-3
-9
-8
-8
-4
-7
-1
-2
-1
-2
-2
-3
-2
-3
-2
-3
-9
-1
-7
-4
-0
-3
-5
-5
-8
-6
-5
-0
-6
-7
-6
-6
-3
-2
-7
-9
-1
-1
-2
-4
-6
-4
-9
-5
-2
-3
-3
-4
-7
-8
-9
-1
-1
-0
-9
-1
-4
-4
-5
-4
-0
-6
-2
-3
-3
-1
-5
-1
-2
-0
-2
-8
-1
-2
-6
-7
-1
-6
-2
-3
-9
-0
-3
-2
-2
-0
-9
-9
diff --git a/tests/TfMobileNet-Armnn/TfMobileNet-Armnn.cpp b/tests/TfMobileNet-Armnn/TfMobileNet-Armnn.cpp
deleted file mode 100644
index 6748b12d9d..0000000000
--- a/tests/TfMobileNet-Armnn/TfMobileNet-Armnn.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-#include "../InferenceTest.hpp"
-#include "../ImagePreprocessor.hpp"
-#include "armnnTfParser/ITfParser.hpp"
-
-int main(int argc, char* argv[])
-{
- int retVal = EXIT_FAILURE;
- try
- {
- // Coverity fix: The following code may throw an exception of type std::length_error.
- std::vector<ImageSet> imageSet =
- {
- {"Dog.jpg", 209},
- // Top five predictions in tensorflow:
- // -----------------------------------
- // 209:Labrador retriever 0.46392533
- // 160:Rhodesian ridgeback 0.29911423
- // 208:golden retriever 0.108059585
- // 169:redbone 0.033753652
- // 274:dingo, warrigal, warragal, ... 0.01232666
-
- {"Cat.jpg", 283},
- // Top five predictions in tensorflow:
- // -----------------------------------
- // 283:tiger cat 0.6508582
- // 286:Egyptian cat 0.2604343
- // 282:tabby, tabby cat 0.028786005
- // 288:lynx, catamount 0.020673484
- // 40:common iguana, iguana, ... 0.0080499435
-
- {"shark.jpg", 3},
- // Top five predictions in tensorflow:
- // -----------------------------------
- // 3:great white shark, white shark, ... 0.96672016
- // 4:tiger shark, Galeocerdo cuvieri 0.028302953
- // 149:killer whale, killer, orca, ... 0.0020228163
- // 5:hammerhead, hammerhead shark 0.0017547971
- // 150:dugong, Dugong dugon 0.0003968083
- };
-
- armnn::TensorShape inputTensorShape({ 1, 224, 224, 3 });
-
- using DataType = float;
- using DatabaseType = ImagePreprocessor<float>;
- using ParserType = armnnTfParser::ITfParser;
- using ModelType = InferenceModel<ParserType, DataType>;
-
- // Coverity fix: ClassifierInferenceTestMain() may throw uncaught exceptions.
- retVal = armnn::test::ClassifierInferenceTestMain<DatabaseType, ParserType>(
- argc, argv,
- "mobilenet_v1_1.0_224_frozen.pb", // model name
- true, // model is binary
- "input", "MobilenetV1/Predictions/Reshape_1", // input and output tensor names
- { 0, 1, 2 }, // test images to test with as above
- [&imageSet](const char* dataDir, const ModelType&) {
- // This creates a 224x224x3 NHWC float tensor to pass to Armnn
- return DatabaseType(
- dataDir,
- 224,
- 224,
- imageSet);
- },
- &inputTensorShape);
- }
- catch (const std::exception& e)
- {
- // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
- // exception of type std::length_error.
- // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
- std::cerr << "WARNING: TfMobileNet-Armnn: An error has occurred when running "
- "the classifier inference tests: " << e.what() << std::endl;
- }
- return retVal;
-}
diff --git a/tests/TfMobileNet-Armnn/Validation.txt b/tests/TfMobileNet-Armnn/Validation.txt
deleted file mode 100644
index 94a11bdabc..0000000000
--- a/tests/TfMobileNet-Armnn/Validation.txt
+++ /dev/null
@@ -1,201 +0,0 @@
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3
-209
-283
-3 \ No newline at end of file
diff --git a/tests/TfMobileNet-Armnn/labels.txt b/tests/TfMobileNet-Armnn/labels.txt
deleted file mode 100644
index d74ff557dd..0000000000
--- a/tests/TfMobileNet-Armnn/labels.txt
+++ /dev/null
@@ -1,1001 +0,0 @@
-0:background
-1:tench, Tinca tinca
-2:goldfish, Carassius auratus
-3:great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias
-4:tiger shark, Galeocerdo cuvieri
-5:hammerhead, hammerhead shark
-6:electric ray, crampfish, numbfish, torpedo
-7:stingray
-8:cock
-9:hen
-10:ostrich, Struthio camelus
-11:brambling, Fringilla montifringilla
-12:goldfinch, Carduelis carduelis
-13:house finch, linnet, Carpodacus mexicanus
-14:junco, snowbird
-15:indigo bunting, indigo finch, indigo bird, Passerina cyanea
-16:robin, American robin, Turdus migratorius
-17:bulbul
-18:jay
-19:magpie
-20:chickadee
-21:water ouzel, dipper
-22:kite
-23:bald eagle, American eagle, Haliaeetus leucocephalus
-24:vulture
-25:great grey owl, great gray owl, Strix nebulosa
-26:European fire salamander, Salamandra salamandra
-27:common newt, Triturus vulgaris
-28:eft
-29:spotted salamander, Ambystoma maculatum
-30:axolotl, mud puppy, Ambystoma mexicanum
-31:bullfrog, Rana catesbeiana
-32:tree frog, tree-frog
-33:tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui
-34:loggerhead, loggerhead turtle, Caretta caretta
-35:leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea
-36:mud turtle
-37:terrapin
-38:box turtle, box tortoise
-39:banded gecko
-40:common iguana, iguana, Iguana iguana
-41:American chameleon, anole, Anolis carolinensis
-42:whiptail, whiptail lizard
-43:agama
-44:frilled lizard, Chlamydosaurus kingi
-45:alligator lizard
-46:Gila monster, Heloderma suspectum
-47:green lizard, Lacerta viridis
-48:African chameleon, Chamaeleo chamaeleon
-49:Komodo dragon, Komodo lizard, dragon lizard, giant lizard, Varanus komodoensis
-50:African crocodile, Nile crocodile, Crocodylus niloticus
-51:American alligator, Alligator mississipiensis
-52:triceratops
-53:thunder snake, worm snake, Carphophis amoenus
-54:ringneck snake, ring-necked snake, ring snake
-55:hognose snake, puff adder, sand viper
-56:green snake, grass snake
-57:king snake, kingsnake
-58:garter snake, grass snake
-59:water snake
-60:vine snake
-61:night snake, Hypsiglena torquata
-62:boa constrictor, Constrictor constrictor
-63:rock python, rock snake, Python sebae
-64:Indian cobra, Naja naja
-65:green mamba
-66:sea snake
-67:horned viper, cerastes, sand viper, horned asp, Cerastes cornutus
-68:diamondback, diamondback rattlesnake, Crotalus adamanteus
-69:sidewinder, horned rattlesnake, Crotalus cerastes
-70:trilobite
-71:harvestman, daddy longlegs, Phalangium opilio
-72:scorpion
-73:black and gold garden spider, Argiope aurantia
-74:barn spider, Araneus cavaticus
-75:garden spider, Aranea diademata
-76:black widow, Latrodectus mactans
-77:tarantula
-78:wolf spider, hunting spider
-79:tick
-80:centipede
-81:black grouse
-82:ptarmigan
-83:ruffed grouse, partridge, Bonasa umbellus
-84:prairie chicken, prairie grouse, prairie fowl
-85:peacock
-86:quail
-87:partridge
-88:African grey, African gray, Psittacus erithacus
-89:macaw
-90:sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita
-91:lorikeet
-92:coucal
-93:bee eater
-94:hornbill
-95:hummingbird
-96:jacamar
-97:toucan
-98:drake
-99:red-breasted merganser, Mergus serrator
-100:goose
-101:black swan, Cygnus atratus
-102:tusker
-103:echidna, spiny anteater, anteater
-104:platypus, duckbill, duckbilled platypus, duck-billed platypus, Ornithorhynchus anatinus
-105:wallaby, brush kangaroo
-106:koala, koala bear, kangaroo bear, native bear, Phascolarctos cinereus
-107:wombat
-108:jellyfish
-109:sea anemone, anemone
-110:brain coral
-111:flatworm, platyhelminth
-112:nematode, nematode worm, roundworm
-113:conch
-114:snail
-115:slug
-116:sea slug, nudibranch
-117:chiton, coat-of-mail shell, sea cradle, polyplacophore
-118:chambered nautilus, pearly nautilus, nautilus
-119:Dungeness crab, Cancer magister
-120:rock crab, Cancer irroratus
-121:fiddler crab
-122:king crab, Alaska crab, Alaskan king crab, Alaska king crab, Paralithodes camtschatica
-123:American lobster, Northern lobster, Maine lobster, Homarus americanus
-124:spiny lobster, langouste, rock lobster, crawfish, crayfish, sea crawfish
-125:crayfish, crawfish, crawdad, crawdaddy
-126:hermit crab
-127:isopod
-128:white stork, Ciconia ciconia
-129:black stork, Ciconia nigra
-130:spoonbill
-131:flamingo
-132:little blue heron, Egretta caerulea
-133:American egret, great white heron, Egretta albus
-134:bittern
-135:crane
-136:limpkin, Aramus pictus
-137:European gallinule, Porphyrio porphyrio
-138:American coot, marsh hen, mud hen, water hen, Fulica americana
-139:bustard
-140:ruddy turnstone, Arenaria interpres
-141:red-backed sandpiper, dunlin, Erolia alpina
-142:redshank, Tringa totanus
-143:dowitcher
-144:oystercatcher, oyster catcher
-145:pelican
-146:king penguin, Aptenodytes patagonica
-147:albatross, mollymawk
-148:grey whale, gray whale, devilfish, Eschrichtius gibbosus, Eschrichtius robustus
-149:killer whale, killer, orca, grampus, sea wolf, Orcinus orca
-150:dugong, Dugong dugon
-151:sea lion
-152:Chihuahua
-153:Japanese spaniel
-154:Maltese dog, Maltese terrier, Maltese
-155:Pekinese, Pekingese, Peke
-156:Shih-Tzu
-157:Blenheim spaniel
-158:papillon
-159:toy terrier
-160:Rhodesian ridgeback
-161:Afghan hound, Afghan
-162:basset, basset hound
-163:beagle
-164:bloodhound, sleuthhound
-165:bluetick
-166:black-and-tan coonhound
-167:Walker hound, Walker foxhound
-168:English foxhound
-169:redbone
-170:borzoi, Russian wolfhound
-171:Irish wolfhound
-172:Italian greyhound
-173:whippet
-174:Ibizan hound, Ibizan Podenco
-175:Norwegian elkhound, elkhound
-176:otterhound, otter hound
-177:Saluki, gazelle hound
-178:Scottish deerhound, deerhound
-179:Weimaraner
-180:Staffordshire bullterrier, Staffordshire bull terrier
-181:American Staffordshire terrier, Staffordshire terrier, American pit bull terrier, pit bull terrier
-182:Bedlington terrier
-183:Border terrier
-184:Kerry blue terrier
-185:Irish terrier
-186:Norfolk terrier
-187:Norwich terrier
-188:Yorkshire terrier
-189:wire-haired fox terrier
-190:Lakeland terrier
-191:Sealyham terrier, Sealyham
-192:Airedale, Airedale terrier
-193:cairn, cairn terrier
-194:Australian terrier
-195:Dandie Dinmont, Dandie Dinmont terrier
-196:Boston bull, Boston terrier
-197:miniature schnauzer
-198:giant schnauzer
-199:standard schnauzer
-200:Scotch terrier, Scottish terrier, Scottie
-201:Tibetan terrier, chrysanthemum dog
-202:silky terrier, Sydney silky
-203:soft-coated wheaten terrier
-204:West Highland white terrier
-205:Lhasa, Lhasa apso
-206:flat-coated retriever
-207:curly-coated retriever
-208:golden retriever
-209:Labrador retriever
-210:Chesapeake Bay retriever
-211:German short-haired pointer
-212:vizsla, Hungarian pointer
-213:English setter
-214:Irish setter, red setter
-215:Gordon setter
-216:Brittany spaniel
-217:clumber, clumber spaniel
-218:English springer, English springer spaniel
-219:Welsh springer spaniel
-220:cocker spaniel, English cocker spaniel, cocker
-221:Sussex spaniel
-222:Irish water spaniel
-223:kuvasz
-224:schipperke
-225:groenendael
-226:malinois
-227:briard
-228:kelpie
-229:komondor
-230:Old English sheepdog, bobtail
-231:Shetland sheepdog, Shetland sheep dog, Shetland
-232:collie
-233:Border collie
-234:Bouvier des Flandres, Bouviers des Flandres
-235:Rottweiler
-236:German shepherd, German shepherd dog, German police dog, alsatian
-237:Doberman, Doberman pinscher
-238:miniature pinscher
-239:Greater Swiss Mountain dog
-240:Bernese mountain dog
-241:Appenzeller
-242:EntleBucher
-243:boxer
-244:bull mastiff
-245:Tibetan mastiff
-246:French bulldog
-247:Great Dane
-248:Saint Bernard, St Bernard
-249:Eskimo dog, husky
-250:malamute, malemute, Alaskan malamute
-251:Siberian husky
-252:dalmatian, coach dog, carriage dog
-253:affenpinscher, monkey pinscher, monkey dog
-254:basenji
-255:pug, pug-dog
-256:Leonberg
-257:Newfoundland, Newfoundland dog
-258:Great Pyrenees
-259:Samoyed, Samoyede
-260:Pomeranian
-261:chow, chow chow
-262:keeshond
-263:Brabancon griffon
-264:Pembroke, Pembroke Welsh corgi
-265:Cardigan, Cardigan Welsh corgi
-266:toy poodle
-267:miniature poodle
-268:standard poodle
-269:Mexican hairless
-270:timber wolf, grey wolf, gray wolf, Canis lupus
-271:white wolf, Arctic wolf, Canis lupus tundrarum
-272:red wolf, maned wolf, Canis rufus, Canis niger
-273:coyote, prairie wolf, brush wolf, Canis latrans
-274:dingo, warrigal, warragal, Canis dingo
-275:dhole, Cuon alpinus
-276:African hunting dog, hyena dog, Cape hunting dog, Lycaon pictus
-277:hyena, hyaena
-278:red fox, Vulpes vulpes
-279:kit fox, Vulpes macrotis
-280:Arctic fox, white fox, Alopex lagopus
-281:grey fox, gray fox, Urocyon cinereoargenteus
-282:tabby, tabby cat
-283:tiger cat
-284:Persian cat
-285:Siamese cat, Siamese
-286:Egyptian cat
-287:cougar, puma, catamount, mountain lion, painter, panther, Felis concolor
-288:lynx, catamount
-289:leopard, Panthera pardus
-290:snow leopard, ounce, Panthera uncia
-291:jaguar, panther, Panthera onca, Felis onca
-292:lion, king of beasts, Panthera leo
-293:tiger, Panthera tigris
-294:cheetah, chetah, Acinonyx jubatus
-295:brown bear, bruin, Ursus arctos
-296:American black bear, black bear, Ursus americanus, Euarctos americanus
-297:ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus
-298:sloth bear, Melursus ursinus, Ursus ursinus
-299:mongoose
-300:meerkat, mierkat
-301:tiger beetle
-302:ladybug, ladybeetle, lady beetle, ladybird, ladybird beetle
-303:ground beetle, carabid beetle
-304:long-horned beetle, longicorn, longicorn beetle
-305:leaf beetle, chrysomelid
-306:dung beetle
-307:rhinoceros beetle
-308:weevil
-309:fly
-310:bee
-311:ant, emmet, pismire
-312:grasshopper, hopper
-313:cricket
-314:walking stick, walkingstick, stick insect
-315:cockroach, roach
-316:mantis, mantid
-317:cicada, cicala
-318:leafhopper
-319:lacewing, lacewing fly
-320:dragonfly, darning needle, devil's darning needle, sewing needle, snake feeder, snake doctor, mosquito hawk, skeeter hawk
-321:damselfly
-322:admiral
-323:ringlet, ringlet butterfly
-324:monarch, monarch butterfly, milkweed butterfly, Danaus plexippus
-325:cabbage butterfly
-326:sulphur butterfly, sulfur butterfly
-327:lycaenid, lycaenid butterfly
-328:starfish, sea star
-329:sea urchin
-330:sea cucumber, holothurian
-331:wood rabbit, cottontail, cottontail rabbit
-332:hare
-333:Angora, Angora rabbit
-334:hamster
-335:porcupine, hedgehog
-336:fox squirrel, eastern fox squirrel, Sciurus niger
-337:marmot
-338:beaver
-339:guinea pig, Cavia cobaya
-340:sorrel
-341:zebra
-342:hog, pig, grunter, squealer, Sus scrofa
-343:wild boar, boar, Sus scrofa
-344:warthog
-345:hippopotamus, hippo, river horse, Hippopotamus amphibius
-346:ox
-347:water buffalo, water ox, Asiatic buffalo, Bubalus bubalis
-348:bison
-349:ram, tup
-350:bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis
-351:ibex, Capra ibex
-352:hartebeest
-353:impala, Aepyceros melampus
-354:gazelle
-355:Arabian camel, dromedary, Camelus dromedarius
-356:llama
-357:weasel
-358:mink
-359:polecat, fitch, foulmart, foumart, Mustela putorius
-360:black-footed ferret, ferret, Mustela nigripes
-361:otter
-362:skunk, polecat, wood pussy
-363:badger
-364:armadillo
-365:three-toed sloth, ai, Bradypus tridactylus
-366:orangutan, orang, orangutang, Pongo pygmaeus
-367:gorilla, Gorilla gorilla
-368:chimpanzee, chimp, Pan troglodytes
-369:gibbon, Hylobates lar
-370:siamang, Hylobates syndactylus, Symphalangus syndactylus
-371:guenon, guenon monkey
-372:patas, hussar monkey, Erythrocebus patas
-373:baboon
-374:macaque
-375:langur
-376:colobus, colobus monkey
-377:proboscis monkey, Nasalis larvatus
-378:marmoset
-379:capuchin, ringtail, Cebus capucinus
-380:howler monkey, howler
-381:titi, titi monkey
-382:spider monkey, Ateles geoffroyi
-383:squirrel monkey, Saimiri sciureus
-384:Madagascar cat, ring-tailed lemur, Lemur catta
-385:indri, indris, Indri indri, Indri brevicaudatus
-386:Indian elephant, Elephas maximus
-387:African elephant, Loxodonta africana
-388:lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens
-389:giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca
-390:barracouta, snoek
-391:eel
-392:coho, cohoe, coho salmon, blue jack, silver salmon, Oncorhynchus kisutch
-393:rock beauty, Holocanthus tricolor
-394:anemone fish
-395:sturgeon
-396:gar, garfish, garpike, billfish, Lepisosteus osseus
-397:lionfish
-398:puffer, pufferfish, blowfish, globefish
-399:abacus
-400:abaya
-401:academic gown, academic robe, judge's robe
-402:accordion, piano accordion, squeeze box
-403:acoustic guitar
-404:aircraft carrier, carrier, flattop, attack aircraft carrier
-405:airliner
-406:airship, dirigible
-407:altar
-408:ambulance
-409:amphibian, amphibious vehicle
-410:analog clock
-411:apiary, bee house
-412:apron
-413:ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin
-414:assault rifle, assault gun
-415:backpack, back pack, knapsack, packsack, rucksack, haversack
-416:bakery, bakeshop, bakehouse
-417:balance beam, beam
-418:balloon
-419:ballpoint, ballpoint pen, ballpen, Biro
-420:Band Aid
-421:banjo
-422:bannister, banister, balustrade, balusters, handrail
-423:barbell
-424:barber chair
-425:barbershop
-426:barn
-427:barometer
-428:barrel, cask
-429:barrow, garden cart, lawn cart, wheelbarrow
-430:baseball
-431:basketball
-432:bassinet
-433:bassoon
-434:bathing cap, swimming cap
-435:bath towel
-436:bathtub, bathing tub, bath, tub
-437:beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon
-438:beacon, lighthouse, beacon light, pharos
-439:beaker
-440:bearskin, busby, shako
-441:beer bottle
-442:beer glass
-443:bell cote, bell cot
-444:bib
-445:bicycle-built-for-two, tandem bicycle, tandem
-446:bikini, two-piece
-447:binder, ring-binder
-448:binoculars, field glasses, opera glasses
-449:birdhouse
-450:boathouse
-451:bobsled, bobsleigh, bob
-452:bolo tie, bolo, bola tie, bola
-453:bonnet, poke bonnet
-454:bookcase
-455:bookshop, bookstore, bookstall
-456:bottlecap
-457:bow
-458:bow tie, bow-tie, bowtie
-459:brass, memorial tablet, plaque
-460:brassiere, bra, bandeau
-461:breakwater, groin, groyne, mole, bulwark, seawall, jetty
-462:breastplate, aegis, egis
-463:broom
-464:bucket, pail
-465:buckle
-466:bulletproof vest
-467:bullet train, bullet
-468:butcher shop, meat market
-469:cab, hack, taxi, taxicab
-470:caldron, cauldron
-471:candle, taper, wax light
-472:cannon
-473:canoe
-474:can opener, tin opener
-475:cardigan
-476:car mirror
-477:carousel, carrousel, merry-go-round, roundabout, whirligig
-478:carpenter's kit, tool kit
-479:carton
-480:car wheel
-481:cash machine, cash dispenser, automated teller machine, automatic teller machine, automated teller, automatic teller, ATM
-482:cassette
-483:cassette player
-484:castle
-485:catamaran
-486:CD player
-487:cello, violoncello
-488:cellular telephone, cellular phone, cellphone, cell, mobile phone
-489:chain
-490:chainlink fence
-491:chain mail, ring mail, mail, chain armor, chain armour, ring armor, ring armour
-492:chain saw, chainsaw
-493:chest
-494:chiffonier, commode
-495:chime, bell, gong
-496:china cabinet, china closet
-497:Christmas stocking
-498:church, church building
-499:cinema, movie theater, movie theatre, movie house, picture palace
-500:cleaver, meat cleaver, chopper
-501:cliff dwelling
-502:cloak
-503:clog, geta, patten, sabot
-504:cocktail shaker
-505:coffee mug
-506:coffeepot
-507:coil, spiral, volute, whorl, helix
-508:combination lock
-509:computer keyboard, keypad
-510:confectionery, confectionary, candy store
-511:container ship, containership, container vessel
-512:convertible
-513:corkscrew, bottle screw
-514:cornet, horn, trumpet, trump
-515:cowboy boot
-516:cowboy hat, ten-gallon hat
-517:cradle
-518:crane
-519:crash helmet
-520:crate
-521:crib, cot
-522:Crock Pot
-523:croquet ball
-524:crutch
-525:cuirass
-526:dam, dike, dyke
-527:desk
-528:desktop computer
-529:dial telephone, dial phone
-530:diaper, nappy, napkin
-531:digital clock
-532:digital watch
-533:dining table, board
-534:dishrag, dishcloth
-535:dishwasher, dish washer, dishwashing machine
-536:disk brake, disc brake
-537:dock, dockage, docking facility
-538:dogsled, dog sled, dog sleigh
-539:dome
-540:doormat, welcome mat
-541:drilling platform, offshore rig
-542:drum, membranophone, tympan
-543:drumstick
-544:dumbbell
-545:Dutch oven
-546:electric fan, blower
-547:electric guitar
-548:electric locomotive
-549:entertainment center
-550:envelope
-551:espresso maker
-552:face powder
-553:feather boa, boa
-554:file, file cabinet, filing cabinet
-555:fireboat
-556:fire engine, fire truck
-557:fire screen, fireguard
-558:flagpole, flagstaff
-559:flute, transverse flute
-560:folding chair
-561:football helmet
-562:forklift
-563:fountain
-564:fountain pen
-565:four-poster
-566:freight car
-567:French horn, horn
-568:frying pan, frypan, skillet
-569:fur coat
-570:garbage truck, dustcart
-571:gasmask, respirator, gas helmet
-572:gas pump, gasoline pump, petrol pump, island dispenser
-573:goblet
-574:go-kart
-575:golf ball
-576:golfcart, golf cart
-577:gondola
-578:gong, tam-tam
-579:gown
-580:grand piano, grand
-581:greenhouse, nursery, glasshouse
-582:grille, radiator grille
-583:grocery store, grocery, food market, market
-584:guillotine
-585:hair slide
-586:hair spray
-587:half track
-588:hammer
-589:hamper
-590:hand blower, blow dryer, blow drier, hair dryer, hair drier
-591:hand-held computer, hand-held microcomputer
-592:handkerchief, hankie, hanky, hankey
-593:hard disc, hard disk, fixed disk
-594:harmonica, mouth organ, harp, mouth harp
-595:harp
-596:harvester, reaper
-597:hatchet
-598:holster
-599:home theater, home theatre
-600:honeycomb
-601:hook, claw
-602:hoopskirt, crinoline
-603:horizontal bar, high bar
-604:horse cart, horse-cart
-605:hourglass
-606:iPod
-607:iron, smoothing iron
-608:jack-o'-lantern
-609:jean, blue jean, denim
-610:jeep, landrover
-611:jersey, T-shirt, tee shirt
-612:jigsaw puzzle
-613:jinrikisha, ricksha, rickshaw
-614:joystick
-615:kimono
-616:knee pad
-617:knot
-618:lab coat, laboratory coat
-619:ladle
-620:lampshade, lamp shade
-621:laptop, laptop computer
-622:lawn mower, mower
-623:lens cap, lens cover
-624:letter opener, paper knife, paperknife
-625:library
-626:lifeboat
-627:lighter, light, igniter, ignitor
-628:limousine, limo
-629:liner, ocean liner
-630:lipstick, lip rouge
-631:Loafer
-632:lotion
-633:loudspeaker, speaker, speaker unit, loudspeaker system, speaker system
-634:loupe, jeweler's loupe
-635:lumbermill, sawmill
-636:magnetic compass
-637:mailbag, postbag
-638:mailbox, letter box
-639:maillot
-640:maillot, tank suit
-641:manhole cover
-642:maraca
-643:marimba, xylophone
-644:mask
-645:matchstick
-646:maypole
-647:maze, labyrinth
-648:measuring cup
-649:medicine chest, medicine cabinet
-650:megalith, megalithic structure
-651:microphone, mike
-652:microwave, microwave oven
-653:military uniform
-654:milk can
-655:minibus
-656:miniskirt, mini
-657:minivan
-658:missile
-659:mitten
-660:mixing bowl
-661:mobile home, manufactured home
-662:Model T
-663:modem
-664:monastery
-665:monitor
-666:moped
-667:mortar
-668:mortarboard
-669:mosque
-670:mosquito net
-671:motor scooter, scooter
-672:mountain bike, all-terrain bike, off-roader
-673:mountain tent
-674:mouse, computer mouse
-675:mousetrap
-676:moving van
-677:muzzle
-678:nail
-679:neck brace
-680:necklace
-681:nipple
-682:notebook, notebook computer
-683:obelisk
-684:oboe, hautboy, hautbois
-685:ocarina, sweet potato
-686:odometer, hodometer, mileometer, milometer
-687:oil filter
-688:organ, pipe organ
-689:oscilloscope, scope, cathode-ray oscilloscope, CRO
-690:overskirt
-691:oxcart
-692:oxygen mask
-693:packet
-694:paddle, boat paddle
-695:paddlewheel, paddle wheel
-696:padlock
-697:paintbrush
-698:pajama, pyjama, pj's, jammies
-699:palace
-700:panpipe, pandean pipe, syrinx
-701:paper towel
-702:parachute, chute
-703:parallel bars, bars
-704:park bench
-705:parking meter
-706:passenger car, coach, carriage
-707:patio, terrace
-708:pay-phone, pay-station
-709:pedestal, plinth, footstall
-710:pencil box, pencil case
-711:pencil sharpener
-712:perfume, essence
-713:Petri dish
-714:photocopier
-715:pick, plectrum, plectron
-716:pickelhaube
-717:picket fence, paling
-718:pickup, pickup truck
-719:pier
-720:piggy bank, penny bank
-721:pill bottle
-722:pillow
-723:ping-pong ball
-724:pinwheel
-725:pirate, pirate ship
-726:pitcher, ewer
-727:plane, carpenter's plane, woodworking plane
-728:planetarium
-729:plastic bag
-730:plate rack
-731:plow, plough
-732:plunger, plumber's helper
-733:Polaroid camera, Polaroid Land camera
-734:pole
-735:police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria
-736:poncho
-737:pool table, billiard table, snooker table
-738:pop bottle, soda bottle
-739:pot, flowerpot
-740:potter's wheel
-741:power drill
-742:prayer rug, prayer mat
-743:printer
-744:prison, prison house
-745:projectile, missile
-746:projector
-747:puck, hockey puck
-748:punching bag, punch bag, punching ball, punchball
-749:purse
-750:quill, quill pen
-751:quilt, comforter, comfort, puff
-752:racer, race car, racing car
-753:racket, racquet
-754:radiator
-755:radio, wireless
-756:radio telescope, radio reflector
-757:rain barrel
-758:recreational vehicle, RV, R.V.
-759:reel
-760:reflex camera
-761:refrigerator, icebox
-762:remote control, remote
-763:restaurant, eating house, eating place, eatery
-764:revolver, six-gun, six-shooter
-765:rifle
-766:rocking chair, rocker
-767:rotisserie
-768:rubber eraser, rubber, pencil eraser
-769:rugby ball
-770:rule, ruler
-771:running shoe
-772:safe
-773:safety pin
-774:saltshaker, salt shaker
-775:sandal
-776:sarong
-777:sax, saxophone
-778:scabbard
-779:scale, weighing machine
-780:school bus
-781:schooner
-782:scoreboard
-783:screen, CRT screen
-784:screw
-785:screwdriver
-786:seat belt, seatbelt
-787:sewing machine
-788:shield, buckler
-789:shoe shop, shoe-shop, shoe store
-790:shoji
-791:shopping basket
-792:shopping cart
-793:shovel
-794:shower cap
-795:shower curtain
-796:ski
-797:ski mask
-798:sleeping bag
-799:slide rule, slipstick
-800:sliding door
-801:slot, one-armed bandit
-802:snorkel
-803:snowmobile
-804:snowplow, snowplough
-805:soap dispenser
-806:soccer ball
-807:sock
-808:solar dish, solar collector, solar furnace
-809:sombrero
-810:soup bowl
-811:space bar
-812:space heater
-813:space shuttle
-814:spatula
-815:speedboat
-816:spider web, spider's web
-817:spindle
-818:sports car, sport car
-819:spotlight, spot
-820:stage
-821:steam locomotive
-822:steel arch bridge
-823:steel drum
-824:stethoscope
-825:stole
-826:stone wall
-827:stopwatch, stop watch
-828:stove
-829:strainer
-830:streetcar, tram, tramcar, trolley, trolley car
-831:stretcher
-832:studio couch, day bed
-833:stupa, tope
-834:submarine, pigboat, sub, U-boat
-835:suit, suit of clothes
-836:sundial
-837:sunglass
-838:sunglasses, dark glasses, shades
-839:sunscreen, sunblock, sun blocker
-840:suspension bridge
-841:swab, swob, mop
-842:sweatshirt
-843:swimming trunks, bathing trunks
-844:swing
-845:switch, electric switch, electrical switch
-846:syringe
-847:table lamp
-848:tank, army tank, armored combat vehicle, armoured combat vehicle
-849:tape player
-850:teapot
-851:teddy, teddy bear
-852:television, television system
-853:tennis ball
-854:thatch, thatched roof
-855:theater curtain, theatre curtain
-856:thimble
-857:thresher, thrasher, threshing machine
-858:throne
-859:tile roof
-860:toaster
-861:tobacco shop, tobacconist shop, tobacconist
-862:toilet seat
-863:torch
-864:totem pole
-865:tow truck, tow car, wrecker
-866:toyshop
-867:tractor
-868:trailer truck, tractor trailer, trucking rig, rig, articulated lorry, semi
-869:tray
-870:trench coat
-871:tricycle, trike, velocipede
-872:trimaran
-873:tripod
-874:triumphal arch
-875:trolleybus, trolley coach, trackless trolley
-876:trombone
-877:tub, vat
-878:turnstile
-879:typewriter keyboard
-880:umbrella
-881:unicycle, monocycle
-882:upright, upright piano
-883:vacuum, vacuum cleaner
-884:vase
-885:vault
-886:velvet
-887:vending machine
-888:vestment
-889:viaduct
-890:violin, fiddle
-891:volleyball
-892:waffle iron
-893:wall clock
-894:wallet, billfold, notecase, pocketbook
-895:wardrobe, closet, press
-896:warplane, military plane
-897:washbasin, handbasin, washbowl, lavabo, wash-hand basin
-898:washer, automatic washer, washing machine
-899:water bottle
-900:water jug
-901:water tower
-902:whiskey jug
-903:whistle
-904:wig
-905:window screen
-906:window shade
-907:Windsor tie
-908:wine bottle
-909:wing
-910:wok
-911:wooden spoon
-912:wool, woolen, woollen
-913:worm fence, snake fence, snake-rail fence, Virginia fence
-914:wreck
-915:yawl
-916:yurt
-917:web site, website, internet site, site
-918:comic book
-919:crossword puzzle, crossword
-920:street sign
-921:traffic light, traffic signal, stoplight
-922:book jacket, dust cover, dust jacket, dust wrapper
-923:menu
-924:plate
-925:guacamole
-926:consomme
-927:hot pot, hotpot
-928:trifle
-929:ice cream, icecream
-930:ice lolly, lolly, lollipop, popsicle
-931:French loaf
-932:bagel, beigel
-933:pretzel
-934:cheeseburger
-935:hotdog, hot dog, red hot
-936:mashed potato
-937:head cabbage
-938:broccoli
-939:cauliflower
-940:zucchini, courgette
-941:spaghetti squash
-942:acorn squash
-943:butternut squash
-944:cucumber, cuke
-945:artichoke, globe artichoke
-946:bell pepper
-947:cardoon
-948:mushroom
-949:Granny Smith
-950:strawberry
-951:orange
-952:lemon
-953:fig
-954:pineapple, ananas
-955:banana
-956:jackfruit, jak, jack
-957:custard apple
-958:pomegranate
-959:hay
-960:carbonara
-961:chocolate sauce, chocolate syrup
-962:dough
-963:meat loaf, meatloaf
-964:pizza, pizza pie
-965:potpie
-966:burrito
-967:red wine
-968:espresso
-969:cup
-970:eggnog
-971:alp
-972:bubble
-973:cliff, drop, drop-off
-974:coral reef
-975:geyser
-976:lakeside, lakeshore
-977:promontory, headland, head, foreland
-978:sandbar, sand bar
-979:seashore, coast, seacoast, sea-coast
-980:valley, vale
-981:volcano
-982:ballplayer, baseball player
-983:groom, bridegroom
-984:scuba diver
-985:rapeseed
-986:daisy
-987:yellow lady's slipper, yellow lady-slipper, Cypripedium calceolus, Cypripedium parviflorum
-988:corn
-989:acorn
-990:hip, rose hip, rosehip
-991:buckeye, horse chestnut, conker
-992:coral fungus
-993:agaric
-994:gyromitra
-995:stinkhorn, carrion fungus
-996:earthstar
-997:hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa
-998:bolete
-999:ear, spike, capitulum
-1000:toilet tissue, toilet paper, bathroom tissue
diff --git a/tests/TfResNext_Quantized-Armnn/TfResNext_Quantized-Armnn.cpp b/tests/TfResNext_Quantized-Armnn/TfResNext_Quantized-Armnn.cpp
deleted file mode 100644
index bec2771d4b..0000000000
--- a/tests/TfResNext_Quantized-Armnn/TfResNext_Quantized-Armnn.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// Copyright © 2017 Arm Ltd. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-#include "../InferenceTest.hpp"
-#include "../ImagePreprocessor.hpp"
-#include "armnnTfParser/ITfParser.hpp"
-
-int main(int argc, char* argv[])
-{
- int retVal = EXIT_FAILURE;
- try
- {
- // Coverity fix: The following code may throw an exception of type std::length_error.
- std::vector<ImageSet> imageSet =
- {
- {"ILSVRC2012_val_00000018.JPEG", 21 },
- {"shark.jpg", 2}
- };
-
- armnn::TensorShape inputTensorShape({ 1, 3, 224, 224 });
-
- using DataType = float;
- using DatabaseType = ImagePreprocessor<DataType>;;
- using ParserType = armnnTfParser::ITfParser;
- using ModelType = InferenceModel<ParserType, DataType>;
-
- // Coverity fix: ClassifierInferenceTestMain() may throw uncaught exceptions.
- retVal = armnn::test::ClassifierInferenceTestMain<DatabaseType, ParserType>(
- argc, argv, "resnext_TF_quantized_for_armnn_team.pb", true,
- "inputs", "pool1", { 0, 1 },
- [&imageSet](const char* dataDir, const ModelType &) {
- return DatabaseType(dataDir, 224, 224, imageSet);
- },
- &inputTensorShape);
- }
- catch (const std::exception& e)
- {
- // Coverity fix: BOOST_LOG_TRIVIAL (typically used to report errors) may throw an
- // exception of type std::length_error.
- // Using stderr instead in this context as there is no point in nesting try-catch blocks here.
- std::cerr << "WARNING: TfResNext_Quantized-Armnn: An error has occurred when running "
- "the classifier inference tests: " << e.what() << std::endl;
- }
- return retVal;
-}