From: 박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 Date: Wed, 7 Aug 2019 09:10:30 +0000 (+0900) Subject: [moco-tf] Common method for calculation of PadData (#6338) X-Git-Tag: submit/tizen/20190809.050447~70 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2a7390a69f15e7c5ae68cfbe3026e9f7db54a3da;p=platform%2Fcore%2Fml%2Fnnfw.git [moco-tf] Common method for calculation of PadData (#6338) This will introduce common method for calculation of PadData that exist in calc_node_pad() and calc_annot_paddata() of FixShapeTransform Signed-off-by: SaeHie Park --- diff --git a/compiler/moco-tf/src/Transforms/FixShapeTransform.cpp b/compiler/moco-tf/src/Transforms/FixShapeTransform.cpp index b9261a2..95459da 100644 --- a/compiler/moco-tf/src/Transforms/FixShapeTransform.cpp +++ b/compiler/moco-tf/src/Transforms/FixShapeTransform.cpp @@ -104,6 +104,29 @@ struct FixPadContext uint32_t effective_window_width; }; +PadData calc_paddata(const FixPadContext &ctx) +{ + assert(ctx.output_height > 0); + assert(ctx.output_width > 0); + + // calculate padding height, width + int64_t i_height = (int64_t)(ctx.output_height - 1) * (int64_t)ctx.stride_height + + (int64_t)ctx.effective_window_height - (int64_t)ctx.input_height; + int64_t i_width = (int64_t)(ctx.output_width - 1) * (int64_t)ctx.stride_width + + (int64_t)ctx.effective_window_width - (int64_t)ctx.input_width; + uint32_t pad_height = i_height >= 0 ? (uint32_t)i_height : 0U; + uint32_t pad_width = i_width >= 0 ? (uint32_t)i_width : 0U; + + PadData pad_data; + + pad_data.pad()->top(pad_height / 2); + pad_data.pad()->bottom(pad_height - pad_data.pad()->top()); + pad_data.pad()->left(pad_width / 2); + pad_data.pad()->right(pad_width - pad_data.pad()->left()); + + return pad_data; +} + template void calc_node_pad(T *node, const FixPadContext &ctx) { assert(node != nullptr);