Skip to content

Commit 5a0e8fb

Browse files
ebrevdotensorflower-gardener
authored andcommitted
Change rnn benchmarks to use variables and initialize only once
Change: 118974851
1 parent 8a8d7c0 commit 5a0e8fb

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

tensorflow/python/kernel_tests/rnn_test.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -922,9 +922,6 @@ def _static_vs_dynamic_rnn_benchmark_dynamic(inputs_t, sequence_length):
922922
def graph_creation_static_vs_dynamic_rnn_benchmark(max_time):
923923
config = tf.ConfigProto()
924924
config.allow_soft_placement = True
925-
# Don't perform optimizations, so we don't run ops on
926-
# CPU during constant folding.
927-
config.graph_options.optimizer_options.opt_level = -1
928925

929926
# These parameters don't matter
930927
batch_size = 512
@@ -1002,11 +999,11 @@ def static_vs_dynamic_rnn_benchmark(batch_size, max_time, num_units, use_gpu):
1002999
with tf.Session(config=config, graph=tf.Graph()) as sess:
10031000
if not use_gpu:
10041001
with tf.device("/cpu:0"):
1005-
inputs_t = tf.constant(inputs)
1002+
inputs_t = tf.Variable(inputs)
10061003
ops = _static_vs_dynamic_rnn_benchmark_dynamic(
10071004
inputs_t, sequence_length)
10081005
else:
1009-
inputs_t = tf.constant(inputs)
1006+
inputs_t = tf.Variable(inputs)
10101007
ops = _static_vs_dynamic_rnn_benchmark_dynamic(
10111008
inputs_t, sequence_length)
10121009
tf.initialize_all_variables().run()
@@ -1050,15 +1047,15 @@ def dynamic_rnn_swap_memory_benchmark(batch_size, max_time, num_units):
10501047

10511048
# No memory swap
10521049
with tf.Session(config=config, graph=tf.Graph()) as sess:
1053-
inputs_t = tf.constant(inputs)
1050+
inputs_t = tf.Variable(inputs)
10541051
ops = _dynamic_rnn_swap_memory_benchmark(
10551052
inputs_t, sequence_length, swap_memory=False)
10561053
tf.initialize_all_variables().run()
10571054
no_swap = _timer(sess, ops)
10581055

10591056
# Memory swap
10601057
with tf.Session(config=config, graph=tf.Graph()) as sess:
1061-
inputs_t = tf.constant(inputs)
1058+
inputs_t = tf.Variable(inputs)
10621059
ops = _dynamic_rnn_swap_memory_benchmark(
10631060
inputs_t, sequence_length, swap_memory=True)
10641061
tf.initialize_all_variables().run()
@@ -1085,7 +1082,7 @@ def rnn_long_sequence_benchmark(batch_size, seqlen, num_units,
10851082
for _ in range(5):
10861083
if dynamic:
10871084
with tf.Session(config=config, graph=tf.Graph()) as sess:
1088-
inputs_t = tf.constant(inputs)
1085+
inputs_t = tf.Variable(inputs)
10891086
ops = _dynamic_rnn_swap_memory_benchmark(
10901087
inputs_t, sequence_length, swap_memory=swap_memory)
10911088
tf.initialize_all_variables().run()

0 commit comments

Comments
 (0)