-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add tp.pad #203
base: main
Are you sure you want to change the base?
Add tp.pad #203
Conversation
Blocked until translation from |
973dd71
to
819d3b2
Compare
Args: | ||
input: The input tensor. | ||
|
||
padding_sizes: A sequence of padding sizes of each dimension. Its length must equal to the rank |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
padding_sizes: A sequence of padding sizes of each dimension. Its length must equal to the rank | |
padding_sizes: A sequence of padding sizes of each dimension. Its length must be equal to the rank |
input: The input tensor. | ||
|
||
padding_sizes: A sequence of padding sizes of each dimension. Its length must equal to the rank | ||
of `input`. Each element of `padding_size` is a tuple of integers or scalars `(low, high)`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
padding_size
can also be a Tensor
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think passing padding_sizes
as a Nx2
Tensor is a common use case, it is always more convenient for users to construct a sequence than a Tensor.
However, using ScalarShape
in padding_sizes
is supported, for example:
pad(inp, [(0, a.shape[0]), (0, a.shape[1])])
sizes_1d = [] | ||
for size in padding_sizes: | ||
if isinstance(size, Tensor): | ||
assert size.rank == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert size.rank == 0 | |
assert size.rank == 0, f"Size expected to be of rank 0, got {size.rank}." |
No description provided.