[moco-pass] Refine error with oops (#9153)
author박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Mon, 25 Nov 2019 01:41:13 +0000 (10:41 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 25 Nov 2019 01:41:13 +0000 (10:41 +0900)
This will refine error message using oops

Signed-off-by: SaeHie Park <saehie.park@samsung.com>
compiler/moco/pass/CMakeLists.txt
compiler/moco/pass/src/Passes/ResolveConstantShape.cpp

index fb6252c..14a2dfd 100644 (file)
@@ -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)
index 83fb823..2a1323f 100644 (file)
@@ -24,6 +24,8 @@
 
 #include <loco.h>
 
+#include <oops/UserExn.h>
+
 #include <cassert>
 
 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<loco::DataType::S32>(axis) = dim;
     }
   }
   else
   {
-    throw std::runtime_error("ResolveConstantShape: Not supported output data type");
+    throw oops::UserExn("Unsupported data type", shape_node->name());
   }
 
   // replace