torch.gcd¶ torch.gcd(input, other, *, out=None) → 张量¶ 计算 input 和 other 的逐元素最大公约数(GCD)。 Both input and other 必须具有整数类型。 注意 这定义了 gcd(0,0)=0gcd(0, 0) = 0gcd(0,0)=0。 Parameters 输入 (张量) – 输入张量。 其他 (Tensor) – 第二个输入张量 Keyword Arguments 输出 (张量, 可选) – 输出张量。 示例: >>> a = torch.tensor([5, 10, 15]) >>> b = torch.tensor([3, 4, 5]) >>> torch.gcd(a, b) tensor([1, 2, 5]) >>> c = torch.tensor([3]) >>> torch.gcd(a, c) tensor([1, 1, 3])