13 explicit ElementWiseUnaryFixture(
const std::string& operatorCode,
14 const std::string& dataType,
15 const std::string& inputShape,
16 const std::string& outputShape)
21 "operator_codes": [ { "builtin_code": )" + operatorCode + R"( } ], 25 "shape": )" + inputShape + R"(, 26 "type": )" + dataType + R"( , 28 "name": "inputTensor", 37 "shape": )" + outputShape + R"( , 38 "type": )" + dataType + R"( , 40 "name": "outputTensor", 56 "custom_options_format": "FLEXBUFFERS" 70 struct SimpleAbsFixture :
public ElementWiseUnaryFixture
72 SimpleAbsFixture() : ElementWiseUnaryFixture(
"ABS",
"FLOAT32",
"[ 2, 2 ]",
"[ 2, 2 ]") {}
77 std::vector<float> inputValues
84 std::vector<float> expectedOutputValues(inputValues.size());
85 for (
unsigned int i = 0; i < inputValues.size(); ++i)
87 expectedOutputValues[i] = std::abs(inputValues[i]);
90 RunTest<2, armnn::DataType::Float32>(0, {{
"inputTensor", { inputValues } }},
91 {{
"outputTensor",{ expectedOutputValues } } });
94 struct SimpleExpFixture :
public ElementWiseUnaryFixture
96 SimpleExpFixture() : ElementWiseUnaryFixture(
"EXP",
"FLOAT32",
"[ 1, 2, 3, 1 ]",
"[ 1, 2, 3, 1 ]") {}
101 RunTest<4, armnn::DataType::Float32>(0, {{
"inputTensor", { 0.0f, 1.0f, 2.0f,
102 3.0f, 4.0f, 5.0f} }},
103 {{
"outputTensor",{ 1.0f, 2.718281f, 7.3890515f,
104 20.0855185f, 54.5980834f, 148.4129329f} } });
107 struct SimpleLogFixture :
public ElementWiseUnaryFixture
109 SimpleLogFixture() : ElementWiseUnaryFixture(
"LOG",
"FLOAT32",
"[ 1, 2, 3, 1 ]",
"[ 1, 2, 3, 1 ]") {}
114 RunTest<4, armnn::DataType::Float32>(0, {{
"inputTensor", { 1.0f, 1.0f, 2.0f,
115 3.0f, 4.0f, 2.71828f} }},
116 {{
"outputTensor",{ 0.f, 0.f, 0.69314718056f,
117 1.09861228867f, 1.38629436112f, 0.99999932734f} } });
120 struct SimpleLogicalNotFixture :
public ElementWiseUnaryFixture
122 SimpleLogicalNotFixture() : ElementWiseUnaryFixture(
"LOGICAL_NOT",
"BOOL",
"[ 1, 1, 1, 4 ]",
"[ 1, 1, 1, 4 ]") {}
127 RunTest<4, armnn::DataType::Boolean>(0, {{
"inputTensor", { 0, 1, 0, 1 } }},
128 {{
"outputTensor",{ 1, 0, 1, 0 } } });
131 struct SimpleNegFixture :
public ElementWiseUnaryFixture
133 SimpleNegFixture() : ElementWiseUnaryFixture(
"NEG",
"FLOAT32",
"[ 1, 2, 3, 1 ]",
"[ 1, 2, 3, 1 ]") {}
138 RunTest<4, armnn::DataType::Float32>(0, {{
"inputTensor", { 0.0f, 1.0f, -2.0f,
139 20.0855185f, -54.5980834f, 5.0f} }},
140 {{
"outputTensor",{ 0.0f, -1.0f, 2.0f,
141 -20.0855185f, 54.5980834f, -5.0f} }});
144 struct SimpleRsqrtFixture :
public ElementWiseUnaryFixture
146 SimpleRsqrtFixture() : ElementWiseUnaryFixture(
"RSQRT",
"FLOAT32",
"[ 1, 2, 3, 1 ]",
"[ 1, 2, 3, 1 ]") {}
151 RunTest<4, armnn::DataType::Float32>(0, {{
"inputTensor", { 1.0f, 4.0f, 16.0f,
152 25.0f, 64.0f, 100.0f } }},
153 {{
"outputTensor",{ 1.0f, 0.5f, 0.25f,
154 0.2f, 0.125f, 0.1f} }});
157 struct SimpleSqrtFixture :
public ElementWiseUnaryFixture
159 SimpleSqrtFixture() : ElementWiseUnaryFixture(
"SQRT",
"FLOAT32",
"[ 1, 2, 3, 1 ]",
"[ 1, 2, 3, 1 ]") {}
164 RunTest<4, armnn::DataType::Float32>(0, {{
"inputTensor", { 9.0f, 4.0f, 16.0f,
165 25.0f, 36.0f, 49.0f } }},
166 {{
"outputTensor",{ 3.0f, 2.0f, 4.0f,
167 5.0f, 6.0f, 7.0f} }});
170 struct SimpleSinFixture :
public ElementWiseUnaryFixture
172 SimpleSinFixture() : ElementWiseUnaryFixture(
"SIN",
"FLOAT32",
"[ 1, 2, 3, 1 ]",
"[ 1, 2, 3, 1 ]") {}
177 RunTest<4, armnn::DataType::Float32>(0, {{
"inputTensor", { 0.0f, 1.0f, 16.0f,
178 0.5f, 36.0f, -1.f } }},
179 {{
"outputTensor",{ 0.0f, 0.8414709848f, -0.28790331666f,
180 0.4794255386f, -0.99177885344f, -0.8414709848f} }});
TEST_SUITE("TensorflowLiteParser_ElementwiseUnary")
TEST_CASE_FIXTURE(ClContextControlFixture, "CopyBetweenNeonAndGpu")
void Setup(bool testDynamic=true)