Skip to content

Commit

Permalink
Remove print by default from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloskath committed Nov 25, 2020
1 parent 5c842dc commit b23ee26
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 31 deletions.
9 changes: 7 additions & 2 deletions tests/aggregate/test_clustered_aggregate_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ def test_aggregate(self):
C = np.random.randint(5, 10)
L = np.random.randint(1, 30) * C
E = np.random.randint(10, 128)
print("Testing: N H L E C: {} {} {} {} {}".format(N, H, L, E, C))
if os.getenv("VERBOSE_TESTS", ""):
print(("Testing: N H L E C: "
"{} {} {} {} {}").format(N, H, L, E, C))

x = torch.rand((N, H, L, E)).cpu()
g = (torch.arange(L) % C).view(1, 1, L).repeat(N, H, 1).int().cpu()
f = torch.ones(N, H, C).cpu() * (C / L)
Expand Down Expand Up @@ -70,8 +73,10 @@ def test_aggregate_masked(self):
C = np.random.randint(5, 10)
L = np.random.randint(2, 30) * C
E = np.random.randint(10, 128)
if os.getenv("VERBOSE_TESTS", ""):
print(("Testing: N H L E C: "
"{} {} {} {} {}").format(N, H, L, E, C))

print("Testing: N H L E C: {} {} {} {} {}".format(N, H, L, E, C))
x = torch.rand((N, H, L, E)).cpu()
g = (torch.arange(L) % C).view(1, 1, L).repeat(N, H, 1).int().cpu()
g[:, :, -C:] = C + 1
Expand Down
6 changes: 4 additions & 2 deletions tests/aggregate/test_clustered_broadcast_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ def test_broadcast_difficult(self):
np.random.randint(C, L+1, N),
dtype=torch.int32
).cpu()
print("Test: N H L S E C: {} {} {} {} {} {}".format(
N, H, L, S, E, C))
if os.getenv("VERBOSE_TESTS", ""):
print(("Test: N H L S E C: "
"{} {} {} {} {} {}").format(N, H, L, S, E, C))

Q = torch.randn(N, H, L, E).cpu()
groups, counts = cluster_queries(Q, lengths, C, I, B)
Q_grouped = aggregate(Q, groups, 1/counts.float())
Expand Down
6 changes: 4 additions & 2 deletions tests/aggregate/test_clustered_broadcast_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ def test_broadcast_difficult(self):
np.random.randint(C, L+1, N),
dtype=torch.int32
).cuda()
print("Test: N H L S E C: {} {} {} {} {} {}".format(
N, H, L, S, E, C))
if os.getenv("VERBOSE_TESTS", ""):
print(("Test: N H L S E C: "
"{} {} {} {} {} {}").format(N, H, L, S, E, C))

Q = torch.randn(N, H, L, E).cuda()
groups, counts = cluster_queries(Q, lengths, C, I, B)
Q_grouped = aggregate(Q, groups, 1/counts.float())
Expand Down
6 changes: 4 additions & 2 deletions tests/clustering/hamming/test_python_api_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def test_clustering_convergence(self):
n_iterations=10

for n_buckets in range(1, 10):
print('Testing convergence for {} bits'.format(n_buckets))
if os.getenv("VERBOSE_TESTS", ""):
print('Testing convergence for {} bits'.format(n_buckets))
k = 2**n_buckets

L=k
Expand Down Expand Up @@ -181,7 +182,8 @@ def test_masked_clustering_convergence(self):


for n_buckets in range(1, 10):
print('Testing convergence for {} bits'.format(n_buckets))
if os.getenv("VERBOSE_TESTS", ""):
print('Testing convergence for {} bits'.format(n_buckets))
k = 2**n_buckets
L = k + 1
n_points = L * N * H
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ def test_masked_simple_grad(self):
S = np.random.randint(100, 1000)
k = np.random.randint(10, 64)

