DDR <-> OCM Data Fetching

memcpy

For explanation and further examples of the below documented API, see here.

template<typename SrcTensorShape, typename DstTensorShape>
INLINE void memCpy(SrcTensorShape &src, DstTensorShape &dst, const std::int32_t ddrRoiBatchOffset = 0, const std::int32_t ddrRoiChOffset = 0, const std::int32_t ddrRoiHeightOffset = 0, const std::int32_t ddrRoiWidthOffset = 0)

: copies data to/from DDR and OCM. Currently ROI is only supported on DDR tensors which implies that data cannot be written into an ROI in the OCM.

Return

INLINE memCpy

Template Parameters
  • SrcTensorShape: Description of source tensor

  • DstTensorShape: Description of destination tensor

Parameters
  • src: source tensor

  • dst: source tensor

  • ddrRoiBatchOffset: ddr roi batch offset

  • ddrRoiChOffset: ddr roi channel offset

  • ddrRoiHeightOffset: ddr roi height offset

  • ddrRoiWidthOffset: ddr roi width offset

Examples

Copy DDR to OCM

Below, see an example of using memcpy to copy from DDR to OCM:

  MemAllocator                          ocmMem;
  DdrTensor<std::int32_t, 1, 2, 12, 15> ddrTensor1;
  OcmTensor<std::int32_t, 1, 2, 12, 15> ocmTensor1;
  ocmMem.allocate(ocmTensor1);  // Allocate space for the OCM tensor.

  // copy data from DDR Tensor to OCM
  memCpy(ddrTensor1,   // Source:      DDR tensor
         ocmTensor1);  // Destination: OCM tensor

Copy OCM to DDR

Below, see an example of using memcpy to copy from OCM to DDR:

  memCpy(ocmTensor1,   // Source:      OCM tensor
         ddrTensor1);  // Destination: DDR tensor