Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion test/test_jit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6008,7 +6008,11 @@ def test_gcd(x, y):
# type: (int, int) -> int
return math.gcd(x, y)

for inputs in [(2, 4), (-5, -15), (-5, 15), (10, 0), (0, 10), (-5, 0), (0, -5), (0, 0), (0, -0)]:
max_int = 2147483647
min_int = -2147483647 - 1
int_vals = list(range(-5, 5, 1)) + [max_int + 5, max_int * 2, min_int - 5, min_int * 2]
vals = [(i, j) for i in int_vals for j in int_vals]
for inputs in vals:
self.checkScript(test_gcd, inputs)

def test_math_ops1(self):
Expand Down
9 changes: 4 additions & 5 deletions torch/csrc/jit/register_prim_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include <c10/core/thread_pool.h>
#include <c10/util/SmallVector.h>

#include <cctype>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <exception>
#include <fstream>
Expand Down Expand Up @@ -63,8 +63,7 @@ void checkImplicitTensorToNum(at::Tensor t, bool toInt) {
throw std::runtime_error(
"Cannot input a tensor of dimension other than 0 as a scalar argument");
}
if (toInt &&
!isIntegralType(t.scalar_type())) {
if (toInt && !isIntegralType(t.scalar_type())) {
std::stringstream ss;
ss << "Cannot input a tensor of type " << t.scalar_type()
<< " as an integral argument";
Expand Down Expand Up @@ -98,9 +97,9 @@ static int64_t floordiv(int64_t a, int64_t b) {
}
}

static int gcd(int a, int b) {
static int64_t gcd(int64_t a, int64_t b) {
while (b != 0) {
int r = a % b;
int64_t r = a % b;
a = b;
b = r;
}
Expand Down