Shortcuts

torch.lcm

torch.lcm(input, other, *, out=None) 张量

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

Both input and other 必须具有整数类型。

注意

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

Parameters
  • 输入 (张量) – 输入张量。

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

Keyword Arguments

输出 (张量, 可选) – 输出张量。

示例:

>>> 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])