Defined in File cg.h
mgb::cg::
::
DeviceMemoryAllocator
allocation strategy for device storage in computing graphs
Note: all the graph params would be NULL for requests originating from ComputingGraph::prealloc_static_storage. Otherwise they are not NULL.
graph
This base class already provides an implementation using memory management on the comp node. Sub-classes can override only the methods of interest.
Public Functions
~DeviceMemoryAllocator
alloc_static
implement the allocation strategy for static graph-wise storage
[in] graph: the computing graph that requests the memory
[in] graph
[out] dest: output tensor storage; its comp node has been initialized to target comp node
[out] dest
alloc_dynamic
implement the allocation strategy for dynamic storage of a variable
Note: if allocation fails,
[in] var: the variable that needs memory
[in] var
defrag_prealloc_contig
Ensure a contiguous storage for memory defragmenter.
When doing memory-defragmentation, it is useful to ensure that following allocation requests can be placed in a contiguous storage. This function would be called before calling alloc_dynamic() on the individual vars.
static_alloc_version
version of static allocation strategy
If version changes before graph exec, static memory would be reallocated. This function would be only called once in each graph execution.
Public Static Attributes
VERSION_INVALID
a version sentinel value that should never be returned by static_alloc_version()