MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / GetImageVectorFromTensorPlanar

Function GetImageVectorFromTensorPlanar

tests/common/TensorDataUtils.hpp:629–656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

627
628template<typename DT>
629static void GetImageVectorFromTensorPlanar(const TensorData &tensorData, int sample, std::vector<DT> &outData)
630{
631 Optional<TensorDataAccessStridedImagePlanar> tDataAc = nvcv::TensorDataAccessStridedImagePlanar::Create(tensorData);
632
633 if (!tDataAc)
634 throw std::runtime_error("Tensor Data not compatible with planar access.");
635
636 if (tDataAc->numSamples() <= sample || sample < 0)
637 throw std::runtime_error("Number of samples smaller than requested sample.");
638
639 int elements = tDataAc->numRows() * tDataAc->numCols() * tDataAc->numChannels();
640
641 // Make sure we have the right size.
642 outData.resize(elements);
643 Byte *basePtr = tDataAc->sampleData(sample);
644 for (int i = 0; i < tDataAc->numChannels(); ++i)
645 {
646 if (cudaSuccess
647 != cudaMemcpy2D(outData.data() + (i * (tDataAc->numCols() * tDataAc->numRows())),
648 tDataAc->numCols() * sizeof(DT), basePtr, tDataAc->rowStride(),
649 tDataAc->numCols() * sizeof(DT), tDataAc->numRows(), cudaMemcpyDeviceToHost))
650 {
651 throw std::runtime_error("CudaMemcpy failed on copy of channel plane from device to host.");
652 }
653 basePtr += tDataAc->planeStride();
654 }
655 return;
656}
657
658// sets the tensor data to the value of data, but honors strides.
659template<typename DT>

Callers

nothing calls this directly

Calls 9

numSamplesMethod · 0.45
numRowsMethod · 0.45
numColsMethod · 0.45
numChannelsMethod · 0.45
resizeMethod · 0.45
sampleDataMethod · 0.45
dataMethod · 0.45
rowStrideMethod · 0.45
planeStrideMethod · 0.45

Tested by

no test coverage detected