ArmNN
 24.08
ClBackendModelContext Class Reference

The ClBackendModelContext is used to pass in CL specific backend ModelOptions. More...

#include <ClBackendModelContext.hpp>

Inheritance diagram for ClBackendModelContext:
[legend]
Collaboration diagram for ClBackendModelContext:
[legend]

Public Member Functions

 ClBackendModelContext (const ModelOptions &modelOptions)
 
std::string GetCachedNetworkFilePath () const
 
bool IsFastMathEnabled () const
 
bool SaveCachedNetwork () const
 
int GetCachedFileDescriptor () const
 
- Public Member Functions inherited from IBackendModelContext
virtual ~IBackendModelContext ()
 

Detailed Description

The ClBackendModelContext is used to pass in CL specific backend ModelOptions.

The supported backend ModelOptions are:

  • "FastMathEnabled"
    Using the fast_math flag can lead to performance improvements in fp32 and fp16 layers but may result in
    results with reduced or different precision. The fast_math flag will not have any effect on int8 performance.
  • "SaveCachedNetwork"
    Using the save_cached_network flag enables saving the cached network
    to a file given with the cached_network_file_path option.
  • "CachedNetworkFilePath"
    If the cached_network_file_path is a valid file and the save_cached_network flag is present
    then the cached network will be saved to the given file.
    If the cached_network_file_path is a valid file and the save_cached_network flag is not present
    then the cached network will be loaded from the given file.
    This will remove the time taken for initial compilation of kernels and speed up the first execution.

Definition at line 28 of file ClBackendModelContext.hpp.

Constructor & Destructor Documentation

◆ ClBackendModelContext()

ClBackendModelContext ( const ModelOptions modelOptions)

Definition at line 34 of file ClBackendModelContext.cpp.

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 }

References armnn::ParseIntBackendOption(), and armnn::ParseOptions().

Member Function Documentation

◆ GetCachedFileDescriptor()

int GetCachedFileDescriptor ( ) const

Definition at line 76 of file ClBackendModelContext.cpp.

77 {
78  return m_CachedFileDescriptor;
79 }

◆ GetCachedNetworkFilePath()

std::string GetCachedNetworkFilePath ( ) const

Definition at line 61 of file ClBackendModelContext.cpp.

62 {
63  return m_CachedNetworkFilePath;
64 }

◆ IsFastMathEnabled()

bool IsFastMathEnabled ( ) const

◆ SaveCachedNetwork()

bool SaveCachedNetwork ( ) const

Definition at line 71 of file ClBackendModelContext.cpp.

72 {
73  return m_SaveCachedNetwork;
74 }

The documentation for this class was generated from the following files:
armnn::ParseIntBackendOption
int ParseIntBackendOption(const armnn::BackendOptions::Var &value, int defaultValue)
Definition: BackendOptions.hpp:330
armnn::ParseOptions
void ParseOptions(const std::vector< BackendOptions > &options, BackendId backend, F f)
Definition: BackendOptions.hpp:297