blob: 81d3c659123df560b997aa75055c1145c27591d8 [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 "CL/CLAccessor.h"
25#include "CL/Helper.h"
26#include "Globals.h"
27#include "TensorLibrary.h"
28#include "benchmark/Datasets.h"
29#include "benchmark/Profiler.h"
30#include "benchmark/WallClockTimer.h"
31
32#include "arm_compute/core/Helpers.h"
33#include "arm_compute/core/Types.h"
34#include "arm_compute/runtime/CL/CLScheduler.h"
35#include "arm_compute/runtime/CL/CLTensor.h"
36#include "arm_compute/runtime/CL/CLTensorAllocator.h"
37#include "arm_compute/runtime/CL/functions/CLNormalizationLayer.h"
38
39#include "benchmark/benchmark_api.h"
40
41using namespace arm_compute;
42using namespace arm_compute::test;
43using namespace arm_compute::test::benchmark;
44using namespace arm_compute::test::cl;
45
46#include "benchmark/common/NormalizationLayer.h"
47
48namespace
49{
50using NormalizationLayerAlexNet = NormalizationLayer<AlexNetNormalizationLayerDataset, CLTensor, CLAccessor, CLNormalizationLayer>;
51using NormalizationLayerGoogLeNet = NormalizationLayer<GoogLeNetNormalizationLayerDataset, CLTensor, CLAccessor, CLNormalizationLayer>;
52
53} // namespace
54
55BENCHMARK_DEFINE_F(NormalizationLayerAlexNet, cl_alexnet)
56(::benchmark::State &state)
57{
58 while(state.KeepRunning())
59 {
60 // Run function
61 profiler.start();
62 norm_layer->run();
63 CLScheduler::get().sync();
64 profiler.stop();
65 }
66}
67
68BENCHMARK_REGISTER_F(NormalizationLayerAlexNet, cl_alexnet)
69->Threads(1)
70->Apply(DataSetArgBatched<AlexNetNormalizationLayerDataset, 0, 1, 4, 8>);
71BENCHMARK_REGISTER_F(NormalizationLayerAlexNet, cl_alexnet)
72->Threads(1)
73->Apply(DataSetArgBatched<AlexNetNormalizationLayerDataset, 1, 1, 4, 8>);
74
75BENCHMARK_DEFINE_F(NormalizationLayerGoogLeNet, cl_googlenet)
76(::benchmark::State &state)
77{
78 while(state.KeepRunning())
79 {
80 // Run function
81 profiler.start();
82 norm_layer->run();
83 CLScheduler::get().sync();
84 profiler.stop();
85 }
86}
87
88BENCHMARK_REGISTER_F(NormalizationLayerGoogLeNet, cl_googlenet)
89->Threads(1)
90->Apply(DataSetArgBatched<GoogLeNetNormalizationLayerDataset, 0, 1, 4, 8>);
91BENCHMARK_REGISTER_F(NormalizationLayerGoogLeNet, cl_googlenet)
92->Threads(1)
93->Apply(DataSetArgBatched<GoogLeNetNormalizationLayerDataset, 1, 1, 4, 8>);