nndeploy C++ API  0.2.0
nndeploy C++ API
Public Member Functions | List of all members
nndeploy::device::Tensor Class Reference

Tensor类 More...

#include <tensor.h>

Public Member Functions

int addRef () const
 
void allocate (Device *device, const base::IntVector &config=base::IntVector())
 
void allocate (MemoryPool *memory_pool, const base::IntVector &config=base::IntVector())
 
void clear ()
 
Tensorclone ()
 
base::Status copyTo (Tensor *dst)
 
void create (const std::string &name)
 
void create (const TensorDesc &desc, Buffer *buffer, const std::string &name="")
 
void create (const TensorDesc &desc, const std::string &name="")
 
void create (Device *device, const TensorDesc &desc, const std::string &name="", const base::IntVector &config=base::IntVector())
 
void create (Device *device, const TensorDesc &desc, void *data_ptr, const std::string &name="", const base::IntVector &config=base::IntVector())
 
void create (MemoryPool *memory_pool, const TensorDesc &desc, const std::string &name="", const base::IntVector &config=base::IntVector())
 
void create (MemoryPool *memory_pool, const TensorDesc &desc, void *data_ptr, const std::string &name="", const base::IntVector &config=base::IntVector())
 
void deallocate ()
 
base::Status deserialize (const std::string &bin_str)
 
bool empty () const
 
int getBatch () const
 
BuffergetBuffer () const
 
BufferDesc getBufferDesc () const
 
int getChannel () const
 
base::IntVector getConfig () const
 
void * getData () const
 
base::DataFormat getDataFormat () const
 
base::DataType getDataType () const
 
int getDepth () const
 
TensorDesc getDesc () const
 
DevicegetDevice () const
 
base::DeviceType getDeviceType () const
 
int getHeight () const
 
MemoryPoolgetMemoryPool () const
 
base::MemoryType getMemoryType () const
 
std::string getName () const
 
template<typename T , typename... Args>
T * getPtr (Args... args)
 
size_t getRealSize () const
 
base::SizeVector getRealSizeVector () const
 
base::IntVector getShape () const
 
int getShapeIndex (int index) const
 
size_t getSize () const
 
base::SizeVector getSizeVector () const
 
base::SizeVector getStride () const
 
size_t getStrideIndex (int index) const
 
int getWidth () const
 
bool isContinue () const
 
bool isExternalBuffer () const
 
bool isMemoryPool () const
 
bool isSameDesc (Tensor *tensor) const
 
bool isSameDevice (Tensor *tensor) const
 
bool isSameMemoryPool (Tensor *tensor) const
 
bool justModify (Buffer *buffer, bool is_external=true)
 
bool justModify (const TensorDesc &desc)
 
Tensoroperator= (const Tensor &tensor)
 
Tensoroperator= (Tensor &&tensor) noexcept
 
void print (std::ostream &stream=std::cout) const
 
base::Status reshape (base::IntVector shape)
 
base::Status serialize (std::string &bin_str)
 
template<typename T >
base::Status set (T value)
 
void setDataFormat (base::DataFormat data_format)
 
void setDataType (base::DataType data_type)
 
base::Status setName (const std::string &)
 
int subRef () const
 
 Tensor ()
 
 Tensor (const std::string &name)
 
 Tensor (const Tensor &tensor)
 
 Tensor (const TensorDesc &desc, Buffer *buffer, const std::string &name="")
 
 Tensor (const TensorDesc &desc, const std::string &name="")
 
 Tensor (Device *device, const TensorDesc &desc, const std::string &name="", const base::IntVector &config=base::IntVector())
 
 Tensor (Device *device, const TensorDesc &desc, void *data_ptr, const std::string &name, const base::IntVector &config=base::IntVector())
 
 Tensor (MemoryPool *memory_pool, const TensorDesc &desc, const std::string &name="", const base::IntVector &config=base::IntVector())
 
 Tensor (MemoryPool *memory_pool, const TensorDesc &desc, void *data_ptr, const std::string &name, const base::IntVector &config=base::IntVector())
 
 Tensor (Tensor &&tensor) noexcept
 
virtual ~Tensor ()
 

Detailed Description

Tensor类

Definition at line 26 of file tensor.h.

Constructor & Destructor Documentation

◆ Tensor() [1/10]

nndeploy::device::Tensor::Tensor ( )
explicit

