Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reenable TestPoolingNNDeviceTypeXLA #6453

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions test/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ function run_torch_op_tests {
run_test "$CDIR/../../test/test_indexing.py" "$@" -v NumpyTestsXLA
run_dynamic "$CDIR/../../test/test_nn.py" "$@" -v TestNNDeviceTypeXLA
run_dynamic "$CDIR/../../test/nn/test_dropout.py" "$@" -v TestDropoutNNDeviceTypeXLA
# TODO: Disable and foward fix, regression due to https://github.com/pytorch/xla/pull/6409
#run_dynamic "$CDIR/../../test/nn/test_pooling.py" "$@" -v TestPoolingNNDeviceTypeXLA
run_dynamic "$CDIR/../../test/nn/test_pooling.py" "$@" -v TestPoolingNNDeviceTypeXLA
run_dynamic "$CDIR/../../test/nn/test_embedding.py" "$@" -v TestEmbeddingNNDeviceTypeXLA
run_dynamic "$CDIR/../../test/nn/test_convolution.py" "$@" -v TestConvolutionNNDeviceTypeXLA
run_dynamic "$CDIR/../../test/nn/test_multihead_attention.py" "$@" -v TestMultiheadAttentionNNDeviceTypeXLA
Expand Down
18 changes: 17 additions & 1 deletion torch_xla/csrc/pooling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,23 @@ std::vector<std::pair<int64_t, int64_t>> CeilModePadding(
(input_size + 2 * left_padding - kernel_size[i]) % stride[i];
int64_t right_padding = left_padding;
if (ceil_mode && output_size_rem != 0) {
right_padding += stride[i];
int64_t extra_padding = stride[i] - output_size_rem;
int64_t new_output_size =
(input_size + left_padding + right_padding + extra_padding -
kernel_size[i] + stride[i] - 1) /
stride[i] +
1;
Comment on lines +148 to +152
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol this computation is really puzzling. reminds me other leetcode questions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what was there before: https://github.com/pytorch/xla/pull/6409/files#diff-b7dcec47bb003c09d0f32235e139ca6f1bb411e30a5194a68d9745cb25032371L143

I thought those are too complex and useless so i removed them... turns out it's useful something

// Ensure that the last pooling starts inside the image.
int64_t size_to_compare = input_size + left_padding;
if (count_include_pad) {
// here left padding is reset to 0;
// but input size already includes both left_padding and
// right padding so we need to substract padding[i]
size_to_compare = input_size - padding[i];
}
if ((new_output_size - 1) * stride[i] < size_to_compare) {
right_padding += extra_padding;
}
}
ceil_mode_padding.emplace_back(left_padding, right_padding);
}
Expand Down
Loading