summaryrefslogtreecommitdiff
path: root/contrib/benchmark_acl/src/Benchmark.h
blob: 200f40952c7579f3055b69336d5962e8efa0062f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __ACL_BENCHMARK_H__
#define __ACL_BENCHMARK_H__

#include "arm_compute/graph/ITensorAccessor.h"
#include "arm_compute/graph.h"
#include "arm_compute/core/CL/OpenCL.h"

struct InputAccessor final : public arm_compute::graph::ITensorAccessor
{
    InputAccessor() = default;
    /** Allows instances to move constructed */
    InputAccessor(InputAccessor &&) = default;

    // Inherited methods overriden:
    bool access_tensor(arm_compute::ITensor &tensor) override
    {
      return true;
    }
};

struct OutputAccessor final : public arm_compute::graph::ITensorAccessor
{
    OutputAccessor() = default;
    /** Allows instances to move constructed */
    OutputAccessor(OutputAccessor &&) = default;

    // Inherited methods overriden:
    bool access_tensor(arm_compute::ITensor &tensor) override
    {
      return false;
    }
};

template <typename T> std::unique_ptr<arm_compute::graph::ITensorAccessor> get_accessor()
{
  return std::unique_ptr<T>(new T());
}

class Count
{
public:
  Count();

public:
  uint32_t value(void) const;

private:
  uint32_t _value;
};

inline arm_compute::graph::Target set_target_hint(int target)
{
    if(target == 1 && arm_compute::opencl_is_available())
    {
        // If type of target is OpenCL, check if OpenCL is available and initialize the scheduler
        return arm_compute::graph::Target::CL;
    }
    else
    {
        return arm_compute::graph::Target::NEON;
    }
}

void run_benchmark(arm_compute::graph::frontend::Stream &graph);

#endif