From 8c6ce58382ce27bc34d73f35a1abdf3b74eed2e4 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: Mon, 28 Oct 2019 16:13:40 +0900 Subject: [PATCH] [moco-tf] Update to use moco TFDialect (#8522) This will update to use moco TFDialect in src folder Signed-off-by: SaeHie Park --- compiler/moco-tf/src/TFEltwiseBinaryCanonicalzeHelper.h | 12 ++++++------ compiler/moco-tf/src/TFFormattedGraph.cpp | 15 ++++++++------- compiler/moco-tf/src/TFReduceCanonicalzeHelper.h | 8 ++++---- compiler/moco-tf/src/TFShapeInferenceHelper.h | 4 +++- compiler/moco-tf/src/TestHelper.h | 10 +++++----- compiler/moco-tf/src/TestHelper.test.cpp | 12 ++++++------ 6 files changed, 32 insertions(+), 29 deletions(-) diff --git a/compiler/moco-tf/src/TFEltwiseBinaryCanonicalzeHelper.h b/compiler/moco-tf/src/TFEltwiseBinaryCanonicalzeHelper.h index e4acfd5..54c03e9 100644 --- a/compiler/moco-tf/src/TFEltwiseBinaryCanonicalzeHelper.h +++ b/compiler/moco-tf/src/TFEltwiseBinaryCanonicalzeHelper.h @@ -1,8 +1,8 @@ #ifndef __TF_ELTWISE_BINARY_CANONICALIZE_HELPER_H__ #define __TF_ELTWISE_BINARY_CANONICALIZE_HELPER_H__ -#include "Dialect/TFDialect.h" -#include "Dialect/TFNodes.h" +#include +#include #include "CanonicalEltwiseInputConnector.h" #include "BroadcastHelper.h" @@ -18,22 +18,22 @@ namespace template struct EltwiseBinaryCanonicalizationRule; -template <> struct EltwiseBinaryCanonicalizationRule +template <> struct EltwiseBinaryCanonicalizationRule { using CanonicalNode = loco::EltwiseAdd; }; -template <> struct EltwiseBinaryCanonicalizationRule +template <> struct EltwiseBinaryCanonicalizationRule { using CanonicalNode = loco::EltwiseSub; }; -template <> struct EltwiseBinaryCanonicalizationRule +template <> struct EltwiseBinaryCanonicalizationRule { using CanonicalNode = loco::EltwiseMul; }; -template <> struct EltwiseBinaryCanonicalizationRule +template <> struct EltwiseBinaryCanonicalizationRule { using CanonicalNode = loco::EltwiseDiv; }; diff --git a/compiler/moco-tf/src/TFFormattedGraph.cpp b/compiler/moco-tf/src/TFFormattedGraph.cpp index 93414c0..9109715 100644 --- a/compiler/moco-tf/src/TFFormattedGraph.cpp +++ b/compiler/moco-tf/src/TFFormattedGraph.cpp @@ -16,8 +16,8 @@ #include "TFFormattedGraph.h" -#include "Dialect/TFDialect.h" -#include "Dialect/TFNodes.h" +#include +#include #include "LogHelper.h" @@ -33,12 +33,12 @@ std::string opname(uint32_t opnum) { static std::string prefix{"tf."}; - switch (static_cast(opnum)) + switch (static_cast(opnum)) { #define TENSORFLOW_NODE(OPCODE, CLASS) \ - case moco::tf::TFOpcode::OPCODE: \ + case moco::TFOpcode::OPCODE: \ return prefix + #OPCODE; -#include "Dialect/TFNodes.lst" +#include #undef TENSORFLOW_NODE default: break; @@ -47,6 +47,7 @@ std::string opname(uint32_t opnum) return prefix + "Invalid"; } +using namespace moco; using namespace moco::tf; /// TFNodeSummaryBuilder with default implementation @@ -69,7 +70,7 @@ protected: s.state(locop::NodeSummary::State::PartiallyKnown); \ return true; \ } -#include "Dialect/TFNodes.lst" +#include #undef TENSORFLOW_NODE protected: @@ -124,7 +125,7 @@ bool TFNodeSummaryBuilderBase::build(const loco::Node *node, locop::NodeSummary s.opname(opname(node->opnum())); \ return summary(dynamic_cast(node), s); \ } -#include "Dialect/TFNodes.lst" +#include #undef TENSORFLOW_NODE return false; diff --git a/compiler/moco-tf/src/TFReduceCanonicalzeHelper.h b/compiler/moco-tf/src/TFReduceCanonicalzeHelper.h index 88d285c..abd24ce 100644 --- a/compiler/moco-tf/src/TFReduceCanonicalzeHelper.h +++ b/compiler/moco-tf/src/TFReduceCanonicalzeHelper.h @@ -17,8 +17,8 @@ #ifndef __TF_REDUCE_CANONICALIZE_HELPER_H__ #define __TF_REDUCE_CANONICALIZE_HELPER_H__ -#include "Dialect/TFDialect.h" -#include "Dialect/TFNodes.h" +#include +#include #include @@ -29,7 +29,7 @@ namespace template loco::ReduceFunc reduceFunc(void); -template <> loco::ReduceFunc reduceFunc(void) { return loco::ReduceFunc::Mean; } +template <> loco::ReduceFunc reduceFunc(void) { return loco::ReduceFunc::Mean; } template bool canonicalize_reduce_node(TFNode *node) { @@ -68,7 +68,7 @@ template bool canonicalize_reduce_node(TFNode *node) // Canonicalization into TensorReduce is valid when reduction indices is constant // TODO Support general TensorReduce case std::vector axes_values; - if (auto const_axes = dynamic_cast(axes_node)) + if (auto const_axes = dynamic_cast(axes_node)) { // TODO Support S64 type assert(const_axes->dtype() == loco::DataType::S32); diff --git a/compiler/moco-tf/src/TFShapeInferenceHelper.h b/compiler/moco-tf/src/TFShapeInferenceHelper.h index 258ceb6..29cbed0 100644 --- a/compiler/moco-tf/src/TFShapeInferenceHelper.h +++ b/compiler/moco-tf/src/TFShapeInferenceHelper.h @@ -17,8 +17,10 @@ #ifndef __MOCO_TF_SHAPE_INFERENCE_HELPER_H__ #define __MOCO_TF_SHAPE_INFERENCE_HELPER_H__ -#include "Dialect/TFNodeDecl.h" // for TFDataLayout +#include +#include +#include #include #include #include diff --git a/compiler/moco-tf/src/TestHelper.h b/compiler/moco-tf/src/TestHelper.h index 0125a5d..d99a53a 100644 --- a/compiler/moco-tf/src/TestHelper.h +++ b/compiler/moco-tf/src/TestHelper.h @@ -77,7 +77,7 @@ void setup_output_node(loco::Graph *graph, loco::Node *last_node); #include "GraphBuilder.h" -#include "Dialect/TFNode.h" +#include #include @@ -96,15 +96,15 @@ public: public: void inputs(const std::vector &names); void output(const char *name); - moco::tf::TFNode *output(void); + moco::TFNode *output(void); - void run(tensorflow::NodeDef &node_def, moco::tf::GraphBuilder &graph_builder); + void run(tensorflow::NodeDef &node_def, moco::GraphBuilder &graph_builder); private: - std::unique_ptr _tensor_names; + std::unique_ptr _tensor_names; std::unique_ptr _graph; - std::vector _inputs; + std::vector _inputs; const char *_output{nullptr}; }; diff --git a/compiler/moco-tf/src/TestHelper.test.cpp b/compiler/moco-tf/src/TestHelper.test.cpp index 23acdde..13c2671 100644 --- a/compiler/moco-tf/src/TestHelper.test.cpp +++ b/compiler/moco-tf/src/TestHelper.test.cpp @@ -46,7 +46,7 @@ void setup_output_node(loco::Graph *graph, loco::Node *last_node) } // namespace tf } // namespace moco -#include "IR/TFConst.h" +#include #include @@ -69,7 +69,7 @@ void TFNodeBuildTester::inputs(const std::vector &names) { for (auto name : names) { - auto input = _graph->nodes()->create(); + auto input = _graph->nodes()->create(); moco::tf::TensorName name_01(name, 0); _tensor_names->enroll(name_01, input); @@ -79,20 +79,20 @@ void TFNodeBuildTester::inputs(const std::vector &names) void TFNodeBuildTester::output(const char *name) { _output = name; } -moco::tf::TFNode *TFNodeBuildTester::output(void) +moco::TFNode *TFNodeBuildTester::output(void) { assert(_output != nullptr); moco::tf::TensorName tname(_output, 0); - return static_cast(_tensor_names->node(tname)); + return static_cast(_tensor_names->node(tname)); } void TFNodeBuildTester::run(tensorflow::NodeDef &nodedef, moco::tf::GraphBuilder &graphbuilder) { assert(_output != nullptr); - auto node_defs = stdex::make_unique(); - auto updates = stdex::make_unique(); + auto node_defs = stdex::make_unique(); + auto updates = stdex::make_unique(); moco::tf::GraphBuilderContext gb_context(_graph.get(), node_defs.get(), _tensor_names.get(), updates.get()); -- 2.7.4