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

Polish reshape error message under @to_static #40599

Merged
merged 1 commit into from
Mar 16, 2022

Conversation

Aurelius84
Copy link
Contributor

PR types

Others

PR changes

APIs

Describe

File "/workspace/env3.7/lib/python3.7/site-packages/paddle/fluid/layers/nn.py", line 6308, in get_attr_shape
    "please turn it into a Tensor under @to_static. See above example for details." % dim_idx)

AssertionError: Only one dimension value of 'shape' in reshape can be -1. But received shape[2] is also -1.

    # N = x.shape()[2]              # N is an int. (NOT recommend under @to_static)
    N = paddle.shape(x)[2]          # N is a Tensor. (Recommend)
    z = paddle.reshape([N, -1, 4])  # z.shape is [-1, -1, 4]

If your target shape in Reshape represents dynamic shape,please turn it into a Tensor under @to_static. See above example for details.

@paddle-bot-old
Copy link

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

Copy link
Contributor

@JZ-LIANG JZ-LIANG left a comment

Choose a reason for hiding this comment

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

LGTM

@Aurelius84 Aurelius84 merged commit 80194bd into PaddlePaddle:develop Mar 16, 2022
liqitong-a pushed a commit to liqitong-a/Paddle that referenced this pull request Mar 17, 2022
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.

2 participants