torch.is_storage#
- torch.is_storage(obj, /)[source]#
Returns True if obj is a PyTorch storage object.
- Parameters:
obj (Object) – Object to test
- Return type:
Example:
>>> import torch >>> # UntypedStorage (recommended) >>> tensor = torch.tensor([1, 2, 3]) >>> storage = tensor.untyped_storage() >>> torch.is_storage(storage) True >>> >>> # TypedStorage (legacy) >>> typed_storage = torch.TypedStorage(5, dtype=torch.float32) >>> torch.is_storage(typed_storage) True >>> >>> # regular tensor (should return False) >>> torch.is_storage(tensor) False >>> >>> # non-storage object >>> torch.is_storage([1, 2, 3]) False