ArmNN
 22.05.01
Activations.cpp File Reference
#include "ParserFlatbuffersFixture.hpp"
#include <doctest/doctest.h>

Go to the source code of this file.

Functions

 TEST_SUITE ("TensorflowLiteParser_Activations")
 

Function Documentation

◆ TEST_SUITE()

TEST_SUITE ( "TensorflowLiteParser_Activations"  )

Definition at line 10 of file Activations.cpp.

References ActivationFixture::ActivationFixture(), and TEST_CASE_FIXTURE().

11 {
13 {
14 
15  explicit ActivationFixture(std::string activationFunction, std::string dataType)
16  {
17  m_JsonString = R"(
18  {
19  "version": 3,
20  "operator_codes": [ { "builtin_code": )" + activationFunction + R"( } ],
21  "subgraphs": [ {
22  "tensors": [
23  {
24  "shape": [ 1, 7 ],
25  "type": )" + dataType + R"(,
26  "buffer": 0,
27  "name": "inputTensor",
28  "quantization": {
29  "min": [ 0.0 ],
30  "max": [ 255.0 ],
31  "scale": [ 1.0 ],
32  "zero_point": [ 0 ],
33  }
34  },
35  {
36  "shape": [ 1, 7 ],
37  "type": )" + dataType + R"(,
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  "custom_options_format": "FLEXBUFFERS"
56  }
57  ],
58  } ],
59  "buffers" : [ {}, {} ]
60  }
61  )";
62  SetupSingleInputSingleOutput("inputTensor", "outputTensor");
63  }
64 
65 };
66 
67 struct ReLuFixture : ActivationFixture
68 {
69  ReLuFixture() : ActivationFixture("RELU", "FLOAT32") {}
70 };
71 TEST_CASE_FIXTURE(ReLuFixture, "ParseReLu")
72 {
73  RunTest<2, armnn::DataType::Float32>(0, { -1.0f, -0.5f, 1.25f, -3.0f, 0.0f, 0.5f, -0.75f },
74  { 0.0f, 0.0f, 1.25f, 0.0f, 0.0f, 0.5f, 0.0f });
75 }
76 
77 struct ReLu6Fixture : ActivationFixture
78 {
79  ReLu6Fixture() : ActivationFixture("RELU6", "FLOAT32") {}
80 };
81 TEST_CASE_FIXTURE(ReLu6Fixture, "ParseReLu6")
82 {
83  RunTest<2, armnn::DataType::Float32>(0, { -1.0f, -0.5f, 7.25f, -3.0f, 0.0f, 0.5f, -0.75f },
84  { 0.0f, 0.0f, 6.0f, 0.0f, 0.0f, 0.5f, 0.0f });
85 }
86 
87 struct SigmoidFixture : ActivationFixture
88 {
89  SigmoidFixture() : ActivationFixture("LOGISTIC", "FLOAT32") {}
90 };
91 TEST_CASE_FIXTURE(SigmoidFixture, "ParseLogistic")
92 {
93  RunTest<2, armnn::DataType::Float32>(0, { -1.0f, -0.5f, 4.0f, -4.0f, 0.0f, 0.5f, -0.75f },
94  {0.268941f, 0.377541f, 0.982013f, 0.0179862f, 0.5f, 0.622459f, 0.320821f });
95 }
96 
97 struct TanHFixture : ActivationFixture
98 {
99  TanHFixture() : ActivationFixture("TANH", "FLOAT32") {}
100 };
101 
102 TEST_CASE_FIXTURE(TanHFixture, "ParseTanH")
103 {
104  RunTest<2, armnn::DataType::Float32>(0,
105  { -0.1f, -0.2f, -0.3f, -0.4f, 0.1f, 0.2f, 0.3f },
106  { -0.09966799f, -0.19737528f, -0.29131261f, -0.379949f, 0.09966799f, 0.19737528f, 0.29131261f });
107 }
108 
109 struct EluFixture : ActivationFixture
110 {
111  EluFixture() : ActivationFixture("ELU", "FLOAT32") {}
112 };
113 
114 TEST_CASE_FIXTURE(EluFixture, "ParseElu")
115 {
116  RunTest<2, armnn::DataType::Float32>(0,
117  { -2.0f, -1.0f, -0.0f, 0.0f, 1.0f, 2.0f, 3.0f },
118  { -0.86466471676f, -0.63212055882f, -0.0f, 0.0f, 1.0f, 2.0f, 3.0f });
119 }
120 
121 struct HardSwishFixture : ActivationFixture
122 {
123  HardSwishFixture() : ActivationFixture("HARD_SWISH", "FLOAT32") {}
124 };
125 
126 TEST_CASE_FIXTURE(HardSwishFixture, "ParseHardSwish")
127 {
128  RunTest<2, armnn::DataType::Float32>(0,
129  { -4.0f, -3.0f, -2.9f, 1.2f, 2.2f, 3.0f, 4.0f },
130  { -0.0f, -0.0f, -0.04833334f, 0.84f, 1.90666667f, 3.0f, 4.0f });
131 }
132 
133 }
TEST_CASE_FIXTURE(ClContextControlFixture, "CopyBetweenNeonAndGpu")