@@ -2419,26 +2419,17 @@ def tensorflow_onnx_mapping(g, continue_on_error, custom_op_handlers):
2419
2419
return mapped_op , unmapped_op
2420
2420
2421
2421
2422
- def tensorflow_onnx_rewrite (g , rewriters ):
2423
- try :
2424
- ops = g .get_nodes ()
2425
- for rewrite in rewriters :
2426
- ops = rewrite (g , ops )
2427
- g .set_nodes (ops )
2428
- for node in ops :
2429
- body_graphs = node .get_body_graphs ()
2430
- if body_graphs :
2431
- for attr , b_g in body_graphs .items ():
2432
- log .debug ("start rewriting subgraph of %s's attribute %s" , node .name , attr )
2433
- tensorflow_onnx_rewrite (b_g , rewriters )
2434
- except Exception as ex :
2435
- type_ , value_ , traceback_ = sys .exc_info ()
2436
- log .error ("node %s: exception %s" % (rewrite , ex ))
2437
- ex_ext = traceback .format_exception (type_ , value_ , traceback_ )
2438
- if continue_on_error :
2439
- log .info (ex_ext )
2440
- else :
2441
- raise ex
2422
+ def run_pre_rewriters (g , rewriters ):
2423
+ ops = g .get_nodes ()
2424
+ for rewrite in rewriters :
2425
+ ops = rewrite (g , ops )
2426
+ g .set_nodes (ops )
2427
+ for node in ops :
2428
+ body_graphs = node .get_body_graphs ()
2429
+ if body_graphs :
2430
+ for attr , b_g in body_graphs .items ():
2431
+ log .debug ("start rewriting subgraph of %s's attribute %s" , node .name , attr )
2432
+ tensorflow_onnx_rewrite (b_g , rewriters )
2442
2433
2443
2434
2444
2435
def transpose_inputs (ctx , inputs_as_nchw ):
@@ -2575,7 +2566,7 @@ def process_tf_graph(tf_graph, continue_on_error=False, verbose=False, target=No
2575
2566
if custom_rewriter is not None :
2576
2567
rewriters .extend (custom_rewriter )
2577
2568
2578
- tensorflow_onnx_rewrite (g , rewriters )
2569
+ run_pre_rewriters (g , rewriters )
2579
2570
2580
2571
# some nodes may already copied into inner Graph, so remove them from main Graph.
2581
2572
g .delete_unused_nodes (output_names )
0 commit comments