blob: f8b354a2d294c255da4dd07193ef580e4f1b1c35 [file] [log] [blame]
John Mcloughlin0ec00872023-05-15 17:03:49 +01001//
2// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "ParserFlatbuffersFixture.hpp"
7
8#include <doctest/doctest.h>
9
10
11TEST_SUITE("TensorflowLiteParser_Power")
12{
13 struct PowerFixture : public ParserFlatbuffersFixture
14 {
15 explicit PowerFixture(const std::string & inputShape1,
16 const std::string & inputShape2,
17 const std::string & outputShape,
18 const std::string & activation="NONE")
19 {
20 m_JsonString = R"(
21 {
22 "version": 3,
23 "operator_codes": [ { "builtin_code": "POW" } ],
24 "subgraphs": [ {
25 "tensors": [
26 {
27 "shape": )" + inputShape1 + R"(,
28 "type": "UINT8",
29 "buffer": 0,
30 "name": "inputTensor1",
31 "quantization": {
32 "min": [ 0.0 ],
33 "max": [ 255.0 ],
34 "scale": [ 1.0 ],
35 "zero_point": [ 0 ],
36 }
37 },
38 {
39 "shape": )" + inputShape2 + R"(,
40 "type": "UINT8",
41 "buffer": 1,
42 "name": "inputTensor2",
43 "quantization": {
44 "min": [ 0.0 ],
45 "max": [ 255.0 ],
46 "scale": [ 1.0 ],
47 "zero_point": [ 0 ],
48 }
49 },
50 {
51 "shape": )" + outputShape + R"( ,
52 "type": "UINT8",
53 "buffer": 2,
54 "name": "outputTensor",
55 "quantization": {
56 "min": [ 0.0 ],
57 "max": [ 255.0 ],
58 "scale": [ 1.0 ],
59 "zero_point": [ 0 ],
60 }
61 }
62 ],
63 "inputs": [ 0, 1 ],
64 "outputs": [ 2 ],
65 "operators": [
66 {
67 "opcode_index": 0,
68 "inputs": [ 0, 1 ],
69 "outputs": [ 2 ],
70 "custom_options_format": "FLEXBUFFERS"
71 }
72 ],
73 } ],
74 "buffers" : [
75 { },
76 { }
77 ]
78 }
79 )";
80 Setup();
81 }
82 };
83
84
85 struct SimplePowerFixture : PowerFixture
86 {
87 SimplePowerFixture() : PowerFixture("[ 2, 2 ]",
88 "[ 2, 2 ]",
89 "[ 2, 2 ]") {}
90 };
91
92 TEST_CASE_FIXTURE(SimplePowerFixture, "SimplePower")
93 {
94 RunTest<2, armnn::DataType::QAsymmU8>(
95 0,
96 {{"inputTensor1", { 0, 1, 2, 3 }},
97 {"inputTensor2", { 4, 5, 6, 3 }}},
98 {{"outputTensor", { 0, 1, 64, 27 }}});
99 }
100
101}