Compute Library
 22.11
ArgMinMax.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"
30 
32 #include "tests/NEON/Accessor.h"
33 #include "tests/datasets/ShapeDatasets.h"
34 #include "tests/datasets/SplitDataset.h"
36 #include "tests/framework/Macros.h"
38 #include "tests/validation/fixtures/ArgMinMaxFixture.h"
39 
40 namespace arm_compute
41 {
42 namespace test
43 {
44 namespace validation
45 {
46 TEST_SUITE(NEON)
47 TEST_SUITE(ArgMinMax)
48 
49 // *INDENT-OFF*
50 // clang-format off
51 DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
52  framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 3U, 16U, 2U), 1, DataType::F32), // Invalid axis
53  TensorInfo(TensorShape(27U, 3U, 16U, 2U), 1, DataType::F32), // Invalid output shape
54  TensorInfo(TensorShape(32U, 16U, 16U, 2U), 1, DataType::F32),
55  TensorInfo(TensorShape(32U, 16U, 16U, 2U), 1, DataType::F32) // Invalid operation
56  }),
57  framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(27U, 3U, 1U, 2U), 1, DataType::F32),
58  TensorInfo(TensorShape(27U, 3U, 1U, 2U), 1, DataType::F32),
59  TensorInfo(TensorShape(32U, 16U, 2U), 1, DataType::S32),
60  TensorInfo(TensorShape(32U, 16U, 1U, 2U), 1, DataType::F32)
61  })),
62  framework::dataset::make("Axis", { 4, 0, 2, 0 })),
64  framework::dataset::make("Expected", { false, false, true, false })),
65  input_info, output_info, axis, operation, expected)
66 {
67  const Status status = NEArgMinMaxLayer::validate(&input_info.clone()->set_is_resizable(false), axis, &output_info.clone()->set_is_resizable(false), operation);
69 }
70 // clang-format on
71 // *INDENT-ON*
72 
73 template <typename T>
74 using NEArgMinMaxValidationFixture = ArgMinMaxValidationFixture<Tensor, Accessor, NEArgMinMaxLayer, T>;
75 
76 TEST_SUITE(S32)
79  framework::DatasetMode::PRECOMMIT,
80  combine(combine(combine(datasets::Small4DShapes(), framework::dataset::make("DataType", DataType::S32)), framework::dataset::make("Axis", { 0, 1, 2, 3 })), framework::dataset::make("Operation", { ReductionOperation::ARG_IDX_MIN, ReductionOperation::ARG_IDX_MAX })))
81 {
82  // Validate output
83  validate(Accessor(_target), _reference);
84 }
85 
90 {
91  // Validate output
92  validate(Accessor(_target), _reference);
93 }
94 TEST_SUITE_END() // S32
95 
96 TEST_SUITE(Float)
97 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
98 TEST_SUITE(FP16)
99 FIXTURE_DATA_TEST_CASE(RunSmall,
103 {
104  // Validate output
105  validate(Accessor(_target), _reference);
106 }
107 
108 FIXTURE_DATA_TEST_CASE(RunLarge,
112 {
113  // Validate output
114  validate(Accessor(_target), _reference);
115 }
116 TEST_SUITE_END() // FP16
117 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
118 
119 TEST_SUITE(FP32)
120 FIXTURE_DATA_TEST_CASE(RunSmall,
124 {
125  // Validate output
126  validate(Accessor(_target), _reference);
127 }
128 
133 {
134  // Validate output
135  validate(Accessor(_target), _reference);
136 }
137 TEST_SUITE_END() // FP32
138 TEST_SUITE_END() // Float
139 
140 template <typename T>
141 using NEArgMinMaxQuantizedValidationFixture = ArgMinMaxValidationQuantizedFixture<Tensor, Accessor, NEArgMinMaxLayer, T>;
142 
145  NEArgMinMaxQuantizedValidationFixture<uint8_t>,
146  framework::DatasetMode::PRECOMMIT,
147  combine(combine(combine(combine(datasets::Small4DShapes(), framework::dataset::make("DataType", DataType::QASYMM8)), framework::dataset::make("Axis", { 0, 1, 2, 3 })),
149  framework::dataset::make("QuantizationInfo", { QuantizationInfo(5.f / 255.f, 20) })))
150 {
151  // Validate output
152  validate(Accessor(_target), _reference);
153 }
154 
156  NEArgMinMaxQuantizedValidationFixture<uint8_t>,
158  combine(combine(combine(combine(datasets::Large4DShapes(), framework::dataset::make("DataType", DataType::QASYMM8)), framework::dataset::make("Axis", { 0, 1, 2, 3 })),
160  framework::dataset::make("QuantizationInfo", { QuantizationInfo(5.f / 255.f, 20) })))
161 {
162  // Validate output
163  validate(Accessor(_target), _reference);
164 }
165 TEST_SUITE_END() // QASYMM8
166 
168 FIXTURE_DATA_TEST_CASE(RunSmall,
171  combine(combine(combine(combine(datasets::Small4DShapes(), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), framework::dataset::make("Axis", { 0, 1, 2, 3 })),
173  framework::dataset::make("QuantizationInfo", { QuantizationInfo(5.f / 127.f, 20) })))
174 {
175  // Validate output
176  validate(Accessor(_target), _reference);
177 }
178 
182  combine(combine(combine(combine(datasets::Large4DShapes(), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED)), framework::dataset::make("Axis", { 0, 1, 2, 3 })),
184  framework::dataset::make("QuantizationInfo", { QuantizationInfo(5.f / 127.f, 20) })))
185 {
186  // Validate output
187  validate(Accessor(_target), _reference);
188 }
189 TEST_SUITE_END() // QASYMM8_SIGNED
190 TEST_SUITE_END() // ArgMinMax
191 TEST_SUITE_END() // Neon
192 } // namespace validation
193 } // namespace test
194 } // namespace arm_compute
Shape of a tensor.
Definition: TensorShape.h:39
static Status validate(const ITensorInfo *input, int axis, const ITensorInfo *output, const ReductionOperation &op)
Static function to check if given info will lead to a valid configuration of NEArgMinMaxLayer.
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.
Status class.
Definition: Error.h:52
Copyright (c) 2017-2022 Arm Limited.
1 channel, 1 F16 per channel
1 channel, 1 S32 per channel
Quantization information.
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]
quantized, asymmetric fixed-point 8-bit number unsigned
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
ArgMinMaxValidationFixture< Tensor, Accessor, NEArgMinMaxLayer, T > NEArgMinMaxValidationFixture
Definition: ArgMinMax.cpp:74
Store the tensor&#39;s metadata.
Definition: TensorInfo.h:43
quantized, asymmetric fixed-point 8-bit number signed
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