Compute Library
 19.11
GraphContext Class Referencefinal

Graph context. More...

#include <GraphContext.h>

Public Member Functions

 GraphContext ()
 Constructor. More...
 
 ~GraphContext ()
 Destructor. More...
 
 GraphContext (const GraphContext &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 GraphContext (GraphContext &&)=default
 Default move constructor. More...
 
GraphContextoperator= (const GraphContext &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
GraphContextoperator= (GraphContext &&)=default
 Default move assignment operator. More...
 
const GraphConfigconfig () const
 Graph configuration accessor. More...
 
void set_config (const GraphConfig &config)
 Sets graph configuration. More...
 
bool insert_memory_management_ctx (MemoryManagerContext &&memory_ctx)
 Inserts a memory manager context. More...
 
MemoryManagerContextmemory_management_ctx (Target target)
 Gets a memory manager context for a given target. More...
 
std::map< Target, MemoryManagerContext > & memory_managers ()
 Gets the memory managers map. More...
 
bool insert_weights_management_ctx (WeightsManagerContext &&weights_ctx)
 Inserts a weights manager context. More...
 
WeightsManagerContextweights_management_ctx (Target target)
 Gets a weights manager context for a given target. More...
 
std::map< Target, WeightsManagerContext > & weights_managers ()
 Gets the weights managers map. More...
 
void finalize ()
 Finalizes memory managers in graph context. More...
 

Detailed Description

Graph context.

Definition at line 57 of file GraphContext.h.

Constructor & Destructor Documentation

◆ GraphContext() [1/3]

Constructor.

Definition at line 34 of file GraphContext.cpp.

35  : _config(), _memory_managers(), _weights_managers()
36 {
37 }

◆ ~GraphContext()

Destructor.

Definition at line 39 of file GraphContext.cpp.

40 {
41  _memory_managers.clear();
42  _weights_managers.clear();
44 }
void release_default_graph_context(GraphContext &ctx)
Default releases the graph context if not done manually.
Definition: Utils.cpp:96

References arm_compute::graph::release_default_graph_context().

◆ GraphContext() [2/3]

GraphContext ( const GraphContext )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ GraphContext() [3/3]

GraphContext ( GraphContext &&  )
default

Default move constructor.

Member Function Documentation

◆ config()

const GraphConfig & config ( ) const

Graph configuration accessor.

Note
Every alteration has to be done before graph finalization
Returns
The graph configuration

Definition at line 46 of file GraphContext.cpp.

47 {
48  return _config;
49 }

Referenced by GraphManager::finalize_graph(), arm_compute::graph::backends::get_memory_manager(), arm_compute::graph::backends::get_weights_manager(), GraphContext::set_config(), NEDeviceBackend::setup_backend_context(), and CLDeviceBackend::setup_backend_context().

◆ finalize()

void finalize ( )

Finalizes memory managers in graph context.

Definition at line 102 of file GraphContext.cpp.

103 {
104  const size_t num_pools = 1;
105  for(auto &mm_obj : _memory_managers)
106  {
107  ARM_COMPUTE_ERROR_ON(!mm_obj.second.allocator);
108 
109  // Finalize intra layer memory manager
110  if(mm_obj.second.intra_mm != nullptr)
111  {
112  mm_obj.second.intra_mm->populate(*mm_obj.second.allocator, num_pools);
113  }
114  // Finalize cross layer memory manager
115  if(mm_obj.second.cross_mm != nullptr)
116  {
117  mm_obj.second.cross_mm->populate(*mm_obj.second.allocator, num_pools);
118  }
119  }
120 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466

References ARM_COMPUTE_ERROR_ON.

Referenced by GraphManager::finalize_graph().

◆ insert_memory_management_ctx()

bool insert_memory_management_ctx ( MemoryManagerContext &&  memory_ctx)

Inserts a memory manager context.

Parameters
[in]memory_ctxMemory manage context
Returns
True if the insertion succeeded else false

Definition at line 56 of file GraphContext.cpp.

57 {
58  Target target = memory_ctx.target;
59  if(target == Target::UNSPECIFIED || _memory_managers.find(target) != std::end(_memory_managers))
60  {
61  return false;
62  }
63 
64  _memory_managers[target] = std::move(memory_ctx);
65  return true;
66 }

References arm_compute::graph::UNSPECIFIED.

Referenced by NEDeviceBackend::setup_backend_context(), GCDeviceBackend::setup_backend_context(), and CLDeviceBackend::setup_backend_context().

◆ insert_weights_management_ctx()

bool insert_weights_management_ctx ( WeightsManagerContext &&  weights_ctx)

Inserts a weights manager context.

Parameters
[in]weights_ctxWeights manager context
Returns
True if the insertion succeeded else false

Definition at line 78 of file GraphContext.cpp.

79 {
80  Target target = weights_managers.target;
81 
82  if(_weights_managers.find(target) != std::end(_weights_managers))
83  {
84  return false;
85  }
86 
87  _weights_managers[target] = std::move(weights_managers);
88 
89  return true;
90 }
std::map< Target, WeightsManagerContext > & weights_managers()
Gets the weights managers map.

References GraphContext::weights_managers().

Referenced by NEDeviceBackend::setup_backend_context(), and CLDeviceBackend::setup_backend_context().

◆ memory_management_ctx()

MemoryManagerContext * memory_management_ctx ( Target  target)

Gets a memory manager context for a given target.

Parameters
[in]targetTo retrieve the management context
Returns
Management context for the target if exists else nullptr

Definition at line 68 of file GraphContext.cpp.

69 {
70  return (_memory_managers.find(target) != std::end(_memory_managers)) ? &_memory_managers[target] : nullptr;
71 }

Referenced by arm_compute::graph::detail::configure_transition_manager(), arm_compute::graph::backends::get_memory_manager(), NEDeviceBackend::setup_backend_context(), GCDeviceBackend::setup_backend_context(), and CLDeviceBackend::setup_backend_context().

◆ memory_managers()

std::map< Target, MemoryManagerContext > & memory_managers ( )

Gets the memory managers map.

Returns
Memory manager contexts

Definition at line 73 of file GraphContext.cpp.

74 {
75  return _memory_managers;
76 }

Referenced by arm_compute::graph::detail::call_all_tasks().

◆ operator=() [1/2]

GraphContext& operator= ( const GraphContext )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ operator=() [2/2]

GraphContext& operator= ( GraphContext &&  )
default

Default move assignment operator.

◆ set_config()

void set_config ( const GraphConfig config)

Sets graph configuration.

Parameters
[in]configConfiguration to use

Definition at line 51 of file GraphContext.cpp.

52 {
53  _config = config;
54 }
const GraphConfig & config() const
Graph configuration accessor.

References GraphContext::config().

Referenced by Stream::finalize().

◆ weights_management_ctx()

WeightsManagerContext * weights_management_ctx ( Target  target)

Gets a weights manager context for a given target.

Parameters
[in]targetTo retrieve the weights management context
Returns
Management context for the target if exists else nullptr

Definition at line 92 of file GraphContext.cpp.

93 {
94  return (_weights_managers.find(target) != std::end(_weights_managers)) ? &_weights_managers[target] : nullptr;
95 }

Referenced by arm_compute::graph::backends::get_weights_manager(), NEDeviceBackend::setup_backend_context(), and CLDeviceBackend::setup_backend_context().

◆ weights_managers()

std::map< Target, WeightsManagerContext > & weights_managers ( )

Gets the weights managers map.

Returns
Weights manager contexts

Definition at line 97 of file GraphContext.cpp.

98 {
99  return _weights_managers;
100 }

Referenced by GraphContext::insert_weights_management_ctx().


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