| 525 | |
| 526 | template<typename DT> |
| 527 | void 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 | |
| 550 | template<typename DT> |
| 551 | static void SetImageTensorFromVectorPlanar(const TensorData &tensorData, std::vector<DT> &data, int sample) |
nothing calls this directly
no test coverage detected