blob: b7f6a66e42aa2bc4267841992b473fd2e9af7880 [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 */
Sang-Hoon Park62eeb532019-10-29 13:13:19 +000024#include "arm_compute/core/Types.h"
25#include "arm_compute/runtime/CL/CLTensor.h"
26#include "arm_compute/runtime/CL/CLTensorAllocator.h"
27#include "arm_compute/runtime/CL/functions/CLSoftmaxLayer.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/SoftmaxLayerFixture.h"
36
37namespace arm_compute
38{
39namespace test
40{
41namespace validation
42{
43namespace
44{
45/** Tolerance for float operations */
46RelativeTolerance<half> tolerance_f16(half(0.2));
47RelativeTolerance<float> tolerance_f32(0.001f);
Sang-Hoon Park62eeb532019-10-29 13:13:19 +000048} // namespace
49
50TEST_SUITE(CL)
51TEST_SUITE(LogSoftmaxLayer)
52
53template <typename T>
54using CLLogSoftmaxLayerFixture = SoftmaxValidationFixture<CLTensor, CLAccessor, CLLogSoftmaxLayer, T, true>;
55
56TEST_SUITE(Float)
57TEST_SUITE(FP16)
58FIXTURE_DATA_TEST_CASE(RunSmall, CLLogSoftmaxLayerFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(datasets::SoftmaxLayerSmallShapes(),
59 framework::dataset::make("DataType", DataType::F16)),
60 framework::dataset::make("Beta", { 1.0f, 2.0f })),
SiCong Li96209c72020-08-21 12:28:30 +010061 framework::dataset::make("Axis", { 0, -1 })))
Sang-Hoon Park62eeb532019-10-29 13:13:19 +000062{
63 // Validate output
64 validate(CLAccessor(_target), _reference, tolerance_f16);
65}
66FIXTURE_DATA_TEST_CASE(RunLarge, CLLogSoftmaxLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::SoftmaxLayerLargeShapes(),
67 framework::dataset::make("DataType", DataType::F16)),
68 framework::dataset::make("Beta", { 1.0f, 2.0f })),
morgolock9c7fed82020-08-05 12:30:56 +010069 framework::dataset::make("Axis", { 0 })))
Sang-Hoon Park62eeb532019-10-29 13:13:19 +000070{
71 // Validate output
72 validate(CLAccessor(_target), _reference, tolerance_f16);
73}
74FIXTURE_DATA_TEST_CASE(Run4D, CLLogSoftmaxLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::SoftmaxLayer4DShapes(),
75 framework::dataset::make("DataType", DataType::F16)),
76 framework::dataset::make("Beta", { 1.0f, 2.0f })),
SiCong Li96209c72020-08-21 12:28:30 +010077 framework::dataset::make("Axis", { 0, -3, 2 })))
Sang-Hoon Park62eeb532019-10-29 13:13:19 +000078{
79 // Validate output
80 validate(CLAccessor(_target), _reference, tolerance_f16);
81}
Sang-Hoon Parka0205b92020-07-07 09:36:09 +010082TEST_SUITE_END() // FP16
Sang-Hoon Park62eeb532019-10-29 13:13:19 +000083
84TEST_SUITE(FP32)
85FIXTURE_DATA_TEST_CASE(RunSmall, CLLogSoftmaxLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(datasets::SoftmaxLayerSmallShapes(),
86 framework::dataset::make("DataType", DataType::F32)),
87 framework::dataset::make("Beta", { 1.0f, 2.0f })),
SiCong Li96209c72020-08-21 12:28:30 +010088 framework::dataset::make("Axis", { 0, 1 })))
Sang-Hoon Park62eeb532019-10-29 13:13:19 +000089{
90 // Validate output
91 validate(CLAccessor(_target), _reference, tolerance_f32);
92}
93FIXTURE_DATA_TEST_CASE(RunLarge, CLLogSoftmaxLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::SoftmaxLayerLargeShapes(),
94 framework::dataset::make("DataType", DataType::F32)),
95 framework::dataset::make("Beta", { 1.0f, 2.0f })),
morgolock9c7fed82020-08-05 12:30:56 +010096 framework::dataset::make("Axis", { 0 })))
Sang-Hoon Park62eeb532019-10-29 13:13:19 +000097{
98 // Validate output
99 validate(CLAccessor(_target), _reference, tolerance_f32);
100}
SiCong Li96209c72020-08-21 12:28:30 +0100101FIXTURE_DATA_TEST_CASE(Run4D, CLLogSoftmaxLayerFixture<float>, framework::DatasetMode::ALL, combine(combine(combine(datasets::SoftmaxLayer4DShapes(),
102 framework::dataset::make("DataType", DataType::F32)),
103 framework::dataset::make("Beta", { 1.0f, 2.0f })),
104 framework::dataset::make("Axis", { 0, -4, 3 })))
Sang-Hoon Park62eeb532019-10-29 13:13:19 +0000105{
106 // Validate output
107 validate(CLAccessor(_target), _reference, tolerance_f32);
108}
Sang-Hoon Parka0205b92020-07-07 09:36:09 +0100109TEST_SUITE_END() // FP32
110TEST_SUITE_END() // Float
111TEST_SUITE_END() // LogSoftmaxLayer
112TEST_SUITE_END() // CL
Sang-Hoon Park62eeb532019-10-29 13:13:19 +0000113} // namespace validation
114} // namespace test
115} // namespace arm_compute