Defined in File tensor.h
manager for raw tensor memory
It contains no dtype information and all sizes are measured in bytes.
Note that ensure_size() is lazy, and memory allocation only happens when ptr() or sub() is called
whether given tensor span is valid in this storage
ensure that its space could hold at least sz bytes
This method is lazy; size would only be changed when memory must be accessed.
This method would only grow storage, but it would not release memory
return a subtensor that shares the memory; the returned subtensor is not allowed to realloc
offset: offset given in bytes
apply lazy resize and get ptr
usable size in bytes until end of allocated block
get underlying comp node; error would be raised if it is invalid
get underlying comp node and allow it to be invalid
whether underlying comp_node is valid
whether this tensor has no valid element (either due to reaching end of mem chunk or no mem allocated)
chain-style computing node setter
note that if allow_mem_node_change is true and memory node is changed, the underlying data would be released and this tensor would become empty
copy from another TensorStorage, possibly of other storage type
This storage must have been initialized
size: number of bytes to be copied; must not exceed size of this or src
reset the tensor storage to given memory area
make a DeviceTensorStorage on default_cpu that shares memory with this
this must be a HostTensorStorage. Alignment not checked.
shortcut for raw_storage().use_count(), but won’t trigger lazy alloc
whether current capacity is 0 (so we are waiting for lazy init)
get underlying raw reference-counted storage
Public Static Functions
make a TensorStorage that shares memory with another TensorStorage some different storage type
This method can be used to convert between HostTensorStorage and DeviceTensorStorage; src must be on CPU memory node.