ArmNN
 21.02
Neg.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include <boost/test/unit_test.hpp>
8 #include "../TfLiteParser.hpp"
9 
10 #include <string>
11 
12 BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
13 
14 struct NegFixture : public ParserFlatbuffersFixture
15 {
16  explicit NegFixture(const std::string & inputShape,
17  const std::string & outputShape)
18  {
19  m_JsonString = R"(
20  {
21  "version": 3,
22  "operator_codes": [ { "builtin_code": "NEG" } ],
23  "subgraphs": [ {
24  "tensors": [
25  {
26  "shape": )" + inputShape + R"(,
27  "type": "FLOAT32",
28  "buffer": 0,
29  "name": "inputTensor",
30  "quantization": {
31  "min": [ 0.0 ],
32  "max": [ 255.0 ],
33  "scale": [ 1.0 ],
34  "zero_point": [ 0 ],
35  }
36  },
37  {
38  "shape": )" + outputShape + R"( ,
39  "type": "FLOAT32",
40  "buffer": 1,
41  "name": "outputTensor",
42  "quantization": {
43  "min": [ 0.0 ],
44  "max": [ 255.0 ],
45  "scale": [ 1.0 ],
46  "zero_point": [ 0 ],
47  }
48  }
49  ],
50  "inputs": [ 0 ],
51  "outputs": [ 1 ],
52  "operators": [
53  {
54  "opcode_index": 0,
55  "inputs": [ 0 ],
56  "outputs": [ 1 ],
57  "custom_options_format": "FLEXBUFFERS"
58  }
59  ],
60  } ],
61  "buffers" : [
62  { },
63  { }
64  ]
65  }
66  )";
67  Setup();
68  }
69 };
70 
71 struct SimpleNegFixture : public NegFixture
72 {
73  SimpleNegFixture() : NegFixture("[ 1, 2, 3, 1 ]", "[ 1, 2, 3, 1 ]") {}
74 };
75 
76 BOOST_FIXTURE_TEST_CASE(ParseNeg, SimpleNegFixture)
77 {
78  using armnn::DataType;
79  RunTest<4, DataType::Float32>(0, {{ "inputTensor", { 0.0f, 1.0f, -2.0f,
80  20.0855185f, -54.5980834f, 5.0f} }},
81  {{ "outputTensor",{ 0.0f, -1.0f, 2.0f,
82  -20.0855185f, 54.5980834f, -5.0f} }});
83 }
84 
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
DataType
Definition: Types.hpp:32
BOOST_AUTO_TEST_SUITE_END()
BOOST_FIXTURE_TEST_CASE(ParseNeg, SimpleNegFixture)
Definition: Neg.cpp:76