@@ -55,11 +55,6 @@ def test_lstm_savedmodel(self):
55
55
helper .make_tensor_value_info ("Y_c" , TensorProto .FLOAT , [1 , 2 , 3 ])
56
56
])
57
57
58
- # prepare the ONNX model and save it as a Tensorflow SavedModel
59
- tf_rep = prepare (helper .make_model (graph_def ))
60
- model_path = "lstm_savedmodel"
61
- tf_rep .export_graph (model_path )
62
-
63
58
# Initializing Inputs
64
59
X = np .array ([[[1. , 2. , 3. , 4. ], [5. , 6. , 7. , 8. ]]]).astype (np .float32 )
65
60
W = weight_scale * np .ones ((1 , number_of_gates * hidden_size , input_size )).astype (np .float32 )
@@ -68,6 +63,12 @@ def test_lstm_savedmodel(self):
68
63
seq_lens = np .repeat (X .shape [0 ], X .shape [1 ]).astype (np .int32 )
69
64
init_h = weight_scale * np .ones ((1 , X .shape [1 ], hidden_size )).astype (np .float32 )
70
65
66
+ # prepare the ONNX model and save it as a Tensorflow SavedModel
67
+ tf_rep = prepare (helper .make_model (graph_def ))
68
+ tf_rep .run ({"X" : X , "W" : W , "R" : R , "B" : B , "sequence_lens" : seq_lens , "initial_h" : init_h })
69
+ model_path = "lstm_savedmodel"
70
+ tf_rep .export_graph (model_path )
71
+
71
72
# use the ONNX reference implementation to get expected output
72
73
lstm = LSTM_Helper (X = X , W = W , R = R , B = B , initial_h = init_h )
73
74
_ , Y_ref = lstm .step ()
@@ -108,10 +109,6 @@ def test_gru_savedmodel(self):
108
109
helper .make_tensor_value_info ("Y_h" , TensorProto .FLOAT , [1 , 3 , 3 ])
109
110
])
110
111
111
- tf_rep = prepare (helper .make_model (graph_def ))
112
- model_path = "gru_savedmodel"
113
- tf_rep .export_graph (model_path )
114
-
115
112
# initializing Inputs
116
113
X = np .array ([[[1. , 2. , 3. ], [4. , 5. , 6. ], [7. , 8. ,
117
114
9. ]]]).astype (np .float32 )
@@ -124,6 +121,12 @@ def test_gru_savedmodel(self):
124
121
R_B = np .zeros ((1 , number_of_gates * hidden_size )).astype (np .float32 )
125
122
B = np .concatenate ((W_B , R_B ), axis = 1 )
126
123
124
+ # prepare the ONNX model and save it as a Tensorflow SavedModel
125
+ tf_rep = prepare (helper .make_model (graph_def ))
126
+ tf_rep .run ({"X" : X , "W" : W , "R" : R , "B" : B })
127
+ model_path = "gru_savedmodel"
128
+ tf_rep .export_graph (model_path )
129
+
127
130
# use the ONNX reference implementation to get the expected output
128
131
gru = GRU_Helper (X = X , W = W , R = R , B = B )
129
132
_ , Y_ref = gru .step ()
@@ -161,15 +164,17 @@ def test_rnn_savedmodel(self):
161
164
helper .make_tensor_value_info ("Y_h" , TensorProto .FLOAT , [1 , 2 , 4 ])
162
165
])
163
166
164
- tf_rep = prepare (helper .make_model (graph_def ))
165
- model_path = "rnn_savedmodel"
166
- tf_rep .export_graph (model_path )
167
-
168
167
# initializing Inputs
169
168
X = np .array ([[[1. , 2. ], [3. , 4. ], [5. , 6. ]]]).astype (np .float32 )
170
169
W = weight_scale * np .ones ((1 , hidden_size , input_size )).astype (np .float32 )
171
170
R = weight_scale * np .ones ((1 , hidden_size , hidden_size )).astype (np .float32 )
172
171
172
+ # prepare the ONNX model and save it as a Tensorflow SavedModel
173
+ tf_rep = prepare (helper .make_model (graph_def ))
174
+ tf_rep .run ({"X" : X , "W" : W , "R" : R })
175
+ model_path = "rnn_savedmodel"
176
+ tf_rep .export_graph (model_path )
177
+
173
178
# use the ONNX reference implementation to get the expected output
174
179
rnn = RNN_Helper (X = X , W = W , R = R )
175
180
_ , Y_ref = rnn .step ()
0 commit comments