ArmNN
 21.11
Dequantize.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
8 
9 TEST_SUITE("TensorflowLiteParser_Dequantize")
10 {
11  struct DequantizeFixture : public ParserFlatbuffersFixture
12  {
13  explicit DequantizeFixture(const std::string & inputShape,
14  const std::string & outputShape,
15  const std::string & dataType)
16  {
17  m_JsonString = R"(
18  {
19  "version": 3,
20  "operator_codes": [ { "builtin_code": "DEQUANTIZE" } ],
21  "subgraphs": [ {
22  "tensors": [
23  {
24  "shape": )" + inputShape + R"(,
25  "type": )" + dataType + R"(,
26  "buffer": 0,
27  "name": "inputTensor",
28  "quantization": {
29  "min": [ 0.0 ],
30  "max": [ 255.0 ],
31  "scale": [ 1.5 ],
32  "zero_point": [ 0 ],
33  }
34  },
35  {
36  "shape": )" + outputShape + R"( ,
37  "type": "FLOAT32",
38  "buffer": 1,
39  "name": "outputTensor",
40  "quantization": {
41  "min": [ 0.0 ],
42  "max": [ 255.0 ],
43  "scale": [ 1.0 ],
44  "zero_point": [ 0 ],
45  }
46  }
47  ],
48  "inputs": [ 0 ],
49  "outputs": [ 1 ],
50  "operators": [
51  {
52  "opcode_index": 0,
53  "inputs": [ 0 ],
54  "outputs": [ 1 ],
55  "builtin_options_type": "DequantizeOptions",
56  "builtin_options": {
57  },
58  "custom_options_format": "FLEXBUFFERS"
59  }
60  ],
61  } ],
62  "buffers" : [
63  { },
64  { },
65  ]
66  }
67  )";
68  SetupSingleInputSingleOutput("inputTensor", "outputTensor");
69  }
70  };
71 
72  struct SimpleDequantizeFixtureQAsymm8 : DequantizeFixture
73  {
74  SimpleDequantizeFixtureQAsymm8() : DequantizeFixture("[ 1, 6 ]",
75  "[ 1, 6 ]",
76  "UINT8") {}
77  };
78 
79  TEST_CASE_FIXTURE(SimpleDequantizeFixtureQAsymm8, "SimpleDequantizeQAsymm8")
80  {
81  RunTest<2, armnn::DataType::QAsymmU8 , armnn::DataType::Float32>(
82  0,
83  {{"inputTensor", { 0u, 1u, 5u, 100u, 200u, 255u }}},
84  {{"outputTensor", { 0.0f, 1.5f, 7.5f, 150.0f, 300.0f, 382.5f }}});
85  }
86 
87  struct SimpleDequantizeFixtureQSymm16 : DequantizeFixture
88  {
89  SimpleDequantizeFixtureQSymm16() : DequantizeFixture("[ 1, 6 ]",
90  "[ 1, 6 ]",
91  "INT16") {}
92  };
93 
94  TEST_CASE_FIXTURE(SimpleDequantizeFixtureQSymm16, "SimpleDequantizeQsymm16")
95  {
96  RunTest<2, armnn::DataType::QSymmS16 , armnn::DataType::Float32>(
97  0,
98  {{"inputTensor", { 0, 1, 5, 32767, -1, -32768 }}},
99  {{"outputTensor", { 0.0f, 1.5f, 7.5f, 49150.5f, -1.5f,-49152.0f }}});
100  }
101 
102  struct SimpleDequantizeFixtureQAsymmS8 : DequantizeFixture
103  {
104  SimpleDequantizeFixtureQAsymmS8() : DequantizeFixture("[ 1, 6 ]",
105  "[ 1, 6 ]",
106  "INT8") {}
107  };
108 
109  TEST_CASE_FIXTURE(SimpleDequantizeFixtureQAsymmS8, "SimpleDequantizeQAsymmS8")
110  {
111  RunTest<2, armnn::DataType::QAsymmS8 , armnn::DataType::Float32>(
112  0,
113  {{"inputTensor", { 0, 1, 5, 127, -128, -1 }}},
114  {{"outputTensor", { 0.0f, 1.5f, 7.5f, 190.5f, -192.0f, -1.5f }}});
115  }
116 
117 }
TEST_SUITE("TensorflowLiteParser_Dequantize")
Definition: Dequantize.cpp:9
TEST_CASE_FIXTURE(ClContextControlFixture, "CopyBetweenNeonAndGpu")
void SetupSingleInputSingleOutput(const std::string &inputName, const std::string &outputName)