megenginelite.tensor¶
- class LiteTensor(layout=None, device_type=LiteDeviceType.LITE_CPU, device_id=0, is_pinned_host=False, shapes=None, dtype=None)[源代码]¶
the tensor to hold a block of data
- property device_id¶
get device id of the tensor
- property device_type¶
get device of the tensor
get the data in the tensor, add share the data with a new numpy, and return the numpy arrray, be careful, the data in numpy is valid before the tensor memory is write again, such as LiteNetwok forward next time.
- property is_continue¶
whether the tensor memory is continue
- property is_pinned_host¶
whether the tensor is pinned tensor
- property layout¶
- property nbytes¶
get the length of the meomry in byte
- reshape(shape)[源代码]¶
reshape the tensor with data not change, only change the shape :param shape: int arrary of dst_shape
- set_data_by_copy(data, data_length=0, layout=None)[源代码]¶
copy the data to the tensor param data: the data to copy to tensor, it should be list, numpy.ndarraya or ctypes with length
share the data to the tensor param data: the data will shared to the tensor, it should be a numpy.ndarray or ctypes data
share the same memory with the src_tensor, the self memory will be freed