From 903763c07f1c8a77783735b05a6a9d722bee1639 Mon Sep 17 00:00:00 2001 From: Kevin Cheng Date: Tue, 28 Sep 2021 16:14:52 -0700 Subject: Add SUBGRAPH_ERROR_IF() to catch graph-level error. - Also replace SIMPLE_FATAL_ERROR() with FATAL_ERROR() since they're duplicate - Replace FATAL_ERROR()/ASSERT_MSG() with ERROR_IF_SUBGRAPH() if the condition is a graph error FATAL_ERROR()/ASSERT() should only be used by model internal/runtime error like file reading. Signed-off-by: Kevin Cheng Change-Id: If1e1e2488054a0ecd800fb0f2ea6487019282500 --- reference_model/src/ops/control_flow.cc | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'reference_model/src/ops/control_flow.cc') diff --git a/reference_model/src/ops/control_flow.cc b/reference_model/src/ops/control_flow.cc index 0945056..2446457 100644 --- a/reference_model/src/ops/control_flow.cc +++ b/reference_model/src/ops/control_flow.cc @@ -39,20 +39,11 @@ int OpControlFlow::evalBlock(TosaSerializationBasicBlock* block, SubgraphTraverser gt(block, tsh); - if (gt.initializeGraph()) - { - FATAL_ERROR("Unable to initialize graph traverser for block %s", block_name.c_str()); - } + ERROR_IF(gt.initializeGraph(), "Unable to initialize graph traverser for block %s", block_name.c_str()); - if (gt.linkTensorsAndNodes()) - { - FATAL_ERROR("Failed to link tensors and nodes for block %s", block_name.c_str()); - } + ERROR_IF(gt.linkTensorsAndNodes(), "Failed to link tensors and nodes for block %s", block_name.c_str()); - if (gt.validateGraph()) - { - FATAL_ERROR("Failed to validate subgraph for block %s", block_name.c_str()); - } + ERROR_IF(gt.validateGraph(), "Failed to validate subgraph for block %s", block_name.c_str()); int num_input_tensors = gt.getNumInputTensors(); int num_output_tensors = gt.getNumOutputTensors(); @@ -105,10 +96,7 @@ int OpControlFlow::evalBlock(TosaSerializationBasicBlock* block, } } - if (gt.evaluateAll()) - { - FATAL_ERROR("Error evaluating network. Giving up."); - } + ERROR_IF(gt.evaluateAll(), "Error evaluating network. Giving up."); // make sure output tensor is evaluated and show its value bool all_output_valid = true; @@ -129,8 +117,8 @@ int OpControlFlow::evalBlock(TosaSerializationBasicBlock* block, if (!all_output_valid) { gt.dumpGraph(g_func_debug.func_debug_file); - FATAL_ERROR("SubgraphTraverser \"%s\" error: Output tensors are not all valid at the end of evaluation.", - block_name.c_str()); + ERROR_IF(true, "SubgraphTraverser \"%s\" error: Output tensors are not all valid at the end of evaluation.", + block_name.c_str()); } // set basic block's output = subgraph_traverser's output -- cgit v1.2.1