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

refine unsqueeze, test=develop #25470

Merged
merged 11 commits into from
Aug 8, 2020
Merged

Conversation

zhiqiu
Copy link
Contributor

@zhiqiu zhiqiu commented Jul 9, 2020

PR types

Breaking changes

PR changes

APIs

Describe

Refine paddle.unsqueeze

  1. paddle.unsqueeze(input, axes, name=None) -> paddle.unsqueeze(x, axis, name=None)
  2. axis supports int, list, tuple
  3. dtype supports float32, float64, bool, int8, int32, int64, (and float16 on CUDAPlace).
  4. refine document

@paddle-bot-old
Copy link

paddle-bot-old bot commented Jul 9, 2020

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Output 好像是多余的?

Copy link
Contributor Author

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. 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.
Copy link
Contributor

Choose a reason for hiding this comment

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

不支持int64?bool类型呢,是否需要支持?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

int64是支持的,bool在c++ kernel中未支持。


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.
Copy link
Contributor

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]

Copy link
Contributor

Choose a reason for hiding this comment

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

应该有一个axis含有tensor的例子

Copy link
Contributor Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

报错问题是怎么解决的?

Copy link
Contributor Author

@zhiqiu zhiqiu Jul 29, 2020

Choose a reason for hiding this comment

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

直接复用了layers.squeeze的报错,报错中 axes -> axis/axes。

image

@zhiqiu
Copy link
Contributor Author

zhiqiu commented Aug 6, 2020

image

@zhiqiu zhiqiu requested a review from jzhang533 August 7, 2020 02:09
@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, thx

@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, thx

jzhang533
jzhang533 previously approved these changes Aug 7, 2020
Copy link
Contributor

@jzhang533 jzhang533 left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@lanxianghit lanxianghit left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@jzhang533 jzhang533 left a comment

Choose a reason for hiding this comment

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

lgtm

@zhiqiu zhiqiu merged commit 5258d53 into PaddlePaddle:develop Aug 8, 2020
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.

None yet

3 participants