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

feature(tensor): Add unsqueeze_dim helper #966

Merged
merged 2 commits into from
Nov 20, 2023

Conversation

dcvz
Copy link
Contributor

@dcvz dcvz commented Nov 18, 2023

Pull Request Template

Checklist

  • Confirm that run-checks script has been executed.

Changes

Adds a unsqueeze_dim method allowing you to target a specific dimension.

Testing

I've added tests for the added method

Related Issue

fixes #876

@dcvz dcvz marked this pull request as ready for review November 18, 2023 23:57
Copy link
Collaborator

@antimora antimora left a comment

Choose a reason for hiding this comment

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

Looks good. A couple changes requested:

  1. Update the example with a preferred style.
  2. Update the Book tensor section with the new op: https://burn.dev/book/building-blocks/tensor.html#basic-operations

///
/// fn example<B: Backend>() {
/// let tensor = Tensor::<B, 2>::ones(Shape::new([3, 3]));
/// let tensor = tensor.unsqueeze_dim::<3>(1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we use this style instead?

let tensor:Tensor<B, 3> = tensor.unsqueeze_dim(1);

<3> stands out compared to other Burn examples.

@dcvz
Copy link
Contributor Author

dcvz commented Nov 19, 2023

@antimora I think I've addressed all comments!

Copy link
Collaborator

@antimora antimora left a comment

Choose a reason for hiding this comment

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

Thank you. Looks good.

@nathanielsimard nathanielsimard merged commit 49e16b6 into tracel-ai:main Nov 20, 2023
6 checks passed
@dcvz dcvz deleted the feature/unsqueeze-dim branch November 20, 2023 15:35
@dcvz dcvz mentioned this pull request Nov 21, 2023
6 tasks
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.

Unsqueeze at Any Dimension
3 participants