blob: 20f95abee5c8577d1017319d3d8f2b9f4c4b9883 [file] [log] [blame]
Sadik Armagan12239e72020-05-27 11:06:17 +01001//
2// Copyright © 2020 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
Sadik Armagan12239e72020-05-27 11:06:17 +01006#include "ParserFlatbuffersFixture.hpp"
7#include "../TfLiteParser.hpp"
8
9#include <string>
10#include <iostream>
11
Sadik Armagan1625efc2021-06-10 18:24:34 +010012TEST_SUITE("TensorflowLiteParser_LeakyRelu")
13{
Sadik Armagan12239e72020-05-27 11:06:17 +010014struct LeakyReluFixture : public ParserFlatbuffersFixture
15{
16 explicit LeakyReluFixture()
17 {
18 m_JsonString = R"(
19 {
20 "version": 3,
21 "operator_codes": [ { "builtin_code": "LEAKY_RELU" } ],
22 "subgraphs": [ {
23 "tensors": [
24 {
25 "shape": [ 1, 7 ],
26 "type": "FLOAT32",
27 "buffer": 0,
28 "name": "inputTensor",
29 "quantization": {
30 "min": [ 0.0 ],
31 "max": [ 255.0 ],
32 "scale": [ 1.0 ],
33 "zero_point": [ 0 ],
34 }
35 },
36 {
37 "shape": [ 1, 7 ],
38 "type": "FLOAT32",
39 "buffer": 1,
40 "name": "outputTensor",
41 "quantization": {
42 "min": [ 0.0 ],
43 "max": [ 255.0 ],
44 "scale": [ 1.0 ],
45 "zero_point": [ 0 ],
46 }
47 }
48 ],
49 "inputs": [ 0 ],
50 "outputs": [ 1 ],
51 "operators": [
52 {
53 "opcode_index": 0,
54 "inputs": [ 0 ],
55 "outputs": [ 1 ],
56 "builtin_options_type": "LeakyReluOptions",
57 "builtin_options": {
58 "alpha": 0.01
59 },
60 "custom_options_format": "FLEXBUFFERS"
61 }
62 ],
63 } ],
64 "buffers" : [ {}, {} ]
65 }
66 )";
67 SetupSingleInputSingleOutput("inputTensor", "outputTensor");
68 }
69};
70
Sadik Armagan1625efc2021-06-10 18:24:34 +010071TEST_CASE_FIXTURE(LeakyReluFixture, "ParseLeakyRelu")
Sadik Armagan12239e72020-05-27 11:06:17 +010072{
73 RunTest<2, armnn::DataType::Float32>(0,
74 {{ "inputTensor", { -0.1f, -0.2f, -0.3f, -0.4f, 0.1f, 0.2f, 0.3f }}},
75 {{ "outputTensor", { -0.001f, -0.002f, -0.003f, -0.004f, 0.1f, 0.2f, 0.3f }}});
76}
77
Sadik Armagan1625efc2021-06-10 18:24:34 +010078}