blob: 15466affc4057c3b9bffa7226202e62fa8d53ff5 [file] [log] [blame]
Sang-Hoon Park62eeb532019-10-29 13:13:19 +00001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2019-2020 Arm Limited.
Sang-Hoon Park62eeb532019-10-29 13:13:19 +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/CL/kernels/CLSoftmaxLayerKernel.h"
25#include "arm_compute/core/Types.h"
26#include "arm_compute/runtime/CL/CLTensor.h"
27#include "arm_compute/runtime/CL/CLTensorAllocator.h"
28#include "arm_compute/runtime/CL/functions/CLSoftmaxLayer.h"
29#include "tests/CL/CLAccessor.h"
30#include "tests/PaddingCalculator.h"
31#include "tests/datasets/ShapeDatasets.h"
32#include "tests/framework/Asserts.h"
33#include "tests/framework/Macros.h"
34#include "tests/framework/datasets/Datasets.h"
35#include "tests/validation/Validation.h"
36#include "tests/validation/fixtures/SoftmaxLayerFixture.h"
37
38namespace arm_compute
39{
40namespace test
41{
42namespace validation
43{
44namespace
45{
46/** Tolerance for float operations */
47RelativeTolerance<half> tolerance_f16(half(0.2));
48RelativeTolerance<float> tolerance_f32(0.001f);
Sang-Hoon Park62eeb532019-10-29 13:13:19 +000049} // namespace
50
51TEST_SUITE(CL)
52TEST_SUITE(LogSoftmaxLayer)
53
54template <typename T>
55using CLLogSoftmaxLayerFixture = SoftmaxValidationFixture<CLTensor, CLAccessor, CLLogSoftmaxLayer, T, true>;
56
57TEST_SUITE(Float)
58TEST_SUITE(FP16)
59FIXTURE_DATA_TEST_CASE(RunSmall, CLLogSoftmaxLayerFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(datasets::SoftmaxLayerSmallShapes(),
60 framework::dataset::make("DataType", DataType::F16)),
61 framework::dataset::make("Beta", { 1.0f, 2.0f })),
morgolock9c7fed82020-08-05 12:30:56 +010062 framework::dataset::make("Axis", { 0 })))
Sang-Hoon Park62eeb532019-10-29 13:13:19 +000063{
64 // Validate output
65 validate(CLAccessor(_target), _reference, tolerance_f16);
66}
67FIXTURE_DATA_TEST_CASE(RunLarge, CLLogSoftmaxLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::SoftmaxLayerLargeShapes(),
68 framework::dataset::make("DataType", DataType::F16)),
69 framework::dataset::make("Beta", { 1.0f, 2.0f })),
morgolock9c7fed82020-08-05 12:30:56 +010070 framework::dataset::make("Axis", { 0 })))
Sang-Hoon Park62eeb532019-10-29 13:13:19 +000071{
72 // Validate output
73 validate(CLAccessor(_target), _reference, tolerance_f16);
74}
75FIXTURE_DATA_TEST_CASE(Run4D, CLLogSoftmaxLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::SoftmaxLayer4DShapes(),
76 framework::dataset::make("DataType", DataType::F16)),
77 framework::dataset::make("Beta", { 1.0f, 2.0f })),
morgolock9c7fed82020-08-05 12:30:56 +010078 framework::dataset::make("Axis", { 0 })))
Sang-Hoon Park62eeb532019-10-29 13:13:19 +000079{
80 // Validate output
81 validate(CLAccessor(_target), _reference, tolerance_f16);
82}
Sang-Hoon Parka0205b92020-07-07 09:36:09 +010083TEST_SUITE_END() // FP16
Sang-Hoon Park62eeb532019-10-29 13:13:19 +000084
85TEST_SUITE(FP32)
86FIXTURE_DATA_TEST_CASE(RunSmall, CLLogSoftmaxLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(datasets::SoftmaxLayerSmallShapes(),
87 framework::dataset::make("DataType", DataType::F32)),
88 framework::dataset::make("Beta", { 1.0f, 2.0f })),
morgolock9c7fed82020-08-05 12:30:56 +010089 framework::dataset::make("Axis", { 0 })))
Sang-Hoon Park62eeb532019-10-29 13:13:19 +000090{
91 // Validate output
92 validate(CLAccessor(_target), _reference, tolerance_f32);
93}
94FIXTURE_DATA_TEST_CASE(RunLarge, CLLogSoftmaxLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::SoftmaxLayerLargeShapes(),
95 framework::dataset::make("DataType", DataType::F32)),
96 framework::dataset::make("Beta", { 1.0f, 2.0f })),
morgolock9c7fed82020-08-05 12:30:56 +010097 framework::dataset::make("Axis", { 0 })))
Sang-Hoon Park62eeb532019-10-29 13:13:19 +000098{
99 // Validate output
100 validate(CLAccessor(_target), _reference, tolerance_f32);
101}
102FIXTURE_DATA_TEST_CASE(Run4D, CLLogSoftmaxLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::SoftmaxLayer4DShapes(),
103 framework::dataset::make("DataType", DataType::F32)),
104 framework::dataset::make("Beta", { 1.0f, 2.0f })),
morgolock9c7fed82020-08-05 12:30:56 +0100105 framework::dataset::make("Axis", { 0 })))
Sang-Hoon Park62eeb532019-10-29 13:13:19 +0000106{
107 // Validate output
108 validate(CLAccessor(_target), _reference, tolerance_f32);
109}
Sang-Hoon Parka0205b92020-07-07 09:36:09 +0100110TEST_SUITE_END() // FP32
111TEST_SUITE_END() // Float
112TEST_SUITE_END() // LogSoftmaxLayer
113TEST_SUITE_END() // CL
Sang-Hoon Park62eeb532019-10-29 13:13:19 +0000114} // namespace validation
115} // namespace test
116} // namespace arm_compute