blob: bc56e844d8c35667394061461822d0ecd51a04b5 [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"
25#include "NEON/Helper.h"
26#include "NEON/NEAccessor.h"
27#include "TensorLibrary.h"
28#include "benchmark/Datasets.h"
29#include "benchmark/Profiler.h"
30#include "benchmark/WallClockTimer.h"
31#include "dataset/ConvolutionLayerDataset.h"
32
33#include "arm_compute/core/Helpers.h"
34#include "arm_compute/core/Types.h"
35#include "arm_compute/runtime/NEON/functions/NEDirectConvolutionLayer.h"
36#include "arm_compute/runtime/Tensor.h"
37#include "arm_compute/runtime/TensorAllocator.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::neon;
45
46#include "benchmark/common/ConvolutionLayer.h"
47
48namespace
49{
50using ConvolutionLayerDirectAlexNet = ConvolutionLayer<AlexNetConvolutionLayerDataset, Tensor, NEAccessor, NEDirectConvolutionLayer>;
51} // namespace
52
53BENCHMARK_DEFINE_F(ConvolutionLayerDirectAlexNet, neon_alexnet)
54(::benchmark::State &state)
55{
56 while(state.KeepRunning())
57 {
58 // Run function
59 profiler.start();
60 conv_layer->run();
61 profiler.stop();
62 }
63}
64
65// Registr only the 3x3 convolution layers
66BENCHMARK_REGISTER_F(ConvolutionLayerDirectAlexNet, neon_alexnet)
67->Threads(1)
68->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 2, 1, 4, 8>);
69BENCHMARK_REGISTER_F(ConvolutionLayerDirectAlexNet, neon_alexnet)
70->Threads(1)
71->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 3, 1, 4, 8>);
72BENCHMARK_REGISTER_F(ConvolutionLayerDirectAlexNet, neon_alexnet)
73->Threads(1)
74->Apply(DataSetArgBatched<AlexNetConvolutionLayerDataset, 4, 1, 4, 8>);