评价此页

torch.can_cast#

torch.can_cast(from_, to) bool#

确定在 PyTorch 转换规则下是否允许类型转换,该规则在类型提升 文档 中进行了描述。

参数

示例

>>> torch.can_cast(torch.double, torch.float)
True
>>> torch.can_cast(torch.float, torch.int)
False