CVCUDA / CV-CUDA

CV-CUDA™ is an open-source, GPU accelerated library for cloud-scale image processing and computer vision.
https://cvcuda.github.io
Other
2.38k stars 216 forks source link

nvcv::Tensor batch dimension operation #161

Closed tensorflowt closed 2 months ago

tensorflowt commented 5 months ago

I would like to ask if nvcv::Tensor currently supports dimension splicing.

For example, when I perform batch preprocessing here, different frame images will produce multiple nvcv::Tensor:

nvcv::Tensor inputTensor1(2, {m_model_width, m_model_height}, nvcv::FMT_RGBf32p ), nvcv::Tensor inputTensor1(3, {m_model_width, m_model_height}, nvcv::FMT_RGBf32p), nvcv::Tensor inputTensor1(7, {m_model_width, m_model_height}, nvcv::FMT_RGBf32p),

what operations do I need to do? Is it spliced into a new inputTensor4(12, {m_model_width, m_model_height}, nvcv::FMT_RGBf32p)?

enmortensen commented 2 months ago

Hi @tensorflowt,

Thank you for your interest is CV-CUDA.

CV-CUDA does not support dimension slicing.

If I understand your example correctly, you want to create a single Tensor with a batch size of 12 and size {m_model_width, m_model_height} by combining three tensors of smaller batch sizes with the same width and height.

Since the smaller tensors are created with their own memory, the memory for the three smaller batch tensors are not consecutive and therefore cannot be used to directly create a larger batch tensor. Instead you will have to copy the memory from the smaller batches to the memory allocated for the larger batch. In CV-CUDA, you can combine multiple images with the PadAndStack operator.