• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
CreateRaw(IGpuAccTunedParameters::Mode mode,IGpuAccTunedParameters::TuningLevel tuningLevel)11 IGpuAccTunedParameters* IGpuAccTunedParameters::CreateRaw(IGpuAccTunedParameters::Mode mode,
12                                                           IGpuAccTunedParameters::TuningLevel tuningLevel)
13 {
14     return new ClTunedParameters(mode, tuningLevel);
15 }
16 
Create(IGpuAccTunedParameters::Mode mode,IGpuAccTunedParameters::TuningLevel tuningLevel)17 IGpuAccTunedParametersPtr IGpuAccTunedParameters::Create(IGpuAccTunedParameters::Mode mode,
18                                                          IGpuAccTunedParameters::TuningLevel tuningLevel)
19 {
20     return IGpuAccTunedParametersPtr(CreateRaw(mode, tuningLevel), &IGpuAccTunedParameters::Destroy);
21 }
22 
Destroy(IGpuAccTunedParameters * params)23 void IGpuAccTunedParameters::Destroy(IGpuAccTunedParameters* params)
24 {
25     delete params;
26 }
27 
ClTunedParameters(IGpuAccTunedParameters::Mode mode,IGpuAccTunedParameters::TuningLevel tuningLevel)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 
Load(const char * filename)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 
Save(const char * filename) const48 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 }