def test_backward(): """Tests that the backwards calculation for combing signatures produces the correct values.""" for signature_combine, amount in ((True, 2), (False, 1), (False, 2), (False, 3), (False, 10)): for device in h.get_devices(): for batch_size, input_stream, input_channels in h.random_sizes(): for depth in (1, 2, 4, 6): inverse = random.choice([False, True]) _test_backward(signature_combine, amount, device, batch_size, input_stream, input_channels, depth, inverse)
def test_backward_expand_words(): """Tests that the backward calculations produce the correct values.""" for class_ in (False, True): for device in h.get_devices(): for batch_size, input_stream, input_channels in h.random_sizes(): for depth in (1, 2, 4, 6): for stream in (False, True): for mode in (h.expand_mode, h.words_mode): _test_backward(class_, device, batch_size, input_stream, input_channels, depth, stream, mode)
def test_memory_leaks(): """Checks that there are no memory leaks.""" for signature_combine, amount in ((True, 2), (False, 1), (False, 2), (False, 3), (False, 10)): for signature_grad in (False, True): for batch_size, input_stream, input_channels in h.random_sizes(): for depth in (1, 2, 5): for inverse in (False, True): _test_memory_leaks(signature_combine, amount, batch_size, input_stream, input_channels, depth, inverse, signature_grad)
def test_forward(): """Tests that the forward calculations produce the correct values.""" for class_ in (False, True): for device in h.get_devices(): for batch_size, input_stream, input_channels in h.random_sizes(): for depth in (1, 2, 4, 6): for stream in (False, True): for mode in h.all_modes: for signature_grad in (False, True): _test_forward(class_, device, batch_size, input_stream, input_channels, depth, stream, mode, signature_grad)
def test_no_adjustments(): """Tests that no memory is modified that shouldn't be modified.""" for class_ in (False, True): for device in h.get_devices(): for batch_size, input_stream, input_channels in h.random_sizes(): for depth in (1, 2, 5): for stream in (False, True): for mode in h.all_modes: for signature_grad in (False, True): _test_no_adjustments(class_, device, batch_size, input_stream, input_channels, depth, stream, mode, signature_grad)
def test_no_adjustments(): """Tests that the calculations for combining signatures don't modify memory they're not supposed to.""" for signature_combine, amount in ((True, 2), (False, 1), (False, 2), (False, 3), (False, 10)): for signature_grad in (False, True): for device in h.get_devices(): for batch_size, input_stream, input_channels in h.random_sizes( ): for depth in (1, 2, 5): for inverse in (False, True): _test_no_adjustments(signature_combine, amount, device, batch_size, input_stream, input_channels, depth, inverse, signature_grad)
def test_repeat_and_memory_leaks(): """Performs two separate tests. First, that the computations are deterministic, and always give the same result when run multiple times; in particular that using the class signatory.SignatureToLogSignature multiple times is fine. Second, that there are no memory leaks. """ for class_ in (False, True): for batch_size, input_stream, input_channels in h.random_sizes(): for depth in (1, 2, 5): for stream in (False, True): for mode in h.all_modes: for signature_grad in (False, True): _test_repeat_and_memory_leaks( class_, batch_size, input_stream, input_channels, depth, stream, mode, signature_grad)