blob: 16ac451c003fae678c7e44f5ec9b705d6969b857 [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
13BOOST_AUTO_TEST_SUITE(MergerTests)
14
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
telsoa01ce3e84a2018-08-31 09:31:35 +010022static const boost::array<armnn::Compute, 2> COMPUTE_DEVICES = {{ armnn::Compute::CpuRef, armnn::Compute::GpuAcc }};
23
surmeh0149b9e102018-05-17 14:11:25 +010024void
25MergerTestImpl(const std::vector<const TestTensor*> & inputs,
26 int32_t concatAxis,
27 const TestTensor & expectedOutputTensor,
telsoa01ce3e84a2018-08-31 09:31:35 +010028 armnn::Compute computeDevice,
surmeh0149b9e102018-05-17 14:11:25 +010029 ErrorStatus expectedPrepareStatus=ErrorStatus::NONE,
30 ErrorStatus expectedExecStatus=ErrorStatus::NONE)
31{
telsoa01ce3e84a2018-08-31 09:31:35 +010032 std::unique_ptr<ArmnnDriver> driver = std::make_unique<ArmnnDriver>(DriverOptions(computeDevice));
Matteo Martincigh8b287c22018-09-07 09:25:10 +010033 V1_0::Model model{};
surmeh0149b9e102018-05-17 14:11:25 +010034
35 hidl_vec<uint32_t> modelInputIds;
36 modelInputIds.resize(inputs.size()+1);
37 for (uint32_t i = 0; i<inputs.size(); ++i)
38 {
39 modelInputIds[i] = i;
40 AddInputOperand(model, inputs[i]->GetDimensions());
41 }
42 modelInputIds[inputs.size()] = inputs.size(); // add an id for the axis too
43 AddIntOperand(model, concatAxis);
44 AddOutputOperand(model, expectedOutputTensor.GetDimensions());
45
46 // make the concat operation
47 model.operations.resize(1);
Matteo Martincigh8b287c22018-09-07 09:25:10 +010048 model.operations[0].type = V1_0::OperationType::CONCATENATION;
surmeh0149b9e102018-05-17 14:11:25 +010049 model.operations[0].inputs = modelInputIds;
50 model.operations[0].outputs = hidl_vec<uint32_t>{static_cast<uint32_t>(inputs.size()+1)};
51
52 // make the prepared model
53 ErrorStatus prepareStatus=ErrorStatus::NONE;
Sadik Armagane6e54a82019-05-08 10:18:05 +010054 android::sp<V1_0::IPreparedModel> preparedModel = PrepareModelWithStatus(model,
surmeh0149b9e102018-05-17 14:11:25 +010055 *driver,
56 prepareStatus,
57 expectedPrepareStatus);
58 BOOST_TEST(prepareStatus == expectedPrepareStatus);
59 if (prepareStatus != ErrorStatus::NONE)
60 {
61 // prepare failed, we cannot continue
62 return;
63 }
64
65 BOOST_TEST(preparedModel.get() != nullptr);
66 if (preparedModel.get() == nullptr)
67 {
68 // don't spoil other tests if prepare failed
69 return;
70 }
71
72 // construct the request
73 hidl_vec<RequestArgument> inputArguments;
74 hidl_vec<RequestArgument> outputArguments;
75 inputArguments.resize(inputs.size());
76 outputArguments.resize(1);
77
78 // the request's memory pools will follow the same order as
79 // the inputs
80 for (uint32_t i = 0; i<inputs.size(); ++i)
81 {
82 DataLocation inloc = {};
83 inloc.poolIndex = i;
84 inloc.offset = 0;
85 inloc.length = inputs[i]->GetNumElements() * sizeof(float);
86 RequestArgument input = {};
87 input.location = inloc;
88 input.dimensions = inputs[i]->GetDimensions();
89 inputArguments[i] = input;
90 }
91
92 // and an additional memory pool is needed for the output
93 {
94 DataLocation outloc = {};
95 outloc.poolIndex = inputs.size();
96 outloc.offset = 0;
97 outloc.length = expectedOutputTensor.GetNumElements() * sizeof(float);
98 RequestArgument output = {};
99 output.location = outloc;
100 output.dimensions = expectedOutputTensor.GetDimensions();
101 outputArguments[0] = output;
102 }
103
104 // make the request based on the arguments
105 Request request = {};
106 request.inputs = inputArguments;
107 request.outputs = outputArguments;
108
109 // set the input data
110 for (uint32_t i = 0; i<inputs.size(); ++i)
111 {
112 AddPoolAndSetData(inputs[i]->GetNumElements(),
113 request,
114 inputs[i]->GetData());
115 }
116
117 // add memory for the output
118 android::sp<IMemory> outMemory = AddPoolAndGetData(expectedOutputTensor.GetNumElements(), request);
119 float* outdata = static_cast<float*>(static_cast<void*>(outMemory->getPointer()));
120
121 // run the execution
122 auto execStatus = Execute(preparedModel, request, expectedExecStatus);
123 BOOST_TEST(execStatus == expectedExecStatus);
124
125 if (execStatus == ErrorStatus::NONE)
126 {
127 // check the result if there was no error
128 const float * expectedOutput = expectedOutputTensor.GetData();
129 for (unsigned int i=0; i<expectedOutputTensor.GetNumElements();++i)
130 {
131 BOOST_TEST(outdata[i] == expectedOutput[i]);
132 }
133 }
134}
135
136} // namespace <anonymous>
137
telsoa01ce3e84a2018-08-31 09:31:35 +0100138
139BOOST_DATA_TEST_CASE(SimpleConcatAxis0, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100140{
141 int32_t axis = 0;
142 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
143 TestTensor bIn{armnn::TensorShape{1,1,1,1},{1}};
144 TestTensor cIn{armnn::TensorShape{1,1,1,1},{2}};
145
146 TestTensor expected{armnn::TensorShape{3,1,1,1},{0,1,2}};
147
telsoa01ce3e84a2018-08-31 09:31:35 +0100148 MergerTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100149}
150
telsoa01ce3e84a2018-08-31 09:31:35 +0100151BOOST_DATA_TEST_CASE(ConcatAxis0_NoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100152{
153 int32_t axis = 0;
154 TestTensor aIn{armnn::TensorShape{2,1,2,1},{0, 1,
155 2, 3}};
156 TestTensor bIn{armnn::TensorShape{3,1,2,1},{4, 5,
157 6, 7,
158 8, 9}};
159 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10, 11}};
160
161 TestTensor expected{armnn::TensorShape{6,1,2,1},{0, 1,
162 2, 3,
163 4, 5,
164 6, 7,
165 8, 9,
166 10, 11}};
167
telsoa01ce3e84a2018-08-31 09:31:35 +0100168 MergerTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100169}
170
telsoa01ce3e84a2018-08-31 09:31:35 +0100171BOOST_DATA_TEST_CASE(SimpleConcatAxis1, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100172{
173 int32_t axis = 1;
174 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
175 TestTensor bIn{armnn::TensorShape{1,1,1,1},{1}};
176 TestTensor cIn{armnn::TensorShape{1,1,1,1},{2}};
177
178 TestTensor expected{armnn::TensorShape{1,3,1,1},{0,1,2}};
179
telsoa01ce3e84a2018-08-31 09:31:35 +0100180 MergerTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100181}
182
telsoa01ce3e84a2018-08-31 09:31:35 +0100183BOOST_DATA_TEST_CASE(ConcatAxis1_NoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100184{
185 int32_t axis = 1;
186 TestTensor aIn{armnn::TensorShape{1,2,2,1},{0, 1,
187 2, 3}};
188 TestTensor bIn{armnn::TensorShape{1,3,2,1},{4, 5,
189 6, 7,
190 8, 9}};
191 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10, 11}};
192
193 TestTensor expected{armnn::TensorShape{1,6,2,1},{0, 1,
194 2, 3,
195 4, 5,
196 6, 7,
197 8, 9,
198 10, 11}};
199
telsoa01ce3e84a2018-08-31 09:31:35 +0100200 MergerTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100201}
202
telsoa01ce3e84a2018-08-31 09:31:35 +0100203BOOST_DATA_TEST_CASE(SimpleConcatAxis1_DoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100204{
205 int32_t axis = 1;
206 TestTensor aIn{armnn::TensorShape{2,2,1,1},{0, 1,
207 2, 3}};
208 TestTensor bIn{armnn::TensorShape{2,3,1,1},{4, 5, 6,
209 7, 8, 9}};
210 TestTensor cIn{armnn::TensorShape{2,1,1,1},{10,
211 11}};
212
213 TestTensor expected{armnn::TensorShape{2,6,1,1},{0, 1, 4, 5, 6, 10,
214 2, 3, 7, 8, 9, 11}};
215
telsoa01ce3e84a2018-08-31 09:31:35 +0100216 MergerTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100217}
218
telsoa01ce3e84a2018-08-31 09:31:35 +0100219BOOST_DATA_TEST_CASE(SimpleConcatAxis2, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100220{
221 int32_t axis = 2;
222 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
223 TestTensor bIn{armnn::TensorShape{1,1,1,1},{1}};
224 TestTensor cIn{armnn::TensorShape{1,1,1,1},{2}};
225
226 TestTensor expected{armnn::TensorShape{1,1,3,1},{0,1,2}};
227
telsoa01ce3e84a2018-08-31 09:31:35 +0100228 MergerTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100229}
230
telsoa01ce3e84a2018-08-31 09:31:35 +0100231BOOST_DATA_TEST_CASE(ConcatAxis2_NoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100232{
233 int32_t axis = 2;
234 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
235 2, 3}};
236 TestTensor bIn{armnn::TensorShape{1,1,3,2},{4, 5,
237 6, 7,
238 8, 9}};
239 TestTensor cIn{armnn::TensorShape{1,1,1,2},{10, 11}};
240
241 TestTensor expected{armnn::TensorShape{1,1,6,2},{0, 1,
242 2, 3,
243 4, 5,
244 6, 7,
245 8, 9,
246 10, 11}};
247
telsoa01ce3e84a2018-08-31 09:31:35 +0100248 MergerTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100249}
250
telsoa01ce3e84a2018-08-31 09:31:35 +0100251BOOST_DATA_TEST_CASE(SimpleConcatAxis2_DoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100252{
253 int32_t axis = 2;
254 TestTensor aIn{armnn::TensorShape{1,2,2,1},{0, 1,
255 2, 3}};
256 TestTensor bIn{armnn::TensorShape{1,2,3,1},{4, 5, 6,
257 7, 8, 9}};
258 TestTensor cIn{armnn::TensorShape{1,2,1,1},{10,
259 11}};
260
261 TestTensor expected{armnn::TensorShape{1,2,6,1},{0, 1, 4, 5, 6, 10,
262 2, 3, 7, 8, 9, 11}};
263
telsoa01ce3e84a2018-08-31 09:31:35 +0100264 MergerTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100265}
266
telsoa01ce3e84a2018-08-31 09:31:35 +0100267BOOST_DATA_TEST_CASE(SimpleConcatAxis3, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100268{
269 int32_t axis = 3;
270 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
271 TestTensor bIn{armnn::TensorShape{1,1,1,1},{1}};
272 TestTensor cIn{armnn::TensorShape{1,1,1,1},{2}};
273
274 TestTensor expected{armnn::TensorShape{1,1,1,3},{0,1,2}};
275
telsoa01ce3e84a2018-08-31 09:31:35 +0100276 MergerTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100277}
278
telsoa01ce3e84a2018-08-31 09:31:35 +0100279BOOST_DATA_TEST_CASE(SimpleConcatAxis3_DoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100280{
281 int32_t axis = 3;
282 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
283 2, 3}};
284 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
285 7, 8, 9}};
286 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10,
287 11}};
288
289 TestTensor expected{armnn::TensorShape{1,1,2,6},{0, 1, 4, 5, 6, 10,
290 2, 3, 7, 8, 9, 11}};
291
telsoa01ce3e84a2018-08-31 09:31:35 +0100292 MergerTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100293}
294
telsoa01ce3e84a2018-08-31 09:31:35 +0100295BOOST_DATA_TEST_CASE(AxisTooBig, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100296{
297 int32_t axis = 4;
298 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
299 TestTensor bIn{armnn::TensorShape{1,1,1,1},{0}};
300
301 // The axis must be within the range of [-rank(values), rank(values))
302 // see: https://www.tensorflow.org/api_docs/python/tf/concat
303 TestTensor uncheckedOutput{armnn::TensorShape{1,1,1,1},{0}};
304 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
telsoa01ce3e84a2018-08-31 09:31:35 +0100305 MergerTestImpl({&aIn, &bIn}, axis, uncheckedOutput, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100306}
307
telsoa01ce3e84a2018-08-31 09:31:35 +0100308BOOST_DATA_TEST_CASE(AxisTooSmall, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100309{
310 int32_t axis = -5;
311 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
312 TestTensor bIn{armnn::TensorShape{1,1,1,1},{0}};
313
314 // The axis must be within the range of [-rank(values), rank(values))
315 // see: https://www.tensorflow.org/api_docs/python/tf/concat
316 TestTensor uncheckedOutput{armnn::TensorShape{1,1,1,1},{0}};
317 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
telsoa01ce3e84a2018-08-31 09:31:35 +0100318 MergerTestImpl({&aIn, &bIn}, axis, uncheckedOutput, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100319}
320
telsoa01ce3e84a2018-08-31 09:31:35 +0100321BOOST_DATA_TEST_CASE(TooFewInputs, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100322{
323 int32_t axis = 0;
324 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
325
326 // We need at least two tensors to concatenate
327 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
telsoa01ce3e84a2018-08-31 09:31:35 +0100328 MergerTestImpl({&aIn}, axis, aIn, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100329}
330
telsoa01ce3e84a2018-08-31 09:31:35 +0100331BOOST_DATA_TEST_CASE(MismatchedInputDimensions, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100332{
333 int32_t axis = 3;
334 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
335 2, 3}};
336 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
337 7, 8, 9}};
338 TestTensor mismatched{armnn::TensorShape{1,1,1,1},{10}};
339
340 TestTensor expected{armnn::TensorShape{1,1,2,6},{0, 1, 4, 5, 6, 10,
341 2, 3, 7, 8, 9, 11}};
342
343 // The input dimensions must be compatible
344 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
telsoa01ce3e84a2018-08-31 09:31:35 +0100345 MergerTestImpl({&aIn, &bIn, &mismatched}, axis, expected, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100346}
347
telsoa01ce3e84a2018-08-31 09:31:35 +0100348BOOST_DATA_TEST_CASE(MismatchedInputRanks, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100349{
350 int32_t axis = 2;
351 TestTensor aIn{armnn::TensorShape{1,1,2},{0,1}};
352 TestTensor bIn{armnn::TensorShape{1,1},{4}};
353 TestTensor expected{armnn::TensorShape{1,1,3},{0,1,4}};
354
355 // The input dimensions must be compatible
356 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
telsoa01ce3e84a2018-08-31 09:31:35 +0100357 MergerTestImpl({&aIn, &bIn}, axis, expected, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100358}
359
telsoa01ce3e84a2018-08-31 09:31:35 +0100360BOOST_DATA_TEST_CASE(MismatchedOutputDimensions, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100361{
362 int32_t axis = 3;
363 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
364 2, 3}};
365 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
366 7, 8, 9}};
367 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10,
368 11}};
369
370 TestTensor mismatched{armnn::TensorShape{1,1,6,2},{0, 1, 4, 5, 6, 10,
371 2, 3, 7, 8, 9, 11}};
372
373 // The input and output dimensions must be compatible
374 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
telsoa01ce3e84a2018-08-31 09:31:35 +0100375 MergerTestImpl({&aIn, &bIn, &cIn}, axis, mismatched, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100376}
377
telsoa01ce3e84a2018-08-31 09:31:35 +0100378BOOST_DATA_TEST_CASE(MismatchedOutputRank, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100379{
380 int32_t axis = 3;
381 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
382 2, 3}};
383 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
384 7, 8, 9}};
385 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10,
386 11}};
387
388 TestTensor mismatched{armnn::TensorShape{6,2},{0, 1, 4, 5, 6, 10,
389 2, 3, 7, 8, 9, 11}};
390
391 // The input and output ranks must match
392 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
telsoa01ce3e84a2018-08-31 09:31:35 +0100393 MergerTestImpl({&aIn, &bIn, &cIn}, axis, mismatched, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100394}
395
telsoa01ce3e84a2018-08-31 09:31:35 +0100396BOOST_DATA_TEST_CASE(ValidNegativeAxis, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100397{
398 // this is the same as 3
399 // see: https://www.tensorflow.org/api_docs/python/tf/concat
400 int32_t axis = -1;
401 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
402 2, 3}};
403 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
404 7, 8, 9}};
405 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10,
406 11}};
407
408 TestTensor expected{armnn::TensorShape{1,1,2,6},{0, 1, 4, 5, 6, 10,
409 2, 3, 7, 8, 9, 11}};
410
telsoa01ce3e84a2018-08-31 09:31:35 +0100411 MergerTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
412}
413
414BOOST_DATA_TEST_CASE(SimpleConcatAxisZero3D, COMPUTE_DEVICES)
415{
416 int32_t axis = 0;
417 TestTensor aIn{armnn::TensorShape{1,1,1},{0}};
418 TestTensor bIn{armnn::TensorShape{1,1,1},{1}};
419 TestTensor cIn{armnn::TensorShape{1,1,1},{2}};
420
421 TestTensor expected{armnn::TensorShape{3,1,1},{0,1,2}};
422
423 MergerTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
424}
425
426BOOST_DATA_TEST_CASE(SimpleConcatAxisOne3D, COMPUTE_DEVICES)
427{
428 int32_t axis = 1;
429 TestTensor aIn{armnn::TensorShape{1,1,1},{0}};
430 TestTensor bIn{armnn::TensorShape{1,1,1},{1}};
431 TestTensor cIn{armnn::TensorShape{1,1,1},{2}};
432
433 TestTensor expected{armnn::TensorShape{1,3,1},{0,1,2}};
434
435 MergerTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
436}
437
438BOOST_DATA_TEST_CASE(SimpleConcatAxisTwo3D, COMPUTE_DEVICES)
439{
440 int32_t axis = 2;
441 TestTensor aIn{armnn::TensorShape{1,1,1},{0}};
442 TestTensor bIn{armnn::TensorShape{1,1,1},{1}};
443 TestTensor cIn{armnn::TensorShape{1,1,1},{2}};
444
445 TestTensor expected{armnn::TensorShape{1,1,3},{0,1,2}};
446
447 MergerTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
448}
449
450BOOST_DATA_TEST_CASE(SimpleConcatAxisZero2D, COMPUTE_DEVICES)
451{
452 int32_t axis = 0;
453 TestTensor aIn{armnn::TensorShape{1,1},{0}};
454 TestTensor bIn{armnn::TensorShape{1,1},{1}};
455 TestTensor cIn{armnn::TensorShape{1,1},{2}};
456
457 TestTensor expected{armnn::TensorShape{3,1},{0,1,2}};
458
459 MergerTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
460}
461
462BOOST_DATA_TEST_CASE(SimpleConcatAxisOne2D, COMPUTE_DEVICES)
463{
464 int32_t axis = 1;
465 TestTensor aIn{armnn::TensorShape{1,1},{0}};
466 TestTensor bIn{armnn::TensorShape{1,1},{1}};
467 TestTensor cIn{armnn::TensorShape{1,1},{2}};
468
469 TestTensor expected{armnn::TensorShape{1,3},{0,1,2}};
470
471 MergerTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
472}
473
474BOOST_DATA_TEST_CASE(SimpleConcatAxisZero1D, COMPUTE_DEVICES)
475{
476 int32_t axis = 0;
477 TestTensor aIn{armnn::TensorShape{1},{0}};
478 TestTensor bIn{armnn::TensorShape{1},{1}};
479 TestTensor cIn{armnn::TensorShape{1},{2}};
480
481 TestTensor expected{armnn::TensorShape{3},{0,1,2}};
482
483 MergerTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100484}
485
486BOOST_AUTO_TEST_SUITE_END()