[ 组合替代实现 ]torch.device¶
该 api 有两组参数列表重载,因此有两组差异分析。
转写示例¶
# PyTorch 写法
torch.device(type='cuda', index=0)
# Paddle 写法
'gpu:0'
# PyTorch 写法
torch.device(type='cpu')
# Paddle 写法
'cpu'
转写示例¶
# PyTorch 写法
torch.device('cpu')
# Paddle 写法
'cpu'
# PyTorch 写法
torch.device(1)
# Paddle 写法
"gpu:1"
# PyTorch 写法
torch.device("cuda:0")
# Paddle 写法
"gpu:0"