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

Function GetVectorFromTensor

tests/common/TensorDataUtils.hpp:527–548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

525
526template<typename DT>
527void GetVectorFromTensor(const TensorData &tensorData, int sample, std::vector<DT> &outData)
528{
529 if (!nvcv::TensorDataAccessStrided::IsCompatible(tensorData))
530 throw std::runtime_error("Tensor Data is not pitch access capable.");
531
532 auto tDataAc = nvcv::TensorDataAccessStrided::Create(tensorData);
533
534 if (tDataAc->numSamples() <= sample || sample < 0)
535 throw std::runtime_error("Number of samples smaller than requested sample.");
536
537 int elements = (tDataAc->sampleStride() / sizeof(DT));
538
539 outData.resize(elements);
540
541 if (cudaSuccess
542 != cudaMemcpy(outData.data(), tDataAc->sampleData(sample), tDataAc->sampleStride(), cudaMemcpyDeviceToHost))
543 {
544 throw std::runtime_error("CudaMemcpy failed");
545 }
546
547 return;
548}
549
550template<typename DT>
551static void SetImageTensorFromVectorPlanar(const TensorData &tensorData, std::vector<DT> &data, int sample)

Callers

nothing calls this directly

Calls 5

sampleStrideMethod · 0.80
numSamplesMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45
sampleDataMethod · 0.45

Tested by

no test coverage detected