blob: 8ea8c95cda06d94cda3381160943bfcac6584959 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
2 * Copyright (c) 2017 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 "Globals.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010025#include "NEON/NEAccessor.h"
26#include "TensorLibrary.h"
27#include "benchmark/Datasets.h"
28#include "benchmark/Profiler.h"
29#include "benchmark/WallClockTimer.h"
30
31#include "arm_compute/core/Helpers.h"
32#include "arm_compute/core/Types.h"
33#include "arm_compute/runtime/NEON/functions/NENormalizationLayer.h"
34#include "arm_compute/runtime/Tensor.h"
35#include "arm_compute/runtime/TensorAllocator.h"
36
37#include "benchmark/benchmark_api.h"
38
39using namespace arm_compute;
40using namespace arm_compute::test;
41using namespace arm_compute::test::benchmark;
42using namespace arm_compute::test::neon;
43
44#include "benchmark/common/NormalizationLayer.h"
45
46namespace
47{
48using NormalizationLayerAlexNetF32 = NormalizationLayer<AlexNetNormalizationLayerDataset, Tensor, NEAccessor, NENormalizationLayer>;
49using NormalizationLayerAlexNetQS8 = NormalizationLayer<AlexNetNormalizationLayerDataset, Tensor, NEAccessor, NENormalizationLayer, DataType::QS8>;
50using NormalizationLayerGoogLeNet = NormalizationLayer<GoogLeNetNormalizationLayerDataset, Tensor, NEAccessor, NENormalizationLayer>;
51} // namespace
52
53// F32
54BENCHMARK_DEFINE_F(NormalizationLayerAlexNetF32, neon_alexnet)
55(::benchmark::State &state)
56{
57 while(state.KeepRunning())
58 {
59 // Run function
60 profiler.start();
61 norm_layer->run();
62 profiler.stop();
63 }
64}
65
66BENCHMARK_REGISTER_F(NormalizationLayerAlexNetF32, neon_alexnet)
67->Threads(1)
68->Apply(DataSetArgBatched<AlexNetNormalizationLayerDataset, 0, 1, 4, 8>);
69BENCHMARK_REGISTER_F(NormalizationLayerAlexNetF32, neon_alexnet)
70->Threads(1)
71->Apply(DataSetArgBatched<AlexNetNormalizationLayerDataset, 1, 1, 4, 8>);
72
73// QS8
74BENCHMARK_DEFINE_F(NormalizationLayerAlexNetQS8, neon_alexnet)
75(::benchmark::State &state)
76{
77 while(state.KeepRunning())
78 {
79 // Run function
80 profiler.start();
81 norm_layer->run();
82 profiler.stop();
83 }
84}
85
86BENCHMARK_REGISTER_F(NormalizationLayerAlexNetQS8, neon_alexnet)
87->Threads(1)
88->Apply(DataSetArgBatched<AlexNetNormalizationLayerDataset, 0, 1, 4, 8>);
89BENCHMARK_REGISTER_F(NormalizationLayerAlexNetQS8, neon_alexnet)
90->Threads(1)
91->Apply(DataSetArgBatched<AlexNetNormalizationLayerDataset, 1, 1, 4, 8>);
92
93BENCHMARK_DEFINE_F(NormalizationLayerGoogLeNet, neon_googlenet)
94(::benchmark::State &state)
95{
96 while(state.KeepRunning())
97 {
98 // Run function
99 profiler.start();
100 norm_layer->run();
101 profiler.stop();
102 }
103}
104
105BENCHMARK_REGISTER_F(NormalizationLayerGoogLeNet, neon_googlenet)
106->Threads(1)
107->Apply(DataSetArgBatched<GoogLeNetNormalizationLayerDataset, 0, 1, 4, 8>);
108BENCHMARK_REGISTER_F(NormalizationLayerGoogLeNet, neon_googlenet)
109->Threads(1)
110->Apply(DataSetArgBatched<GoogLeNetNormalizationLayerDataset, 1, 1, 4, 8>);