Skip to content

Commit 49942b1

Browse files
committed
Address PR comments
1 parent b011336 commit 49942b1

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

tf2onnx/tfonnx.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,11 @@ def rewrite_constant_fold(g, ops):
6565
if set(op.output) & set(g.outputs): continue
6666
try:
6767
inputs = []
68-
skip = False
6968
for node in op.inputs:
7069
if not node.is_const():
71-
skip = True
7270
break
7371
inputs.append(node.get_tensor_value(as_list=False))
7472

75-
if skip: continue
76-
7773
logger.debug("op name %s, %s, %s", op.name, len(op.input), len(inputs))
7874
if inputs and len(op.input) == len(inputs):
7975
logger.info("folding node type=%s, name=%s" % (op.type, op.name))
@@ -453,14 +449,14 @@ def compat_handler(ctx, node, **kwargs):
453449

454450
# pre-processing graph rewrites
455451
# bi-directional re-writer should be placed after single directional re-writer
456-
rewriters = [rewrite_quantize_and_dequantize, rewrite_transpose, rewrite_flatten, rewrite_gemm,
457-
rewrite_random_uniform, rewrite_random_uniform_fold_const,
452+
rewriters = [rewrite_constant_fold, rewrite_quantize_and_dequantize, rewrite_transpose, rewrite_flatten,
453+
rewrite_gemm, rewrite_random_uniform, rewrite_random_uniform_fold_const,
458454
rewrite_random_normal, rewrite_dropout, rewrite_eye,
459455
rewrite_leakyrelu, rewrite_thresholded_relu, rewrite_conv2d_with_pad,
460456
rewrite_single_direction_lstm, rewrite_bi_direction_lstm,
461457
rewrite_single_direction_gru, rewrite_bi_direction_gru,
462458
rewrite_custom_rnn_cell, rewrite_generic_loop, rewrite_cond,
463-
rewrite_biasadd_with_conv2d, rewrite_constant_fold
459+
rewrite_biasadd_with_conv2d,
464460
]
465461

466462
if custom_rewriter is not None:

0 commit comments

Comments
 (0)