diff options
Diffstat (limited to 'src/armnnTfParser/test')
42 files changed, 0 insertions, 7747 deletions
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() |