27 struct InsideDescribe;
63 Tensor(
int dimSize = 4, DimensionType type = CAFFE);
72 Tensor(
const Tensor* tensor, DimensionType type = CAFFE,
bool allocMemory =
true);
93 static Tensor* createDevice(
const std::vector<int>& shape,
halide_type_t type, DimensionType dimType = TENSORFLOW);
102 template <
typename T>
104 return createDevice(shape, halide_type_of<T>(), dimType);
115 static Tensor* create(
const std::vector<int>& shape,
halide_type_t type,
void* data = NULL,
116 DimensionType dimType = TENSORFLOW);
125 template <
typename T>
127 return create(shape, halide_type_of<T>(), data, dimType);
136 bool copyFromHostTensor(
const Tensor* hostTensor);
143 bool copyToHostTensor(
Tensor* hostTensor)
const;
151 static Tensor* createHostTensorFromDevice(
const Tensor* deviceTensor,
bool copyData =
true);
165 DimensionType getDimensionType()
const;
171 HandleDataType getHandleDataType()
const;
177 void setType(
int type);
191 template <
typename T>
193 return (T*)mBuffer.host;
201 return mBuffer.device;
206 return mBuffer.dimensions;
213 std::vector<int> shape()
const;
226 return size() / mBuffer.type.bytes();
232 return mBuffer.dim[3].extent;
235 return mBuffer.dim[2].extent;
238 return mBuffer.dim[1].extent;
241 return mBuffer.dim[0].extent;
246 return mBuffer.dim[2].extent;
249 return mBuffer.dim[1].extent;
252 return mBuffer.dim[3].extent;
255 return mBuffer.dim[0].extent;
260 return mBuffer.dim[index].stride;
263 return mBuffer.dim[index].extent;
266 mBuffer.dim[index].stride = stride;
269 mBuffer.dim[index].extent = length;
280 struct InsideDescribe* mDescribe;
283 friend class TensorUtils;
int elementSize() const
calculate number of elements needed to store data taking reordering flag into account.
Definition: Tensor.hpp:225
int batch() const
Definition: Tensor.hpp:240
static Tensor * createDevice(const std::vector< int > &shape, DimensionType dimType=TENSORFLOW)
create tensor with shape and dimension type. data type is represented by T.
Definition: Tensor.hpp:103
Definition: Tensor.hpp:34
DataReorderType
Definition: Tensor.hpp:48
int tfBatch() const
Definition: Tensor.hpp:254
Definition: Tensor.hpp:32
int width() const
Definition: Tensor.hpp:231
halide_buffer_t & buffer()
Definition: Tensor.hpp:157
int length(int index) const
Definition: Tensor.hpp:262
void setLength(int index, int length)
Definition: Tensor.hpp:268
int height() const
Definition: Tensor.hpp:234
int tfWidth() const
Definition: Tensor.hpp:245
int stride(int index) const
Definition: Tensor.hpp:259
Definition: Tensor.hpp:25
T * host() const
visit host memory, data type is represented by T.
Definition: Tensor.hpp:192
#define MNN_PUBLIC
Definition: MNNDefine.h:53
const halide_buffer_t & buffer() const
Definition: Tensor.hpp:154
DimensionType
Definition: Tensor.hpp:30
int tfChannel() const
Definition: Tensor.hpp:251
Definition: HalideRuntime.h:82
halide_type_t getType() const
get data type.
Definition: Tensor.hpp:183
Definition: AutoTime.hpp:16
void setStride(int index, int stride)
Definition: Tensor.hpp:265
int dimensions() const
Definition: Tensor.hpp:205
int channel() const
Definition: Tensor.hpp:237
int tfHeight() const
Definition: Tensor.hpp:248
Definition: HalideRuntime.h:203
uint64_t deviceId() const
visit device memory.
Definition: Tensor.hpp:200
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.
Definition: Tensor.hpp:126
HandleDataType
Definition: Tensor.hpp:40