From: 윤현식/On-Device Lab(SR)/Principal Engineer/삼성전자 Date: Thu, 22 Aug 2019 07:21:26 +0000 (+0900) Subject: [moco-tf] suporting custom op when inferencing shape and type (#6818) X-Git-Tag: accepted/tizen/unified/20190903.052428~204 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af51d863c86adadaac1008a51bc0d9fb5c4f5e23;p=platform%2Fcore%2Fml%2Fnnfw.git [moco-tf] suporting custom op when inferencing shape and type (#6818) Added shape and type support for custom op. Signed-off-by: Hyun Sik Yoon --- diff --git a/compiler/moco-tf/src/Transforms/ShapeInferencePass.cpp b/compiler/moco-tf/src/Transforms/ShapeInferencePass.cpp index d82cdf1..7b075e7 100644 --- a/compiler/moco-tf/src/Transforms/ShapeInferencePass.cpp +++ b/compiler/moco-tf/src/Transforms/ShapeInferencePass.cpp @@ -28,6 +28,9 @@ #include #include +#include +#include + namespace moco { namespace tf @@ -37,11 +40,13 @@ bool ShapeInferencePass::run(loco::Graph *graph) { loco::CanonicalShapeInferenceRule canonical_rule; TFShapeInferenceRule tf_rule; + locoex::COpShapeInferenceRule cop_rule; // rule for custop op loco::MultiDialectShapeInferenceRule rules; - rules.bind(loco::CanonicalDialect::get(), &canonical_rule).bind(TFDialect::get(), &tf_rule); - // TODO: add CustomOp shape inference + rules.bind(loco::CanonicalDialect::get(), &canonical_rule) + .bind(TFDialect::get(), &tf_rule) + .bind(locoex::COpDialect::get(), &cop_rule); loco::apply(&rules).to(graph); diff --git a/compiler/moco-tf/src/Transforms/TypeInferencePass.cpp b/compiler/moco-tf/src/Transforms/TypeInferencePass.cpp index 331c055..efdacc5 100644 --- a/compiler/moco-tf/src/Transforms/TypeInferencePass.cpp +++ b/compiler/moco-tf/src/Transforms/TypeInferencePass.cpp @@ -24,6 +24,9 @@ #include #include +#include +#include + namespace moco { namespace tf @@ -32,11 +35,14 @@ namespace tf bool TypeInferencePass::run(loco::Graph *graph) { loco::CanonicalTypeInferenceRule canonical_rule; - TFTypeInferenceRule tf_rule; // rule for TF dialect + TFTypeInferenceRule tf_rule; // rule for TF dialect + locoex::COpTypeInferenceRule cop_rule; // rule for custop op loco::MultiDialectTypeInferenceRule rules; - rules.bind(loco::CanonicalDialect::get(), &canonical_rule).bind(TFDialect::get(), &tf_rule); + rules.bind(loco::CanonicalDialect::get(), &canonical_rule) + .bind(TFDialect::get(), &tf_rule) + .bind(locoex::COpDialect::get(), &cop_rule); loco::apply(&rules).to(graph);