class dlstreamer::MemoryMapper#

Overview#

MemoryMapper objects can map TensorPtr or FramePtr from one context to another context. It could be mapping between GPU memory and CPU memory, or GPU to GPU mapping between two different frameworks (for example, mapping from OpenCL to SYCL) assuming two contexts allocated on same GPU device. MemoryMapper objects are created by Context::get_mapper function, or utility function create_mapper which is able to create MemoryMapper object as chain of multiple mappers, for example OpenCL to DPC++/SYCL mapper is internally chain of three mappers OpenCL -> DMA -> LevelZero -> SYCL. More…

#include <memory_mapper.h>

class MemoryMapper {
public:
    // methods

    virtual TensorPtr map(TensorPtr src, AccessMode mode = AccessMode::ReadWrite) = 0;
    virtual FramePtr map(FramePtr src, AccessMode mode = AccessMode::ReadWrite) = 0;
    virtual ContextPtr input_context() const = 0;
    virtual ContextPtr output_context() const = 0;
};

// direct descendants

class BaseMemoryMapper;
class MemoryMapperCache;
class MemoryMapperChain;

Detailed Documentation#

MemoryMapper objects can map TensorPtr or FramePtr from one context to another context. It could be mapping between GPU memory and CPU memory, or GPU to GPU mapping between two different frameworks (for example, mapping from OpenCL to SYCL) assuming two contexts allocated on same GPU device. MemoryMapper objects are created by Context::get_mapper function, or utility function create_mapper which is able to create MemoryMapper object as chain of multiple mappers, for example OpenCL to DPC++/SYCL mapper is internally chain of three mappers OpenCL -> DMA -> LevelZero -> SYCL.

Methods#

virtual TensorPtr map(TensorPtr src, AccessMode mode = AccessMode::ReadWrite) = 0

Map tensor into another context. The function returns mapped tensor, so that the parent() on output tensor returns original tensor and context() on output tensor returns input_context().

Parameters:

src

Tensor to map

mode

Access mode - read or write or read+write

virtual FramePtr map(FramePtr src, AccessMode mode = AccessMode::ReadWrite) = 0

Map frame into another context. The function returns mapped frame, so that the parent() on output frame returns original frame and context() on output frame returns input_context().

Parameters:

src

Frame to map

mode

Access mode - read or write or read+write

virtual ContextPtr input_context() const = 0

Returns context specified as input context on mapper object creation.

virtual ContextPtr output_context() const = 0

Returns context specified as output context on mapper object creation.