torch.Storage¶
A torch.Storage
is a contiguous, one-dimensional array of a single
data type.
Every torch.Tensor
has a corresponding storage of the same data type.
-
class
torch.
FloatStorage
[source]¶ -
byte
()¶ Casts this storage to byte type
-
char
()¶ Casts this storage to char type
-
clone
()¶ Returns a copy of this storage
-
copy_
()¶
-
cpu
()¶ Returns a CPU copy of this storage if it’s not already on the CPU
-
cuda
(device=None, non_blocking=False, **kwargs)¶ Returns a copy of this object in CUDA memory.
If this object is already in CUDA memory and on the correct device, then no copy is performed and the original object is returned.
Parameters: - device (int) – The destination GPU id. Defaults to the current device.
- non_blocking (bool) – If
True
and the source is in pinned memory, the copy will be asynchronous with respect to the host. Otherwise, the argument has no effect. - **kwargs – For compatibility, may contain the key
async
in place of thenon_blocking
argument.
-
data_ptr
()¶
-
double
()¶ Casts this storage to double type
-
element_size
()¶
-
fill_
()¶
-
float
()¶ Casts this storage to float type
-
static
from_buffer
()¶
-
static
from_file
(filename, shared=False, size=0) → Storage¶ If shared is True, then memory is shared between all processes. All changes are written to the file. If shared is False, then the changes on the storage do not affect the file.
size is the number of elements in the storage. If shared is False, then the file must contain at least size * sizeof(Type) bytes (Type is the type of storage). If shared is True the file will be created if needed.
Parameters:
-
half
()¶ Casts this storage to half type
-
int
()¶ Casts this storage to int type
-
is_cuda
= False¶
-
is_pinned
()¶
-
is_sparse
= False¶
-
long
()¶ Casts this storage to long type
-
new
()¶
-
pin_memory
()¶ Copies the storage to pinned memory, if it’s not already pinned.
-
resize_
()¶
Moves the storage to shared memory.
This is a no-op for storages already in shared memory and for CUDA storages, which do not need to be moved for sharing across processes. Storages in shared memory cannot be resized.
Returns: self
-
short
()¶ Casts this storage to short type
-
size
()¶
-
tolist
()¶ Returns a list containing the elements of this storage
-
type
(dtype=None, non_blocking=False, **kwargs)¶ Returns the type if dtype is not provided, else casts this object to the specified type.
If this is already of the correct type, no copy is performed and the original object is returned.
Parameters: - dtype (type or string) – The desired type
- non_blocking (bool) – If
True
, and the source is in pinned memory and destination is on the GPU or vice versa, the copy is performed asynchronously with respect to the host. Otherwise, the argument has no effect. - **kwargs – For compatibility, may contain the key
async
in place of thenon_blocking
argument. Theasync
arg is deprecated.
-