Compute Library
 19.08
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...
 
void finalize ()
 Finalizes memory managers in graph context. More...
 

Detailed Description

Graph context.

Definition at line 49 of file GraphContext.h.

Constructor & Destructor Documentation

◆ GraphContext() [1/3]

Constructor.

Definition at line 34 of file GraphContext.cpp.

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

◆ ~GraphContext()

Destructor.

Definition at line 39 of file GraphContext.cpp.

40 {
41  _memory_managers.clear();
43 }
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 45 of file GraphContext.cpp.

46 {
47  return _config;
48 }

Referenced by GraphManager::finalize_graph(), arm_compute::graph::backends::get_memory_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 77 of file GraphContext.cpp.

78 {
79  const size_t num_pools = 1;
80  for(auto &mm_obj : _memory_managers)
81  {
82  ARM_COMPUTE_ERROR_ON(!mm_obj.second.allocator);
83 
84  // Finalize intra layer memory manager
85  if(mm_obj.second.intra_mm != nullptr)
86  {
87  mm_obj.second.intra_mm->populate(*mm_obj.second.allocator, num_pools);
88  }
89  // Finalize cross layer memory manager
90  if(mm_obj.second.cross_mm != nullptr)
91  {
92  mm_obj.second.cross_mm->populate(*mm_obj.second.allocator, num_pools);
93  }
94  }
95 }
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337

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
If the insertion succeeded else false

Definition at line 55 of file GraphContext.cpp.

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

References arm_compute::graph::UNSPECIFIED.

Referenced by NEDeviceBackend::setup_backend_context(), GCDeviceBackend::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 67 of file GraphContext.cpp.

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

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 72 of file GraphContext.cpp.

73 {
74  return _memory_managers;
75 }

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 50 of file GraphContext.cpp.

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

References GraphContext::config().

Referenced by Stream::finalize().


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