blob: 9beb67bd08e4be7d707205800a86378e4784b232 [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,
surmeh0149b9e102018-05-17 14:11:25 +010038 ErrorStatus expectedPrepareStatus=ErrorStatus::NONE,
39 ErrorStatus expectedExecStatus=ErrorStatus::NONE)
40{
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
62 ErrorStatus prepareStatus=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);
68 if (prepareStatus != ErrorStatus::NONE)
69 {
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
114 Request request = {};
115 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
131 auto execStatus = Execute(preparedModel, request, expectedExecStatus);
132 BOOST_TEST(execStatus == expectedExecStatus);
133
134 if (execStatus == ErrorStatus::NONE)
135 {
136 // check the result if there was no error
137 const float * expectedOutput = expectedOutputTensor.GetData();
138 for (unsigned int i=0; i<expectedOutputTensor.GetNumElements();++i)
139 {
140 BOOST_TEST(outdata[i] == expectedOutput[i]);
141 }
142 }
143}
144
145} // namespace <anonymous>
146
telsoa01ce3e84a2018-08-31 09:31:35 +0100147
148BOOST_DATA_TEST_CASE(SimpleConcatAxis0, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100149{
150 int32_t axis = 0;
151 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
152 TestTensor bIn{armnn::TensorShape{1,1,1,1},{1}};
153 TestTensor cIn{armnn::TensorShape{1,1,1,1},{2}};
154
155 TestTensor expected{armnn::TensorShape{3,1,1,1},{0,1,2}};
156
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100157 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100158}
159
telsoa01ce3e84a2018-08-31 09:31:35 +0100160BOOST_DATA_TEST_CASE(ConcatAxis0_NoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100161{
162 int32_t axis = 0;
163 TestTensor aIn{armnn::TensorShape{2,1,2,1},{0, 1,
164 2, 3}};
165 TestTensor bIn{armnn::TensorShape{3,1,2,1},{4, 5,
166 6, 7,
167 8, 9}};
168 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10, 11}};
169
170 TestTensor expected{armnn::TensorShape{6,1,2,1},{0, 1,
171 2, 3,
172 4, 5,
173 6, 7,
174 8, 9,
175 10, 11}};
176
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100177 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100178}
179
telsoa01ce3e84a2018-08-31 09:31:35 +0100180BOOST_DATA_TEST_CASE(SimpleConcatAxis1, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100181{
182 int32_t axis = 1;
183 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
184 TestTensor bIn{armnn::TensorShape{1,1,1,1},{1}};
185 TestTensor cIn{armnn::TensorShape{1,1,1,1},{2}};
186
187 TestTensor expected{armnn::TensorShape{1,3,1,1},{0,1,2}};
188
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100189 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100190}
191
telsoa01ce3e84a2018-08-31 09:31:35 +0100192BOOST_DATA_TEST_CASE(ConcatAxis1_NoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100193{
194 int32_t axis = 1;
195 TestTensor aIn{armnn::TensorShape{1,2,2,1},{0, 1,
196 2, 3}};
197 TestTensor bIn{armnn::TensorShape{1,3,2,1},{4, 5,
198 6, 7,
199 8, 9}};
200 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10, 11}};
201
202 TestTensor expected{armnn::TensorShape{1,6,2,1},{0, 1,
203 2, 3,
204 4, 5,
205 6, 7,
206 8, 9,
207 10, 11}};
208
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100209 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100210}
211
telsoa01ce3e84a2018-08-31 09:31:35 +0100212BOOST_DATA_TEST_CASE(SimpleConcatAxis1_DoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100213{
214 int32_t axis = 1;
215 TestTensor aIn{armnn::TensorShape{2,2,1,1},{0, 1,
216 2, 3}};
217 TestTensor bIn{armnn::TensorShape{2,3,1,1},{4, 5, 6,
218 7, 8, 9}};
219 TestTensor cIn{armnn::TensorShape{2,1,1,1},{10,
220 11}};
221
222 TestTensor expected{armnn::TensorShape{2,6,1,1},{0, 1, 4, 5, 6, 10,
223 2, 3, 7, 8, 9, 11}};
224
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100225 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100226}
227
telsoa01ce3e84a2018-08-31 09:31:35 +0100228BOOST_DATA_TEST_CASE(SimpleConcatAxis2, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100229{
230 int32_t axis = 2;
231 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
232 TestTensor bIn{armnn::TensorShape{1,1,1,1},{1}};
233 TestTensor cIn{armnn::TensorShape{1,1,1,1},{2}};
234
235 TestTensor expected{armnn::TensorShape{1,1,3,1},{0,1,2}};
236
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100237 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100238}
239
telsoa01ce3e84a2018-08-31 09:31:35 +0100240BOOST_DATA_TEST_CASE(ConcatAxis2_NoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100241{
242 int32_t axis = 2;
243 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
244 2, 3}};
245 TestTensor bIn{armnn::TensorShape{1,1,3,2},{4, 5,
246 6, 7,
247 8, 9}};
248 TestTensor cIn{armnn::TensorShape{1,1,1,2},{10, 11}};
249
250 TestTensor expected{armnn::TensorShape{1,1,6,2},{0, 1,
251 2, 3,
252 4, 5,
253 6, 7,
254 8, 9,
255 10, 11}};
256
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100257 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100258}
259
telsoa01ce3e84a2018-08-31 09:31:35 +0100260BOOST_DATA_TEST_CASE(SimpleConcatAxis2_DoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100261{
262 int32_t axis = 2;
263 TestTensor aIn{armnn::TensorShape{1,2,2,1},{0, 1,
264 2, 3}};
265 TestTensor bIn{armnn::TensorShape{1,2,3,1},{4, 5, 6,
266 7, 8, 9}};
267 TestTensor cIn{armnn::TensorShape{1,2,1,1},{10,
268 11}};
269
270 TestTensor expected{armnn::TensorShape{1,2,6,1},{0, 1, 4, 5, 6, 10,
271 2, 3, 7, 8, 9, 11}};
272
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100273 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100274}
275
telsoa01ce3e84a2018-08-31 09:31:35 +0100276BOOST_DATA_TEST_CASE(SimpleConcatAxis3, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100277{
278 int32_t axis = 3;
279 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
280 TestTensor bIn{armnn::TensorShape{1,1,1,1},{1}};
281 TestTensor cIn{armnn::TensorShape{1,1,1,1},{2}};
282
283 TestTensor expected{armnn::TensorShape{1,1,1,3},{0,1,2}};
284
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100285 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100286}
287
telsoa01ce3e84a2018-08-31 09:31:35 +0100288BOOST_DATA_TEST_CASE(SimpleConcatAxis3_DoInterleave, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100289{
290 int32_t axis = 3;
291 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
292 2, 3}};
293 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
294 7, 8, 9}};
295 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10,
296 11}};
297
298 TestTensor expected{armnn::TensorShape{1,1,2,6},{0, 1, 4, 5, 6, 10,
299 2, 3, 7, 8, 9, 11}};
300
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100301 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100302}
303
telsoa01ce3e84a2018-08-31 09:31:35 +0100304BOOST_DATA_TEST_CASE(AxisTooBig, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100305{
306 int32_t axis = 4;
307 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
308 TestTensor bIn{armnn::TensorShape{1,1,1,1},{0}};
309
310 // The axis must be within the range of [-rank(values), rank(values))
311 // see: https://www.tensorflow.org/api_docs/python/tf/concat
312 TestTensor uncheckedOutput{armnn::TensorShape{1,1,1,1},{0}};
313 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100314 ConcatTestImpl({&aIn, &bIn}, axis, uncheckedOutput, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100315}
316
telsoa01ce3e84a2018-08-31 09:31:35 +0100317BOOST_DATA_TEST_CASE(AxisTooSmall, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100318{
319 int32_t axis = -5;
320 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
321 TestTensor bIn{armnn::TensorShape{1,1,1,1},{0}};
322
323 // The axis must be within the range of [-rank(values), rank(values))
324 // see: https://www.tensorflow.org/api_docs/python/tf/concat
325 TestTensor uncheckedOutput{armnn::TensorShape{1,1,1,1},{0}};
326 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100327 ConcatTestImpl({&aIn, &bIn}, axis, uncheckedOutput, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100328}
329
telsoa01ce3e84a2018-08-31 09:31:35 +0100330BOOST_DATA_TEST_CASE(TooFewInputs, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100331{
332 int32_t axis = 0;
333 TestTensor aIn{armnn::TensorShape{1,1,1,1},{0}};
334
335 // We need at least two tensors to concatenate
336 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100337 ConcatTestImpl({&aIn}, axis, aIn, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100338}
339
telsoa01ce3e84a2018-08-31 09:31:35 +0100340BOOST_DATA_TEST_CASE(MismatchedInputDimensions, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100341{
342 int32_t axis = 3;
343 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
344 2, 3}};
345 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
346 7, 8, 9}};
347 TestTensor mismatched{armnn::TensorShape{1,1,1,1},{10}};
348
349 TestTensor expected{armnn::TensorShape{1,1,2,6},{0, 1, 4, 5, 6, 10,
350 2, 3, 7, 8, 9, 11}};
351
352 // The input dimensions must be compatible
353 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100354 ConcatTestImpl({&aIn, &bIn, &mismatched}, axis, expected, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100355}
356
telsoa01ce3e84a2018-08-31 09:31:35 +0100357BOOST_DATA_TEST_CASE(MismatchedInputRanks, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100358{
359 int32_t axis = 2;
360 TestTensor aIn{armnn::TensorShape{1,1,2},{0,1}};
361 TestTensor bIn{armnn::TensorShape{1,1},{4}};
362 TestTensor expected{armnn::TensorShape{1,1,3},{0,1,4}};
363
364 // The input dimensions must be compatible
365 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100366 ConcatTestImpl({&aIn, &bIn}, axis, expected, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100367}
368
telsoa01ce3e84a2018-08-31 09:31:35 +0100369BOOST_DATA_TEST_CASE(MismatchedOutputDimensions, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100370{
371 int32_t axis = 3;
372 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
373 2, 3}};
374 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
375 7, 8, 9}};
376 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10,
377 11}};
378
379 TestTensor mismatched{armnn::TensorShape{1,1,6,2},{0, 1, 4, 5, 6, 10,
380 2, 3, 7, 8, 9, 11}};
381
382 // The input and output dimensions must be compatible
383 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100384 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, mismatched, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100385}
386
telsoa01ce3e84a2018-08-31 09:31:35 +0100387BOOST_DATA_TEST_CASE(MismatchedOutputRank, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100388{
389 int32_t axis = 3;
390 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
391 2, 3}};
392 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
393 7, 8, 9}};
394 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10,
395 11}};
396
397 TestTensor mismatched{armnn::TensorShape{6,2},{0, 1, 4, 5, 6, 10,
398 2, 3, 7, 8, 9, 11}};
399
400 // The input and output ranks must match
401 ErrorStatus expectedParserStatus = ErrorStatus::GENERAL_FAILURE;
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100402 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, mismatched, sample, expectedParserStatus);
surmeh0149b9e102018-05-17 14:11:25 +0100403}
404
telsoa01ce3e84a2018-08-31 09:31:35 +0100405BOOST_DATA_TEST_CASE(ValidNegativeAxis, COMPUTE_DEVICES)
surmeh0149b9e102018-05-17 14:11:25 +0100406{
407 // this is the same as 3
408 // see: https://www.tensorflow.org/api_docs/python/tf/concat
409 int32_t axis = -1;
410 TestTensor aIn{armnn::TensorShape{1,1,2,2},{0, 1,
411 2, 3}};
412 TestTensor bIn{armnn::TensorShape{1,1,2,3},{4, 5, 6,
413 7, 8, 9}};
414 TestTensor cIn{armnn::TensorShape{1,1,2,1},{10,
415 11}};
416
417 TestTensor expected{armnn::TensorShape{1,1,2,6},{0, 1, 4, 5, 6, 10,
418 2, 3, 7, 8, 9, 11}};
419
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100420 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100421}
422
423BOOST_DATA_TEST_CASE(SimpleConcatAxisZero3D, COMPUTE_DEVICES)
424{
425 int32_t axis = 0;
426 TestTensor aIn{armnn::TensorShape{1,1,1},{0}};
427 TestTensor bIn{armnn::TensorShape{1,1,1},{1}};
428 TestTensor cIn{armnn::TensorShape{1,1,1},{2}};
429
430 TestTensor expected{armnn::TensorShape{3,1,1},{0,1,2}};
431
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100432 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100433}
434
435BOOST_DATA_TEST_CASE(SimpleConcatAxisOne3D, COMPUTE_DEVICES)
436{
437 int32_t axis = 1;
438 TestTensor aIn{armnn::TensorShape{1,1,1},{0}};
439 TestTensor bIn{armnn::TensorShape{1,1,1},{1}};
440 TestTensor cIn{armnn::TensorShape{1,1,1},{2}};
441
442 TestTensor expected{armnn::TensorShape{1,3,1},{0,1,2}};
443
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100444 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100445}
446
447BOOST_DATA_TEST_CASE(SimpleConcatAxisTwo3D, COMPUTE_DEVICES)
448{
449 int32_t axis = 2;
450 TestTensor aIn{armnn::TensorShape{1,1,1},{0}};
451 TestTensor bIn{armnn::TensorShape{1,1,1},{1}};
452 TestTensor cIn{armnn::TensorShape{1,1,1},{2}};
453
454 TestTensor expected{armnn::TensorShape{1,1,3},{0,1,2}};
455
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100456 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100457}
458
459BOOST_DATA_TEST_CASE(SimpleConcatAxisZero2D, COMPUTE_DEVICES)
460{
461 int32_t axis = 0;
462 TestTensor aIn{armnn::TensorShape{1,1},{0}};
463 TestTensor bIn{armnn::TensorShape{1,1},{1}};
464 TestTensor cIn{armnn::TensorShape{1,1},{2}};
465
466 TestTensor expected{armnn::TensorShape{3,1},{0,1,2}};
467
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100468 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100469}
470
471BOOST_DATA_TEST_CASE(SimpleConcatAxisOne2D, COMPUTE_DEVICES)
472{
473 int32_t axis = 1;
474 TestTensor aIn{armnn::TensorShape{1,1},{0}};
475 TestTensor bIn{armnn::TensorShape{1,1},{1}};
476 TestTensor cIn{armnn::TensorShape{1,1},{2}};
477
478 TestTensor expected{armnn::TensorShape{1,3},{0,1,2}};
479
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100480 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
telsoa01ce3e84a2018-08-31 09:31:35 +0100481}
482
483BOOST_DATA_TEST_CASE(SimpleConcatAxisZero1D, COMPUTE_DEVICES)
484{
485 int32_t axis = 0;
486 TestTensor aIn{armnn::TensorShape{1},{0}};
487 TestTensor bIn{armnn::TensorShape{1},{1}};
488 TestTensor cIn{armnn::TensorShape{1},{2}};
489
490 TestTensor expected{armnn::TensorShape{3},{0,1,2}};
491
Jim Flynn7b1e41f2019-05-22 18:00:04 +0100492 ConcatTestImpl({&aIn, &bIn, &cIn}, axis, expected, sample);
surmeh0149b9e102018-05-17 14:11:25 +0100493}
494
495BOOST_AUTO_TEST_SUITE_END()