blob: b4b650fa8cb9f98b2158aefa835c67d47477cec6 [file] [log] [blame]
surmeh0149b9e102018-05-17 14:11:25 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beck93e48982018-09-05 13:05:09 +01003// SPDX-License-Identifier: MIT
surmeh0149b9e102018-05-17 14:11:25 +01004//
5#include "DriverTestHelpers.hpp"
6#include "TestTensor.hpp"
Aron Virginas-Tar44cfd842019-06-14 15:45:03 +01007
8#include "../1.0/HalPolicy.hpp"
9
telsoa01ce3e84a2018-08-31 09:31:35 +010010#include <boost/array.hpp>
surmeh0149b9e102018-05-17 14:11:25 +010011#include <boost/test/unit_test.hpp>
telsoa01ce3e84a2018-08-31 09:31:35 +010012#include <boost/test/data/test_case.hpp>
surmeh0149b9e102018-05-17 14:11:25 +010013
Aron Virginas-Tar44cfd842019-06-14 15:45:03 +010014#include <log/log.h>
surmeh0149b9e102018-05-17 14:11:25 +010015
Jim Flynn7b1e41f2019-05-22 18:00:04 +010016BOOST_AUTO_TEST_SUITE(ConcatTests)
surmeh0149b9e102018-05-17 14:11:25 +010017
telsoa01ce3e84a2018-08-31 09:31:35 +010018using namespace android::hardware;
surmeh0149b9e102018-05-17 14:11:25 +010019using namespace driverTestHelpers;
telsoa01ce3e84a2018-08-31 09:31:35 +010020using namespace armnn_driver;
surmeh0149b9e102018-05-17 14:11:25 +010021
Aron Virginas-Tar44cfd842019-06-14 15:45:03 +010022using HalPolicy = hal_1_0::HalPolicy;
23
surmeh0149b9e102018-05-17 14:11:25 +010024namespace
25{
26
Kevin Mayedc5ffa2019-05-22 12:02:53 +010027#ifndef ARMCOMPUTECL_ENABLED
28 static const boost::array<armnn::Compute, 1> COMPUTE_DEVICES = {{ armnn::Compute::CpuRef }};
29#else
30 static const boost::array<armnn::Compute, 2> COMPUTE_DEVICES = {{ armnn::Compute::CpuRef, armnn::Compute::GpuAcc }};
31#endif
telsoa01ce3e84a2018-08-31 09:31:35 +010032
surmeh0149b9e102018-05-17 14:11:25 +010033void
Jim Flynn7b1e41f2019-05-22 18:00:04 +010034ConcatTestImpl(const std::vector<const TestTensor*> & inputs,
surmeh0149b9e102018-05-17 14:11:25 +010035 int32_t concatAxis,
36 const TestTensor & expectedOutputTensor,
telsoa01ce3e84a2018-08-31 09:31:35 +010037 armnn::Compute computeDevice,
Kevin Mayec1e5b82020-02-26 17:00:39 +000038 V1_0::ErrorStatus expectedPrepareStatus=V1_0::ErrorStatus::NONE,
39 V1_0::ErrorStatus expectedExecStatus=V1_0::ErrorStatus::NONE)
surmeh0149b9e102018-05-17 14:11:25 +010040{
telsoa01ce3e84a2018-08-31 09:31:35 +010041 std::unique_ptr<ArmnnDriver> driver = std::make_unique<ArmnnDriver>(DriverOptions(computeDevice));
Aron Virginas-Tar44cfd842019-06-14 15:45:03 +010042 HalPolicy::Model model{};
surmeh0149b9e102018-05-17 14:11:25 +010043
44 hidl_vec<uint32_t> modelInputIds;
45 modelInputIds.resize(inputs.size()+1);
46 for (uint32_t i = 0; i<inputs.size(); ++i)
47 {
48 modelInputIds[i] = i;
Aron Virginas-Tar44cfd842019-06-14 15:45:03 +010049 AddInputOperand<HalPolicy>(model, inputs[i]->GetDimensions());
surmeh0149b9e102018-05-17 14:11:25 +010050 }
51 modelInputIds[inputs.size()] = inputs.size(); // add an id for the axis too
Aron Virginas-Tar44cfd842019-06-14 15:45:03 +010052 AddIntOperand<HalPolicy>(model, concatAxis);
53 AddOutputOperand<HalPolicy>(model, expectedOutputTensor.GetDimensions());
surmeh0149b9e102018-05-17 14:11:25 +010054
55 // make the concat operation
56 model.operations.resize(1);
Aron Virginas-Tar44cfd842019-06-14 15:45:03 +010057 model.operations[0].type = HalPolicy::OperationType::CONCATENATION;
surmeh0149b9e102018-05-17 14:11:25 +010058 model.operations[0].inputs = modelInputIds;
59 model.operations[0].outputs = hidl_vec<uint32_t>{static_cast<uint32_t>(inputs.size()+1)};
60
61 // make the prepared model
Kevin Mayec1e5b82020-02-26 17:00:39 +000062 V1_0::ErrorStatus prepareStatus=V1_0::ErrorStatus::NONE;
Sadik Armagane6e54a82019-05-08 10:18:05 +010063 android::sp<V1_0::IPreparedModel> preparedModel = PrepareModelWithStatus(model,
Aron Virginas-Tar44cfd842019-06-14 15:45:03 +010064 *driver,
65 prepareStatus,
66 expectedPrepareStatus);
surmeh0149b9e102018-05-17 14:11:25 +010067 BOOST_TEST(prepareStatus == expectedPrepareStatus);
Kevin Mayec1e5b82020-02-26 17:00:39 +000068 if (prepareStatus != V1_0::ErrorStatus::NONE)
surmeh0149b9e102018-05-17 14:11:25 +010069 {
70 // prepare failed, we cannot continue
71 return;
72 }
73
74 BOOST_TEST(preparedModel.get() != nullptr);
75 if (preparedModel.get() == nullptr)
76 {
77 // don't spoil other tests if prepare failed
78 return;
79 }
80
81 // construct the request
82 hidl_vec<RequestArgument> inputArguments;
83 hidl_vec<RequestArgument> outputArguments;
84 inputArguments.resize(inputs.size());
85 outputArguments.resize(1);
86
87 // the request's memory pools will follow the same order as
88 // the inputs
89 for (uint32_t i = 0; i<inputs.size(); ++i)
90 {
91 DataLocation inloc = {};
92 inloc.poolIndex = i;
93 inloc.offset = 0;
94 inloc.length = inputs[i]->GetNumElements() * sizeof(float);
95 RequestArgument input = {};
96 input.location = inloc;
97 input.dimensions = inputs[i]->GetDimensions();
98 inputArguments[i] = input;
99 }
100
101 // and an additional memory pool is needed for the output
102 {
103 DataLocation outloc = {};
104 outloc.poolIndex = inputs.size();
105 outloc.offset = 0;
106 outloc.length = expectedOutputTensor.GetNumElements() * sizeof(float);
107 RequestArgument output = {};
108 output.location = outloc;
109 output.dimensions = expectedOutputTensor.GetDimensions();
110 outputArguments[0] = output;
111 }
112
113 // make the request based on the arguments
Kevin Mayec1e5b82020-02-26 17:00:39 +0000114 V1_0::Request request = {};
surmeh0149b9e102018-05-17 14:11:25 +0100115 request.inputs = inputArguments;
116 request.outputs = outputArguments;
117
118 // set the input data
119 for (uint32_t i = 0; i<inputs.size(); ++i)
120 {
121 AddPoolAndSetData(inputs[i]->GetNumElements(),
122 request,
123 inputs[i]->GetData());
124 }
125
126 // add memory for the output
Ellen Norris-Thompson976ad3e2019-08-21 15:21:14 +0100127 android::sp<IMemory> outMemory = AddPoolAndGetData<float>(expectedOutputTensor.GetNumElements(), request);
surmeh0149b9e102018-05-17 14:11:25 +0100128 float* outdata = static_cast<float*>(static_cast<void*>(outMemory->getPointer()));
129
130 // run the execution
David Monahanc60d0fd2020-05-19 14:58:34 +0100131 ARMNN_ASSERT(preparedModel.get() != nullptr);
surmeh0149b9e102018-05-17 14:11:25 +0100132 auto execStatus = Execute(preparedModel, request, expectedExecStatus);
133 BOOST_TEST(execStatus == expectedExecStatus);
134
Kevin Mayec1e5b82020-02-26 17:00:39 +0000135 if (execStatus == V1_0::ErrorStatus::NONE)
surmeh0149b9e102018-05-17 14:11:25 +0100136 {
137 // check the result if there was no error
138 const float * expectedOutput = expectedOutputTensor.GetData();
139 for (unsigned int i=0; i<expectedOutputTensor.GetNumElements();++i)
140 {
141 BOOST_TEST(outdata[i] == expectedOutput[i]);
142 }
143 }
144}
145
146} // namespace <anonymous>
147
telsoa01ce3e84a2018-08-31 09:31:35 +0100148
149BOOST_DATA_TEST_CASE(SimpleConcatAxis0, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100150{
151 int32_t axis = 0;
152 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
153 TestTensor bIn{armnn::TensorShape{1,1,1,1},{1}};
154 TestTensor cIn{armnn::TensorShape{1,1,1,1},{2}};
155
156 TestTensor expected{armnn::TensorShape{3,1,1,1},{0,1,2}};
157
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100158 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100159}
160
telsoa01ce3e84a2018-08-31 09:31:35 +0100161BOOST_DATA_TEST_CASE(ConcatAxis0_NoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100162{
163 int32_t axis = 0;
164 TestTensor aIn{armnn::TensorShape{2,1,2,1},{0, 1,
165 2, 3}};
166 TestTensor bIn{armnn::TensorShape{3,1,2,1},{4, 5,
167 6, 7,
168 8, 9}};
169 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10, 11}};
170
171 TestTensor expected{armnn::TensorShape{6,1,2,1},{0, 1,
172 2, 3,
173 4, 5,
174 6, 7,
175 8, 9,
176 10, 11}};
177
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100178 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100179}
180
telsoa01ce3e84a2018-08-31 09:31:35 +0100181BOOST_DATA_TEST_CASE(SimpleConcatAxis1, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100182{
183 int32_t axis = 1;
184 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
185 TestTensor bIn{armnn::TensorShape{1,1,1,1},{1}};
186 TestTensor cIn{armnn::TensorShape{1,1,1,1},{2}};
187
188 TestTensor expected{armnn::TensorShape{1,3,1,1},{0,1,2}};
189
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100190 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100191}
192
telsoa01ce3e84a2018-08-31 09:31:35 +0100193BOOST_DATA_TEST_CASE(ConcatAxis1_NoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100194{
195 int32_t axis = 1;
196 TestTensor aIn{armnn::TensorShape{1,2,2,1},{0, 1,
197 2, 3}};
198 TestTensor bIn{armnn::TensorShape{1,3,2,1},{4, 5,
199 6, 7,
200 8, 9}};
201 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10, 11}};
202
203 TestTensor expected{armnn::TensorShape{1,6,2,1},{0, 1,
204 2, 3,
205 4, 5,
206 6, 7,
207 8, 9,
208 10, 11}};
209
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100210 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100211}
212
telsoa01ce3e84a2018-08-31 09:31:35 +0100213BOOST_DATA_TEST_CASE(SimpleConcatAxis1_DoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100214{
215 int32_t axis = 1;
216 TestTensor aIn{armnn::TensorShape{2,2,1,1},{0, 1,
217 2, 3}};
218 TestTensor bIn{armnn::TensorShape{2,3,1,1},{4, 5, 6,
219 7, 8, 9}};
220 TestTensor cIn{armnn::TensorShape{2,1,1,1},{10,
221 11}};
222
223 TestTensor expected{armnn::TensorShape{2,6,1,1},{0, 1, 4, 5, 6, 10,
224 2, 3, 7, 8, 9, 11}};
225
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100226 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100227}
228
telsoa01ce3e84a2018-08-31 09:31:35 +0100229BOOST_DATA_TEST_CASE(SimpleConcatAxis2, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100230{
231 int32_t axis = 2;
232 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
233 TestTensor bIn{armnn::TensorShape{1,1,1,1},{1}};
234 TestTensor cIn{armnn::TensorShape{1,1,1,1},{2}};
235
236 TestTensor expected{armnn::TensorShape{1,1,3,1},{0,1,2}};
237
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100238 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100239}
240
telsoa01ce3e84a2018-08-31 09:31:35 +0100241BOOST_DATA_TEST_CASE(ConcatAxis2_NoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100242{
243 int32_t axis = 2;
244 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
245 2, 3}};
246 TestTensor bIn{armnn::TensorShape{1,1,3,2},{4, 5,
247 6, 7,
248 8, 9}};
249 TestTensor cIn{armnn::TensorShape{1,1,1,2},{10, 11}};
250
251 TestTensor expected{armnn::TensorShape{1,1,6,2},{0, 1,
252 2, 3,
253 4, 5,
254 6, 7,
255 8, 9,
256 10, 11}};
257
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100258 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100259}
260
telsoa01ce3e84a2018-08-31 09:31:35 +0100261BOOST_DATA_TEST_CASE(SimpleConcatAxis2_DoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100262{
263 int32_t axis = 2;
264 TestTensor aIn{armnn::TensorShape{1,2,2,1},{0, 1,
265 2, 3}};
266 TestTensor bIn{armnn::TensorShape{1,2,3,1},{4, 5, 6,
267 7, 8, 9}};
268 TestTensor cIn{armnn::TensorShape{1,2,1,1},{10,
269 11}};
270
271 TestTensor expected{armnn::TensorShape{1,2,6,1},{0, 1, 4, 5, 6, 10,
272 2, 3, 7, 8, 9, 11}};
273
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100274 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100275}
276
telsoa01ce3e84a2018-08-31 09:31:35 +0100277BOOST_DATA_TEST_CASE(SimpleConcatAxis3, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100278{
279 int32_t axis = 3;
280 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
281 TestTensor bIn{armnn::TensorShape{1,1,1,1},{1}};
282 TestTensor cIn{armnn::TensorShape{1,1,1,1},{2}};
283
284 TestTensor expected{armnn::TensorShape{1,1,1,3},{0,1,2}};
285
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100286 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100287}
288
telsoa01ce3e84a2018-08-31 09:31:35 +0100289BOOST_DATA_TEST_CASE(SimpleConcatAxis3_DoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100290{
291 int32_t axis = 3;
292 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
293 2, 3}};
294 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
295 7, 8, 9}};
296 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10,
297 11}};
298
299 TestTensor expected{armnn::TensorShape{1,1,2,6},{0, 1, 4, 5, 6, 10,
300 2, 3, 7, 8, 9, 11}};
301
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100302 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100303}
304
telsoa01ce3e84a2018-08-31 09:31:35 +0100305BOOST_DATA_TEST_CASE(AxisTooBig, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100306{
307 int32_t axis = 4;
308 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
309 TestTensor bIn{armnn::TensorShape{1,1,1,1},{0}};
310
311 // The axis must be within the range of [-rank(values), rank(values))
312 // see: https://www.tensorflow.org/api_docs/python/tf/concat
313 TestTensor uncheckedOutput{armnn::TensorShape{1,1,1,1},{0}};
Kevin Mayec1e5b82020-02-26 17:00:39 +0000314 V1_0::ErrorStatus expectedParserStatus = V1_0::ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100315 ConcatTestImpl({&aIn, &bIn}, axis, uncheckedOutput, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100316}
317
telsoa01ce3e84a2018-08-31 09:31:35 +0100318BOOST_DATA_TEST_CASE(AxisTooSmall, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100319{
320 int32_t axis = -5;
321 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
322 TestTensor bIn{armnn::TensorShape{1,1,1,1},{0}};
323
324 // The axis must be within the range of [-rank(values), rank(values))
325 // see: https://www.tensorflow.org/api_docs/python/tf/concat
326 TestTensor uncheckedOutput{armnn::TensorShape{1,1,1,1},{0}};
Kevin Mayec1e5b82020-02-26 17:00:39 +0000327 V1_0::ErrorStatus expectedParserStatus = V1_0::ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100328 ConcatTestImpl({&aIn, &bIn}, axis, uncheckedOutput, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100329}
330
telsoa01ce3e84a2018-08-31 09:31:35 +0100331BOOST_DATA_TEST_CASE(TooFewInputs, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100332{
333 int32_t axis = 0;
334 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
335
336 // We need at least two tensors to concatenate
Kevin Mayec1e5b82020-02-26 17:00:39 +0000337 V1_0::ErrorStatus expectedParserStatus = V1_0::ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100338 ConcatTestImpl({&aIn}, axis, aIn, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100339}
340
telsoa01ce3e84a2018-08-31 09:31:35 +0100341BOOST_DATA_TEST_CASE(MismatchedInputDimensions, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100342{
343 int32_t axis = 3;
344 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
345 2, 3}};
346 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
347 7, 8, 9}};
348 TestTensor mismatched{armnn::TensorShape{1,1,1,1},{10}};
349
350 TestTensor expected{armnn::TensorShape{1,1,2,6},{0, 1, 4, 5, 6, 10,
351 2, 3, 7, 8, 9, 11}};
352
353 // The input dimensions must be compatible
Kevin Mayec1e5b82020-02-26 17:00:39 +0000354 V1_0::ErrorStatus expectedParserStatus = V1_0::ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100355 ConcatTestImpl({&aIn, &bIn, &mismatched}, axis, expected, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100356}
357
telsoa01ce3e84a2018-08-31 09:31:35 +0100358BOOST_DATA_TEST_CASE(MismatchedInputRanks, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100359{
360 int32_t axis = 2;
361 TestTensor aIn{armnn::TensorShape{1,1,2},{0,1}};
362 TestTensor bIn{armnn::TensorShape{1,1},{4}};
363 TestTensor expected{armnn::TensorShape{1,1,3},{0,1,4}};
364
365 // The input dimensions must be compatible
Kevin Mayec1e5b82020-02-26 17:00:39 +0000366 V1_0::ErrorStatus expectedParserStatus = V1_0::ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100367 ConcatTestImpl({&aIn, &bIn}, axis, expected, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100368}
369
telsoa01ce3e84a2018-08-31 09:31:35 +0100370BOOST_DATA_TEST_CASE(MismatchedOutputDimensions, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100371{
372 int32_t axis = 3;
373 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
374 2, 3}};
375 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
376 7, 8, 9}};
377 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10,
378 11}};
379
380 TestTensor mismatched{armnn::TensorShape{1,1,6,2},{0, 1, 4, 5, 6, 10,
381 2, 3, 7, 8, 9, 11}};
382
383 // The input and output dimensions must be compatible
Kevin Mayec1e5b82020-02-26 17:00:39 +0000384 V1_0::ErrorStatus expectedParserStatus = V1_0::ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100385 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, mismatched, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100386}
387
telsoa01ce3e84a2018-08-31 09:31:35 +0100388BOOST_DATA_TEST_CASE(MismatchedOutputRank, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100389{
390 int32_t axis = 3;
391 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
392 2, 3}};
393 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
394 7, 8, 9}};
395 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10,
396 11}};
397
398 TestTensor mismatched{armnn::TensorShape{6,2},{0, 1, 4, 5, 6, 10,
399 2, 3, 7, 8, 9, 11}};
400
401 // The input and output ranks must match
Kevin Mayec1e5b82020-02-26 17:00:39 +0000402 V1_0::ErrorStatus expectedParserStatus = V1_0::ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100403 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, mismatched, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100404}
405
telsoa01ce3e84a2018-08-31 09:31:35 +0100406BOOST_DATA_TEST_CASE(ValidNegativeAxis, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100407{
408 // this is the same as 3
409 // see: https://www.tensorflow.org/api_docs/python/tf/concat
410 int32_t axis = -1;
411 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
412 2, 3}};
413 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
414 7, 8, 9}};
415 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10,
416 11}};
417
418 TestTensor expected{armnn::TensorShape{1,1,2,6},{0, 1, 4, 5, 6, 10,
419 2, 3, 7, 8, 9, 11}};
420
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100421 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100422}
423
424BOOST_DATA_TEST_CASE(SimpleConcatAxisZero3D, COMPUTE_DEVICES)
425{
426 int32_t axis = 0;
427 TestTensor aIn{armnn::TensorShape{1,1,1},{0}};
428 TestTensor bIn{armnn::TensorShape{1,1,1},{1}};
429 TestTensor cIn{armnn::TensorShape{1,1,1},{2}};
430
431 TestTensor expected{armnn::TensorShape{3,1,1},{0,1,2}};
432
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100433 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100434}
435
436BOOST_DATA_TEST_CASE(SimpleConcatAxisOne3D, COMPUTE_DEVICES)
437{
438 int32_t axis = 1;
439 TestTensor aIn{armnn::TensorShape{1,1,1},{0}};
440 TestTensor bIn{armnn::TensorShape{1,1,1},{1}};
441 TestTensor cIn{armnn::TensorShape{1,1,1},{2}};
442
443 TestTensor expected{armnn::TensorShape{1,3,1},{0,1,2}};
444
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100445 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100446}
447
448BOOST_DATA_TEST_CASE(SimpleConcatAxisTwo3D, COMPUTE_DEVICES)
449{
450 int32_t axis = 2;
451 TestTensor aIn{armnn::TensorShape{1,1,1},{0}};
452 TestTensor bIn{armnn::TensorShape{1,1,1},{1}};
453 TestTensor cIn{armnn::TensorShape{1,1,1},{2}};
454
455 TestTensor expected{armnn::TensorShape{1,1,3},{0,1,2}};
456
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100457 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100458}
459
460BOOST_DATA_TEST_CASE(SimpleConcatAxisZero2D, COMPUTE_DEVICES)
461{
462 int32_t axis = 0;
463 TestTensor aIn{armnn::TensorShape{1,1},{0}};
464 TestTensor bIn{armnn::TensorShape{1,1},{1}};
465 TestTensor cIn{armnn::TensorShape{1,1},{2}};
466
467 TestTensor expected{armnn::TensorShape{3,1},{0,1,2}};
468
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100469 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100470}
471
472BOOST_DATA_TEST_CASE(SimpleConcatAxisOne2D, COMPUTE_DEVICES)
473{
474 int32_t axis = 1;
475 TestTensor aIn{armnn::TensorShape{1,1},{0}};
476 TestTensor bIn{armnn::TensorShape{1,1},{1}};
477 TestTensor cIn{armnn::TensorShape{1,1},{2}};
478
479 TestTensor expected{armnn::TensorShape{1,3},{0,1,2}};
480
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100481 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100482}
483
484BOOST_DATA_TEST_CASE(SimpleConcatAxisZero1D, COMPUTE_DEVICES)
485{
486 int32_t axis = 0;
487 TestTensor aIn{armnn::TensorShape{1},{0}};
488 TestTensor bIn{armnn::TensorShape{1},{1}};
489 TestTensor cIn{armnn::TensorShape{1},{2}};
490
491 TestTensor expected{armnn::TensorShape{3},{0,1,2}};
492
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100493 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100494}
495
496BOOST_AUTO_TEST_SUITE_END()