本文整理汇总了Python中torch._storage_classes方法的典型用法代码示例。如果您正苦于以下问题:Python torch._storage_classes方法的具体用法?Python torch._storage_classes怎么用?Python torch._storage_classes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类torch
的用法示例。
在下文中一共展示了torch._storage_classes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_print
# 需要导入模块: import torch [as 别名]
# 或者: from torch import _storage_classes [as 别名]
def test_print(self):
for t in torch._tensor_classes:
if t.is_cuda and not torch.cuda.is_available():
continue
obj = t(100, 100).fill_(1)
obj.__repr__()
str(obj)
for t in torch._storage_classes:
if t.is_cuda and not torch.cuda.is_available():
continue
obj = t(100).fill_(1)
obj.__repr__()
str(obj)
x = torch.Tensor([4, float('inf'), 1.5, float('-inf'), 0, float('nan'), 1])
x.__repr__()
str(x)
示例2: test_print
# 需要导入模块: import torch [as 别名]
# 或者: from torch import _storage_classes [as 别名]
def test_print(self):
for t in torch._tensor_classes:
if t in torch.sparse._sparse_tensor_classes:
continue
if t.is_cuda and not torch.cuda.is_available():
continue
obj = t(100, 100).fill_(1)
obj.__repr__()
str(obj)
for t in torch._storage_classes:
if t.is_cuda and not torch.cuda.is_available():
continue
obj = t(100).fill_(1)
obj.__repr__()
str(obj)
x = torch.Tensor([4, float('inf'), 1.5, float('-inf'), 0, float('nan'), 1])
x.__repr__()
str(x)
示例3: test_print
# 需要导入模块: import torch [as 别名]
# 或者: from torch import _storage_classes [as 别名]
def test_print(self):
for t in torch._tensor_classes:
if t == torch.HalfTensor:
continue # HalfTensor does not support fill
if t in torch.sparse._sparse_tensor_classes:
continue
if t.is_cuda and not torch.cuda.is_available():
continue
obj = t(100, 100).fill_(1)
obj.__repr__()
str(obj)
for t in torch._storage_classes:
if t.is_cuda and not torch.cuda.is_available():
continue
obj = t(100).fill_(1)
obj.__repr__()
str(obj)
x = torch.Tensor([4, float('inf'), 1.5, float('-inf'), 0, float('nan'), 1])
x.__repr__()
str(x)
示例4: __init__
# 需要导入模块: import torch [as 别名]
# 或者: from torch import _storage_classes [as 别名]
def __init__(self, context=None, reducers=None):
if context is None:
context = multiprocessing
if reducers is None:
reducers = {}
for t in torch._tensor_classes:
reducers.setdefault(t, reduce_tensor)
for t in torch._storage_classes:
reducers.setdefault(t, reduce_storage)
super(Queue, self).__init__(context, reducers)
示例5: init_reductions
# 需要导入模块: import torch [as 别名]
# 或者: from torch import _storage_classes [as 别名]
def init_reductions():
ForkingPickler.register(torch.cuda.Event, reduce_event)
for t in torch._storage_classes:
ForkingPickler.register(t, reduce_storage)
for t in torch._tensor_classes:
ForkingPickler.register(t, reduce_tensor)
示例6: test_print
# 需要导入模块: import torch [as 别名]
# 或者: from torch import _storage_classes [as 别名]
def test_print(self):
for t in torch._tensor_classes:
if IS_WINDOWS and t in [torch.cuda.sparse.HalfTensor, torch.cuda.HalfTensor]:
return # CUDA HalfTensor is not supported on Windows yet
if t == torch.HalfTensor:
continue # HalfTensor does not support fill
if t in torch.sparse._sparse_tensor_classes:
continue
if t.is_cuda and not torch.cuda.is_available():
continue
obj = t(100, 100).fill_(1)
obj.__repr__()
str(obj)
for t in torch._storage_classes:
if t.is_cuda and not torch.cuda.is_available():
continue
obj = t(100).fill_(1)
obj.__repr__()
str(obj)
x = torch.Tensor([4, float('inf'), 1.5, float('-inf'), 0, float('nan'), 1])
x.__repr__()
str(x)
x = torch.DoubleTensor([1e-324, 1e-323, 1e-322, 1e307, 1e308, 1e309])
x.__repr__()
str(x),