jax icon indicating copy to clipboard operation
jax copied to clipboard

Clarify that lax.top_k returns values and corresponding indices in descending order

Open Sohl-Dickstein opened this issue 10 months ago • 4 comments

Share the fruits of my debugging journey, so that future people like me are less likely to assume index order is preserved.

NOTE: The statement that values are sorted in descending order is based on observed behavior in a colab. I don't know if this is guaranteed or not.

Sohl-Dickstein avatar Apr 16 '24 17:04 Sohl-Dickstein

Yes please!

On Tue, Apr 16, 2024, 10:15 Peter Hawkins @.***> wrote:

@.**** commented on this pull request.

This is explicitly not something we promise: there are reasonable implementations (e.g., a heap, say) that don't have this property.

Would it suffice to say that explicitly: that order is not guaranteed?

— Reply to this email directly, view it on GitHub https://github.com/google/jax/pull/20781#pullrequestreview-2004212091, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADZW4B6M7K6RRDMM2HWEYLY5VMBXAVCNFSM6AAAAABGJYFWP6VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDAMBUGIYTEMBZGE . You are receiving this because you authored the thread.Message ID: @.***>

Sohl-Dickstein avatar Apr 16 '24 17:04 Sohl-Dickstein

I just made that change to the PR.

Sohl-Dickstein avatar Apr 16 '24 17:04 Sohl-Dickstein

Before we merge this, could you squash your changes into a single commit? See https://jax.readthedocs.io/en/latest/contributing.html#single-change-commits-and-pull-requests

Thanks!

jakevdp avatar Apr 16 '24 18:04 jakevdp

Done. PTAL.

Sohl-Dickstein avatar Apr 16 '24 18:04 Sohl-Dickstein