From 7ec5cb631f32e716a2f4764932ccc8b3c2f6f308 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Fri, 21 Sep 2018 08:51:50 +0900 Subject: [PATCH] [enco] Throw an exception on unknown operand type (#1606) The current implementation assumes that operand is either scalar or tensor and validates it through assert. This commit explicitly validates dynamic casted pointer, which allows us to detect such an abnormal case even for release build. Signed-off-by: Jonghyun Park --- contrib/enco/core/src/CppGen/Subnet.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/contrib/enco/core/src/CppGen/Subnet.cpp b/contrib/enco/core/src/CppGen/Subnet.cpp index 95213f3..121e4c0 100644 --- a/contrib/enco/core/src/CppGen/Subnet.cpp +++ b/contrib/enco/core/src/CppGen/Subnet.cpp @@ -328,12 +328,14 @@ std::unique_ptr SubnetStructBuilder::build(const ANNBinder *binder { res->ctor() << ScalarOperandDecl{mname, scalar->dtype()}; } - else + else if (auto tensor = dynamic_cast(info)) { - auto tensor = dynamic_cast(info); - assert(tensor != nullptr); res->ctor() << TensorOperandDecl{mname, tensor->dtype(), tensor->shape()}; } + else + { + throw std::runtime_error{"Unsupported"}; + } if (info->weight()) { -- 2.7.4