ArmNN
 21.02
ClBackendModelContext Class Reference

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

#include <ClBackendModelContext.hpp>

Inheritance diagram for ClBackendModelContext:
IBackendModelContext

Public Member Functions

 ClBackendModelContext (const ModelOptions &modelOptions)
 
std::string GetCachedNetworkFilePath () const
 
bool IsFastMathEnabled () const
 
bool SaveCachedNetwork () 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.

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

35  : m_CachedNetworkFilePath(""), m_IsFastMathEnabled(false), m_SaveCachedNetwork(false)
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  });
54  }
55 }
void ParseOptions(const std::vector< BackendOptions > &options, BackendId backend, F f)
std::string ParseFile(const BackendOptions::Var &value, std::string defaultValue)

Member Function Documentation

◆ GetCachedNetworkFilePath()

std::string GetCachedNetworkFilePath ( ) const

Definition at line 57 of file ClBackendModelContext.cpp.

Referenced by ClWorkloadFactory::AfterWorkloadsCreated().

58 {
59  return m_CachedNetworkFilePath;
60 }

◆ IsFastMathEnabled()

bool IsFastMathEnabled ( ) const

Definition at line 62 of file ClBackendModelContext.cpp.

Referenced by ClWorkloadFactory::CreateConvolution2d(), ClLayerSupport::IsConvolution2dSupported(), and ClBackend::OptimizeSubgraphView().

63 {
64  return m_IsFastMathEnabled;
65 }

◆ SaveCachedNetwork()

bool SaveCachedNetwork ( ) const

Definition at line 67 of file ClBackendModelContext.cpp.

68 {
69  return m_SaveCachedNetwork;
70 }

The documentation for this class was generated from the following files: