NVIDIA DeepStream SDK API Reference

8.0 Release
deepstream::Tensor Class Reference

Detailed Description

The Tensor class abstracts the tensor data access

Definition at line 49 of file service-maker/includes/tensor.hpp.

Data Structures

class  Context
 Context object of the tensor, which associates the tensor with what creates it. More...
 

Public Types

enum  DataType {
  INVALID = -1,
  UNSIGNED,
  SIGNED,
  FLOAT,
  COMPLEX
}
 Code for tensor data types. More...
 
enum  DeviceType {
  NONE = -1,
  CPU,
  GPU
}
 

Public Member Functions

 Tensor (unsigned int rank, DataType dtype, unsigned int bits, const int64_t shape[], const int64_t strides[], void *data, std::string format, unsigned int device_id, DeviceType device, Context *context)
 Construct from common tensor configurations. More...
 
 Tensor (const Tensor &)=delete
 Copy of a tensor is not allowed, use clone instead. More...
 
virtual ~Tensor ()
 Destructor. More...
 
unsigned int rank () const
 Number of dimenstions of the tensor. More...
 
TensorShape shape () const
 Shape of the tensor in vector. More...
 
DataType dtype () const
 Data type of the tensor elements. More...
 
unsigned int bits () const
 Number of bits for each data. More...
 
uint64_t stride (unsigned int d) const
 Retrieve the stride of a specific dimension. More...
 
void * data () const
 Retrieve the allocated data pointer. More...
 
unsigned int deviceId () const
 Retrieve the device id. More...
 
DeviceType deviceType () const
 Retrieve the device type. More...
 
Buffer wrap (NvBufSurfaceColorFormat format)
 Wrap the tensor to a buffer. More...
 
Tensorclone () const
 Clone a tensor. More...
 
TensortoGPU (unsigned int device_id) const
 Copy the tensor to GPU. More...
 
uint64_t size () const
 total size of the tensor in bytes More...
 

Protected Attributes

TensorImplementation * impl_
 
std::string format_
 
std::unique_ptr< Contextcontext_
 

Member Enumeration Documentation

◆ DataType

Code for tensor data types.

Enumerator
INVALID 
UNSIGNED 
SIGNED 
FLOAT 
COMPLEX 

Definition at line 54 of file service-maker/includes/tensor.hpp.

◆ DeviceType

Enumerator
NONE 
CPU 
GPU 

Definition at line 62 of file service-maker/includes/tensor.hpp.

Constructor & Destructor Documentation

◆ Tensor() [1/2]

deepstream::Tensor::Tensor ( unsigned int  rank,
DataType  dtype,
unsigned int  bits,
const int64_t  shape[],
const int64_t  strides[],
void *  data,
std::string  format,
unsigned int  device_id,
DeviceType  device,
Context context 
)

Construct from common tensor configurations.

◆ Tensor() [2/2]

deepstream::Tensor::Tensor ( const Tensor )
delete

Copy of a tensor is not allowed, use clone instead.

◆ ~Tensor()

virtual deepstream::Tensor::~Tensor ( )
virtual

Destructor.

Member Function Documentation

◆ bits()

unsigned int deepstream::Tensor::bits ( ) const

Number of bits for each data.

◆ clone()

Tensor* deepstream::Tensor::clone ( ) const

Clone a tensor.

◆ data()

void* deepstream::Tensor::data ( ) const

Retrieve the allocated data pointer.

◆ deviceId()

unsigned int deepstream::Tensor::deviceId ( ) const

Retrieve the device id.

◆ deviceType()

DeviceType deepstream::Tensor::deviceType ( ) const

Retrieve the device type.

◆ dtype()

DataType deepstream::Tensor::dtype ( ) const

Data type of the tensor elements.

◆ rank()

unsigned int deepstream::Tensor::rank ( ) const

Number of dimenstions of the tensor.

◆ shape()

TensorShape deepstream::Tensor::shape ( ) const

Shape of the tensor in vector.

◆ size()

uint64_t deepstream::Tensor::size ( ) const

total size of the tensor in bytes

◆ stride()

uint64_t deepstream::Tensor::stride ( unsigned int  d) const

Retrieve the stride of a specific dimension.

◆ toGPU()

Tensor* deepstream::Tensor::toGPU ( unsigned int  device_id) const

Copy the tensor to GPU.

◆ wrap()

Buffer deepstream::Tensor::wrap ( NvBufSurfaceColorFormat  format)

Wrap the tensor to a buffer.

Field Documentation

◆ context_

std::unique_ptr<Context> deepstream::Tensor::context_
protected

Definition at line 164 of file service-maker/includes/tensor.hpp.

◆ format_

std::string deepstream::Tensor::format_
protected

Definition at line 163 of file service-maker/includes/tensor.hpp.

◆ impl_

TensorImplementation* deepstream::Tensor::impl_
protected

Definition at line 162 of file service-maker/includes/tensor.hpp.


The documentation for this class was generated from the following file: