-
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 the concat Op test=develop #25307
refine the concat Op test=develop #25307
Conversation
Thanks for your contribution! |
1 similar comment
Thanks for your contribution! |
x_2 = fluid.data(shape=[2, 1, 4, 5], dtype='int32', name='x_2') | ||
x_3 = fluid.data(shape=[2, 2, 4, 5], dtype='int32', name='x_3') | ||
positive_1_int32 = paddle.fill_constant([1], "int32", 1) | ||
positive_1_int64 = paddle.fill_constant([1], "int64", 1) |
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.
为什么没有负数的case?
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
:alias: paddle.concat,paddle.tensor.concat,paddle.tensor.manipulation.concat | ||
:old_api: paddle.fluid.layers.concat | ||
|
||
**Concat** |
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.
Done
python/paddle/tensor/manipulation.py
Outdated
x(list): List of input Tensors with data type float32, float64, int32, int64. | ||
axis(int|Variable, optional): A scalar with type ``int32`` or a ``Tensor`` | ||
with shape [1] and type ``int32``. Axis to compute indices along. The effective range | ||
is [-R, R), where R is Rank(x). when axis<0, it works the same way |
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<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.
Done
out_1 = paddle.concat(x=[x_2, x_3], axis=1) | ||
out_2 = paddle.concat(x=[x_2, x_3], axis=positive_1_int32) | ||
out_3 = paddle.concat(x=[x_2, x_3], axis=positive_1_int64) | ||
out_4 = paddle.concat(x=[x_2, x_3], axis=positive_1_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.
copy&paste?忘了改成负数的case了?
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
""" | ||
:alias_main: paddle.concat | ||
:alias: paddle.concat,paddle.tensor.concat,paddle.tensor.manipulation.concat | ||
:old_api: paddle.fluid.layers.concat |
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.
与 @TCChenlong 确认一下,这里到底是怎么规定的,我看到有写update_api的,还有写old_api的
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.
蓝翔老师,2.0里API的文档不需要写update_api或old_api,在版本发布时,会在2.0版本里的兼容1.8版本的API统一增加一行Note or Warning
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/fluid/layers/tensor.py
Outdated
@@ -270,7 +270,7 @@ def concat(input, axis=0, name=None): | |||
|
|||
Args: | |||
input(list): List of input Tensors with data type float16, float32, float64, int32, | |||
int64. The data type of ``input`` must be same. | |||
int64. All tensor in ``input`` must have same data type. |
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. All tensor in ``input`` must have same data type. | |
int64. All Tensors in ``input`` must have the same data type. |
python/paddle/fluid/layers/tensor.py
Outdated
@@ -332,6 +333,8 @@ def concat(input, axis=0, name=None): | |||
check_variable_and_dtype( | |||
x, 'input[' + str(id) + ']', | |||
['float16', 'float32', 'float64', 'int32', 'int64'], 'concat') | |||
if convert_dtype(x.dtype) != convert_dtype(input[0].dtype): | |||
raise TypeError("All Tensor in the input must has same data type.") |
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.
raise TypeError("All Tensor in the input must has same data type.") | |
raise TypeError("All Tensors in the input must have same data type.") |
同样一句话出现在几个位置,每次都不相同,请仔细检查一下是否还有其他问题
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
python/paddle/tensor/manipulation.py
Outdated
@@ -69,6 +71,7 @@ def concat(x, axis=0, name=None): | |||
Raises: | |||
TypeError: The dtype of `x` must be one of float16, float32, float64, int32 and int64. | |||
TypeError: The `axis` must be int or Variable. | |||
TypeError: All the tensor in ``x`` must have the same data type. |
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.
Done
as axis+R. Default is 0. | ||
name (str, optional): The default value is None. Normally there is no | ||
need for user to set this property. For more information, please | ||
refer to :ref:`api_guide_Name`. | ||
Raises: | ||
TypeError: The dtype of input must be one of float16, float32, float64, int32 and int64. | ||
TypeError: The `axis` must be int or Variable. | ||
TypeError: All the tensor in ``input`` must have the same data type. | ||
TypeError: The ``axis`` must be int or Variable. The dtype of ``axis`` must be int32 or int64 when it's 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.
Variable要统一改为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.
后面关于2.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.
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,input应该变为x,Variable变为Tensor,这些私下沟通后面会单独提PR改
PR types
Function optimization
PR changes
Ops
Describe
old
new
concat
fluid.concat
full
![image](https://user-images.githubusercontent.com/13411999/88172227-36aed200-cc53-11ea-9be1-c4321175d8af.png)
![image](https://user-images.githubusercontent.com/13411999/88172269-47f7de80-cc53-11ea-81e8-ea5bb40cae85.png)
eye
![image](https://user-images.githubusercontent.com/13411999/88172295-5645fa80-cc53-11ea-95a9-c0f112f6d11a.png)
![image](https://user-images.githubusercontent.com/13411999/88172320-5e9e3580-cc53-11ea-8ffd-455ea58b5988.png)
linspace
![image](https://user-images.githubusercontent.com/13411999/88172378-74135f80-cc53-11ea-8e22-00f8fe7dd53e.png)
![image](https://user-images.githubusercontent.com/13411999/88172406-8097b800-cc53-11ea-9029-8f65cb587bff.png)
full_like
![image](https://user-images.githubusercontent.com/13411999/88190608-112ec200-cc6d-11ea-94fc-d3244c77ed1c.png)
![image](https://user-images.githubusercontent.com/13411999/88190649-1be95700-cc6d-11ea-9161-6b3bf395880a.png)
index_select
![image](https://user-images.githubusercontent.com/13411999/88190698-299edc80-cc6d-11ea-87f9-b2ede3c6e568.png)
zeros:
![image](https://user-images.githubusercontent.com/13411999/88206744-58bf4900-cc81-11ea-9486-e5fdbed30d3a.png)
![image](https://user-images.githubusercontent.com/13411999/88206756-607eed80-cc81-11ea-9af8-33aa70f713c8.png)