print("Testing Masked: N H L S E C k: {} {} {} {} {} {} {}".format(
N, H, L, S, E, C, k))
if os.getenv("VERBOSE_TESTS", ""):
print(("Testing Masked: N H L S E C k: "
"{} {} {} {} {} {} {}").format(N, H, L, S, E, C, k))

Q = torch.randn(N, H, L, E).to(self.device).requires_grad_(True)
K = torch.randn(N, H, S, E).to(self.device).requires_grad_(True)
Expand Down Expand Up @@ -209,8 +210,9 @@ def test_difficult_grad(self):
S = np.random.randint(100, 1000)
k = np.random.randint(10, 64)

print("Testing: N H L S E C k: {} {} {} {} {} {} {}".format(
N, H, L, S, E, C, k))
if os.getenv("VERBOSE_TESTS", ""):
print(("Testing: N H L S E C k: "
"{} {} {} {} {} {} {}").format(N, H, L, S, E, C, k))

Q = torch.randn(N, H, L, E).to(self.device)
K = torch.randn(N, H, S, E).to(self.device)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ def test_masked_simple_grad(self):
S = np.random.randint(100, 1000)
k = np.random.randint(10, 64)

print("Testing Masked: N H L S E C k: {} {} {} {} {} {} {}".format(
N, H, L, S, E, C, k))
if os.getenv("VEROSE_TESTS", ""):
print(("Testing Masked: N H L S E C k: "
"{} {} {} {} {} {} {}").format(N, H, L, S, E, C, k))

Q = torch.randn(N, H, L, E).to(self.device).requires_grad_(True)
K = torch.randn(N, H, S, E).to(self.device).requires_grad_(True)
Expand Down Expand Up @@ -214,8 +215,9 @@ def test_difficult_grad(self):
S = np.random.randint(100, 1000)
k = np.random.randint(10, 64)

print("Testing: N H L S E C k: {} {} {} {} {} {} {}".format(
N, H, L, S, E, C, k))
if os.getenv("VERBOSE_TESTS", ""):
print(("Testing: N H L S E C k: "
"{} {} {} {} {} {} {}").format(N, H, L, S, E, C, k))

Q = torch.randn(N, H, L, E).to(self.device)
K = torch.randn(N, H, S, E).to(self.device)
Expand Down
9 changes: 7 additions & 2 deletions tests/sparse_product/test_clustered_sparse_product_cpu_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ def test_simple_product(self):
E = np.random.randint(10, 129)
k = 32
E = 32
print("Testing: N H L S E C k: {} {} {} {} {} {} {}".format(N, H, L, S, E, C, k))
if os.getenv("VERBOSE_TESTS", ""):
print(("Testing: N H L S E C k: "
"{} {} {} {} {} {} {}").format(N, H, L, S, E, C, k))

Q = torch.randn(N, H, L, E).to(self.device)
K = torch.randn(N, H, S, E).to(self.device)
lengths = torch.full((N,), L, dtype=torch.int32).to(self.device)
Expand Down Expand Up @@ -141,7 +144,9 @@ def test_difficult_product(self):
S = np.random.randint(100, 1000)
k = np.random.randint(10, 64)

print("Testing: N H L S E C k: {} {} {} {} {} {} {}".format(N, H, L, S, E, C, k))
if os.getenv("VERBOSE_TESTS", ""):
print(("Testing: N H L S E C k: "
"{} {} {} {} {} {} {}").format(N, H, L, S, E, C, k))
Q = torch.randn(N, H, L, E).to(self.device)
K = torch.randn(N, H, S, E).to(self.device)
lengths = torch.full((N,), L, dtype=torch.int32).to(self.device)
Expand Down
5 changes: 4 additions & 1 deletion tests/sparse_product/test_clustered_sparse_product_gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ def test_difficult_product(self):
S = np.random.randint(100, 1000)
k = np.random.randint(10, 64)

