| 488 | |
| 489 | template<typename DT> |
| 490 | void SetTensorFromVector(const TensorData &tensorData, std::vector<DT> &data, int sample) |
| 491 | { |
| 492 | if (!nvcv::TensorDataAccessStrided::IsCompatible(tensorData)) |
| 493 | throw std::runtime_error("Tensor Data is not pitch access capable."); |
| 494 | |
| 495 | auto tDataAc = nvcv::TensorDataAccessStrided::Create(tensorData); |
| 496 | |
| 497 | if ((int64_t)(data.size() * sizeof(DT)) != tDataAc->sampleStride()) |
| 498 | throw std::runtime_error("Data vector is incorrect size."); |
| 499 | |
| 500 | if (tDataAc->numSamples() <= sample) |
| 501 | throw std::runtime_error("Number of samples smaller than requested sample."); |
| 502 | |
| 503 | if (sample < 0) |
| 504 | { |
| 505 | for (int i = 0; i < tDataAc->numSamples(); ++i) |
| 506 | { |
| 507 | if (cudaSuccess |
| 508 | != cudaMemcpy(tDataAc->sampleData(i), data.data(), tDataAc->sampleStride(), cudaMemcpyHostToDevice)) |
| 509 | { |
| 510 | throw std::runtime_error("CudaMemcpy failed"); |
| 511 | } |
| 512 | } |
| 513 | } |
| 514 | else |
| 515 | { |
| 516 | if (cudaSuccess |
| 517 | != cudaMemcpy(tDataAc->sampleData(sample), data.data(), tDataAc->sampleStride(), cudaMemcpyHostToDevice)) |
| 518 | { |
| 519 | throw std::runtime_error("CudaMemcpy failed"); |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | return; |
| 524 | } |
| 525 | |
| 526 | template<typename DT> |
| 527 | void GetVectorFromTensor(const TensorData &tensorData, int sample, std::vector<DT> &outData) |
nothing calls this directly
no test coverage detected