From: 윤현식/On-Device Lab(SR)/Principal Engineer/삼성전자 Date: Thu, 5 Sep 2019 09:35:41 +0000 (+0900) Subject: [exo-tflite] introducing TypeInferencePass (#7225) X-Git-Tag: accepted/tizen/unified/20190911.111615~88 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=71b7143bf15ea8b0963a9a6348811a3163f0868b;p=platform%2Fcore%2Fml%2Fnnfw.git [exo-tflite] introducing TypeInferencePass (#7225) TypeInferencePass annotates dtype of nodes (canonical/TFL/COp nodes). Signed-off-by: Hyun Sik Yoon --- diff --git a/compiler/exo-tflite/src/Conversion/TypeInferencePass.cpp b/compiler/exo-tflite/src/Conversion/TypeInferencePass.cpp new file mode 100644 index 0000000..0996828 --- /dev/null +++ b/compiler/exo-tflite/src/Conversion/TypeInferencePass.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "TypeInferencePass.h" + +#include "Dialect/IR/TFLDialect.h" +#include "Dialect/Service/TFLTypeInferenceRule.h" + +#include +#include +#include + +#include +#include + +namespace exo +{ + +bool TypeInferencePass::run(loco::Graph *g) +{ + loco::CanonicalTypeInferenceRule canonical_rule; + locoex::TFLTypeInferenceRule tfl_rule; + locoex::COpTypeInferenceRule cop_rule; + + loco::MultiDialectTypeInferenceRule rules; + + rules.bind(loco::CanonicalDialect::get(), &canonical_rule) + .bind(locoex::TFLDialect::get(), &tfl_rule) + .bind(locoex::COpDialect::get(), &cop_rule); + + return loco::apply(&rules).to(g); +} + +} // namespace exo diff --git a/compiler/exo-tflite/src/Conversion/TypeInferencePass.h b/compiler/exo-tflite/src/Conversion/TypeInferencePass.h new file mode 100644 index 0000000..ecb1ab4 --- /dev/null +++ b/compiler/exo-tflite/src/Conversion/TypeInferencePass.h @@ -0,0 +1,41 @@ + +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CONVERSION_TYPE_INFERENCE_PASS_H__ +#define __CONVERSION_TYPE_INFERENCE_PASS_H__ + +#include +#include + +namespace exo +{ + +/** + * @brief Pass to infer type of nodes + */ +class TypeInferencePass : public logo::Pass +{ +public: + virtual const char *name(void) const { return "TypeInferencePass"; } + +public: + bool run(loco::Graph *graph); +}; + +} // namespace exo + +#endif //__CONVERSION_TYPE_INFERENCE_PASS_H__