ArmNN
 25.11
Loading...
Searching...
No Matches
ClBackendModelContext.cpp
Go to the documentation of this file.
1//
2// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
7
8namespace
9{
10
11bool ParseBool(const armnn::BackendOptions::Var& value, bool defaultValue)
12{
13 if (value.IsBool())
14 {
15 return value.AsBool();
16 }
17 return defaultValue;
18}
19
20std::string ParseFile(const armnn::BackendOptions::Var& value, std::string defaultValue)
21{
22 if (value.IsString())
23 {
24 return value.AsString();
25 }
26 return defaultValue;
27}
28
29} // namespace anonymous
30
31namespace armnn
32{
33
35 : m_CachedNetworkFilePath(""), m_IsFastMathEnabled(false), m_SaveCachedNetwork(false), m_CachedFileDescriptor(-1)
36{
37 if (!modelOptions.empty())
38 {
39 ParseOptions(modelOptions, "GpuAcc", [&](std::string name, const BackendOptions::Var& value)
40 {
41 if (name == "FastMathEnabled")
42 {
43 m_IsFastMathEnabled |= ParseBool(value, false);
44 }
45 if (name == "SaveCachedNetwork")
46 {
47 m_SaveCachedNetwork |= ParseBool(value, false);
48 }
49 if (name == "CachedNetworkFilePath")
50 {
51 m_CachedNetworkFilePath = ParseFile(value, "");
52 }
53 if (name == "CachedFileDescriptor")
54 {
55 m_CachedFileDescriptor = armnn::ParseIntBackendOption(value, -1);
56 }
57 });
58 }
59}
60
62{
63 return m_CachedNetworkFilePath;
64}
65
67{
68 return m_IsFastMathEnabled;
69}
70
72{
73 return m_SaveCachedNetwork;
74}
75
77{
78 return m_CachedFileDescriptor;
79}
80
81} // namespace armnn
Very basic type safe variant.
std::string AsString() const
bool AsBool() const
Value getters.
bool IsBool() const
Type getters.
ClBackendModelContext(const ModelOptions &modelOptions)
std::string GetCachedNetworkFilePath() const
Copyright (c) 2021 ARM Limited and Contributors.
std::vector< BackendOptions > ModelOptions