csprng icon indicating copy to clipboard operation
csprng copied to clipboard

ZeroDivisionError: float division by zero in test_cpu_parallel

Open pbelevich opened this issue 5 years ago • 3 comments

@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

pbelevich avatar Dec 02 '20 16:12 pbelevich

fixed

pbelevich avatar Dec 09 '20 02:12 pbelevich

actually not https://app.circleci.com/pipelines/github/pytorch/csprng/828/workflows/795e4b7e-7ddf-482f-8057-910c14bf3d60/jobs/39115

pbelevich avatar Dec 15 '20 18:12 pbelevich

https://app.circleci.com/pipelines/github/pytorch/csprng/889/workflows/09900b65-8fd8-4d4f-98c0-fab5e5002ef0/jobs/47137

pbelevich avatar Jan 20 '21 02:01 pbelevich