Fix cuDNN tests
Move `times = []` from the outer to the inner loop
Delete `clear_session()` which is redundant with `keras_test`
Reduce the example size under the 3x speed-up is satisfied
@@ -122,18 +122,18 @@ def test_cudnn_rnn_canonical_to_params_gru():
@keras_test
+@pytest.mark.parametrize('rnn_type', ['lstm', 'gru'], ids=['LSTM', 'GRU'])
@pytest.mark.skipif((keras.backend.backend() != 'tensorflow'),
reason='Requires TensorFlow backend')
@pytest.mark.skipif(not keras.backend.tensorflow_backend._get_available_gpus(),
reason='Requires GPU')
-def test_cudnn_rnn_timing():
+def test_cudnn_rnn_timing(rnn_type):
input_size = 1000
timesteps = 60
units = 256
num_samples = 10000
times = []
- for rnn_type in ['lstm', 'gru']:
for use_cudnn in [True, False]:
start_time = time.time()
inputs = keras.layers.Input(shape=(None, input_size))
@@ -161,7 +161,6 @@ def test_cudnn_rnn_timing():
speedup = times[1] / times[0]
print(rnn_type, 'speedup', speedup)
assert speedup > 3
- keras.backend.clear_session()
@keras_test
