csprng
csprng copied to clipboard
ZeroDivisionError: float division by zero in test_cpu_parallel
@unittest.skipIf(torch.get_num_threads() < 2, "requires multithreading CPU")
def test_cpu_parallel(self):
urandom_gen = csprng.create_random_device_generator('/dev/urandom')
def measure(size):
t = torch.empty(size, dtype=torch.float32, device='cpu')
start = time.time()
for i in range(10):
t.normal_(generator=urandom_gen)
finish = time.time()
return finish - start
time_for_1K = measure(1000)
time_for_1M = measure(1000000)
# Pessimistic check that parallel execution gives >= 1.5 performance boost
> self.assertTrue(time_for_1M/time_for_1K < 1000 / min(1.5, torch.get_num_threads()))
E ZeroDivisionError: float division by zero
test\test_csprng.py:308: ZeroDivisionError
fixed
actually not https://app.circleci.com/pipelines/github/pytorch/csprng/828/workflows/795e4b7e-7ddf-482f-8057-910c14bf3d60/jobs/39115
https://app.circleci.com/pipelines/github/pytorch/csprng/889/workflows/09900b65-8fd8-4d4f-98c0-fab5e5002ef0/jobs/47137