Compute Library
 22.05
Split.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2021 Arm Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #include "arm_compute/core/Types.h"
28 
29 #include "tests/NEON/Accessor.h"
30 #include "tests/datasets/SplitDataset.h"
32 #include "tests/framework/Macros.h"
35 #include "tests/validation/fixtures/SplitFixture.h"
36 
37 namespace arm_compute
38 {
39 namespace test
40 {
41 namespace validation
42 {
43 TEST_SUITE(NEON)
44 TEST_SUITE(Split)
45 
46 // *INDENT-OFF*
47 // clang-format off
49  framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 3U, 16U, 2U), 1, DataType::F32), // Invalid axis
50  TensorInfo(TensorShape(27U, 3U, 16U, 2U), 1, DataType::F32), // Invalid number of splits
51  TensorInfo(TensorShape(27U, 3U, 16U, 2U), 1, DataType::F32)
52  }),
53  framework::dataset::make("Axis", { 4, 2, 2 })),
54  framework::dataset::make("Splits", { 4, 5, 4 })),
55  framework::dataset::make("Expected", { false, false, true })),
56  input_info, axis, splits, expected)
57 {
58  std::vector<TensorInfo> outputs_info(splits);
59  std::vector<ITensorInfo*> outputs_info_ptr;
60  outputs_info_ptr.reserve(splits);
61  for(auto &output_info : outputs_info)
62  {
63  outputs_info_ptr.emplace_back(&output_info);
64  }
65  const Status status = NESplit::validate(&input_info.clone()->set_is_resizable(false), outputs_info_ptr, axis);
67 }
68 
70  framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 3U, 16U, 2U), 1, DataType::F32),
71  TensorInfo(TensorShape(27U, 3U, 16U, 2U), 1, DataType::F32)
72  }),
73  framework::dataset::make("Axis", { 2, 2 })),
74  framework::dataset::make("Splits", { std::vector<TensorInfo>{TensorInfo(TensorShape(27U, 3U, 4U, 2U), 1, DataType::F32),
75  TensorInfo(TensorShape(27U, 3U, 4U, 2U), 1, DataType::F32),
76  TensorInfo(TensorShape(27U, 3U, 8U, 2U), 1, DataType::F32)},
77  std::vector<TensorInfo>{TensorInfo(TensorShape(27U, 3U, 3U, 2U), 1, DataType::F32),
78  TensorInfo(TensorShape(27U, 3U, 13U, 2U), 1, DataType::F32)} })),
79  framework::dataset::make("Expected", { true, true })),
80  input_info, axis, splits, expected)
81 {
82  std::vector<ITensorInfo*> outputs_info_ptr;
83 
84  for(auto &split : splits)
85  {
86  outputs_info_ptr.emplace_back(const_cast<TensorInfo*>(&split));
87  }
88  const Status status = NESplit::validate(&input_info.clone()->set_is_resizable(false), outputs_info_ptr, axis);
90 }
91 // clang-format on
92 // *INDENT-ON*
93 
94 template <typename T>
95 using NESplitFixture = SplitFixture<Tensor, ITensor, Accessor, NESplit, T>;
96 
97 template <typename T>
98 using NESplitShapesFixture = SplitShapesFixture<Tensor, ITensor, Accessor, NESplit, T>;
99 
100 TEST_SUITE(Float)
101 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
102 TEST_SUITE(FP16)
103 FIXTURE_DATA_TEST_CASE(RunSmall,
106  combine(datasets::SmallSplitDataset(), framework::dataset::make("DataType", DataType::F16)))
107 {
108  // Validate outputs
109  for(unsigned int i = 0; i < _target.size(); ++i)
110  {
111  validate(Accessor(_target[i]), _reference[i]);
112  }
113 }
114 
115 FIXTURE_DATA_TEST_CASE(RunLarge,
118  combine(datasets::LargeSplitDataset(), framework::dataset::make("DataType", DataType::F16)))
119 {
120  // Validate outputs
121  for(unsigned int i = 0; i < _target.size(); ++i)
122  {
123  validate(Accessor(_target[i]), _reference[i]);
124  }
125 }
126 TEST_SUITE_END() // FP16
127 #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
128 
129 TEST_SUITE(FP32)
131  NESplitFixture<float>,
132  framework::DatasetMode::PRECOMMIT,
133  combine(datasets::SmallSplitDataset(), framework::dataset::make("DataType", DataType::F32)))
134 {
135  // Validate outputs
136  for(unsigned int i = 0; i < _target.size(); ++i)
137  {
138  validate(Accessor(_target[i]), _reference[i]);
139  }
140 }
141 
145  combine(datasets::LargeSplitDataset(), framework::dataset::make("DataType", DataType::F32)))
146 {
147  // Validate outputs
148  for(unsigned int i = 0; i < _target.size(); ++i)
149  {
150  validate(Accessor(_target[i]), _reference[i]);
151  }
152 }
153 
154 FIXTURE_DATA_TEST_CASE(RunSmallSplitShapes,
157  combine(datasets::SmallSplitShapesDataset(), framework::dataset::make("DataType", DataType::F32)))
158 {
159  // Validate outputs
160  for(unsigned int i = 0; i < _target.size(); ++i)
161  {
162  validate(Accessor(_target[i]), _reference[i]);
163  }
164 }
165 TEST_SUITE_END() // FP32
166 TEST_SUITE_END() // Float
167 
168 TEST_SUITE_END() // Split
169 TEST_SUITE_END() // Neon
170 } // namespace validation
171 } // namespace test
172 } // namespace arm_compute
SplitShapesFixture< Tensor, ITensor, Accessor, NESplit, T > NESplitShapesFixture
Definition: Split.cpp:98
static Status validate(const ITensorInfo *input, const std::vector< ITensorInfo * > &outputs, unsigned int axis)
Static function to check if given info will lead to a valid configuration of CPPSplit.
Definition: CPPSplit.h:58
1 channel, 1 F32 per channel
ARM_COMPUTE_EXPECT(has_error==expected, framework::LogLevel::ERRORS)
std::enable_if< is_container< T >::value, ContainerDataset< T > >::type make(std::string name, T &&values)
Helper function to create a ContainerDataset.
Copyright (c) 2017-2022 Arm Limited.
1 channel, 1 F16 per channel
DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), }), framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F16), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(30U, 11U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), })), framework::dataset::make("ActivationInfo", { ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::SQRT), })), framework::dataset::make("Expected", { false, true, true, true, false, false, true, true, false })), input_info, output_info, act_info, expected)
Accessor implementation for Tensor objects.
Definition: Accessor.h:35
DatasetMode
Possible dataset modes.
Definition: DatasetModes.h:40
TEST_SUITE_END() FIXTURE_DATA_TEST_CASE(RunSmall
[CLActivationLayer Test snippet]
validate(CLAccessor(output_state), expected_output)
FIXTURE_DATA_TEST_CASE(RunSmall, CLAbsLayerFixture< half >, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16)))
Definition: AbsLayer.cpp:50
SplitFixture< Tensor, ITensor, Accessor, NESplit, T > NESplitFixture
Definition: Split.cpp:95
zip(zip(framework::dataset::make("Weights", { TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 1U), 1, DataType::F32), }), framework::dataset::make("MVBGInfo",{ TensorInfo(TensorShape(2U), 1, DataType::F32), TensorInfo(TensorShape(2U), 1, DataType::F16), TensorInfo(TensorShape(5U), 1, DataType::F32), })), framework::dataset::make("Expected", { true, false, false}))
TEST_SUITE(QASYMM8_to_F32) FIXTURE_DATA_TEST_CASE(RunSmall
DataType
Available data types.
Definition: Types.h:79
combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)))
Definition: AbsLayer.cpp:65