-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
refine unsqueeze, test=develop #25470
Conversation
Thanks for your contribution! |
49b4466
to
66d1a0a
Compare
python/paddle/tensor/manipulation.py
Outdated
@@ -556,7 +577,7 @@ def squeeze(x, axis=None, name=None): | |||
name (str, optional): Please refer to :ref:`api_guide_Name`, Default None. | |||
|
|||
Returns: | |||
Tensor: Output squeezed Tensor. Data type is same as input Tensor. | |||
Tensor: Output squeezed Tensor with the same data type as input 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.
Output 好像是多余的?
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.
好的
python/paddle/tensor/manipulation.py
Outdated
input (Variable): The input Tensor to be unsqueezed. It is a N-D Tensor of data types float32, float64, int32. | ||
axes (int|list|tuple|Variable): Indicates the dimensions to be inserted. The data type is ``int32`` . If ``axes`` is a list or tuple, the elements of it should be integers or Tensors with shape [1]. If ``axes`` is an Variable, it should be an 1-D Tensor . | ||
name (str|None): Name for this layer. | ||
x (Tensor): The input Tensor to be unsqueezed. It is a N-D Tensor of data types float32, float64, int32. |
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.
不支持int64?bool类型呢,是否需要支持?
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.
int64是支持的,bool在c++ kernel中未支持。
python/paddle/tensor/manipulation.py
Outdated
|
||
Returns: | ||
Variable: Output unsqueezed Tensor, with data type being float32, float64, int32, int64. | ||
Tensor: Output unsqueezed Tensor with the same data type as input 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.
同上
|
||
out2 = paddle.unsqueeze(x, axis=[0, 2]) | ||
print(out2.shape) # [1, 5, 1, 10] | ||
|
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.
应该有一个axis含有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.
好的
|
||
return out | ||
return layers.unsqueeze(x, axis, name) |
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.
报错问题是怎么解决的?
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.
7e246e5
to
064618a
Compare
python/paddle/fluid/layers/nn.py
Outdated
@@ -6253,12 +6254,12 @@ def unsqueeze(input, axes, name=None): | |||
then Unsqueezed tensor with axes=[0, 4] has shape [1, 3, 4, 5, 1]. | |||
|
|||
Args: | |||
input (Variable): The input Tensor to be unsqueezed. It is a N-D Tensor of data types float32, float64, int32. | |||
input (Variable): The input Tensor to be unsqueezed. Support data type: float32, float64, bool, int8, int32, int64. |
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.
input (Variable): The input Tensor to be unsqueezed. Support data type: float32, float64, bool, int8, int32, int64. | |
input (Variable): The input Tensor to be unsqueezed. Supported data type: float32, float64, bool, int8, int32, int64. |
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.
done, thx
python/paddle/tensor/manipulation.py
Outdated
@@ -473,18 +494,19 @@ def squeeze(x, axis=None, name=None): | |||
out.shape = [1, 3, 5] | |||
|
|||
Args: | |||
input (Tensor): The input Tensor. Support data type: float32, float64, int8, int32, int64. | |||
x (Tensor): The input Tensor. Support data type: float32, float64, bool, int8, int32, int64. |
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.
x (Tensor): The input Tensor. Support data type: float32, float64, bool, int8, int32, int64. | |
x (Tensor): The input Tensor. Supported data type: float32, float64, bool, int8, int32, int64. |
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.
done, thx
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.
lgtm
fccb560
to
6860851
Compare
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.
LGTM
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.
lgtm
PR types
Breaking changes
PR changes
APIs
Describe
Refine paddle.unsqueeze
axis
supportsint, list, tuple
dtype
supports float32, float64, bool, int8, int32, int64, (and float16 on CUDAPlace).