pytorch / 2 / generated / torch.lcm.html

torch.lcm

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

Computes the element-wise least common multiple (LCM) of input and other.

Both input and other must have integer types.

Note

This defines l c m ( 0 , 0 ) = 0 lcm(0, 0) = 0 and l c m ( 0 , a ) = 0 lcm(0, a) = 0 .

Parameters
  • input (Tensor) – the input tensor.
  • other (Tensor) – the second input tensor
Keyword Arguments

out (Tensor, optional) – the output tensor.

Example:

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

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