From 945e58bc096f556d4efc81d985a7296cc7213f86 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, 1 Jul 2019 14:23:37 +0900 Subject: [PATCH] [moco/tf] Import to Importer (#4019) * [moco/tf] Import to Importer This will rename Import class to Importer - abd method load() to `import` Signed-off-by: SaeHie Park * fix header --- contrib/moco-tf/src/Frontend.cpp | 6 +++--- contrib/moco-tf/src/{Import.cpp => Importer.cpp} | 8 ++++---- contrib/moco-tf/src/{Import.h => Importer.h} | 6 +++--- .../src/{Import.test.cpp => Importer.test.cpp} | 8 ++++---- contrib/moco-tf/src/Op/AvgPool2D.test.cpp | 6 +++--- contrib/moco-tf/src/Op/BiasAdd.test.cpp | 10 +++++----- contrib/moco-tf/src/Op/Concat.test.cpp | 14 +++++++------- contrib/moco-tf/src/Op/Const.test.cpp | 22 +++++++++++----------- contrib/moco-tf/src/Op/Conv2D.test.cpp | 10 +++++----- contrib/moco-tf/src/Op/MaxPool2D.test.cpp | 6 +++--- contrib/moco-tf/src/Op/Placeholder.test.cpp | 18 +++++++++--------- contrib/moco-tf/src/Op/Relu.test.cpp | 6 +++--- 12 files changed, 60 insertions(+), 60 deletions(-) rename contrib/moco-tf/src/{Import.cpp => Importer.cpp} (97%) rename contrib/moco-tf/src/{Import.h => Importer.h} (88%) rename contrib/moco-tf/src/{Import.test.cpp => Importer.test.cpp} (94%) diff --git a/contrib/moco-tf/src/Frontend.cpp b/contrib/moco-tf/src/Frontend.cpp index 66b1b20..022dba3 100644 --- a/contrib/moco-tf/src/Frontend.cpp +++ b/contrib/moco-tf/src/Frontend.cpp @@ -16,7 +16,7 @@ #include -#include "Import.h" +#include "Importer.h" #include "Optimizer.h" #include "Transforms.h" @@ -150,9 +150,9 @@ void cleanup(loco::Graph *graph) std::unique_ptr Frontend::import(const ModelSignature &signature, tensorflow::GraphDef &tf_graph_def) const { - Import import; + Importer importer; - auto graph = import.load(signature, tf_graph_def); + auto graph = importer.import(signature, tf_graph_def); // Optimize imported loco::Graph Optimizer optimizer; diff --git a/contrib/moco-tf/src/Import.cpp b/contrib/moco-tf/src/Importer.cpp similarity index 97% rename from contrib/moco-tf/src/Import.cpp rename to contrib/moco-tf/src/Importer.cpp index b0b4c2b..8c2eb89 100644 --- a/contrib/moco-tf/src/Import.cpp +++ b/contrib/moco-tf/src/Importer.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "Import.h" +#include "Importer.h" #include "GraphBuilder.h" #include "GraphBuilderContext.h" @@ -250,13 +250,13 @@ namespace moco namespace tf { -Import::Import() +Importer::Importer() { // DO NOTHING } -std::unique_ptr Import::load(const ModelSignature &signature, - tensorflow::GraphDef &tf_graph_def) const +std::unique_ptr Importer::import(const ModelSignature &signature, + tensorflow::GraphDef &tf_graph_def) const { auto graph = loco::make_graph(); diff --git a/contrib/moco-tf/src/Import.h b/contrib/moco-tf/src/Importer.h similarity index 88% rename from contrib/moco-tf/src/Import.h rename to contrib/moco-tf/src/Importer.h index 115f44f..6875e50 100644 --- a/contrib/moco-tf/src/Import.h +++ b/contrib/moco-tf/src/Importer.h @@ -31,13 +31,13 @@ namespace moco namespace tf { -class Import final +class Importer final { public: - Import(); + Importer(); public: - std::unique_ptr load(const ModelSignature &, tensorflow::GraphDef &) const; + std::unique_ptr import(const ModelSignature &, tensorflow::GraphDef &) const; }; } // namespace tf diff --git a/contrib/moco-tf/src/Import.test.cpp b/contrib/moco-tf/src/Importer.test.cpp similarity index 94% rename from contrib/moco-tf/src/Import.test.cpp rename to contrib/moco-tf/src/Importer.test.cpp index 885e79e..5c5235b 100644 --- a/contrib/moco-tf/src/Import.test.cpp +++ b/contrib/moco-tf/src/Importer.test.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "Import.h" +#include "Importer.h" #include "TestHelper.h" @@ -24,7 +24,7 @@ using namespace moco::tf::test; -TEST(TensorFlowImport, Dummy) { moco::tf::Import import; } +TEST(TensorFlowImport, Dummy) { moco::tf::Importer import; } namespace { @@ -78,7 +78,7 @@ node { TEST(TensorFlowImport, load_model_withio) { - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_input(moco::tf::TensorName("Placeholder", 0)); @@ -86,7 +86,7 @@ TEST(TensorFlowImport, load_model_withio) tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(basic_pbtxtdata, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); loco::Graph::InputContext *inputs = graph->inputs(); ASSERT_EQ(inputs->size(), 1); diff --git a/contrib/moco-tf/src/Op/AvgPool2D.test.cpp b/contrib/moco-tf/src/Op/AvgPool2D.test.cpp index 514e671..3cdc2b9 100644 --- a/contrib/moco-tf/src/Op/AvgPool2D.test.cpp +++ b/contrib/moco-tf/src/Op/AvgPool2D.test.cpp @@ -16,7 +16,7 @@ #include "TestHelper.h" -#include "Import.h" +#include "Importer.h" #include #include @@ -117,14 +117,14 @@ node { TEST(TensorFlowImport, AvgPool2D_01) { - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_output(moco::tf::TensorName("avgpool2d", 0)); tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(avgpool2d_01_pbtxtdata, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); // test 1. // loco node : ConstGen - FeatureEncode - AvgPool2D - FeatureDecode - Push diff --git a/contrib/moco-tf/src/Op/BiasAdd.test.cpp b/contrib/moco-tf/src/Op/BiasAdd.test.cpp index 6192cac..b679950 100644 --- a/contrib/moco-tf/src/Op/BiasAdd.test.cpp +++ b/contrib/moco-tf/src/Op/BiasAdd.test.cpp @@ -16,7 +16,7 @@ #include "TestHelper.h" -#include "Import.h" +#include "Importer.h" #include @@ -95,13 +95,13 @@ node { TEST(TensorFlowImport, bias_add_01) { - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_output(moco::tf::TensorName("out", 0)); tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(bias_add_01_pbtxtdata, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); // test 1. // loco node : 1. ConstGen ------------------+-- 4. BiasAdd -- 5. Push @@ -211,13 +211,13 @@ node { TEST(TensorFlowImport, bias_add_NCHW_axis) { - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_output(moco::tf::TensorName("out", 0)); tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(bias_add_NCHW_pbtxtdata, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); // testing axis value of biasAdd loco::Graph::NodeContext *loco_nodes = graph->nodes(); diff --git a/contrib/moco-tf/src/Op/Concat.test.cpp b/contrib/moco-tf/src/Op/Concat.test.cpp index 2d06916..74d983a 100644 --- a/contrib/moco-tf/src/Op/Concat.test.cpp +++ b/contrib/moco-tf/src/Op/Concat.test.cpp @@ -16,7 +16,7 @@ #include "TestHelper.h" -#include "Import.h" +#include "Importer.h" #include @@ -146,7 +146,7 @@ node { TEST(TensorFlowImport, concat_01) { - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; moco::tf::TensorName output("Concat", 0); @@ -154,7 +154,7 @@ TEST(TensorFlowImport, concat_01) tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(concat_01_pbtxtdata, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); // check all nodes are created // - 0 input, 3 const, 1 concat, 1 output @@ -339,7 +339,7 @@ node { TEST(TensorFlowImport, concat_02) { - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; moco::tf::TensorName output("Concat", 0); @@ -347,7 +347,7 @@ TEST(TensorFlowImport, concat_02) tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(concat_02_pbtxtdata, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); // check all nodes are created // - 0 input, 4 const, 2 concat, 1 output @@ -487,7 +487,7 @@ node { TEST(TensorFlowImport, concat_03) { - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_input(moco::tf::TensorName("Input01", 0)); @@ -496,7 +496,7 @@ TEST(TensorFlowImport, concat_03) tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(concat_03_pbtxtdata, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); // check all nodes are created // - 2 pull, 1 const, 1 concat, 1 output diff --git a/contrib/moco-tf/src/Op/Const.test.cpp b/contrib/moco-tf/src/Op/Const.test.cpp index 9eb35c9..1cb83c2 100644 --- a/contrib/moco-tf/src/Op/Const.test.cpp +++ b/contrib/moco-tf/src/Op/Const.test.cpp @@ -16,7 +16,7 @@ #include "TestHelper.h" -#include "Import.h" +#include "Importer.h" #include @@ -72,14 +72,14 @@ node { TEST(TensorFlowImport, const_float_01) { - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_output(moco::tf::TensorName("const/float", 0)); tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(const_float_01_pbtxtdata, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); loco::Graph::OutputContext *outputs = graph->outputs(); ASSERT_EQ(outputs->size(), 1); @@ -142,14 +142,14 @@ node { TEST(TensorFlowImport, const_float_02) { - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_output(moco::tf::TensorName("const/float", 0)); tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(const_float_02_pbtxtdata, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); loco::Graph::OutputContext *outputs = graph->outputs(); ASSERT_EQ(outputs->size(), 1); @@ -213,14 +213,14 @@ node { TEST(TensorFlowImport, const_float_03) { - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_output(moco::tf::TensorName("const/float", 0)); tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(const_float_03_pbtxtdata, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); loco::Graph::OutputContext *outputs = graph->outputs(); ASSERT_EQ(outputs->size(), 1); @@ -284,14 +284,14 @@ node { TEST(TensorFlowImport, const_float_04) { - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_output(moco::tf::TensorName("const/float", 0)); tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(const_float_04_pbtxtdata, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); loco::Graph::OutputContext *outputs = graph->outputs(); ASSERT_EQ(outputs->size(), 1); @@ -355,14 +355,14 @@ node { TEST(TensorFlowImport, const_int32_04) { - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_output(moco::tf::TensorName("const/int", 0)); tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(const_int32_04_pbtxtdata, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); loco::Graph::OutputContext *outputs = graph->outputs(); ASSERT_EQ(outputs->size(), 1); diff --git a/contrib/moco-tf/src/Op/Conv2D.test.cpp b/contrib/moco-tf/src/Op/Conv2D.test.cpp index 93b28bd..70df9cd 100644 --- a/contrib/moco-tf/src/Op/Conv2D.test.cpp +++ b/contrib/moco-tf/src/Op/Conv2D.test.cpp @@ -16,7 +16,7 @@ #include "TestHelper.h" -#include "Import.h" +#include "Importer.h" #include #include @@ -90,14 +90,14 @@ node { TEST(TensorFlowImport, Conv2D_01) { - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_output(moco::tf::TensorName("conv2d", 0)); tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(conv2d_01_pbtxtdata, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); // test 1. // loco node : ConstGen - FeatureEncode -- Conv2D - FeatureDecode - Push @@ -295,7 +295,7 @@ node { TEST(TensorFlowImport, Conv2D_inception_indexed_tensor_name) { - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_input(moco::tf::TensorName("input", 0)); @@ -303,7 +303,7 @@ TEST(TensorFlowImport, Conv2D_inception_indexed_tensor_name) tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(conv2d_inception_pbtxtdata, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); // test 1. // loco node : Pull - FeatureEncode -- Conv2D - FeatureDecode - Push diff --git a/contrib/moco-tf/src/Op/MaxPool2D.test.cpp b/contrib/moco-tf/src/Op/MaxPool2D.test.cpp index 733d936..b82c9fe 100644 --- a/contrib/moco-tf/src/Op/MaxPool2D.test.cpp +++ b/contrib/moco-tf/src/Op/MaxPool2D.test.cpp @@ -16,7 +16,7 @@ #include "TestHelper.h" -#include "Import.h" +#include "Importer.h" #include #include @@ -117,14 +117,14 @@ node { TEST(TensorFlowImport, MaxPool2D_01) { - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_output(moco::tf::TensorName("maxpool2d", 0)); tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(maxpool2d_01_pbtxtdata, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); // test 1. // loco node : ConstGen - FeatureEncode - MaxPull2D - FeatureDecode - Push diff --git a/contrib/moco-tf/src/Op/Placeholder.test.cpp b/contrib/moco-tf/src/Op/Placeholder.test.cpp index 0607b81..d9fd3e8 100644 --- a/contrib/moco-tf/src/Op/Placeholder.test.cpp +++ b/contrib/moco-tf/src/Op/Placeholder.test.cpp @@ -17,7 +17,7 @@ #include "TestHelper.h" #include "CompilerArgs.h" -#include "Import.h" +#include "Importer.h" #include #include @@ -68,13 +68,13 @@ node { TEST(TensorFlowImport, placeholder_knwon_batch) { // load graph - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_output(moco::tf::TensorName("output", 0)); tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(known_batch_pbtxt, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); // get loco::Pull loco::Graph::NodeContext *loco_nodes = graph->nodes(); @@ -94,13 +94,13 @@ TEST(TensorFlowImport, placeholder_wrong_user_input_0) moco::tf::CompilerArgs::get()->addInput("placeholder", shape); // load graph - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_output(moco::tf::TensorName("output", 0)); tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(known_batch_pbtxt, graph_def)); - ASSERT_ANY_THROW(import.load(signature, graph_def)); + ASSERT_ANY_THROW(importer.import(signature, graph_def)); moco::tf::CompilerArgs::get()->clear(); } @@ -149,13 +149,13 @@ TEST(TensorFlowImport, placeholder_unknwon_batch) moco::tf::CompilerArgs::get()->addInput("placeholder", shape); // load graph - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_output(moco::tf::TensorName("output", 0)); tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(unknown_batch_pbtxt, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); // get loco::Pull loco::Graph::NodeContext *loco_nodes = graph->nodes(); @@ -179,13 +179,13 @@ TEST(TensorFlowImport, placeholder_wrong_user_input_1) moco::tf::CompilerArgs::get()->addInput("placeholder", shape); // load graph - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_output(moco::tf::TensorName("output", 0)); tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(unknown_batch_pbtxt, graph_def)); - ASSERT_ANY_THROW(import.load(signature, graph_def)); + ASSERT_ANY_THROW(importer.import(signature, graph_def)); moco::tf::CompilerArgs::get()->clear(); } diff --git a/contrib/moco-tf/src/Op/Relu.test.cpp b/contrib/moco-tf/src/Op/Relu.test.cpp index a739e30..0c4d60e 100644 --- a/contrib/moco-tf/src/Op/Relu.test.cpp +++ b/contrib/moco-tf/src/Op/Relu.test.cpp @@ -16,7 +16,7 @@ #include "TestHelper.h" -#include "Import.h" +#include "Importer.h" #include @@ -72,7 +72,7 @@ node { TEST(TensorFlowImport, relu_01) { - moco::tf::Import import; + moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_input(moco::tf::TensorName("Placeholder", 0)); @@ -80,7 +80,7 @@ TEST(TensorFlowImport, relu_01) tensorflow::GraphDef graph_def; EXPECT_TRUE(parse_graphdef(relu_01_pbtxtdata, graph_def)); - std::unique_ptr graph = import.load(signature, graph_def); + std::unique_ptr graph = importer.import(signature, graph_def); // Check input shape is correct loco::Graph::InputContext *inputs = graph->inputs(); -- 2.7.4