|
|
NVIDIA DeepStream SDK API Reference
|
8.0 Release
|
Go to the documentation of this file.
13 #ifndef __TENSOR_HPP__
14 #define __TENSOR_HPP__
24 namespace ds3d {
namespace v2xinfer {
26 static inline std::string
format(
const char* fmt, ...) {
30 vsnprintf(buffer,
sizeof(buffer), fmt, vl);
51 template <
typename _T>
72 std::shared_ptr<TensorData>
data;
79 return data ? (T*)
data->data :
nullptr;
83 int64_t
size(
int index)
const {
return shape[index]; }
90 void to_host_(
void* stream =
nullptr);
96 bool save(
const std::string& file,
void* stream =
nullptr)
const;
97 void print(
const char* prefix =
"Tensor",
size_t offset = 0,
size_t num_per_line = 10,
size_t lines = 1)
const;
98 void memset(
unsigned char value = 0,
void* stream =
nullptr);
99 void arange(
void* stream =
nullptr);
105 unsigned int offset(
unsigned int idim)
const;
113 static Tensor load(
const std::string& file,
bool device =
true,
void* stream =
nullptr);
115 static bool save(
const Tensor& tensor,
const std::string& file,
void* stream =
nullptr);
120 #endif // __TENSOR_HPP__
void copy_from_device(const void *data, void *stream)
void to_host_(void *stream=nullptr)
void reference(void *data, size_t bytes, DataType dtype, bool device)
Tensor clone(void *stream) const
std::string format_shape(const std::vector< _T > &shape)
std::vector< int64_t > shape
static TensorData * reference_new(void *data, size_t bytes, DataType dtype, bool device)
static Tensor from_data_reference(void *data, std::vector< int64_t > shape, DataType dtype, bool device=true)
void memset(unsigned char value=0, void *stream=nullptr)
static Tensor loadbinary(const std::string &file, std::vector< int64_t > shape, DataType dtype, bool device=true)
static Tensor load(const std::string &file, bool device=true, void *stream=nullptr)
int64_t size(int index) const
void reference(void *data, std::vector< int64_t > shape, DataType dtype, bool device=true)
void print(const char *prefix="Tensor", size_t offset=0, size_t num_per_line=10, size_t lines=1) const
Tensor to_float(void *stream=nullptr) const
bool save(const std::string &file, void *stream=nullptr) const
unsigned int offset(unsigned int idim) const
std::shared_ptr< TensorData > data
Tensor to_host(void *stream=nullptr) const
void arange(void *stream=nullptr)
Tensor to_device(void *stream=nullptr) const
void create_(std::vector< int64_t > shape, DataType dtype, bool device=true)
static Tensor from_data(void *data, std::vector< int64_t > shape, DataType dtype, bool device=true, void *stream=nullptr)
Tensor to_half(void *stream=nullptr) const
void copy_from_host(const void *data, void *stream)
void to_device_(void *stream=nullptr)
static Tensor create(std::vector< int64_t > shape, DataType dtype, bool device=true)
static TensorData * create(size_t bytes, DataType dtype, bool device)
size_t dtype_bytes(DataType dtype)
const char * dtype_string(DataType dtype)
static std::string format(const char *fmt,...)
void self_byte_check(size_t type_bytes) const