◆ Tensor() [2/10]

nndeploy::device::Tensor::Tensor ( const std::string &  name)
explicit

◆ Tensor() [3/10]

nndeploy::device::Tensor::Tensor ( const TensorDesc desc,
const std::string &  name = "" 
)
explicit

◆ Tensor() [4/10]

nndeploy::device::Tensor::Tensor ( const TensorDesc desc,
Buffer buffer,
const std::string &  name = "" 
)
explicit

◆ Tensor() [5/10]

nndeploy::device::Tensor::Tensor ( Device device,
const TensorDesc desc,
const std::string &  name = "",
const base::IntVector config = base::IntVector() 
)
explicit

◆ Tensor() [6/10]

nndeploy::device::Tensor::Tensor ( Device device,
const TensorDesc desc,
void *  data_ptr,
const std::string &  name,
const base::IntVector config = base::IntVector() 
)
explicit

◆ Tensor() [7/10]

nndeploy::device::Tensor::Tensor ( MemoryPool memory_pool,
const TensorDesc desc,
const std::string &  name = "",
const base::IntVector config = base::IntVector() 
)
explicit

◆ Tensor() [8/10]

nndeploy::device::Tensor::Tensor ( MemoryPool memory_pool,
const TensorDesc desc,
void *  data_ptr,
const std::string &  name,
const base::IntVector config = base::IntVector() 
)
explicit

◆ Tensor() [9/10]

nndeploy::device::Tensor::Tensor ( const Tensor tensor)

◆ Tensor() [10/10]

nndeploy::device::Tensor::Tensor ( Tensor &&  tensor)
noexcept

◆ ~Tensor()

virtual nndeploy::device::Tensor::~Tensor ( )
virtual

Member Function Documentation

◆ addRef()

int nndeploy::device::Tensor::addRef ( ) const
inline

Definition at line 223 of file tensor.h.

◆ allocate() [1/2]

void nndeploy::device::Tensor::allocate ( Device device,
const base::IntVector config = base::IntVector() 
)

◆ allocate() [2/2]

void nndeploy::device::Tensor::allocate ( MemoryPool memory_pool,
const base::IntVector config = base::IntVector() 
)

◆ clear()

void nndeploy::device::Tensor::clear ( )

◆ clone()

Tensor* nndeploy::device::Tensor::clone ( )

◆ copyTo()

base::Status nndeploy::device::Tensor::copyTo ( Tensor dst)

◆ create() [1/7]

void nndeploy::device::Tensor::create ( const std::string &  name)

◆ create() [2/7]

void nndeploy::device::Tensor::create ( const TensorDesc desc,
Buffer buffer,
const std::string &  name = "" 
)

◆ create() [3/7]

void nndeploy::device::Tensor::create ( const TensorDesc desc,
const std::string &  name = "" 
)

◆ create() [4/7]

void nndeploy::device::Tensor::create ( Device device,
const TensorDesc desc,
const std::string &  name = "",
const base::IntVector config = base::IntVector() 
)

◆ create() [5/7]

void nndeploy::device::Tensor::create ( Device device,
const TensorDesc desc,
void *  data_ptr,
const std::string &  name = "",
const base::IntVector config = base::IntVector() 
)

◆ create() [6/7]

void nndeploy::device::Tensor::create ( MemoryPool memory_pool,
const TensorDesc desc,
const std::string &  name = "",
const base::IntVector config = base::IntVector() 
)

◆ create() [7/7]

void nndeploy::device::Tensor::create ( MemoryPool memory_pool,
const TensorDesc desc,
void *  data_ptr,
const std::string &  name = "",
const base::IntVector config = base::IntVector() 
)

◆ deallocate()

void nndeploy::device::Tensor::deallocate ( )

◆ deserialize()

base::Status nndeploy::device::Tensor::deserialize ( const std::string &  bin_str)

◆ empty()

bool nndeploy::device::Tensor::empty ( ) const

◆ getBatch()

int nndeploy::device::Tensor::getBatch ( ) const

◆ getBuffer()

Buffer* nndeploy::device::Tensor::getBuffer ( ) const

◆ getBufferDesc()

BufferDesc nndeploy::device::Tensor::getBufferDesc ( ) const

◆ getChannel()

int nndeploy::device::Tensor::getChannel ( ) const

◆ getConfig()

base::IntVector nndeploy::device::Tensor::getConfig ( ) const

◆ getData()

void* nndeploy::device::Tensor::getData ( ) const

◆ getDataFormat()

base::DataFormat nndeploy::device::Tensor::getDataFormat ( ) const

◆ getDataType()

base::DataType nndeploy::device::Tensor::getDataType ( ) const

◆ getDepth()

int nndeploy::device::Tensor::getDepth ( ) const

◆ getDesc()

TensorDesc nndeploy::device::Tensor::getDesc ( ) const

◆ getDevice()

Device* nndeploy::device::Tensor::getDevice ( ) const

◆ getDeviceType()

base::DeviceType nndeploy::device::Tensor::getDeviceType ( ) const

◆ getHeight()

int nndeploy::device::Tensor::getHeight ( ) const

◆ getMemoryPool()

MemoryPool* nndeploy::device::Tensor::getMemoryPool ( ) const

◆ getMemoryType()

base::MemoryType nndeploy::device::Tensor::getMemoryType ( ) const

◆ getName()

std::string nndeploy::device::Tensor::getName ( ) const

◆ getPtr()

template<typename T , typename... Args>
T* nndeploy::device::Tensor::getPtr ( Args...  args)
inline

Definition at line 178 of file tensor.h.

◆ getRealSize()

size_t nndeploy::device::Tensor::getRealSize ( ) const

◆ getRealSizeVector()

base::SizeVector nndeploy::device::Tensor::getRealSizeVector ( ) const

◆ getShape()

base::IntVector nndeploy::device::Tensor::getShape ( ) const

◆ getShapeIndex()

int nndeploy::device::Tensor::getShapeIndex ( int  index) const

◆ getSize()

size_t nndeploy::device::Tensor::getSize ( ) const

◆ getSizeVector()

base::SizeVector nndeploy::device::Tensor::getSizeVector ( ) const

◆ getStride()

base::SizeVector nndeploy::device::Tensor::getStride ( ) const

◆ getStrideIndex()

size_t nndeploy::device::Tensor::getStrideIndex ( int  index) const

◆ getWidth()

int nndeploy::device::Tensor::getWidth ( ) const

◆ isContinue()

bool nndeploy::device::Tensor::isContinue ( ) const

◆ isExternalBuffer()

bool nndeploy::device::Tensor::isExternalBuffer ( ) const

◆ isMemoryPool()

bool nndeploy::device::Tensor::isMemoryPool ( ) const

◆ isSameDesc()

bool nndeploy::device::Tensor::isSameDesc ( Tensor tensor) const

◆ isSameDevice()

bool nndeploy::device::Tensor::isSameDevice ( Tensor tensor) const

◆ isSameMemoryPool()

bool nndeploy::device::Tensor::isSameMemoryPool ( Tensor tensor) const

◆ justModify() [1/2]

bool nndeploy::device::Tensor::justModify ( Buffer buffer,
bool  is_external = true 
)

◆ justModify() [2/2]

bool nndeploy::device::Tensor::justModify ( const TensorDesc desc)

◆ operator=() [1/2]

Tensor& nndeploy::device::Tensor::operator= ( const Tensor tensor)

◆ operator=() [2/2]

Tensor& nndeploy::device::Tensor::operator= ( Tensor &&  tensor)
noexcept

◆ print()

void nndeploy::device::Tensor::print ( std::ostream &  stream = std::cout) const

◆ reshape()

base::Status nndeploy::device::Tensor::reshape ( base::IntVector  shape)
Parameters
shape
Returns
base::Status
Note
三种情况

buffer为空,直接reshape

# buffer不为空,reshape后的buffer空间小于或当前buffer的空间,reshape并且更新buffer

buffer不为空,

◆ serialize()

base::Status nndeploy::device::Tensor::serialize ( std::string &  bin_str)

◆ set()

template<typename T >
base::Status nndeploy::device::Tensor::set ( value)
inline

Definition at line 88 of file tensor.h.

◆ setDataFormat()

void nndeploy::device::Tensor::setDataFormat ( base::DataFormat  data_format)

◆ setDataType()

void nndeploy::device::Tensor::setDataType ( base::DataType  data_type)

◆ setName()

base::Status nndeploy::device::Tensor::setName ( const std::string &  )

◆ subRef()

int nndeploy::device::Tensor::subRef ( ) const
inline

Definition at line 224 of file tensor.h.


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