From 1e80cdf26f8381e970fe52f6d4c8ddf7214848cd 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: Thu, 5 Sep 2019 07:30:46 +0900 Subject: [PATCH] [loco] Revise shape inference condition (#7161) * [loco] Revise shape inference condition This will add condition to ShapeInference to infer when target node shape is unknown and input(s) shape is ready Signed-off-by: SaeHie Park * remove print code --- compiler/loco/src/Service/ShapeInference.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/compiler/loco/src/Service/ShapeInference.cpp b/compiler/loco/src/Service/ShapeInference.cpp index 8b86d48..025376b 100644 --- a/compiler/loco/src/Service/ShapeInference.cpp +++ b/compiler/loco/src/Service/ShapeInference.cpp @@ -21,6 +21,25 @@ #include +namespace +{ + +bool inputs_shape_ready(loco::Node *node) +{ + assert(node != nullptr); + + for (uint32_t arity = 0; arity < node->arity(); ++arity) + { + if (!loco::ShapeInference::known(node->arg(arity))) + { + return false; + } + } + return true; +} + +} // namespace + // // Infrastructure // @@ -57,10 +76,13 @@ bool ShapeInferenceSession::to(Graph *g) const { loco::NodeShape shape; - if (_rule->infer(node, shape)) + if (!shape_known(node) && inputs_shape_ready(node)) { - node->annot(stdex::make_unique(shape)); - changed = true; + if (_rule->infer(node, shape)) + { + node->annot(stdex::make_unique(shape)); + changed = true; + } } } } -- 2.7.4