Cathal Corbett | d9e55f0 | 2023-01-11 13:03:21 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2023 Arm Ltd and Contributors. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ArmComputeTuningUtils.hpp" |
| 7 | |
| 8 | namespace armnn |
| 9 | { |
| 10 | |
| 11 | IGpuAccTunedParameters* IGpuAccTunedParameters::CreateRaw(IGpuAccTunedParameters::Mode mode, |
| 12 | IGpuAccTunedParameters::TuningLevel tuningLevel) |
| 13 | { |
| 14 | return new ClTunedParameters(mode, tuningLevel); |
| 15 | } |
| 16 | |
| 17 | IGpuAccTunedParametersPtr IGpuAccTunedParameters::Create(IGpuAccTunedParameters::Mode mode, |
| 18 | IGpuAccTunedParameters::TuningLevel tuningLevel) |
| 19 | { |
| 20 | return IGpuAccTunedParametersPtr(CreateRaw(mode, tuningLevel), &IGpuAccTunedParameters::Destroy); |
| 21 | } |
| 22 | |
| 23 | void IGpuAccTunedParameters::Destroy(IGpuAccTunedParameters* params) |
| 24 | { |
| 25 | delete params; |
| 26 | } |
| 27 | |
| 28 | ClTunedParameters::ClTunedParameters(IGpuAccTunedParameters::Mode mode, |
| 29 | IGpuAccTunedParameters::TuningLevel tuningLevel) |
| 30 | : m_Mode(mode) |
| 31 | , m_TuningLevel(tuningLevel) |
| 32 | , m_Tuner(mode == ClTunedParameters::Mode::UpdateTunedParameters) |
| 33 | { |
| 34 | } |
| 35 | |
| 36 | void ClTunedParameters::Load(const char* filename) |
| 37 | { |
| 38 | try |
| 39 | { |
| 40 | m_Tuner.load_from_file(filename); |
| 41 | } |
| 42 | catch (const std::exception& e) |
| 43 | { |
| 44 | throw Exception(std::string("Failed to load tuned parameters file '") + filename + "': " + e.what()); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | void ClTunedParameters::Save(const char* filename) const |
| 49 | { |
| 50 | try |
| 51 | { |
| 52 | m_Tuner.save_to_file(filename); |
| 53 | } |
| 54 | catch (const std::exception& e) |
| 55 | { |
| 56 | throw Exception(std::string("Failed to save tuned parameters file to '") + filename + "': " + e.what()); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | } |