From: 박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 Date: Mon, 5 Aug 2019 09:40:03 +0000 (+0900) Subject: [moco-tf] Fix pad for Conv2D in fix shape (#6221) X-Git-Tag: submit/tizen/20190809.050447~163 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=40a954284a37ef7a574dc09165614da99bdb7861;p=platform%2Fcore%2Fml%2Fnnfw.git [moco-tf] Fix pad for Conv2D in fix shape (#6221) This will merge fix pad for Conv2D node in fix shape transform Signed-off-by: SaeHie Park --- diff --git a/compiler/moco-tf/src/Transforms/FixShapeTransform.cpp b/compiler/moco-tf/src/Transforms/FixShapeTransform.cpp index 149ef06..e23360a 100644 --- a/compiler/moco-tf/src/Transforms/FixShapeTransform.cpp +++ b/compiler/moco-tf/src/Transforms/FixShapeTransform.cpp @@ -285,8 +285,24 @@ bool fix_shape(loco::Conv2D *node) shape_data->feature_shape(ofm_feature_shape); node->annot(std::move(shape_data)); + // calculate padding height, width + int32_t i_height = (output_height - 1) * stride_height + effective_ker_height - input_height; + int32_t i_width = (output_width - 1) * stride_width + effective_ker_width - input_width; + uint32_t pad_height = i_height >= 0 ? i_height : 0U; + uint32_t pad_width = i_width >= 0 ? i_width : 0U; + + // set padding values + node->pad()->top(pad_height / 2); + node->pad()->bottom(pad_height - node->pad()->top()); + node->pad()->left(pad_width / 2); + node->pad()->right(pad_width - node->pad()->left()); + + // clear annotation PaddingData + node->annot(nullptr); + INFO(l) << "Fix Conv2D shape = ifm" << ifm_feature_shape << " ker" << ker_filter_shape << " --> ofm" << ofm_feature_shape; + INFO(l) << " pad = " << *node->pad(); return true; }