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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

pad: support alternate value types. #459

Merged
merged 4 commits into from
May 28, 2024
Merged

pad: support alternate value types. #459

merged 4 commits into from
May 28, 2024

Conversation

tfogal
Copy link
Collaborator

@tfogal tfogal commented May 24, 2024

PyTorch actually allows the value argument to have a different type than the input type, as long as the type of value is convertible to the type of input. This contradicts the documentation which indicates that the padding value, if specified, must be a float. 馃し

Fixes #458.

cc @tfogal

PyTorch actually allows the `value` argument to have a different
type than the input type, as long as the type of `value` is
convertible to the type of `input`. This contradicts the
documentation at:

   https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html

which indicates that the padding value, if specified, must be a
float.

Fixes #458.
@tfogal tfogal added the nemo Issues needed to support NVIDIA NeMo models. label May 24, 2024
@tfogal tfogal marked this pull request as ready for review May 28, 2024 16:45
Copy link
Collaborator

@jjsjann123 jjsjann123 left a comment

Choose a reason for hiding this comment

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

Thanks for patching this one. It's surprising to see how pad handles the promotion differently from a pointwise operation.

Copy link
Collaborator

@lantiga lantiga left a comment

Choose a reason for hiding this comment

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

LGTM. Sneaky!

@lantiga lantiga merged commit 2fa5cab into main May 28, 2024
37 checks passed
@lantiga lantiga deleted the tfogal/pad-value-type branch May 28, 2024 20:58
crcrpar pushed a commit that referenced this pull request May 29, 2024
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
tfogal added a commit that referenced this pull request Jun 5, 2024
As per #459's review comments.
@tfogal tfogal mentioned this pull request Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nemo Issues needed to support NVIDIA NeMo models.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError with torch.nn.functional.pad
4 participants