MNN
1.0
|
#include <Tensor.hpp>
Public 类型 | |
enum | DimensionType { TENSORFLOW, CAFFE, CAFFE_C4 } |
enum | HandleDataType { HANDLE_NONE = 0, HANDLE_STRING = 1 } |
enum | DataReorderType { NO_REORDER = 0, REORDER_4 = 1, REORDER_8 } |
Public 成员函数 | |
Tensor (int dimSize=4, DimensionType type=CAFFE) | |
create a tensor with dimension size and type without acquire memory for data. 更多... | |
Tensor (const Tensor *tensor, DimensionType type=CAFFE, bool allocMemory=true) | |
create a tensor with same shape as given tensor. 更多... | |
~Tensor () | |
bool | copyFromHostTensor (const Tensor *hostTensor) |
for DEVICE tensor, copy data from given host tensor. 更多... | |
bool | copyToHostTensor (Tensor *hostTensor) const |
for DEVICE tensor, copy data to given host tensor. 更多... | |
const halide_buffer_t & | buffer () const |
halide_buffer_t & | buffer () |
DimensionType | getDimensionType () const |
get dimension type. 更多... | |
HandleDataType | getHandleDataType () const |
handle data type. used when data type code is halide_type_handle. 更多... | |
void | setType (int type) |
set data type. 更多... | |
halide_type_t | getType () const |
get data type. 更多... | |
template<typename T > | |
T * | host () const |
visit host memory, data type is represented by T . 更多... | |
uint64_t | deviceId () const |
visit device memory. 更多... | |
int | dimensions () const |
std::vector< int > | shape () const |
get all dimensions' extent. 更多... | |
int | size () const |
calculate number of bytes needed to store data taking reordering flag into account. 更多... | |
int | elementSize () const |
calculate number of elements needed to store data taking reordering flag into account. 更多... | |
int | width () const |
int | height () const |
int | channel () const |
int | batch () const |
int | tfWidth () const |
int | tfHeight () const |
int | tfChannel () const |
int | tfBatch () const |
int | stride (int index) const |
int | length (int index) const |
void | setStride (int index, int stride) |
void | setLength (int index, int length) |
void | print () const |
print tensor data. for DEBUG use only. 更多... | |
静态 Public 成员函数 | |
static Tensor * | createDevice (const std::vector< int > &shape, halide_type_t type, DimensionType dimType=TENSORFLOW) |
create tensor with shape, data type and dimension type. 更多... | |
template<typename T > | |
static Tensor * | createDevice (const std::vector< int > &shape, DimensionType dimType=TENSORFLOW) |
create tensor with shape and dimension type. data type is represented by T . 更多... | |
static Tensor * | create (const std::vector< int > &shape, halide_type_t type, void *data=NULL, DimensionType dimType=TENSORFLOW) |
create tensor with shape, data type, data and dimension type. 更多... | |
template<typename T > | |
static Tensor * | create (const std::vector< int > &shape, void *data=NULL, DimensionType dimType=TENSORFLOW) |
create tensor with shape, data and dimension type. data type is represented by T . 更多... | |
static Tensor * | createHostTensorFromDevice (const Tensor *deviceTensor, bool copyData=true) |
create HOST tensor from DEVICE tensor, with or without data copying. 更多... | |
友元 | |
class | TensorUtils |
data container. data for host tensor is saved in host
field. its memory is allocated malloc directly. data for device tensor is saved in deviceId
field. its memory is allocated by session's backend. usually, device tensors are created by engine (like net, session). meanwhile, host tensors could be created by engine or user.
MNN::Tensor::Tensor | ( | int | dimSize = 4 , |
DimensionType | type = CAFFE |
||
) |
create a tensor with dimension size and type without acquire memory for data.
dimSize | dimension size. |
type | dimension type. |
MNN::Tensor::Tensor | ( | const Tensor * | tensor, |
DimensionType | type = CAFFE , |
||
bool | allocMemory = true |
||
) |
create a tensor with same shape as given tensor.
tensor | shape provider. |
type | dimension type. |
allocMemory | acquire memory for data or not. |
MNN::Tensor::~Tensor | ( | ) |
deinitializer
|
inline |
|
inline |
|
inline |
|
inline |
bool MNN::Tensor::copyFromHostTensor | ( | const Tensor * | hostTensor | ) |
for DEVICE tensor, copy data from given host tensor.
hostTensor | host tensor, the data provider. |
bool MNN::Tensor::copyToHostTensor | ( | Tensor * | hostTensor | ) | const |
for DEVICE tensor, copy data to given host tensor.
hostTensor | host tensor, the data consumer. |
|
static |
create tensor with shape, data type, data and dimension type.
shape | tensor shape. |
type | data type. |
data | data to save. |
dimType | dimension type. |
|
inlinestatic |
create tensor with shape, data and dimension type. data type is represented by T
.
shape | tensor shape. |
data | data to save. |
dimType | dimension type. |
|
static |
create tensor with shape, data type and dimension type.
shape | tensor shape. |
type | data type. |
dimType | dimension type. |
|
inlinestatic |
create tensor with shape and dimension type. data type is represented by T
.
shape | tensor shape. |
dimType | dimension type. |
|
static |
create HOST tensor from DEVICE tensor, with or without data copying.
deviceTensor | given device tensor. |
copyData | copy data or not. |
|
inline |
visit device memory.
|
inline |
|
inline |
calculate number of elements needed to store data taking reordering flag into account.
DimensionType MNN::Tensor::getDimensionType | ( | ) | const |
get dimension type.
HandleDataType MNN::Tensor::getHandleDataType | ( | ) | const |
handle data type. used when data type code is halide_type_handle.
|
inline |
get data type.
|
inline |
|
inline |
visit host memory, data type is represented by T
.
T
type.
|
inline |
void MNN::Tensor::print | ( | ) | const |
print tensor data. for DEBUG use only.
|
inline |
|
inline |
void MNN::Tensor::setType | ( | int | type | ) |
set data type.
type | data type defined in 'Type_generated.h'. |
std::vector<int> MNN::Tensor::shape | ( | ) | const |
get all dimensions' extent.
int MNN::Tensor::size | ( | ) | const |
calculate number of bytes needed to store data taking reordering flag into account.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
friend |