Spec-Zone.ru › PyTorch 2.14

torch.can_cast

torch.can_cast(from_, to) → bool

Определяет, разрешено ли преобразование типа согласно правилам приведения типов PyTorch, описанным в документации по повышению типа.

Параметры:
  • from_ (dtype) – Исходный torch.dtype.
  • to (dtype) – Целевой torch.dtype.

Пример:

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

© 2026, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://docs.pytorch.org/docs/2.14/generated/torch.can_cast.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API