24.08
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
6
#include "
ClBackendModelContext.hpp
"
7
8
namespace
9
{
10
11
bool
ParseBool(
const
armnn::BackendOptions::Var
& value,
bool
defaultValue)
12
{
13
if
(value.
IsBool
())
14
{
15
return
value.
AsBool
();
16
}
17
return
defaultValue;
18
}
19
20
std::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
31
namespace
armnn
32
{
33
34
ClBackendModelContext::ClBackendModelContext
(
const
ModelOptions
& modelOptions)
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
61
std::string
ClBackendModelContext::GetCachedNetworkFilePath
()
const
62
{
63
return
m_CachedNetworkFilePath;
64
}
65
66
bool
ClBackendModelContext::IsFastMathEnabled
()
const
67
{
68
return
m_IsFastMathEnabled;
69
}
70
71
bool
ClBackendModelContext::SaveCachedNetwork
()
const
72
{
73
return
m_SaveCachedNetwork;
74
}
75
76
int
ClBackendModelContext::GetCachedFileDescriptor
()
const
77
{
78
return
m_CachedFileDescriptor;
79
}
80
81
}
// namespace armnn
armnn::ClBackendModelContext::GetCachedNetworkFilePath
std::string GetCachedNetworkFilePath() const
Definition:
ClBackendModelContext.cpp:61
armnn::ClBackendModelContext::ClBackendModelContext
ClBackendModelContext(const ModelOptions &modelOptions)
Definition:
ClBackendModelContext.cpp:34
armnn::ParseIntBackendOption
int ParseIntBackendOption(const armnn::BackendOptions::Var &value, int defaultValue)
Definition:
BackendOptions.hpp:330
ClBackendModelContext.hpp
armnn::ClBackendModelContext::GetCachedFileDescriptor
int GetCachedFileDescriptor() const
Definition:
ClBackendModelContext.cpp:76
armnn::BackendOptions::Var::IsString
bool IsString() const
Definition:
BackendOptions.hpp:116
armnn::BackendOptions::Var::AsBool
bool AsBool() const
Value getters.
Definition:
BackendOptions.hpp:119
armnn::BackendOptions::Var::AsString
std::string AsString() const
Definition:
BackendOptions.hpp:123
armnn::ParseOptions
void ParseOptions(const std::vector< BackendOptions > &options, BackendId backend, F f)
Definition:
BackendOptions.hpp:297
armnn::BackendOptions::Var::IsBool
bool IsBool() const
Type getters.
Definition:
BackendOptions.hpp:112
armnn::BackendOptions::Var
Very basic type safe variant.
Definition:
BackendOptions.hpp:38
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition:
01_00_quick_start.dox:6
armnn::ClBackendModelContext::SaveCachedNetwork
bool SaveCachedNetwork() const
Definition:
ClBackendModelContext.cpp:71
armnn::ModelOptions
std::vector< BackendOptions > ModelOptions
Definition:
BackendOptions.hpp:18
armnn::ClBackendModelContext::IsFastMathEnabled
bool IsFastMathEnabled() const
Definition:
ClBackendModelContext.cpp:66
src
backends
cl
ClBackendModelContext.cpp
Generated on Wed Aug 28 2024 14:31:50 for Arm NN by
1.8.17