aboutsummaryrefslogtreecommitdiff
path: root/src/backends/neon/NeonInterceptorScheduler.cpp
blob: c20be2b35919ca8d4a3815a3dbcc65bdb17a66f9 (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
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//

#include "NeonInterceptorScheduler.hpp"

namespace armnn{

NeonInterceptorScheduler::NeonInterceptorScheduler(arm_compute::IScheduler &realScheduler)
        : m_Kernels(nullptr), m_RealScheduler(realScheduler)
{
}

void NeonInterceptorScheduler::set_num_threads(unsigned int numThreads)
{
    m_RealScheduler.set_num_threads(numThreads);
}

unsigned int NeonInterceptorScheduler::num_threads() const
{
    return m_RealScheduler.num_threads();
}

void NeonInterceptorScheduler::schedule(arm_compute::ICPPKernel* kernel, const Hints& hints)
{
    WallClockTimer::clock::time_point startTime = WallClockTimer::clock::now();
    m_RealScheduler.schedule(kernel, hints.split_dimension());
    WallClockTimer::clock::time_point stopTime = WallClockTimer::clock::now();

    const auto delta       = std::chrono::duration<double, std::micro>(stopTime - startTime);
    m_Kernels->emplace_back(kernel->name(), delta.count(), Measurement::Unit::TIME_US);
}

void NeonInterceptorScheduler::run_workloads(std::vector <Workload>& workloads)
{
    WallClockTimer::clock::time_point startTime = WallClockTimer::clock::now();
    m_RealScheduler.run_tagged_workloads(workloads, nullptr);
    WallClockTimer::clock::time_point stopTime = WallClockTimer::clock::now();

    const auto delta       = std::chrono::duration<double, std::micro>(stopTime - startTime);
    m_Kernels->emplace_back(std::string("Workload"), delta.count(), Measurement::Unit::TIME_US);
}

void NeonInterceptorScheduler::run_tagged_workloads(std::vector<Workload> &workloads, const char *tag)
{
    WallClockTimer::clock::time_point startTime = WallClockTimer::clock::now();
    m_RealScheduler.run_tagged_workloads(workloads, tag);
    WallClockTimer::clock::time_point stopTime = WallClockTimer::clock::now();

    const auto delta       = std::chrono::duration<double, std::micro>(stopTime - startTime);
    m_Kernels->emplace_back(std::string(tag != nullptr ? tag : "Unknown"), delta.count(), Measurement::Unit::TIME_US);
}

void NeonInterceptorScheduler::schedule_op(arm_compute::ICPPKernel *kernel,
                                           const Hints &hints,
                                           arm_compute::ITensorPack &tensors )
{

    WallClockTimer::clock::time_point startTime = WallClockTimer::clock::now();
    m_RealScheduler.schedule_op(kernel, hints, tensors);
    WallClockTimer::clock::time_point stopTime = WallClockTimer::clock::now();

    const auto delta       = std::chrono::duration<double, std::micro>(stopTime - startTime);
    m_Kernels->emplace_back(kernel->name(), delta.count(), Measurement::Unit::TIME_US);
}

} // namespace armnn