blob: ed39525ef5002436e5f59d0145651b471825c0e9 [file] [log] [blame]
John Richardsonf89a49f2017-09-05 11:21:56 +01001/*
Michalis Spyrou80943252019-01-10 17:19:50 +00002 * Copyright (c) 2017-2019 ARM Limited.
John Richardsonf89a49f2017-09-05 11:21:56 +01003 *
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/runtime/CL/functions/CLMinMaxLocation.h"
25#include "tests/CL/CLAccessor.h"
26#include "tests/CL/CLArrayAccessor.h"
27#include "tests/PaddingCalculator.h"
28#include "tests/datasets/ShapeDatasets.h"
29#include "tests/framework/Macros.h"
30#include "tests/validation/Validation.h"
31#include "tests/validation/fixtures/MinMaxLocationFixture.h"
32
33namespace arm_compute
34{
35namespace test
36{
37namespace validation
38{
39TEST_SUITE(CL)
40TEST_SUITE(MinMaxLocation)
41
42template <typename T>
43using CLMinMaxLocationFixture = MinMaxLocationValidationFixture<CLTensor, CLAccessor, CLArray<Coordinates2D>, CLArrayAccessor<Coordinates2D>, CLMinMaxLocation, T>;
44
45void validate_configuration(const CLTensor &src, TensorShape shape)
46{
47 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
48
49 // Create output storage
Moritz Pflanzer4726fdf2017-09-23 10:47:54 +010050 int32_t min = 0;
51 int32_t max = 0;
John Richardsonf89a49f2017-09-05 11:21:56 +010052 CLCoordinates2DArray min_loc(shape.total_size());
53 CLCoordinates2DArray max_loc(shape.total_size());
54
55 // Create and configure function
56 CLMinMaxLocation min_max_loc;
57 min_max_loc.configure(&src, &min, &max, &min_loc, &max_loc);
58
59 // Validate padding
Moritz Pflanzer4726fdf2017-09-23 10:47:54 +010060 const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding();
John Richardsonf89a49f2017-09-05 11:21:56 +010061 validate(src.info()->padding(), padding);
62}
63
64TEST_SUITE(U8)
Michalis Spyrou80943252019-01-10 17:19:50 +000065DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::U8)), shape, data_type)
John Richardsonf89a49f2017-09-05 11:21:56 +010066{
67 // Create tensors
68 CLTensor src = create_tensor<CLTensor>(shape, data_type);
69 src.info()->set_format(Format::U8);
70
71 validate_configuration(src, shape);
72}
73
74FIXTURE_DATA_TEST_CASE(RunSmall, CLMinMaxLocationFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType",
75 DataType::U8)))
76{
77 validate_min_max_loc(_target, _reference);
78}
79
80FIXTURE_DATA_TEST_CASE(RunLarge, CLMinMaxLocationFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType",
81 DataType::U8)))
82{
83 validate_min_max_loc(_target, _reference);
84}
85
86TEST_SUITE_END() // U8
87
88TEST_SUITE(S16)
Michalis Spyrou80943252019-01-10 17:19:50 +000089DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::S16)), shape, data_type)
John Richardsonf89a49f2017-09-05 11:21:56 +010090{
91 // Create tensors
92 CLTensor src = create_tensor<CLTensor>(shape, data_type);
93 src.info()->set_format(Format::S16);
94
95 validate_configuration(src, shape);
96}
97
98FIXTURE_DATA_TEST_CASE(RunSmall, CLMinMaxLocationFixture<int16_t>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType",
99 DataType::S16)))
100{
101 validate_min_max_loc(_target, _reference);
102}
103
104FIXTURE_DATA_TEST_CASE(RunLarge, CLMinMaxLocationFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType",
105 DataType::S16)))
106{
107 validate_min_max_loc(_target, _reference);
108}
109
110TEST_SUITE_END() // S16
111
112TEST_SUITE(Float)
Michalis Spyrou80943252019-01-10 17:19:50 +0000113DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::F32)), shape, data_type)
John Richardsonf89a49f2017-09-05 11:21:56 +0100114{
115 // Create tensors
116 CLTensor src = create_tensor<CLTensor>(shape, data_type);
117 src.info()->set_format(Format::F32);
118
119 validate_configuration(src, shape);
120}
121
122FIXTURE_DATA_TEST_CASE(RunSmall, CLMinMaxLocationFixture<float>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType",
123 DataType::F32)))
124{
125 validate_min_max_loc(_target, _reference);
126}
127
128FIXTURE_DATA_TEST_CASE(RunLarge, CLMinMaxLocationFixture<float>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType",
129 DataType::F32)))
130{
131 validate_min_max_loc(_target, _reference);
132}
133
134TEST_SUITE_END() // F32
135
136TEST_SUITE_END() // MinMaxLocation
137TEST_SUITE_END() // CL
138} // namespace validation
139} // namespace test
140} // namespace arm_compute