| 627 | |
| 628 | template<typename DT> |
| 629 | static 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. |
| 659 | template<typename DT> |
nothing calls this directly
no test coverage detected