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

Restrict the inputs of ops.pad() #20348

Merged
merged 1 commit into from
Oct 13, 2024
Merged

Conversation

Grvzard
Copy link
Contributor

@Grvzard Grvzard commented Oct 13, 2024

If the dimensions of pad_width and input are not the same, other backends will throw a corresponding exception, but PyTorch can still work, which may result in an unrelated exception being raised.

Users may assume that the pad_width = ((0, 0), (1, 2), (0, 0)) can be shortened to pad_width = ((0, 0), (1, 2)).
However, due to torch's use of reverse order, the latter will be processed to ((1, 2),) (reversed and with higher dimensions removed).

pad_width = list(pad_width)[::-1] # torch uses reverse order

if pad_width_sum == 0: # early break when no padding in higher order
break

@codecov-commenter
Copy link

codecov-commenter commented Oct 13, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 78.88%. Comparing base (8e7843c) to head (b652ccc).

Files with missing lines Patch % Lines
keras/src/ops/numpy.py 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #20348      +/-   ##
==========================================
- Coverage   78.88%   78.88%   -0.01%     
==========================================
  Files         512      512              
  Lines       49250    49252       +2     
  Branches     7954     7955       +1     
==========================================
  Hits        38853    38853              
- Misses       8539     8540       +1     
- Partials     1858     1859       +1     
Flag Coverage Δ
keras 78.75% <0.00%> (-0.01%) ⬇️
keras-jax 62.40% <0.00%> (-0.01%) ⬇️
keras-numpy 57.42% <0.00%> (-0.01%) ⬇️
keras-tensorflow 63.64% <0.00%> (-0.01%) ⬇️
keras-torch 62.37% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Oct 13, 2024
@fchollet fchollet merged commit e0533f8 into keras-team:master Oct 13, 2024
7 checks passed
@google-ml-butler google-ml-butler bot removed ready to pull Ready to be merged into the codebase kokoro:force-run labels Oct 13, 2024
@Grvzard Grvzard deleted the grvz/upstream-1 branch October 14, 2024 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants