blob: 82fbed3b5de1594b233b6baf060bf51676df44f9 [file] [log] [blame]
Michalis Spyroue9362622018-11-23 17:41:37 +00001/*
Michalis Spyrou80943252019-01-10 17:19:50 +00002 * Copyright (c) 2018-2019 ARM Limited.
Michalis Spyroue9362622018-11-23 17:41:37 +00003 *
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"
25#include "arm_compute/runtime/CL/functions/CLElementWiseUnaryLayer.h"
26#include "arm_compute/runtime/Tensor.h"
27#include "arm_compute/runtime/TensorAllocator.h"
28#include "tests/CL/CLAccessor.h"
29#include "tests/PaddingCalculator.h"
30#include "tests/datasets/ShapeDatasets.h"
31#include "tests/framework/Asserts.h"
32#include "tests/framework/Macros.h"
33#include "tests/framework/datasets/Datasets.h"
34#include "tests/validation/Validation.h"
35#include "tests/validation/fixtures/ElementWiseUnaryFixture.h"
36
37namespace arm_compute
38{
39namespace test
40{
41namespace validation
42{
43namespace
44{
45RelativeTolerance<float> tolerance_fp32(0.000001f);
46RelativeTolerance<float> tolerance_fp16(0.001f);
47} // namespace
48TEST_SUITE(CL)
49TEST_SUITE(RsqrtLayer)
50
Michalis Spyrou80943252019-01-10 17:19:50 +000051// *INDENT-OFF*
52// clang-format off
53DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(
54 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching data types
55 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), // Valid
56 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching shapes
57 }),
58 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F16),
59 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32),
60 TensorInfo(TensorShape(30U, 11U, 2U), 1, DataType::F32),
61 })),
62 framework::dataset::make("Expected", { false, true, false })),
63 input_info, output_info, expected)
Michalis Spyroue9362622018-11-23 17:41:37 +000064{
Michalis Spyrou80943252019-01-10 17:19:50 +000065 ARM_COMPUTE_EXPECT(bool(CLRsqrtLayer::validate(&input_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false))) == expected, framework::LogLevel::ERRORS);
Michalis Spyroue9362622018-11-23 17:41:37 +000066}
Michalis Spyrou80943252019-01-10 17:19:50 +000067// clang-format on
68// *INDENT-ON*
Michalis Spyroue9362622018-11-23 17:41:37 +000069template <typename T>
70using CLRsqrtLayerFixture = RsqrtValidationFixture<CLTensor, CLAccessor, CLRsqrtLayer, T>;
71
72TEST_SUITE(Float)
73TEST_SUITE(FP16)
74FIXTURE_DATA_TEST_CASE(RunSmall, CLRsqrtLayerFixture<half>, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType",
75 DataType::F16)))
76{
77 // Validate output
78 validate(CLAccessor(_target), _reference, tolerance_fp16);
79}
80FIXTURE_DATA_TEST_CASE(RunLarge, CLRsqrtLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType",
81 DataType::F16)))
82{
83 // Validate output
84 validate(CLAccessor(_target), _reference, tolerance_fp16);
85}
86
87TEST_SUITE_END() // FP16
88TEST_SUITE(FP32)
89FIXTURE_DATA_TEST_CASE(RunSmall, CLRsqrtLayerFixture<float>, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType",
90 DataType::F32)))
91{
92 // Validate output
93 validate(CLAccessor(_target), _reference, tolerance_fp32);
94}
95FIXTURE_DATA_TEST_CASE(RunLarge, CLRsqrtLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType",
96 DataType::F32)))
97{
98 // Validate output
99 validate(CLAccessor(_target), _reference, tolerance_fp32);
100}
101
102TEST_SUITE_END() // FP32
103TEST_SUITE_END() // Float
104
105TEST_SUITE_END() // RsqrtLayer
106TEST_SUITE_END() // CL
107} // namespace validation
108} // namespace test
109} // namespace arm_compute