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

fill_diagonal op fix border cross caused by offset #36212

Merged
merged 1 commit into from
Oct 9, 2021
Merged

fill_diagonal op fix border cross caused by offset #36212

merged 1 commit into from
Oct 9, 2021

Conversation

zhiboniu
Copy link
Contributor

@zhiboniu zhiboniu commented Sep 29, 2021

PR types

Bug fixes

PR changes

OPs

Describe

fill_diagonal op fix border cross caused by offset

原来的方式offset非0时修改值会出现跨行的问题,
本次修复添加行位置越界判断,避免了这类问题。

修复前:
x.fill_diagonal_(1,offset=2)
image
修改了(0,2)、(2,0)两个位置,其中(2,0)由(1,1)右移2(offset值)导致。

修复后:
x.fill_diagonal_(4,offset=2)
image
只修改了(0,2)位置

@paddle-bot-old
Copy link

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

Comment on lines +112 to +117
if (i % out_dims[1] + offset >= 0 &&
i % out_dims[1] + offset < out_dims[1]) {
Copy link
Contributor

@jeff41404 jeff41404 Oct 8, 2021

Choose a reason for hiding this comment

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

suggest adding a annotation to explain this if statement

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

Comment on lines +30 to +35
if ((idx * strides) % dims + offset < dims &&
(idx * strides) % dims + offset >= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest adding a annotation to explain this if statement

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

@jeff41404
Copy link
Contributor

and it would be better to add a unittest to cover this case

Copy link
Contributor

@jeff41404 jeff41404 left a comment

Choose a reason for hiding this comment

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

lgtm

@jeff41404 jeff41404 merged commit 62e4115 into PaddlePaddle:develop Oct 9, 2021
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