blob: b5ea689ef5841696388373b7fe8f684a70f1f322 [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"
telsoa01ce3e84a2018-08-31 09:31:35 +01007#include <boost/array.hpp>
surmeh0149b9e102018-05-17 14:11:25 +01008#include <boost/test/unit_test.hpp>
telsoa01ce3e84a2018-08-31 09:31:35 +01009#include <boost/test/data/test_case.hpp>
surmeh0149b9e102018-05-17 14:11:25 +010010#include <log/log.h>
11
12
Jim Flynn7b1e41f2019-05-22 18:00:04 +010013BOOST_AUTO_TEST_SUITE(ConcatTests)
surmeh0149b9e102018-05-17 14:11:25 +010014
telsoa01ce3e84a2018-08-31 09:31:35 +010015using namespace android::hardware;
surmeh0149b9e102018-05-17 14:11:25 +010016using namespace driverTestHelpers;
telsoa01ce3e84a2018-08-31 09:31:35 +010017using namespace armnn_driver;
surmeh0149b9e102018-05-17 14:11:25 +010018
19namespace
20{
21
Kevin Mayedc5ffa2019-05-22 12:02:53 +010022#ifndef ARMCOMPUTECL_ENABLED
23 static const boost::array<armnn::Compute, 1> COMPUTE_DEVICES = {{ armnn::Compute::CpuRef }};
24#else
25 static const boost::array<armnn::Compute, 2> COMPUTE_DEVICES = {{ armnn::Compute::CpuRef, armnn::Compute::GpuAcc }};
26#endif
telsoa01ce3e84a2018-08-31 09:31:35 +010027
surmeh0149b9e102018-05-17 14:11:25 +010028void
Jim Flynn7b1e41f2019-05-22 18:00:04 +010029ConcatTestImpl(const std::vector<const TestTensor*> & inputs,
surmeh0149b9e102018-05-17 14:11:25 +010030 int32_t concatAxis,
31 const TestTensor & expectedOutputTensor,
telsoa01ce3e84a2018-08-31 09:31:35 +010032 armnn::Compute computeDevice,
surmeh0149b9e102018-05-17 14:11:25 +010033 ErrorStatus expectedPrepareStatus=ErrorStatus::NONE,
34 ErrorStatus expectedExecStatus=ErrorStatus::NONE)
35{
telsoa01ce3e84a2018-08-31 09:31:35 +010036 std::unique_ptr<ArmnnDriver> driver = std::make_unique<ArmnnDriver>(DriverOptions(computeDevice));
Matteo Martincigh8b287c22018-09-07 09:25:10 +010037 V1_0::Model model{};
surmeh0149b9e102018-05-17 14:11:25 +010038
39 hidl_vec<uint32_t> modelInputIds;
40 modelInputIds.resize(inputs.size()+1);
41 for (uint32_t i = 0; i<inputs.size(); ++i)
42 {
43 modelInputIds[i] = i;
44 AddInputOperand(model, inputs[i]->GetDimensions());
45 }
46 modelInputIds[inputs.size()] = inputs.size(); // add an id for the axis too
47 AddIntOperand(model, concatAxis);
48 AddOutputOperand(model, expectedOutputTensor.GetDimensions());
49
50 // make the concat operation
51 model.operations.resize(1);
Matteo Martincigh8b287c22018-09-07 09:25:10 +010052 model.operations[0].type = V1_0::OperationType::CONCATENATION;
surmeh0149b9e102018-05-17 14:11:25 +010053 model.operations[0].inputs = modelInputIds;
54 model.operations[0].outputs = hidl_vec<uint32_t>{static_cast<uint32_t>(inputs.size()+1)};
55
56 // make the prepared model
57 ErrorStatus prepareStatus=ErrorStatus::NONE;
Sadik Armagane6e54a82019-05-08 10:18:05 +010058 android::sp<V1_0::IPreparedModel> preparedModel = PrepareModelWithStatus(model,
surmeh0149b9e102018-05-17 14:11:25 +010059 *driver,
60 prepareStatus,
61 expectedPrepareStatus);
62 BOOST_TEST(prepareStatus == expectedPrepareStatus);
63 if (prepareStatus != ErrorStatus::NONE)
64 {
65 // prepare failed, we cannot continue
66 return;
67 }
68
69 BOOST_TEST(preparedModel.get() != nullptr);
70 if (preparedModel.get() == nullptr)
71 {
72 // don't spoil other tests if prepare failed
73 return;
74 }
75
76 // construct the request
77 hidl_vec<RequestArgument> inputArguments;
78 hidl_vec<RequestArgument> outputArguments;
79 inputArguments.resize(inputs.size());
80 outputArguments.resize(1);
81
82 // the request's memory pools will follow the same order as
83 // the inputs
84 for (uint32_t i = 0; i<inputs.size(); ++i)
85 {
86 DataLocation inloc = {};
87 inloc.poolIndex = i;
88 inloc.offset = 0;
89 inloc.length = inputs[i]->GetNumElements() * sizeof(float);
90 RequestArgument input = {};
91 input.location = inloc;
92 input.dimensions = inputs[i]->GetDimensions();
93 inputArguments[i] = input;
94 }
95
96 // and an additional memory pool is needed for the output
97 {
98 DataLocation outloc = {};
99 outloc.poolIndex = inputs.size();
100 outloc.offset = 0;
101 outloc.length = expectedOutputTensor.GetNumElements() * sizeof(float);
102 RequestArgument output = {};
103 output.location = outloc;
104 output.dimensions = expectedOutputTensor.GetDimensions();
105 outputArguments[0] = output;
106 }
107
108 // make the request based on the arguments
109 Request request = {};
110 request.inputs = inputArguments;
111 request.outputs = outputArguments;
112
113 // set the input data
114 for (uint32_t i = 0; i<inputs.size(); ++i)
115 {
116 AddPoolAndSetData(inputs[i]->GetNumElements(),
117 request,
118 inputs[i]->GetData());
119 }
120
121 // add memory for the output
122 android::sp<IMemory> outMemory = AddPoolAndGetData(expectedOutputTensor.GetNumElements(), request);
123 float* outdata = static_cast<float*>(static_cast<void*>(outMemory->getPointer()));
124
125 // run the execution
126 auto execStatus = Execute(preparedModel, request, expectedExecStatus);
127 BOOST_TEST(execStatus == expectedExecStatus);
128
129 if (execStatus == ErrorStatus::NONE)
130 {
131 // check the result if there was no error
132 const float * expectedOutput = expectedOutputTensor.GetData();
133 for (unsigned int i=0; i<expectedOutputTensor.GetNumElements();++i)
134 {
135 BOOST_TEST(outdata[i] == expectedOutput[i]);
136 }
137 }
138}
139
140} // namespace <anonymous>
141
telsoa01ce3e84a2018-08-31 09:31:35 +0100142
143BOOST_DATA_TEST_CASE(SimpleConcatAxis0, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100144{
145 int32_t axis = 0;
146 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
147 TestTensor bIn{armnn::TensorShape{1,1,1,1},{1}};
148 TestTensor cIn{armnn::TensorShape{1,1,1,1},{2}};
149
150 TestTensor expected{armnn::TensorShape{3,1,1,1},{0,1,2}};
151
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100152 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100153}
154
telsoa01ce3e84a2018-08-31 09:31:35 +0100155BOOST_DATA_TEST_CASE(ConcatAxis0_NoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100156{
157 int32_t axis = 0;
158 TestTensor aIn{armnn::TensorShape{2,1,2,1},{0, 1,
159 2, 3}};
160 TestTensor bIn{armnn::TensorShape{3,1,2,1},{4, 5,
161 6, 7,
162 8, 9}};
163 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10, 11}};
164
165 TestTensor expected{armnn::TensorShape{6,1,2,1},{0, 1,
166 2, 3,
167 4, 5,
168 6, 7,
169 8, 9,
170 10, 11}};
171
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100172 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100173}
174
telsoa01ce3e84a2018-08-31 09:31:35 +0100175BOOST_DATA_TEST_CASE(SimpleConcatAxis1, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100176{
177 int32_t axis = 1;
178 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
179 TestTensor bIn{armnn::TensorShape{1,1,1,1},{1}};
180 TestTensor cIn{armnn::TensorShape{1,1,1,1},{2}};
181
182 TestTensor expected{armnn::TensorShape{1,3,1,1},{0,1,2}};
183
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100184 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100185}
186
telsoa01ce3e84a2018-08-31 09:31:35 +0100187BOOST_DATA_TEST_CASE(ConcatAxis1_NoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100188{
189 int32_t axis = 1;
190 TestTensor aIn{armnn::TensorShape{1,2,2,1},{0, 1,
191 2, 3}};
192 TestTensor bIn{armnn::TensorShape{1,3,2,1},{4, 5,
193 6, 7,
194 8, 9}};
195 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10, 11}};
196
197 TestTensor expected{armnn::TensorShape{1,6,2,1},{0, 1,
198 2, 3,
199 4, 5,
200 6, 7,
201 8, 9,
202 10, 11}};
203
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100204 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100205}
206
telsoa01ce3e84a2018-08-31 09:31:35 +0100207BOOST_DATA_TEST_CASE(SimpleConcatAxis1_DoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100208{
209 int32_t axis = 1;
210 TestTensor aIn{armnn::TensorShape{2,2,1,1},{0, 1,
211 2, 3}};
212 TestTensor bIn{armnn::TensorShape{2,3,1,1},{4, 5, 6,
213 7, 8, 9}};
214 TestTensor cIn{armnn::TensorShape{2,1,1,1},{10,
215 11}};
216
217 TestTensor expected{armnn::TensorShape{2,6,1,1},{0, 1, 4, 5, 6, 10,
218 2, 3, 7, 8, 9, 11}};
219
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100220 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100221}
222
telsoa01ce3e84a2018-08-31 09:31:35 +0100223BOOST_DATA_TEST_CASE(SimpleConcatAxis2, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100224{
225 int32_t axis = 2;
226 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
227 TestTensor bIn{armnn::TensorShape{1,1,1,1},{1}};
228 TestTensor cIn{armnn::TensorShape{1,1,1,1},{2}};
229
230 TestTensor expected{armnn::TensorShape{1,1,3,1},{0,1,2}};
231
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100232 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100233}
234
telsoa01ce3e84a2018-08-31 09:31:35 +0100235BOOST_DATA_TEST_CASE(ConcatAxis2_NoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100236{
237 int32_t axis = 2;
238 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
239 2, 3}};
240 TestTensor bIn{armnn::TensorShape{1,1,3,2},{4, 5,
241 6, 7,
242 8, 9}};
243 TestTensor cIn{armnn::TensorShape{1,1,1,2},{10, 11}};
244
245 TestTensor expected{armnn::TensorShape{1,1,6,2},{0, 1,
246 2, 3,
247 4, 5,
248 6, 7,
249 8, 9,
250 10, 11}};
251
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100252 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100253}
254
telsoa01ce3e84a2018-08-31 09:31:35 +0100255BOOST_DATA_TEST_CASE(SimpleConcatAxis2_DoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100256{
257 int32_t axis = 2;
258 TestTensor aIn{armnn::TensorShape{1,2,2,1},{0, 1,
259 2, 3}};
260 TestTensor bIn{armnn::TensorShape{1,2,3,1},{4, 5, 6,
261 7, 8, 9}};
262 TestTensor cIn{armnn::TensorShape{1,2,1,1},{10,
263 11}};
264
265 TestTensor expected{armnn::TensorShape{1,2,6,1},{0, 1, 4, 5, 6, 10,
266 2, 3, 7, 8, 9, 11}};
267
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100268 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100269}
270
telsoa01ce3e84a2018-08-31 09:31:35 +0100271BOOST_DATA_TEST_CASE(SimpleConcatAxis3, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100272{
273 int32_t axis = 3;
274 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
275 TestTensor bIn{armnn::TensorShape{1,1,1,1},{1}};
276 TestTensor cIn{armnn::TensorShape{1,1,1,1},{2}};
277
278 TestTensor expected{armnn::TensorShape{1,1,1,3},{0,1,2}};
279
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100280 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100281}
282
telsoa01ce3e84a2018-08-31 09:31:35 +0100283BOOST_DATA_TEST_CASE(SimpleConcatAxis3_DoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100284{
285 int32_t axis = 3;
286 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
287 2, 3}};
288 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
289 7, 8, 9}};
290 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10,
291 11}};
292
293 TestTensor expected{armnn::TensorShape{1,1,2,6},{0, 1, 4, 5, 6, 10,
294 2, 3, 7, 8, 9, 11}};
295
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100296 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100297}
298
telsoa01ce3e84a2018-08-31 09:31:35 +0100299BOOST_DATA_TEST_CASE(AxisTooBig, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100300{
301 int32_t axis = 4;
302 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
303 TestTensor bIn{armnn::TensorShape{1,1,1,1},{0}};
304
305 // The axis must be within the range of [-rank(values), rank(values))
306 // see: https://www.tensorflow.org/api_docs/python/tf/concat
307 TestTensor uncheckedOutput{armnn::TensorShape{1,1,1,1},{0}};
308 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100309 ConcatTestImpl({&aIn, &bIn}, axis, uncheckedOutput, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100310}
311
telsoa01ce3e84a2018-08-31 09:31:35 +0100312BOOST_DATA_TEST_CASE(AxisTooSmall, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100313{
314 int32_t axis = -5;
315 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
316 TestTensor bIn{armnn::TensorShape{1,1,1,1},{0}};
317
318 // The axis must be within the range of [-rank(values), rank(values))
319 // see: https://www.tensorflow.org/api_docs/python/tf/concat
320 TestTensor uncheckedOutput{armnn::TensorShape{1,1,1,1},{0}};
321 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100322 ConcatTestImpl({&aIn, &bIn}, axis, uncheckedOutput, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100323}
324
telsoa01ce3e84a2018-08-31 09:31:35 +0100325BOOST_DATA_TEST_CASE(TooFewInputs, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100326{
327 int32_t axis = 0;
328 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
329
330 // We need at least two tensors to concatenate
331 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100332 ConcatTestImpl({&aIn}, axis, aIn, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100333}
334
telsoa01ce3e84a2018-08-31 09:31:35 +0100335BOOST_DATA_TEST_CASE(MismatchedInputDimensions, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100336{
337 int32_t axis = 3;
338 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
339 2, 3}};
340 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
341 7, 8, 9}};
342 TestTensor mismatched{armnn::TensorShape{1,1,1,1},{10}};
343
344 TestTensor expected{armnn::TensorShape{1,1,2,6},{0, 1, 4, 5, 6, 10,
345 2, 3, 7, 8, 9, 11}};
346
347 // The input dimensions must be compatible
348 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100349 ConcatTestImpl({&aIn, &bIn, &mismatched}, axis, expected, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100350}
351
telsoa01ce3e84a2018-08-31 09:31:35 +0100352BOOST_DATA_TEST_CASE(MismatchedInputRanks, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100353{
354 int32_t axis = 2;
355 TestTensor aIn{armnn::TensorShape{1,1,2},{0,1}};
356 TestTensor bIn{armnn::TensorShape{1,1},{4}};
357 TestTensor expected{armnn::TensorShape{1,1,3},{0,1,4}};
358
359 // The input dimensions must be compatible
360 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100361 ConcatTestImpl({&aIn, &bIn}, axis, expected, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100362}
363
telsoa01ce3e84a2018-08-31 09:31:35 +0100364BOOST_DATA_TEST_CASE(MismatchedOutputDimensions, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100365{
366 int32_t axis = 3;
367 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
368 2, 3}};
369 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
370 7, 8, 9}};
371 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10,
372 11}};
373
374 TestTensor mismatched{armnn::TensorShape{1,1,6,2},{0, 1, 4, 5, 6, 10,
375 2, 3, 7, 8, 9, 11}};
376
377 // The input and output dimensions must be compatible
378 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100379 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, mismatched, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100380}
381
telsoa01ce3e84a2018-08-31 09:31:35 +0100382BOOST_DATA_TEST_CASE(MismatchedOutputRank, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100383{
384 int32_t axis = 3;
385 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
386 2, 3}};
387 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
388 7, 8, 9}};
389 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10,
390 11}};
391
392 TestTensor mismatched{armnn::TensorShape{6,2},{0, 1, 4, 5, 6, 10,
393 2, 3, 7, 8, 9, 11}};
394
395 // The input and output ranks must match
396 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100397 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, mismatched, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100398}
399
telsoa01ce3e84a2018-08-31 09:31:35 +0100400BOOST_DATA_TEST_CASE(ValidNegativeAxis, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100401{
402 // this is the same as 3
403 // see: https://www.tensorflow.org/api_docs/python/tf/concat
404 int32_t axis = -1;
405 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
406 2, 3}};
407 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
408 7, 8, 9}};
409 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10,
410 11}};
411
412 TestTensor expected{armnn::TensorShape{1,1,2,6},{0, 1, 4, 5, 6, 10,
413 2, 3, 7, 8, 9, 11}};
414
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100415 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100416}
417
418BOOST_DATA_TEST_CASE(SimpleConcatAxisZero3D, COMPUTE_DEVICES)
419{
420 int32_t axis = 0;
421 TestTensor aIn{armnn::TensorShape{1,1,1},{0}};
422 TestTensor bIn{armnn::TensorShape{1,1,1},{1}};
423 TestTensor cIn{armnn::TensorShape{1,1,1},{2}};
424
425 TestTensor expected{armnn::TensorShape{3,1,1},{0,1,2}};
426
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100427 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100428}
429
430BOOST_DATA_TEST_CASE(SimpleConcatAxisOne3D, COMPUTE_DEVICES)
431{
432 int32_t axis = 1;
433 TestTensor aIn{armnn::TensorShape{1,1,1},{0}};
434 TestTensor bIn{armnn::TensorShape{1,1,1},{1}};
435 TestTensor cIn{armnn::TensorShape{1,1,1},{2}};
436
437 TestTensor expected{armnn::TensorShape{1,3,1},{0,1,2}};
438
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100439 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100440}
441
442BOOST_DATA_TEST_CASE(SimpleConcatAxisTwo3D, COMPUTE_DEVICES)
443{
444 int32_t axis = 2;
445 TestTensor aIn{armnn::TensorShape{1,1,1},{0}};
446 TestTensor bIn{armnn::TensorShape{1,1,1},{1}};
447 TestTensor cIn{armnn::TensorShape{1,1,1},{2}};
448
449 TestTensor expected{armnn::TensorShape{1,1,3},{0,1,2}};
450
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100451 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100452}
453
454BOOST_DATA_TEST_CASE(SimpleConcatAxisZero2D, COMPUTE_DEVICES)
455{
456 int32_t axis = 0;
457 TestTensor aIn{armnn::TensorShape{1,1},{0}};
458 TestTensor bIn{armnn::TensorShape{1,1},{1}};
459 TestTensor cIn{armnn::TensorShape{1,1},{2}};
460
461 TestTensor expected{armnn::TensorShape{3,1},{0,1,2}};
462
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100463 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100464}
465
466BOOST_DATA_TEST_CASE(SimpleConcatAxisOne2D, COMPUTE_DEVICES)
467{
468 int32_t axis = 1;
469 TestTensor aIn{armnn::TensorShape{1,1},{0}};
470 TestTensor bIn{armnn::TensorShape{1,1},{1}};
471 TestTensor cIn{armnn::TensorShape{1,1},{2}};
472
473 TestTensor expected{armnn::TensorShape{1,3},{0,1,2}};
474
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100475 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100476}
477
478BOOST_DATA_TEST_CASE(SimpleConcatAxisZero1D, COMPUTE_DEVICES)
479{
480 int32_t axis = 0;
481 TestTensor aIn{armnn::TensorShape{1},{0}};
482 TestTensor bIn{armnn::TensorShape{1},{1}};
483 TestTensor cIn{armnn::TensorShape{1},{2}};
484
485 TestTensor expected{armnn::TensorShape{3},{0,1,2}};
486
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100487 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100488}
489
490BOOST_AUTO_TEST_SUITE_END()