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

Makes ops.split in torch consistent with other backends #914

Merged
merged 2 commits into from
Sep 19, 2023

Conversation

james77777778
Copy link
Contributor

Fixes #544

Unit test has been updated to verify the behavior consistency across backends.

...
        # test zero dimension
        x = np.ones(shape=(0,))
        self.assertEqual(len(knp.split(x, 2)), 2)
        self.assertEqual(len(knp.Split(2)(x)), 2)
...

@codecov
Copy link

codecov bot commented Sep 19, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -3.80% ⚠️

Comparison is base (b4019bc) 83.63% compared to head (4b56db2) 79.83%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #914      +/-   ##
==========================================
- Coverage   83.63%   79.83%   -3.80%     
==========================================
  Files         318      318              
  Lines       28391    28591     +200     
  Branches     5409     5447      +38     
==========================================
- Hits        23745    22827     -918     
- Misses       3147     4297    +1150     
+ Partials     1499     1467      -32     
Flag Coverage Δ
keras_core 79.76% <100.00%> (-3.77%) ⬇️
keras_core-jax ?
keras_core-numpy 60.46% <0.00%> (-0.27%) ⬇️
keras_core-tensorflow 66.90% <0.00%> (-0.18%) ⬇️
keras_core-torch 69.30% <100.00%> (-0.14%) ⬇️

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

Files Changed Coverage Δ
keras_core/backend/torch/numpy.py 95.17% <100.00%> (+0.04%) ⬆️

... and 34 files with indirect coverage changes

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

Copy link
Contributor

@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.

Thanks for the fix!

return torch.split(
if dim % indices_or_sections != 0:
raise ValueError(
"`indices_or_sections` is given as an integar, but it cannot "
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: integer

Use the following:

Received indices_or_sections={indices_or_sections}
(interpreted as a number of sections) and axis={axis},
but input dimension x.shape[{axis}]={x.shape[axis]}
is not divisible by {indices_or_sections}.
Full input shape: x.shape={x.shape}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Fixed.

Copy link
Contributor

@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

The JAX CI failure seems persistent, despite not occurring with local testing and having no clear connection to the commit where it started failing. We'll investigate it. There's something weird going on.

@fchollet fchollet merged commit ffd736e into keras-team:main Sep 19, 2023
@james77777778
Copy link
Contributor Author

The JAX CI failure seems persistent, despite not occurring with local testing and having no clear connection to the commit where it started failing. We'll investigate it. There's something weird going on.

I could not reproduce these JAX CI failure in my local env, too.

It appears that this run has started to fail:
https://github.com/keras-team/keras-core/actions/runs/6230566801/job/16910778781

@james77777778 james77777778 deleted the fix-torch-split branch September 19, 2023 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Behavior of ops.split
2 participants