print("Testing: N H L S E C k: {} {} {} {} {} {} {}".format(N, H, L, S, E, C, k))
if os.getenv("VERBOSE_TESTS", ""):
print("Testing: N H L S E C k: {} {} {} {} {} {} {}".format(
N, H, L, S, E, C, k
))
Q = torch.randn(N, H, L, E).to(self.device)
K = torch.randn(N, H, S, E).to(self.device)
lengths = torch.full((N,), L, dtype=torch.int32).to(self.device)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ def test_correctness_masked(self):
S = np.random.randint(100, 1000)
k = np.random.randint(10, 64)

print("Testing Masked: N H L S E C k: {} {} {} {} {} {} {}".format(
N, H, L, S, E, C, k))
if os.getenv("VERBOSE_TESTS", ""):
print(("Testing Masked: N H L S E C k: "
"{} {} {} {} {} {} {}").format(N, H, L, S, E, C, k))

Q = torch.randn(N, H, L, E).to(self.device)
K = torch.randn(N, H, S, E).to(self.device)
Expand Down Expand Up @@ -173,8 +174,9 @@ def test_correctness(self):
S = np.random.randint(100, 1000)
k = np.random.randint(10, 64)

print("Testing: N H L S E C k: {} {} {} {} {} {} {}".format(
N, H, L, S, E, C, k))
if os.getenv("VERBOSE_TESTS", ""):
print(("Testing: N H L S E C k: "
"{} {} {} {} {} {} {}").format(N, H, L, S, E, C, k))

Q = torch.randn(N, H, L, E).to(self.device)
K = torch.randn(N, H, S, E).to(self.device)
Expand Down Expand Up @@ -267,8 +269,10 @@ def test_forward(self):
S = np.random.randint(100, 1000)
k = np.random.randint(10, 64)

print("Testing: N H L S E C k: {} {} {} {} {} {} {}".format(
N, H, L, S, E, C, k))
if os.getenv("VERBOSE_TESTS", ""):
print(("Testing: N H L S E C k: "
"{} {} {} {} {} {} {}").format(N, H, L, S, E, C, k))

Q = torch.randn(N, H, L, E).to(self.device)
K = torch.randn(N, H, S, E).to(self.device)
lengths = torch.full((N,), L, dtype=torch.int32).to(self.device)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ def test_correctness_masked(self):
S = np.random.randint(100, 1000)
k = np.random.randint(10, 64)

print("Testing Masked: N H L S E C k: {} {} {} {} {} {} {}".format(
N, H, L, S, E, C, k))
if os.getenv("VERBOSE_TESTS", ""):
print(("Testing Masked: N H L S E C k: "
"{} {} {} {} {} {} {}").format(N, H, L, S, E, C, k))

Q = torch.randn(N, H, L, E).to(self.device)
K = torch.randn(N, H, S, E).to(self.device)
Expand Down Expand Up @@ -178,8 +179,9 @@ def test_correctness(self):
S = np.random.randint(100, 1000)
k = np.random.randint(10, 64)

print("Testing: N H L S E C k: {} {} {} {} {} {} {}".format(
N, H, L, S, E, C, k))
if os.getenv("VERBOSE_TESTS", ""):
print(("Testing: N H L S E C k: "
"{} {} {} {} {} {} {}").format(N, H, L, S, E, C, k))

Q = torch.randn(N, H, L, E).to(self.device)
K = torch.randn(N, H, S, E).to(self.device)
Expand Down Expand Up @@ -271,9 +273,10 @@ def test_forward(self):
E = np.random.randint(10, 128)
S = np.random.randint(100, 1000)
k = np.random.randint(10, 64)
if os.getenv("VERBOSE_TESTS", ""):
print(("Testing: N H L S E C k: "
"{} {} {} {} {} {} {}").format(N, H, L, S, E, C, k))

print("Testing: N H L S E C k: {} {} {} {} {} {} {}".format(
N, H, L, S, E, C, k))
Q = torch.randn(N, H, L, E).to(self.device)
K = torch.randn(N, H, S, E).to(self.device)
lengths = torch.full((N,), L, dtype=torch.int32).to(self.device)
Expand Down

0 comments on commit b23ee26

Please sign in to comment.