Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.lcm function

PyTorch torch.lcm function


PyTorch torch reference manual 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:


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

)

print

(

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

)

print

(

y

)

The output is:

tensor([ 36,  75])


PyTorch torch reference manual PyTorch torch reference manual