summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>2019-09-17 06:11:34 (GMT)
committerGitHub Enterprise <noreply-CODE@samsung.com>2019-09-17 06:11:34 (GMT)
commit53b524f84c156e6aaf4cba7d6504817074b93bd2 (patch)
tree928b7e015e7980fddc257f9c7866c394b1730faf
parent5ca3824b58da9aacb41b4fd9e44895714da855b1 (diff)
downloadnnfw-53b524f84c156e6aaf4cba7d6504817074b93bd2.zip
nnfw-53b524f84c156e6aaf4cba7d6504817074b93bd2.tar.gz
nnfw-53b524f84c156e6aaf4cba7d6504817074b93bd2.tar.bz2
[moco-tf] Read Knob from top-level Canonicalizer (#7495)
Several canonicalization implementations shows different behavior according to Knob configuration. This design makes it a bit difficult to test each implementation in isolation. To address this issue, this commit extracts Knob control code and put them in top-level Canonicalizer. Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
-rw-r--r--compiler/moco-tf/src/Canonicalization/AvgPoolCanonicalizer.cpp2
-rw-r--r--compiler/moco-tf/src/Canonicalization/BiasAddCanonicalizer.cpp5
-rw-r--r--compiler/moco-tf/src/Canonicalization/ConstCanonicalizer.cpp5
-rw-r--r--compiler/moco-tf/src/Canonicalization/Conv2DCanonicalizer.cpp5
-rw-r--r--compiler/moco-tf/src/Canonicalization/IdentityCanonicalizer.cpp1
-rw-r--r--compiler/moco-tf/src/Canonicalizer.cpp9
6 files changed, 6 insertions, 21 deletions
diff --git a/compiler/moco-tf/src/Canonicalization/AvgPoolCanonicalizer.cpp b/compiler/moco-tf/src/Canonicalization/AvgPoolCanonicalizer.cpp
index 4ffc74d..66a7108 100644
--- a/compiler/moco-tf/src/Canonicalization/AvgPoolCanonicalizer.cpp
+++ b/compiler/moco-tf/src/Canonicalization/AvgPoolCanonicalizer.cpp
@@ -21,8 +21,6 @@
#include "Annotations/ShapeInferenceData.h"
#include "Annotations/WindowData.h"
-#include "Knob.h"
-
#include "Dialect/TFDialect.h"
#include "Dialect/TFNodes.h"
#include "Dialect/TFNodeVisitor.h"
diff --git a/compiler/moco-tf/src/Canonicalization/BiasAddCanonicalizer.cpp b/compiler/moco-tf/src/Canonicalization/BiasAddCanonicalizer.cpp
index a42891a..37b660e 100644
--- a/compiler/moco-tf/src/Canonicalization/BiasAddCanonicalizer.cpp
+++ b/compiler/moco-tf/src/Canonicalization/BiasAddCanonicalizer.cpp
@@ -16,8 +16,6 @@
#include "BiasAddCanonicalizer.h"
-#include "Knob.h"
-
#include "Dialect/TFDialect.h"
#include "Dialect/TFNodes.h"
#include "Dialect/TFNodeVisitor.h"
@@ -33,9 +31,6 @@ using plier::tf::DataLayout;
bool canonicalize_biasadd(loco::Graph *graph, moco::tf::TFBiasAdd *node)
{
- if (!moco::tf::get<moco::tf::Knob::CanonicalizeBiasAdd>())
- return false;
-
LOGGER(l);
/**
diff --git a/compiler/moco-tf/src/Canonicalization/ConstCanonicalizer.cpp b/compiler/moco-tf/src/Canonicalization/ConstCanonicalizer.cpp
index 7bfc7c4..dea97f9 100644
--- a/compiler/moco-tf/src/Canonicalization/ConstCanonicalizer.cpp
+++ b/compiler/moco-tf/src/Canonicalization/ConstCanonicalizer.cpp
@@ -16,8 +16,6 @@
#include "ConstCanonicalizer.h"
-#include "Knob.h"
-
#include "Dialect/TFDialect.h"
#include "Dialect/TFNodes.h"
#include "Dialect/TFNodeVisitor.h"
@@ -31,9 +29,6 @@ namespace
bool canonicalize_const(loco::Graph *graph, moco::tf::TFConst *node)
{
- if (!moco::tf::get<moco::tf::Knob::CanonicalizeConst>())
- return false;
-
LOGGER(l);
/**
diff --git a/compiler/moco-tf/src/Canonicalization/Conv2DCanonicalizer.cpp b/compiler/moco-tf/src/Canonicalization/Conv2DCanonicalizer.cpp
index c497117..f34339d 100644
--- a/compiler/moco-tf/src/Canonicalization/Conv2DCanonicalizer.cpp
+++ b/compiler/moco-tf/src/Canonicalization/Conv2DCanonicalizer.cpp
@@ -19,8 +19,6 @@
#include "Annotations/PadData.h"
#include "Annotations/StrideData.h"
-#include "Knob.h"
-
#include "Dialect/TFDialect.h"
#include "Dialect/TFNodes.h"
#include "Dialect/TFNodeVisitor.h"
@@ -95,9 +93,6 @@ void set_feature_dec(loco::FeatureDecode *feature_dec, DataLayout data_layout)
bool canonicalize_conv2d(loco::Graph *graph, moco::tf::TFConv2D *node)
{
- if (!moco::tf::get<moco::tf::Knob::CanonicalizeConv2D>())
- return false;
-
LOGGER(l);
/**
diff --git a/compiler/moco-tf/src/Canonicalization/IdentityCanonicalizer.cpp b/compiler/moco-tf/src/Canonicalization/IdentityCanonicalizer.cpp
index 9183298..c4d5d80 100644
--- a/compiler/moco-tf/src/Canonicalization/IdentityCanonicalizer.cpp
+++ b/compiler/moco-tf/src/Canonicalization/IdentityCanonicalizer.cpp
@@ -17,7 +17,6 @@
#include "IdentityCanonicalizer.h"
#include "Convert.h"
-#include "Knob.h"
#include "Dialect/TFDialect.h"
#include "Dialect/TFNodes.h"
diff --git a/compiler/moco-tf/src/Canonicalizer.cpp b/compiler/moco-tf/src/Canonicalizer.cpp
index c23371f..c705d68 100644
--- a/compiler/moco-tf/src/Canonicalizer.cpp
+++ b/compiler/moco-tf/src/Canonicalizer.cpp
@@ -91,10 +91,13 @@ void Canonicalizer::canonicalize(loco::Graph *g) const
phase.emplace_back(stdex::make_unique<AddCanonicalizer>());
phase.emplace_back(stdex::make_unique<AvgPoolCanonicalizer>());
- phase.emplace_back(stdex::make_unique<BiasAddCanonicalizer>());
+ if (moco::tf::get<moco::tf::Knob::CanonicalizeBiasAdd>())
+ phase.emplace_back(stdex::make_unique<BiasAddCanonicalizer>());
phase.emplace_back(stdex::make_unique<ConcatV2Canonicalizer>());
- phase.emplace_back(stdex::make_unique<ConstCanonicalizer>());
- phase.emplace_back(stdex::make_unique<Conv2DCanonicalizer>());
+ if (moco::tf::get<moco::tf::Knob::CanonicalizeConst>())
+ phase.emplace_back(stdex::make_unique<ConstCanonicalizer>());
+ if (moco::tf::get<moco::tf::Knob::CanonicalizeConv2D>())
+ phase.emplace_back(stdex::make_unique<Conv2DCanonicalizer>());
phase.emplace_back(stdex::make_unique<DepthwiseConv2dNativeCanonicalizer>());
phase.emplace_back(stdex::make_unique<IdentityCanonicalizer>());
phase.emplace_back(stdex::make_unique<MaxPoolCanonicalizer>());