Class TensorBatch

Nested Relationships

Nested Types

Inheritance Relationships

Base Type

Class Documentation

class TensorBatch : public nvcv::CoreResource<NVCVTensorBatchHandle, TensorBatch>

Handle to a tensor batch object.

Tensor batch is a container type that can hold a list of non-uniformly shaped tensors. Rank, data type and layout must be consistent between the tensors.

Public Types

using Base = CoreResource<NVCVTensorBatchHandle, TensorBatch>
using Requirements = NVCVTensorBatchRequirements
using HandleType = NVCVTensorBatchHandle

Public Functions

inline TensorBatch(const TensorBatch &other)
inline TensorBatch(TensorBatch &&other)
inline TensorBatch &operator=(const TensorBatch &other)
inline TensorBatch &operator=(TensorBatch &&other)
inline TensorBatch(const Requirements &reqs, const Allocator &alloc = nullptr)
inline TensorBatch(int32_t capacity, const Allocator &alloc = nullptr)
inline int32_t capacity() const

Return the maximal number of tensors the tensor batch can hold.

inline int32_t rank() const

Return the rank of the tensors in the tensor batch or -1 for an empty batch.

inline int32_t numTensors() const

Return the number of tensors in the tensor batch.

inline DataType dtype() const

Return the data type of the tensors in the tensor batch.

inline TensorLayout layout() const

Return the layout of the tensors in the tensor batch.

inline NVCVTensorBufferType type() const

Return the buffer type of the tensors’ data.

inline Allocator alloc() const

Return the allocator used by the tensor batch.

template<typename It>
inline void pushBack(It begin, It end)

Append tensors from the given range to the end of the batch.

Parameters:

begin, end – range of the tensors to append.

inline void pushBack(const Tensor &tensor)

Append the tensor to the end of the batch.

Parameters:

tensor – Appended tensor.

inline void popTensors(int32_t numTensors)

Truncate tensors from the end of the batch.

Parameters:

numTensors – Number of tensors to remove.

inline void popTensor()

Delete the last tensor from the batch.

inline TensorBatchData exportData(CUstream stream)

Generate the tensor batch data descriptor.

The necessary copies to GPU are scheduled on the given stream. The struct is valid after the scheduled work is finished.

Parameters:

stream – CUDA stream on which the buffers copy will be scheduled.

inline void clear()
inline void setUserPointer(void *ptr)

Associates a user pointer to the tensor batch.

Parameters:

ptr – User pointer

inline void *getUserPointer() const

Get the user pointer that was previously assciated to the tensor batch with the setUserPointer(void*) method. Returns nullptr if no pointer was set.

inline Tensor operator[](int32_t idx) const

Return a handle to a tensor at a given positon.

Parameters:

idx – Index of a tensor to return

inline void setTensor(int32_t index, const Tensor &tensor)

Replace the tensor on position index.

inline Iterator begin() const
inline Iterator end() const

Public Static Functions

static inline Requirements CalcRequirements(int32_t capacity)
class Iterator

Public Types

using value_type = Tensor
using reference = const Tensor&
using pointer = const Tensor*
using iterator_category = std::random_access_iterator_tag
using difference_type = int32_t

Public Functions

inline reference operator*() const
inline pointer operator->() const
inline Iterator operator++(int)
inline Iterator &operator++()
inline Iterator operator--(int)
inline Iterator &operator--()
inline Iterator operator+(difference_type diff) const
inline Iterator operator-(difference_type diff) const
inline difference_type operator-(const Iterator &rhs) const
inline bool operator==(const Iterator &rhs) const
inline bool operator!=(const Iterator &rhs) const
inline bool operator<(const Iterator &rhs) const
inline bool operator>(const Iterator &rhs) const
inline bool operator<=(const Iterator &rhs) const
inline bool operator>=(const Iterator &rhs) const
inline Iterator(Iterator &other)
inline Iterator(Iterator &&other)
inline Iterator &operator=(Iterator &other)
inline Iterator &operator=(Iterator &&other)