PyTorch torch.lcm function
PyTorch torch reference manual
torch.lcm is a function in PyTorch used to compute the least common multiple (Least Common Multiple) of elements of two tensors.
Function definition
torch.lcm(input, other, out=None)
Parameter Description:
input: The first input tensorother: The second input tensorout: Output tensor
Usage examples
Example
import
torch
Create two tensors
a
=
torch.
tensor
(
[
3
,
4
,
5
]
)
b
=
torch.
tensor
(
[
6
,
8
,
10
]
)
Compute the least common multiple
y
=
torch.
lcm
(
a
,
b
)
(
y
)
The output is:
tensor([ 6, 8, 10])
Example
import
torch
Create two tensors
a
=
torch.
tensor
(
[
12
,
15
]
)
b
=
torch.
tensor
(
[
18
,
25
]
)
Compute the least common multiple
y
=
torch.
lcm
(
a
,
b
)
(
y
)
The output is:
tensor([ 36, 75])