// // Copyright © 2023 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // #pragma once #include #include #include #include #include #include namespace armnn { enum class TuningLevel { None, Rapid, Normal, Exhaustive }; inline TuningLevel ParseTuningLevel(const BackendOptions::Var& value, TuningLevel defaultValue) { if (value.IsInt()) { int v = value.AsInt(); if (v > static_cast(TuningLevel::Exhaustive) || v < static_cast(TuningLevel::None)) { ARMNN_LOG(warning) << "Invalid GpuAcc tuning level ("<< v << ") selected. " "Using default(" << static_cast(defaultValue) << ")"; } else { return static_cast(v); } } return defaultValue; } inline void ConfigureTuner(arm_compute::CLTuner &tuner, TuningLevel level) { tuner.set_tune_new_kernels(true); // Turn on tuning initially. switch (level) { case TuningLevel::Rapid: ARMNN_LOG(info) << "Gpu tuning is activated. TuningLevel: Rapid (1)"; tuner.set_tuner_mode(arm_compute::CLTunerMode::RAPID); break; case TuningLevel::Normal: ARMNN_LOG(info) << "Gpu tuning is activated. TuningLevel: Normal (2)"; tuner.set_tuner_mode(arm_compute::CLTunerMode::NORMAL); break; case TuningLevel::Exhaustive: ARMNN_LOG(info) << "Gpu tuning is activated. TuningLevel: Exhaustive (3)"; tuner.set_tuner_mode(arm_compute::CLTunerMode::EXHAUSTIVE); break; case TuningLevel::None: default: tuner.set_tune_new_kernels(false); // Turn off tuning. Set to "use" only mode. break; } } class ClTunedParameters : public IGpuAccTunedParameters { public: ClTunedParameters(IGpuAccTunedParameters::Mode mode, IGpuAccTunedParameters::TuningLevel tuningLevel); virtual void Load(const char* filename); virtual void Save(const char* filename) const; Mode m_Mode; TuningLevel m_TuningLevel; arm_compute::CLTuner m_Tuner; arm_compute::CLGEMMHeuristicsHandle m_HeuristicsHandle; }; }