Update the padding computation for PADDING_SAME to be consistent with TensorFlow.

This commit is contained in:
Yangzihao Wang
2017-12-12 11:15:24 -08:00
parent 393b7c4959
commit 3122477c86
2 changed files with 56 additions and 0 deletions

View File

@@ -265,6 +265,10 @@ struct TensorEvaluator<const TensorImagePatchOp<Rows, Cols, ArgType>, Device>
// Calculate the padding
m_rowPaddingTop = ((m_outputRows - 1) * m_row_strides + m_patch_rows_eff - m_input_rows_eff) / 2;
m_colPaddingLeft = ((m_outputCols - 1) * m_col_strides + m_patch_cols_eff - m_input_cols_eff) / 2;
// The padding size calculation for PADDING_SAME has been updated to
// be consistent with how TensorFlow extracts its paddings.
m_rowPaddingTop = numext::maxi<Index>(0, m_rowPaddingTop);
m_colPaddingLeft = numext::maxi<Index>(0, m_colPaddingLeft);
break;
default:
eigen_assert(false && "unexpected padding");