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

refactor: Nx.Random.key as deftransform #1525

Merged
merged 3 commits into from
Sep 4, 2024

Conversation

polvalente
Copy link
Contributor

No description provided.

nx/lib/nx/random.ex Outdated Show resolved Hide resolved
@jonatanklosko
Copy link
Member

Good call!

polvalente and others added 2 commits September 4, 2024 11:24
Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>
seed

%Nx.Tensor{} = seed when seed.type == {:s, 64} ->
Nx.bitcast(seed, {:u, 64})
Copy link
Collaborator

@josevalim josevalim Sep 4, 2024

Choose a reason for hiding this comment

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

Do we really need this clause? No-one should be passing s64 now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or do we also want to do bitcasts for f64?

Copy link
Member

Choose a reason for hiding this comment

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

We do logical and with another :u64, so that's good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the s64 case because there are explicit tests for this, and it has the same entropy as u64. Not sure about floats.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I misread the question. I think it's fair to assume seed is always an integer.

No preference on {:s, 64}, if there are tests, then yeah, bitcast sounds good.

@polvalente polvalente merged commit e9b3d73 into main Sep 4, 2024
8 checks passed
@polvalente polvalente deleted the pv-refactor/deftransform-nx-random-key branch September 4, 2024 16:19
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.

3 participants