From 50de4fa4e7e0dd02a442ba350a1b40f293cb5a01 Mon Sep 17 00:00:00 2001 From: Teresa Charlin Date: Mon, 31 May 2021 18:47:33 +0100 Subject: IVGCVSW-6088 Add Sin and Log to ElementWiseUnary * Ref workload * Cl workload * Neon workload * Serializer * Deserializer * Remove boost include from TensorTest.cpp Signed-off-by: Teresa Charlin Change-Id: I498548169cc77609c55cf3105f1de5a7429772cf --- .../test/DeserializeElementwiseUnary.cpp | 173 +++++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 src/armnnDeserializer/test/DeserializeElementwiseUnary.cpp (limited to 'src/armnnDeserializer/test') diff --git a/src/armnnDeserializer/test/DeserializeElementwiseUnary.cpp b/src/armnnDeserializer/test/DeserializeElementwiseUnary.cpp new file mode 100644 index 0000000000..0a89f48f18 --- /dev/null +++ b/src/armnnDeserializer/test/DeserializeElementwiseUnary.cpp @@ -0,0 +1,173 @@ +// +// Copyright © 2021 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "ParserFlatbuffersSerializeFixture.hpp" +#include + +#include + +TEST_SUITE(Deserializer) +{ +struct ElementwiseUnaryFixture : public ParserFlatbuffersSerializeFixture +{ + explicit ElementwiseUnaryFixture(const std::string& inputShape, + const std::string& outputShape, + const std::string& dataType, + const std::string& unaryOperation = "Abs") + { + m_JsonString = R"( + { + inputIds: [0], + outputIds: [2], + layers: [ + { + layer_type: "InputLayer", + layer: { + base: { + layerBindingId: 0, + base: { + index: 0, + layerName: "InputLayer", + layerType: "Input", + inputSlots: [{ + index: 0, + connection: {sourceLayerIndex:0, outputSlotIndex:0 }, + }], + outputSlots: [{ + index: 0, + tensorInfo: { + dimensions: )" + inputShape + R"(, + dataType: )" + dataType + R"( + } + }] + } + } + } + }, + { + layer_type: "ElementwiseUnaryLayer", + layer: { + base: { + index: 1, + layerName: "ElementwiseUnaryLayer", + layerType: "ElementwiseUnary", + inputSlots: [{ + index: 0, + connection: {sourceLayerIndex:0, outputSlotIndex:0 }, + }], + outputSlots: [{ + index: 0, + tensorInfo: { + dimensions: )" + outputShape + R"(, + dataType: )" + dataType + R"( + } + }] + }, + descriptor: { + activationFunction: )" + unaryOperation + R"( + }, + } + }, + { + layer_type: "OutputLayer", + layer: { + base:{ + layerBindingId: 2, + base: { + index: 2, + layerName: "OutputLayer", + layerType: "Output", + inputSlots: [{ + index: 0, + connection: {sourceLayerIndex:1, outputSlotIndex:0 }, + }], + outputSlots: [{ + index: 0, + tensorInfo: { + dimensions: )" + outputShape + R"(, + dataType: )" + dataType + R"( + }, + }], + } + } + }, + } + ] + } + )"; + Setup(); + } +}; + +struct SimpleAbsFixture : ElementwiseUnaryFixture +{ + SimpleAbsFixture() : ElementwiseUnaryFixture("[ 1, 2, 2, 2 ]", // inputShape + "[ 1, 2, 2, 2 ]", // outputShape + "Float32", // dataType + "Abs") // unaryOperation + {} +}; + +FIXTURE_TEST_CASE(SimpleAbsTest, SimpleAbsFixture) +{ + RunTest<4, armnn::DataType::Float32>( + 0, + {{"InputLayer", {-100.0f, -50.5f, -25.9999f, -0.5f, 0.0f, 1.5555f, 25.5f, 100.0f}}}, + {{"OutputLayer", {100.0f, 50.5f, 25.9999f, 0.5f, 0.0f, 1.5555f, 25.5f, 100.0f}}}); +} + +struct SimpleLogFixture : ElementwiseUnaryFixture +{ + SimpleLogFixture() : ElementwiseUnaryFixture("[ 1, 2, 2, 2 ]", // inputShape + "[ 1, 2, 2, 2 ]", // outputShape + "Float32", // dataType + "Log") // unaryOperation + {} +}; + +FIXTURE_TEST_CASE(SimpleLogTest, SimpleLogFixture) +{ + RunTest<4, armnn::DataType::Float32>( + 0, + {{"InputLayer", {1.0f, 2.1f, 3.2f, 4.3f, 10.f, 100.f, 25.5f, 200.0f}}}, + {{"OutputLayer", {0.f, 0.74193734472f, 1.16315080981f, 1.4586150227f, + 2.30258509299f, 4.60517018599f, 3.23867845216f, 5.29831736655f}}}); +} + +struct SimpleNegFixture : ElementwiseUnaryFixture +{ + SimpleNegFixture() : ElementwiseUnaryFixture("[ 1, 2, 2, 2 ]", // inputShape + "[ 1, 2, 2, 2 ]", // outputShape + "Float32", // dataType + "Neg") // unaryOperation + {} +}; + +FIXTURE_TEST_CASE(SimpleNegTest, SimpleNegFixture) +{ + RunTest<4, armnn::DataType::Float32>( + 0, + {{"InputLayer", {100.0f, 50.5f, 25.9999f, 0.5f, 0.0f, -1.5555f, -25.5f, -100.0f}}}, + {{"OutputLayer", {-100.0f, -50.5f, -25.9999f, -0.5f, 0.0f, 1.5555f, 25.5f, 100.0f}}}); +} + +struct SimpleSinFixture : ElementwiseUnaryFixture +{ + SimpleSinFixture() : ElementwiseUnaryFixture("[ 1, 2, 2, 2 ]", // inputShape + "[ 1, 2, 2, 2 ]", // outputShape + "Float32", // dataType + "Sin") // unaryOperation + {} +}; + +FIXTURE_TEST_CASE(SimpleSinTest, SimpleSinFixture) +{ + RunTest<4, armnn::DataType::Float32>( + 0, + {{"InputLayer", {-100.0f, -50.5f, -25.9999f, -0.5f, 0.0f, 1.5555f, 25.5f, 100.0f}}}, + {{"OutputLayer", {0.50636564111f, -0.23237376165f, -0.76249375473f, -0.4794255386f, + 0.0f, 0.99988301347f, 0.35905835402f, -0.50636564111f}}}); +} +} \ No newline at end of file -- cgit v1.2.1