From: 박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 Date: Wed, 4 Sep 2019 22:30:46 +0000 (+0900) Subject: [loco] Revise shape inference condition (#7161) X-Git-Tag: accepted/tizen/unified/20190911.111615~130 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1e80cdf26f8381e970fe52f6d4c8ddf7214848cd;p=platform%2Fcore%2Fml%2Fnnfw.git [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 --- 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; + } } } }