blob: 7c3728cedf383ea11e4fd1a0d53f2c1d19926227 [file] [log] [blame]
Matthew Sloyan080ffd82023-04-24 12:53:04 +01001//
2// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "ConvolutionTestHelper.hpp"
7
8#include <armnn_delegate.hpp>
9
10#include <flatbuffers/flatbuffers.h>
11#include <tensorflow/lite/interpreter.h>
12#include <tensorflow/lite/kernels/register.h>
13#include <tensorflow/lite/model.h>
Matthew Sloyan080ffd82023-04-24 12:53:04 +010014#include <tensorflow/lite/version.h>
15
16#include <doctest/doctest.h>
17
18namespace armnnDelegate
19{
20
Colm Donelaneff204a2023-11-28 15:46:09 +000021void TransposeConvInt8Test()
Matthew Sloyan080ffd82023-04-24 12:53:04 +010022{
23 // Set input data
24 std::vector<int32_t> transposeTensorShape { 4 };
25 std::vector<int32_t> filterShape { 1, 2, 2, 1 };
26 std::vector<int32_t> inputShape { 1, 2, 2, 1 };
27 std::vector<int32_t> outputShape { 1, 3, 3, 1 };
28
29 std::vector<int32_t> transposeData = { 1, 3, 3, 1 };
30 static std::vector<int8_t> inputValues = { 1, 2, 3, 4 };
31 std::vector<int8_t> filterValues = { 0, 1, 2, 4 };
32 std::vector<int8_t> expectedOutputValues =
33 {
34 0, 1, 2,
35 2, 11, 12,
36 6, 20, 16
37 };
38
39 tflite::Padding padding = tflite::Padding_VALID;
Colm Donelaneff204a2023-11-28 15:46:09 +000040 TransposeConvTest<int8_t>(::tflite::TensorType_INT8,
Matthew Sloyan080ffd82023-04-24 12:53:04 +010041 1, // strideX
42 1, // strideY
43 padding,
44 transposeTensorShape,
45 filterShape,
46 inputShape,
47 outputShape,
48 transposeData,
49 filterValues,
50 inputValues,
51 expectedOutputValues);
52}
53
Colm Donelaneff204a2023-11-28 15:46:09 +000054void TransposeConvFp32Test()
Matthew Sloyan080ffd82023-04-24 12:53:04 +010055{
56 std::vector<int32_t> transposeTensorShape { 4 };
57 std::vector<int32_t> filterShape { 1, 2, 2, 1 };
58 std::vector<int32_t> inputShape { 1, 2, 2, 1 };
59 std::vector<int32_t> outputShape { 1, 3, 3, 1 };
60
61 std::vector<int32_t> transposeData = { 1, 3, 3, 1 };
62 static std::vector<float> inputValues = { 1, 2, 3, 4 };
63 std::vector<float> filterValues = { 0, 1, 2, 4 };
64 std::vector<float> expectedOutputValues =
65 {
66 0, 1, 2,
67 2, 11, 12,
68 6, 20, 16
69 };
70
71 tflite::Padding padding = tflite::Padding_VALID;
Colm Donelaneff204a2023-11-28 15:46:09 +000072 TransposeConvTest<float>(::tflite::TensorType_FLOAT32,
Matthew Sloyan080ffd82023-04-24 12:53:04 +010073 1, // strideX
74 1, // strideY
75 padding,
76 transposeTensorShape,
77 filterShape,
78 inputShape,
79 outputShape,
80 transposeData,
81 filterValues,
82 inputValues,
83 expectedOutputValues);
84}
85
Colm Donelaneff204a2023-11-28 15:46:09 +000086TEST_SUITE("TransposeConv_Test")
Matthew Sloyan080ffd82023-04-24 12:53:04 +010087{
88
Colm Donelaneff204a2023-11-28 15:46:09 +000089TEST_CASE ("TransposeConv_Fp32_Test")
Matthew Sloyan080ffd82023-04-24 12:53:04 +010090{
Colm Donelaneff204a2023-11-28 15:46:09 +000091 TransposeConvFp32Test();
Matthew Sloyan080ffd82023-04-24 12:53:04 +010092}
93
Colm Donelaneff204a2023-11-28 15:46:09 +000094TEST_CASE ("TransposeConv_Int8_Test")
Matthew Sloyan080ffd82023-04-24 12:53:04 +010095{
Colm Donelaneff204a2023-11-28 15:46:09 +000096 TransposeConvInt8Test();
Matthew Sloyan080ffd82023-04-24 12:53:04 +010097}
98
Colm Donelaneff204a2023-11-28 15:46:09 +000099} // End of TEST_SUITE(TransposeConv_Test)
Matthew Sloyan080ffd82023-04-24 12:53:04 +0100100
101} // namespace armnnDelegate