[moco-tf] Use TFShapeInferenceHelper from moco (#8545)
author박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Tue, 29 Oct 2019 00:04:32 +0000 (09:04 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Tue, 29 Oct 2019 00:04:32 +0000 (09:04 +0900)
This will update to use TFShapeInferenceHelper from moco

Signed-off-by: SaeHie Park <saehie.park@samsung.com>
compiler/moco-tf/CMakeLists.txt
compiler/moco-tf/src/Canonicalization/AvgPoolCanonicalizer.cpp
compiler/moco-tf/src/Canonicalization/Conv2DCanonicalizer.cpp
compiler/moco-tf/src/Canonicalization/DepthwiseConv2dNativeCanonicalizer.cpp
compiler/moco-tf/src/Canonicalization/MaxPoolCanonicalizer.cpp

index 812814d..224c12c 100644 (file)
@@ -15,6 +15,7 @@ target_link_libraries(moco_tf_frontend PUBLIC moco_import)
 target_link_libraries(moco_tf_frontend PUBLIC moco_pass)
 target_link_libraries(moco_tf_frontend PUBLIC mio_tf)
 target_link_libraries(moco_tf_frontend PRIVATE moco_service)
+target_link_libraries(moco_tf_frontend PRIVATE moco_support)
 target_link_libraries(moco_tf_frontend PRIVATE bino)
 target_link_libraries(moco_tf_frontend PRIVATE fipe)
 target_link_libraries(moco_tf_frontend PRIVATE locop)
index 924121c..e07a4f6 100644 (file)
@@ -15,9 +15,9 @@
  */
 
 #include "AvgPoolCanonicalizer.h"
-#include "TFShapeInferenceHelper.h"
 
 #include <moco/IR/TFDialect.h>
+#include <moco/Support/TFShapeInferenceHelper.h>
 
 #include "CodecHelper.h"
 
@@ -61,20 +61,20 @@ bool canonicalize_avgpool2d(loco::Graph *graph, moco::TFAvgPool *node)
 
   avgPool2d_node->convention(loco::AvgPool2D::Convention::Valid);
 
-  auto value_shape = moco::tf::node_shape(node->value());
+  auto value_shape = moco::node_shape(node->value());
   assert(value_shape.domain() != loco::Domain::Unknown);
 
-  auto node_stride = moco::tf::stride_of(node->strides(), node->data_layout());
-  auto node_window = moco::tf::window_of(node->ksize(), node->data_layout());
+  auto node_stride = moco::stride_of(node->strides(), node->data_layout());
+  auto node_window = moco::window_of(node->ksize(), node->data_layout());
 
-  moco::tf::Padding2DInference infer_padding2d;
+  moco::Padding2DInference infer_padding2d;
 
   infer_padding2d.padding(node->padding());
   infer_padding2d.stride(node_stride);
   infer_padding2d.window(node_window);
 
-  auto input_feature_shape = moco::tf::as_feature_shape(value_shape, node->data_layout());
-  auto input_plane_shape = moco::tf::make_plane_shape(input_feature_shape);
+  auto input_feature_shape = moco::as_feature_shape(value_shape, node->data_layout());
+  auto input_plane_shape = moco::make_plane_shape(input_feature_shape);
 
   *avgPool2d_node->pad() = infer_padding2d(input_plane_shape);
   *avgPool2d_node->stride() = node_stride;
index ea8dde4..a955793 100644 (file)
@@ -15,9 +15,9 @@
  */
 
 #include "Conv2DCanonicalizer.h"
-#include "TFShapeInferenceHelper.h"
 
 #include <moco/IR/TFDialect.h>
+#include <moco/Support/TFShapeInferenceHelper.h>
 
 #include "CodecHelper.h"
 
@@ -78,23 +78,23 @@ bool canonicalize_conv2d(loco::Graph *graph, moco::TFConv2D *node)
   set_filter_enc(filter_enc);
   set_feature_dec(feature_dec, data_layout);
 
-  auto input_shape = moco::tf::node_shape(node->input());
+  auto input_shape = moco::node_shape(node->input());
   assert(input_shape.domain() != loco::Domain::Unknown);
 
-  auto ker_shape = moco::tf::node_shape(node->filter());
+  auto ker_shape = moco::node_shape(node->filter());
   auto ker_tensor_shape = ker_shape.as<loco::TensorShape>(); // in HWIO
 
-  auto node_stride = moco::tf::stride_of(node->strides(), node->data_layout());
-  auto node_window = moco::tf::window_of(ker_tensor_shape, "HWIO");
+  auto node_stride = moco::stride_of(node->strides(), node->data_layout());
+  auto node_window = moco::window_of(ker_tensor_shape, "HWIO");
 
-  moco::tf::Padding2DInference infer_padding2d;
+  moco::Padding2DInference infer_padding2d;
 
   infer_padding2d.padding(node->padding());
   infer_padding2d.stride(node_stride);
   infer_padding2d.window(node_window);
 
-  auto input_feature_shape = moco::tf::as_feature_shape(input_shape, node->data_layout());
-  auto input_plane_shape = moco::tf::make_plane_shape(input_feature_shape);
+  auto input_feature_shape = moco::as_feature_shape(input_shape, node->data_layout());
+  auto input_plane_shape = moco::make_plane_shape(input_feature_shape);
 
   *conv2d->pad() = infer_padding2d(input_plane_shape);
   *conv2d->stride() = node_stride;
index abf77ce..50dddf6 100644 (file)
@@ -15,9 +15,9 @@
  */
 
 #include "DepthwiseConv2dNativeCanonicalizer.h"
-#include "TFShapeInferenceHelper.h"
 
 #include <moco/IR/TFDialect.h>
+#include <moco/Support/TFShapeInferenceHelper.h>
 
 #include "CodecHelper.h"
 
@@ -84,20 +84,20 @@ bool canonicalize_depthwiseconv2dnative(loco::Graph *graph, moco::TFDepthwiseCon
   set_feature_dec(feature_dec, data_layout);
 
   // Calculate Pad and Stride from inference
-  auto input_shape = moco::tf::node_shape(node->input());
-  auto ker_shape = moco::tf::node_shape(node->filter());
+  auto input_shape = moco::node_shape(node->input());
+  auto ker_shape = moco::node_shape(node->filter());
   auto ker_tensor_shape = ker_shape.as<loco::TensorShape>();
-  auto node_stride = moco::tf::stride_of(node->strides(), node->data_layout());
-  auto node_window = moco::tf::window_of(ker_tensor_shape, "HWCM");
+  auto node_stride = moco::stride_of(node->strides(), node->data_layout());
+  auto node_window = moco::window_of(ker_tensor_shape, "HWCM");
 
-  moco::tf::Padding2DInference infer_padding2d;
+  moco::Padding2DInference infer_padding2d;
 
   infer_padding2d.padding(node->padding());
   infer_padding2d.stride(node_stride);
   infer_padding2d.window(node_window);
 
-  auto input_feature_shape = moco::tf::as_feature_shape(input_shape, node->data_layout());
-  auto input_plane_shape = moco::tf::make_plane_shape(input_feature_shape);
+  auto input_feature_shape = moco::as_feature_shape(input_shape, node->data_layout());
+  auto input_plane_shape = moco::make_plane_shape(input_feature_shape);
 
   *depthwiseconv2d->pad() = infer_padding2d(input_plane_shape);
   *depthwiseconv2d->stride() = node_stride;
index 0d8d8b4..06a6057 100644 (file)
@@ -15,9 +15,9 @@
  */
 
 #include "MaxPoolCanonicalizer.h"
-#include "TFShapeInferenceHelper.h"
 
 #include <moco/IR/TFDialect.h>
+#include <moco/Support/TFShapeInferenceHelper.h>
 
 #include "CodecHelper.h"
 
@@ -58,20 +58,20 @@ bool canonicalize_maxpool2d(loco::Graph *graph, moco::TFMaxPool *node)
   set_feature_dec(feature_dec, data_layout);
 
   // paddata to pad
-  auto input_shape = moco::tf::node_shape(node->input());
+  auto input_shape = moco::node_shape(node->input());
   assert(input_shape.domain() != loco::Domain::Unknown);
 
-  auto node_stride = moco::tf::stride_of(node->strides(), node->data_layout());
-  auto node_window = moco::tf::window_of(node->ksize(), node->data_layout());
+  auto node_stride = moco::stride_of(node->strides(), node->data_layout());
+  auto node_window = moco::window_of(node->ksize(), node->data_layout());
 
-  moco::tf::Padding2DInference infer_padding2d;
+  moco::Padding2DInference infer_padding2d;
 
   infer_padding2d.padding(node->padding());
   infer_padding2d.stride(node_stride);
   infer_padding2d.window(node_window);
 
-  auto input_feature_shape = moco::tf::as_feature_shape(input_shape, node->data_layout());
-  auto input_plane_shape = moco::tf::make_plane_shape(input_feature_shape);
+  auto input_feature_shape = moco::as_feature_shape(input_shape, node->data_layout());
+  auto input_plane_shape = moco::make_plane_shape(input_feature_shape);
 
   *maxPool2d_node->pad() = infer_padding2d(input_plane_shape);
   *maxPool2d_node->stride() = node_stride;