gcd¶
- paddle. gcd ( x, y, name=None ) [source]
- 
         Computes the element-wise greatest common divisor (GCD) of input |x| and |y|. Both x and y must have integer types. Note gcd(0,0)=0, gcd(0, y)=|y| If x.shape != y.shape, they must be broadcastable to a common shape (which becomes the shape of the output). - Parameters
- 
           - x (Tensor) – An N-D Tensor, the data type is int32,int64. 
- y (Tensor) – An N-D Tensor, the data type is int32,int64. 
- name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name. 
 
- Returns
- 
           An N-D Tensor, the data type is the same with input. 
- Return type
- 
           out (Tensor) 
 Examples import paddle x1 = paddle.to_tensor(12) x2 = paddle.to_tensor(20) paddle.gcd(x1, x2) # Tensor(shape=[1], dtype=int64, place=CUDAPlace(0), stop_gradient=True, # [4]) x3 = paddle.arange(6) paddle.gcd(x3, x2) # Tensor(shape=[6], dtype=int64, place=CUDAPlace(0), stop_gradient=True, # [20, 1 , 2 , 1 , 4 , 5]) x4 = paddle.to_tensor(0) paddle.gcd(x4, x2) # Tensor(shape=[1], dtype=int64, place=CUDAPlace(0), stop_gradient=True, # [20]) paddle.gcd(x4, x4) # Tensor(shape=[1], dtype=int64, place=CUDAPlace(0), stop_gradient=True, # [0]) x5 = paddle.to_tensor(-20) paddle.gcd(x1, x5) # Tensor(shape=[1], dtype=int64, place=CUDAPlace(0), stop_gradient=True, # [4]) 
