From 51ba8da6f78f558db0f8f2cd37467d920fdcaabf Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=84=B8=ED=9D=AC/On-Device=20Lab=28SR=29/Princip?= =?utf8?q?al=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Mon, 25 Nov 2019 10:41:13 +0900 Subject: [PATCH] [moco-pass] Refine error with oops (#9153) This will refine error message using oops Signed-off-by: SaeHie Park --- compiler/moco/pass/CMakeLists.txt | 1 + compiler/moco/pass/src/Passes/ResolveConstantShape.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/moco/pass/CMakeLists.txt b/compiler/moco/pass/CMakeLists.txt index fb6252c..14a2dfd 100644 --- a/compiler/moco/pass/CMakeLists.txt +++ b/compiler/moco/pass/CMakeLists.txt @@ -8,4 +8,5 @@ target_link_libraries(moco_pass PUBLIC logo_core) target_link_libraries(moco_pass PUBLIC moco_lang) target_link_libraries(moco_pass PRIVATE moco_support) target_link_libraries(moco_pass PRIVATE stdex) +target_link_libraries(moco_pass PRIVATE oops) install(TARGETS moco_pass DESTINATION lib) diff --git a/compiler/moco/pass/src/Passes/ResolveConstantShape.cpp b/compiler/moco/pass/src/Passes/ResolveConstantShape.cpp index 83fb823..2a1323f 100644 --- a/compiler/moco/pass/src/Passes/ResolveConstantShape.cpp +++ b/compiler/moco/pass/src/Passes/ResolveConstantShape.cpp @@ -24,6 +24,8 @@ #include +#include + #include namespace @@ -86,13 +88,16 @@ bool resolve_constant_shape(loco::Graph *graph, moco::TFShape *shape_node) for (uint32_t axis = 0; axis < shape_rank; ++axis) { int32_t dim = (int32_t)input_tensor_shape.dim(axis).value(); - assert(dim > 0); + if (!(dim > 0)) + { + throw oops::UserExn("Invalid input shape", shape_node->name()); + } const_node->at(axis) = dim; } } else { - throw std::runtime_error("ResolveConstantShape: Not supported output data type"); + throw oops::UserExn("Unsupported data type", shape_node->name()); } // replace -- 2.7.4