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

Add signbit and fix argmin and argmax #20821

Merged
merged 8 commits into from
Jan 30, 2025

Conversation

james77777778
Copy link
Contributor

Based on this issue jax-ml/jax#24280, we should patch argmin and argmax ops only when using the CPU due to the flush-to-zero (FTZ) issue.

Since we need signbit to patch these ops, adding it is straightforward.

@codecov-commenter
Copy link

codecov-commenter commented Jan 29, 2025

Codecov Report

Attention: Patch coverage is 94.59459% with 6 lines in your changes missing coverage. Please review.

Project coverage is 82.03%. Comparing base (9c8da1f) to head (f926946).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
keras/src/backend/tensorflow/numpy.py 95.45% 1 Missing and 1 partial ⚠️
keras/src/testing/test_case.py 60.00% 1 Missing and 1 partial ⚠️
keras/api/_tf_keras/keras/ops/__init__.py 0.00% 1 Missing ⚠️
keras/api/_tf_keras/keras/ops/numpy/__init__.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #20821      +/-   ##
==========================================
+ Coverage   82.01%   82.03%   +0.02%     
==========================================
  Files         559      559              
  Lines       52291    52367      +76     
  Branches     8084     8096      +12     
==========================================
+ Hits        42884    42961      +77     
+ Misses       7431     7428       -3     
- Partials     1976     1978       +2     
Flag Coverage Δ
keras 81.85% <94.59%> (+0.02%) ⬆️
keras-jax 64.25% <37.83%> (-0.02%) ⬇️
keras-numpy 58.98% <35.13%> (-0.02%) ⬇️
keras-openvino 29.81% <11.71%> (-0.02%) ⬇️
keras-tensorflow 64.81% <54.95%> (+<0.01%) ⬆️
keras-torch 64.15% <18.91%> (-0.04%) ⬇️

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.

@james77777778
Copy link
Contributor Author

We need to fix the version of torch until torch-xla supports a higher version.

In this PR, the testing env is:

  • CPU: 2.5.1 (latest: 2.6.0)
  • GPU: 2.5.1 (latest: 2.6.0 with cuda 12.4 & 12.6; 2.5.1 with cuda 12.1)
  • torch-xla: 2.5.1

Copy link
Collaborator

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for the contribution! Noted on torch version freezing.

@@ -15,6 +16,14 @@
from keras.src.backend.jax.core import convert_to_tensor


def jax_uses_cpu():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please move this to keras/src/testing/test_case.py. We can also have corresponding functions for other backends if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! I have added uses_cpu() to test_case.py

@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Jan 29, 2025
@google-ml-butler google-ml-butler bot removed the ready to pull Ready to be merged into the codebase label Jan 30, 2025
@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Jan 30, 2025
@fchollet fchollet merged commit 738c313 into keras-team:master Jan 30, 2025
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 Jan 30, 2025
@james77777778 james77777778 deleted the add-signbit branch February 1, 2025 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Assigned Reviewer
Development

Successfully merging this pull request may close these issues.

5 participants