Skip to content

Add sigil for tensors #498

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

Merged
merged 14 commits into from
Oct 3, 2021
Merged

Add sigil for tensors #498

merged 14 commits into from
Oct 3, 2021

Conversation

dannote
Copy link
Contributor

@dannote dannote commented Oct 3, 2021

This PR adds ~M[] sigil that evaluates to #Nx.Tensor<> as discussed in #358, but with type in the modifier.

I've added conditional compilation since support for digits in sigils was just merged to Elixir (elixir-lang/elixir#11283).

3
4] == Nx.tensor([[1], [2], [3], [4]])
assert ~M[1.0 2 3
11 12 13] == Nx.tensor([[1.0, 2, 3], [11, 12, 13]])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't forget to format this file. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's how it looks after running mix formatter, I double-checked :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting. It may be a formatter bug. :)

Copy link
Collaborator

@josevalim josevalim left a comment

Choose a reason for hiding this comment

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

The implementation looks great! I have dropped only some minor comments. :)

@josevalim josevalim merged commit 0924388 into elixir-nx:main Oct 3, 2021
@josevalim
Copy link
Collaborator

💚 💙 💜 💛 ❤️

@dannote dannote deleted the tensor-sigils branch October 3, 2021 16:33
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