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 paddle.summary's bug when outputs contains non-tensor #34160

Merged
merged 8 commits into from
Jul 29, 2021

Conversation

HydrogenSulfate
Copy link
Contributor

@HydrogenSulfate HydrogenSulfate commented Jul 14, 2021

PR types

Bug fixes

PR changes

APIs

Describe

该问题是复现TimeSformer模型时遇到的,当网络中的某些层的输出含有非tensor的元素时,使用paddle.summary会报错,因为递归逻辑中遇到单个元素时直接调用其.shape()方法,而这个元素可能并不是tensor,导致无法获取到output中非tensor的shape并且报错,见图1。

修复后在递归逻辑中加入了调用shape方法前的判断,如果不是tensor,则它的形状用[]代替,见图2。

torchsummary目前也存在这个问题,见图3。

以下是修改前,修改后,以及torchsummary的例子
修改前的例子,会报错

修改后的例子,正常

torchsummary目前也存在这个问题

@paddle-bot-old
Copy link

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

@CLAassistant
Copy link

CLAassistant commented Jul 14, 2021

CLA assistant check
All committers have signed the CLA.

@HydrogenSulfate HydrogenSulfate changed the title fix paddle.summary's bug when output contains non-tensor fix paddle.summary's bug when outputs contains non-tensor Jul 14, 2021
@LielinJiang LielinJiang merged commit b7fac0f into PaddlePaddle:develop Jul 29, 2021
@HydrogenSulfate HydrogenSulfate deleted the summary_bug_fix branch October 26, 2021 09:12
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.

3 participants