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

Fix Python IndexError of Case12: paddle.static.nn.bilinear_tensor_product #50008

Merged
merged 23 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8ef0f2b
修改linspace参数"stop"的介绍
longranger2 Dec 15, 2022
8137693
更新了conv2d_transpose英文文档中 1.公式异常 2.参数说明异常 3.padding=SAME和VALID的公式说明; t…
longranger2 Dec 15, 2022
f355003
Merge branch 'PaddlePaddle:develop' into develop
longranger2 Dec 16, 2022
5b92b78
解决了
longranger2 Dec 16, 2022
5b4f20e
更新了paddle.static.auc的英文文档的Return描述以及函数的参数
longranger2 Dec 16, 2022
370646c
Update python/paddle/tensor/creation.py
longranger2 Dec 16, 2022
009ee89
更新了shard_index的ignore_value描述
longranger2 Dec 16, 2022
3574b14
Merge remote-tracking branch 'origin/develop' into loneranger_paddle
longranger2 Dec 16, 2022
0603c66
修改了英文文档的paddle.static.nn.conv3d_transpose的公式介绍
longranger2 Dec 16, 2022
dc8be6d
add py_func COPY-FROM label; test=document_fix
Ligoml Dec 19, 2022
f25a731
Update python/paddle/tensor/manipulation.py
longranger2 Dec 19, 2022
968a848
formula; test=document_fix
Ligoml Dec 23, 2022
3d1b7a9
formula; test=document_fix
Ligoml Dec 23, 2022
18a171d
formula; test=document_fix
Ligoml Dec 23, 2022
3af6cf3
Merge branch 'PaddlePaddle:develop' into develop
longranger2 Jan 20, 2023
5a3689b
为bilinear_tensor_product增加x和y维度的判断
longranger2 Jan 22, 2023
9c461b0
Merge branch 'PaddlePaddle:develop' into bilinear_tensor_product
longranger2 Jan 30, 2023
33f9bc6
为bilinear_tensor_product增加单测
longranger2 Jan 30, 2023
dbf3bd2
Merge remote-tracking branch 'origin/bilinear_tensor_product' into bi…
longranger2 Jan 30, 2023
56f3026
Merge branch 'PaddlePaddle:develop' into bilinear_tensor_product
longranger2 Feb 5, 2023
c01848b
完善bilinear_tensor_product的单测
longranger2 Feb 5, 2023
3a7bd1a
Merge branch 'PaddlePaddle:develop' into bilinear_tensor_product
longranger2 Feb 6, 2023
1997d77
fix bilinear_tensor_product
longranger2 Feb 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ def test_errors(self):
x1 = fluid.data(name='x1', shape=[-1, 5], dtype="float16")
x2 = fluid.data(name='x2', shape=[-1, 4], dtype="float32")
self.assertRaises(TypeError, layer, x1, x2)
# the dimensions of x and y must be 2
paddle.enable_static()
x3 = paddle.static.data("", shape=[0], dtype="float32")
x4 = paddle.static.data("", shape=[0], dtype="float32")
self.assertRaises(
ValueError,
paddle.static.nn.bilinear_tensor_product,
x3,
x4,
1000,
)


class TestBilinearTensorProductOp(OpTest):
Expand Down
7 changes: 6 additions & 1 deletion python/paddle/static/nn/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2568,7 +2568,12 @@ def bilinear_tensor_product(
"""
helper = LayerHelper('bilinear_tensor_product', **locals())
dtype = helper.input_dtype('x')

if len(x.shape) != 2 or len(y.shape) != 2:
raise ValueError(
"Input x and y should be 2D tensor, but received x with the shape of {}, y with the shape of {}".format(
x.shape, y.shape
)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

image

单测覆盖率不够,可以再添加下单测,或者把2571和2577行写在一起,类似
if len(x.shape) != 2 || len(y.shape) != 2:
raise ValueError(
            "Input x and y should be 2D tensor, but received x and y with shape xxxx"
        )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的👌

param_shape = [size, x.shape[1], y.shape[1]]

w = helper.create_parameter(
Expand Down