@@ -922,9 +922,6 @@ def _static_vs_dynamic_rnn_benchmark_dynamic(inputs_t, sequence_length):
922
922
def graph_creation_static_vs_dynamic_rnn_benchmark (max_time ):
923
923
config = tf .ConfigProto ()
924
924
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
928
925
929
926
# These parameters don't matter
930
927
batch_size = 512
@@ -1002,11 +999,11 @@ def static_vs_dynamic_rnn_benchmark(batch_size, max_time, num_units, use_gpu):
1002
999
with tf .Session (config = config , graph = tf .Graph ()) as sess :
1003
1000
if not use_gpu :
1004
1001
with tf .device ("/cpu:0" ):
1005
- inputs_t = tf .constant (inputs )
1002
+ inputs_t = tf .Variable (inputs )
1006
1003
ops = _static_vs_dynamic_rnn_benchmark_dynamic (
1007
1004
inputs_t , sequence_length )
1008
1005
else :
1009
- inputs_t = tf .constant (inputs )
1006
+ inputs_t = tf .Variable (inputs )
1010
1007
ops = _static_vs_dynamic_rnn_benchmark_dynamic (
1011
1008
inputs_t , sequence_length )
1012
1009
tf .initialize_all_variables ().run ()
@@ -1050,15 +1047,15 @@ def dynamic_rnn_swap_memory_benchmark(batch_size, max_time, num_units):
1050
1047
1051
1048
# No memory swap
1052
1049
with tf .Session (config = config , graph = tf .Graph ()) as sess :
1053
- inputs_t = tf .constant (inputs )
1050
+ inputs_t = tf .Variable (inputs )
1054
1051
ops = _dynamic_rnn_swap_memory_benchmark (
1055
1052
inputs_t , sequence_length , swap_memory = False )
1056
1053
tf .initialize_all_variables ().run ()
1057
1054
no_swap = _timer (sess , ops )
1058
1055
1059
1056
# Memory swap
1060
1057
with tf .Session (config = config , graph = tf .Graph ()) as sess :
1061
- inputs_t = tf .constant (inputs )
1058
+ inputs_t = tf .Variable (inputs )
1062
1059
ops = _dynamic_rnn_swap_memory_benchmark (
1063
1060
inputs_t , sequence_length , swap_memory = True )
1064
1061
tf .initialize_all_variables ().run ()
@@ -1085,7 +1082,7 @@ def rnn_long_sequence_benchmark(batch_size, seqlen, num_units,
1085
1082
for _ in range (5 ):
1086
1083
if dynamic :
1087
1084
with tf .Session (config = config , graph = tf .Graph ()) as sess :
1088
- inputs_t = tf .constant (inputs )
1085
+ inputs_t = tf .Variable (inputs )
1089
1086
ops = _dynamic_rnn_swap_memory_benchmark (
1090
1087
inputs_t , sequence_length , swap_memory = swap_memory )
1091
1088
tf .initialize_all_variables ().run ()
0 commit comments