Spec-Zone.ru › PyTorch 2.14

torch.gcd

torch.gcd(input, other, *, out=None) → Tensor

Вычисляет наибольший общий делитель (НОД) элементов input и other.

Типы input и other должны быть целочисленными.

Примечание

Здесь определяется gcd(0,0)=0gcd(0, 0) = 0.

Параметры:
  • input (Tensor) – входной тензор.
  • other (Tensor) – второй входной тензор
Именованные аргументы:

out (Tensor, необязательный) – выходной тензор.

Пример:

>>> a = torch.tensor([5, 10, 15])
>>> b = torch.tensor([3, 4, 5])
>>> torch.gcd(a, b)
tensor([1, 2, 5])
>>> c = torch.tensor([3])
>>> torch.gcd(a, c)
tensor([1, 1, 3])

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

Spec-Zone.ru

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