From c316152f8b5ec874a8fb151b64a4d304af458e04 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9C=A4=ED=98=84=EC=8B=9D/On-Device=20Lab=28SR=29/Princip?= =?utf8?q?al=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Fri, 25 Oct 2019 16:40:06 +0900 Subject: [PATCH] [exo] refactoring: rearranging if.. else.. in FuseBiasAddPass (#8479) This re-arranges `if (abnormal case) else if (normal case)` to `if (normal case) else if (abnormal case)` for better readability. Signed-off-by: Hyun Sik Yoon --- compiler/exo/src/Pass/FuseBiasAddPass.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/exo/src/Pass/FuseBiasAddPass.cpp b/compiler/exo/src/Pass/FuseBiasAddPass.cpp index ef34cdc..e50a447 100644 --- a/compiler/exo/src/Pass/FuseBiasAddPass.cpp +++ b/compiler/exo/src/Pass/FuseBiasAddPass.cpp @@ -242,8 +242,12 @@ struct Collector final : public locoex::TFLNodeMutableVisitor auto conv2d_depth = loco::shape_get(conv2d_node).as().dim(3).value(); auto const_shape = loco::shape_get(const_node).as(); - // if Const has only one value, create a new const with shape [depth_of_conv] - if (const_shape.rank() == 0 or (const_shape.rank() == 1 and const_shape.dim(0) == 1)) + if (const_shape.rank() == 1 and const_shape.dim(0) == conv2d_depth) + { + candidates.insert(node); + } + // when Const has only one value, create a new const with shape [depth_of_conv] + else if (const_shape.rank() == 0 or (const_shape.rank() == 1 and const_shape.dim(0) == 1)) { if (!(loco::dtype_get(conv2d_node) == loco::DataType::FLOAT32)) EXO_THROW("unsupported TFLConv2D data type"); @@ -259,10 +263,6 @@ struct Collector final : public locoex::TFLNodeMutableVisitor candidates.insert(node); } - else if (const_shape.rank() == 1 and const_shape.dim(0) == conv2d_depth) - { - candidates.insert(node); - } } void visit(locoex::TFLAdd *node) final { setCandidate(node, node->x(), node->y()); } -- 2.7.4