评价此页

torch.lcm#

torch.lcm(input, other, *, out=None) Tensor#

计算 inputother 的逐元素最小公倍数 (LCM)。

input 和 `other` 都必须是整数类型。

注意

定义了 lcm(0,0)=0lcm(0, 0) = 0lcm(0,a)=0lcm(0, a) = 0

参数
  • input (Tensor) – 输入张量。

  • other (Tensor) – 第二个输入张量

关键字参数

out (Tensor, optional) – 输出张量。

示例

>>> a = torch.tensor([5, 10, 15])
>>> b = torch.tensor([3, 4, 5])
>>> torch.lcm(a, b)
tensor([15, 20, 15])
>>> c = torch.tensor([3])
>>> torch.lcm(a, c)
tensor([15, 30, 15])