File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -79,18 +79,23 @@ void ResizeBilinearLayer<Dtype>::compute_interpolation_weights(const int out_siz
7979 {
8080 in = static_cast <float >(i) * scale;
8181 }
82- else // if (half_pixel_centers_)
83- {
84- if (half_pixel_centers_ || out_size > 1 ) {
82+ else if (pytorch_half_pixel_) {
83+ // ref: https://github.com/onnx/onnx/blob/master/docs/Operators.md#Resize
84+ // https://github.com/onnx/onnx/blob/master/onnx/backend/test/case/node/resize.py#L132
85+ if (out_size > 1 ) {
8586 in = (static_cast <float >(i) + 0 .5f ) * scale - 0 .5f ;
86- // ref: https://github.com/tensorflow/tensorflow/blob/r1.15/tensorflow/core/kernels/image_resizer_state.h#L50
87- }else {
88- // pytorch_half_pixel_ && out_size <= 1
87+ } else {
8988 in = -0 .5f ;
90- // ref: https://github.com/onnx/onnx/blob/master/docs/Operators.md#Resize
91- // https://github.com/onnx/onnx/blob/master/onnx/backend/test/case/node/resize.py#L132
9289 }
9390 }
91+ else if (half_pixel_centers_)
92+ {
93+ in = (static_cast <float >(i) + 0 .5f ) * scale - 0 .5f ;
94+ // ref: https://github.com/tensorflow/tensorflow/blob/r1.15/tensorflow/core/kernels/image_resizer_state.h#L50
95+ }
96+ else { // no coordinate_transformation_mode required
97+ in = static_cast <float >(i) * scale;
98+ }
9499 const float in_f = std::floor (in);
95100 interpolation[i].lower =
96101 std::max (static_cast <int >(in_f), static_cast <int >(0 ));
You can’t perform that action at this time.
0 commit comments