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

mlx - implement segment_sum and segment_max #19652

Closed
wants to merge 1 commit into from

Conversation

lkarthee
Copy link
Contributor

@lkarthee lkarthee commented May 1, 2024

No description provided.

@lkarthee lkarthee changed the title Implement segment_sum and segment_max mlx - implement segment_sum and segment_max May 1, 2024
@codecov-commenter
Copy link

codecov-commenter commented May 1, 2024

Codecov Report

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

❗ No coverage uploaded for pull request base (mlx@4c90dfb). Click here to learn what that means.

Files Patch % Lines
keras/src/backend/mlx/math.py 0.00% 22 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##             mlx   #19652   +/-   ##
======================================
  Coverage       ?   68.43%           
======================================
  Files          ?      506           
  Lines          ?    45959           
  Branches       ?     8496           
======================================
  Hits           ?    31451           
  Misses         ?    12857           
  Partials       ?     1651           
Flag Coverage Δ
keras 68.35% <0.00%> (?)
keras-jax 58.82% <0.00%> (?)
keras-numpy 53.16% <0.00%> (?)
keras-tensorflow 59.97% <0.00%> (?)

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.

@@ -6,11 +6,37 @@


def segment_sum(data, segment_ids, num_segments=None, sorted=False):
raise NotImplementedError("segment_sum is not implemented for mlx")
data = convert_to_tensor(data)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

mlx does not have unique and boolean indices ml-explore/mlx#246 and ml-explore/mlx#377 . So the implementation is buggy with varying values of num_segments and negative segment_ids.

Copy link
Contributor Author

@lkarthee lkarthee May 1, 2024

Choose a reason for hiding this comment

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

One way to solve this is using numpy.unique on segment_ids to determine num_segments. Let me know what to do.

Copy link
Member

Choose a reason for hiding this comment

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

@angeloskath could you please advise here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @angeloskath Any update on above comment from @fchollet ? Please. Thank you!

@Faisal-Alsrheed
Copy link
Contributor

Faisal-Alsrheed commented May 1, 2024

Hi @lkarthee,

I have noticed the same issue: there are missing and needed functions in MLX.

What is the best strategy here? Should we use NumPy temporarily and add a TODO comment?

I have decided to start with core files and functions.
#19619

I suggest creating a roadmap where we start with fundamental functions and then move up.

best

@lkarthee
Copy link
Contributor Author

lkarthee commented May 1, 2024

@Faisal-Alsrheed My thoughts regarding missing functions which can't be added due to design decisions/limitations of mlx:

  • we have to check if there is a workaround.
  • if there is no workaround, may be we have to fallback to using numpy or jax adding a TODO?

Regarding fixing core first, I have been doing that in my PRs. I tried to implement Pooling and CNN related funcs, realised many tests are failing and started fixing test cases.

@fchollet any thoughts on what to use as fallback - numpy or jax.

@lkarthee lkarthee mentioned this pull request May 2, 2024
62 tasks
@gbaned gbaned requested a review from fchollet May 3, 2024 03:22
@gbaned
Copy link
Collaborator

gbaned commented Jul 12, 2024

Hi @fchollet Any update on this PR? Please. Thank you!

@fchollet
Copy link
Member

@fchollet any thoughts on what to use as fallback - numpy or jax.

Sorry, just checking this now. I would say that JAX is preferable as fallback since numpy would not be sufficiently performant.

@gbaned
Copy link
Collaborator

gbaned commented Sep 9, 2024

Hi @lkarthee Any update on this PR? Please. Thank you!

Copy link

This PR is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale label Sep 24, 2024
Copy link

github-actions bot commented Oct 8, 2024

This PR was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.

@github-actions github-actions bot closed this Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Closed/Rejected
Development

Successfully merging this pull request may close these issues.

5 participants