as_tensor_shape(*shape_data.get(), ofm_feature_shape, node->data_layout());
node->annot(std::move(shape_data));
- // PadData should be null
- assert(node->annot<PadData>() == nullptr);
-
- // calculate padding height, width
- int32_t i_height = (output_height - 1) * stride_height + effective_window_height - input_height;
- int32_t i_width = (output_width - 1) * stride_width + effective_window_width - input_width;
- uint32_t pad_height = i_height >= 0 ? i_height : 0U;
- uint32_t pad_width = i_width >= 0 ? i_width : 0U;
-
- // annotation of pad data
- auto pad_data = stdex::make_unique<PadData>();
-
- 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());
-
- node->annot(std::move(pad_data));
+ FixPadContext ctx = {
+ input_height, input_width, output_height, output_width,
+ stride_height, stride_width, effective_window_height, effective_window_width};
- assert(node->annot<PadData>() != nullptr);
+ calc_annot_paddata(node, ctx);
INFO(l) << "Fix TFAvgPool shape = ifm" << value_feature_shape << " --> ofm" << ofm_feature_shape;
INFO(l) << " pad = " << *node->annot<PadData>();