aboutsummaryrefslogtreecommitdiff
path: root/src/armnnDeserializer/test/DeserializeScatterNd.cpp
diff options
context:
space:
mode:
authorKevin May <kevin.may@arm.com>2024-02-26 09:12:23 +0000
committerTeresaARM <teresa.charlinreyes@arm.com>2024-03-12 16:59:29 +0000
commite3cc71663e39a2d46bad3ef7e6c146ff9a9e5b0e (patch)
tree2559295d707eb88b0370370ccca36f250856a6a5 /src/armnnDeserializer/test/DeserializeScatterNd.cpp
parent70dc5e9dc375c2feb306c7e709078c9f61ef8b1a (diff)
downloadarmnn-e3cc71663e39a2d46bad3ef7e6c146ff9a9e5b0e.tar.gz
IVGCVSW-8230 Add ScatterNd to Serializer and Deserializer
* Added parsing functions to the serializer and deserializer * Added ScatterNd and its Descriptor to the ArmnnSchema.fbs * Added Unittest for Serializer and Deserializer Signed-off-by: Kevin May <kevin.may@arm.com> Change-Id: I1ed674dc32d2e2d0d84dca4c7018984ea367ea50
Diffstat (limited to 'src/armnnDeserializer/test/DeserializeScatterNd.cpp')
-rw-r--r--src/armnnDeserializer/test/DeserializeScatterNd.cpp179
1 files changed, 179 insertions, 0 deletions
diff --git a/src/armnnDeserializer/test/DeserializeScatterNd.cpp b/src/armnnDeserializer/test/DeserializeScatterNd.cpp
new file mode 100644
index 0000000000..3e88310c8e
--- /dev/null
+++ b/src/armnnDeserializer/test/DeserializeScatterNd.cpp
@@ -0,0 +1,179 @@
+//
+// Copyright © 2024 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "ParserFlatbuffersSerializeFixture.hpp"
+#include <armnnDeserializer/IDeserializer.hpp>
+
+#include <string>
+
+TEST_SUITE("Deserializer_ScatterNd")
+{
+struct ScatterNdFixture : public ParserFlatbuffersSerializeFixture
+{
+ explicit ScatterNdFixture(const std::string& inputShape,
+ const std::string& indicesShape,
+ const std::string& updatesShape,
+ const std::string& outputShape,
+ const std::string& indicesData,
+ const std::string& updatesData,
+ const std::string dataType,
+ const std::string constDataType)
+ {
+ m_JsonString = R"(
+ {
+ inputIds: [0],
+ outputIds: [4],
+ 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: "ConstantLayer",
+ layer: {
+ base: {
+ index:1,
+ layerName: "ConstantLayer",
+ layerType: "Constant",
+ outputSlots: [ {
+ index: 0,
+ tensorInfo: {
+ dimensions: )" + indicesShape + R"(,
+ dataType: "Signed32",
+ },
+ }],
+ },
+ input: {
+ info: {
+ dimensions: )" + indicesShape + R"(,
+ dataType: "Signed32",
+ },
+ data_type: )" + constDataType + R"(,
+ data: {
+ data: )" + indicesData + R"(,
+ } }
+ },},
+ {
+ layer_type: "ConstantLayer",
+ layer: {
+ base: {
+ index:2,
+ layerName: "ConstantLayer",
+ layerType: "Constant",
+ outputSlots: [ {
+ index: 0,
+ tensorInfo: {
+ dimensions: )" + updatesShape + R"(,
+ dataType: )" + dataType + R"(
+ },
+ }],
+ },
+ input: {
+ info: {
+ dimensions: )" + updatesShape + R"(,
+ dataType: )" + dataType + R"(
+ },
+ data_type: )" + constDataType + R"(,
+ data: {
+ data: )" + updatesData + R"(,
+ } }
+ },},
+ {
+ layer_type: "ScatterNdLayer",
+ layer: {
+ base: {
+ index: 3,
+ layerName: "ScatterNdLayer",
+ layerType: "ScatterNd",
+ inputSlots: [
+ {
+ index: 0,
+ connection: {sourceLayerIndex:0, outputSlotIndex:0 },
+ },
+ {
+ index: 1,
+ connection: {sourceLayerIndex:1, outputSlotIndex:0 },
+ },
+ {
+ index: 2,
+ connection: {sourceLayerIndex:2, outputSlotIndex:0 },
+ }],
+ outputSlots: [ {
+ index: 0,
+ tensorInfo: {
+ dimensions: )" + outputShape + R"(,
+ dataType: )" + dataType + R"(
+
+ }}]},
+ descriptor: {
+ m_Function: Update,
+ m_InputEnabled: true,
+ m_Axis: 0,
+ m_AxisEnabled: false
+ },
+ }},
+ {
+ layer_type: "OutputLayer",
+ layer: {
+ base:{
+ layerBindingId: 0,
+ base: {
+ index: 4,
+ layerName: "OutputLayer",
+ layerType: "Output",
+ inputSlots: [{
+ index: 0,
+ connection: {sourceLayerIndex:3, outputSlotIndex:0 },
+ }],
+ outputSlots: [ {
+ index: 0,
+ tensorInfo: {
+ dimensions: )" + outputShape + R"(,
+ dataType: )" + dataType + R"(
+ },
+ }],
+ }}},
+ }],
+ featureVersions: {
+ weightsLayoutScheme: 1,
+ }
+ } )";
+
+ Setup();
+ }
+};
+
+struct SimpleScatterNdFixtureSigned32 : ScatterNdFixture
+{
+ SimpleScatterNdFixtureSigned32() : ScatterNdFixture("[ 5 ]", "[ 3, 1 ]", "[ 3 ]", "[ 5 ]",
+ "[ 0, 1, 2 ]", "[ 1, 2, 3 ]", "Signed32", "IntData") {}
+};
+
+TEST_CASE_FIXTURE(SimpleScatterNdFixtureSigned32, "ScatterNdSigned32")
+{
+ RunTest<1, armnn::DataType::Signed32>(0,
+ {{"InputLayer", { 0, 0, 0, 0, 0 }}},
+ {{"OutputLayer", { 1, 2, 3, 0, 0 }}});
+}
+
+}
+