ArmNN
 25.11
Loading...
Searching...
No Matches
ArmComputeTuningUtils.hpp
Go to the documentation of this file.
1//
2// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5#pragma once
6
8#include <armnn/IRuntime.hpp>
9#include <armnn/Logging.hpp>
10
11#include <arm_compute/runtime/CL/CLTuner.h>
12#include <arm_compute/runtime/CL/CLTunerTypes.h>
13#include <arm_compute/runtime/CL/CLGEMMHeuristicsHandle.h>
14
15namespace armnn
16{
17
25
27{
28 if (value.IsInt())
29 {
30 int v = value.AsInt();
31 if (v > static_cast<int>(TuningLevel::Exhaustive) ||
32 v < static_cast<int>(TuningLevel::None))
33 {
34 ARMNN_LOG(warning) << "Invalid GpuAcc tuning level ("<< v << ") selected. "
35 "Using default(" << static_cast<int>(defaultValue) << ")";
36 } else
37 {
38 return static_cast<TuningLevel>(v);
39 }
40 }
41 return defaultValue;
42}
43
44inline void ConfigureTuner(arm_compute::CLTuner &tuner, TuningLevel level)
45{
46 tuner.set_tune_new_kernels(true); // Turn on tuning initially.
47
48 switch (level)
49 {
51 ARMNN_LOG(info) << "Gpu tuning is activated. TuningLevel: Rapid (1)";
52 tuner.set_tuner_mode(arm_compute::CLTunerMode::RAPID);
53 break;
55 ARMNN_LOG(info) << "Gpu tuning is activated. TuningLevel: Normal (2)";
56 tuner.set_tuner_mode(arm_compute::CLTunerMode::NORMAL);
57 break;
59 ARMNN_LOG(info) << "Gpu tuning is activated. TuningLevel: Exhaustive (3)";
60 tuner.set_tuner_mode(arm_compute::CLTunerMode::EXHAUSTIVE);
61 break;
63 default:
64 tuner.set_tune_new_kernels(false); // Turn off tuning. Set to "use" only mode.
65 break;
66 }
67}
68
70{
71public:
73
74 virtual void Load(const char* filename);
75 virtual void Save(const char* filename) const;
76
79
80 arm_compute::CLTuner m_Tuner;
81 arm_compute::CLGEMMHeuristicsHandle m_HeuristicsHandle;
82};
83
84}
#define ARMNN_LOG(severity)
Definition Logging.hpp:212
Very basic type safe variant.
arm_compute::CLGEMMHeuristicsHandle m_HeuristicsHandle
virtual void Load(const char *filename)
Loads an existing set of tuned parameters from the given file.
virtual void Save(const char *filename) const
Saves the current set of tuned parameters to the given file.
ClTunedParameters(IGpuAccTunedParameters::Mode mode, IGpuAccTunedParameters::TuningLevel tuningLevel)
Manages a set of GpuAcc parameters which have been tuned for maximum performance.
Definition IRuntime.hpp:282
Copyright (c) 2021 ARM Limited and Contributors.
void ConfigureTuner(arm_compute::CLTuner &tuner, TuningLevel level)
TuningLevel ParseTuningLevel(const BackendOptions::Var &value, TuningLevel defaultValue)