Skip to content

Conversation

@qjia7
Copy link
Contributor

@qjia7 qjia7 commented Feb 8, 2023

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.


This change is Reviewable

@qjia7 qjia7 requested review from gyagp and xhcao February 8, 2023 07:35
@qjia7
Copy link
Contributor Author

qjia7 commented Feb 8, 2023

@hujiajie As offline talked with you, please take a look. Thanks.

return ${op}(a, b);
`;
}
const ATAN2 = 'var resultTemp = atan2(a, b);';
Copy link
Contributor

Choose a reason for hiding this comment

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

Ops are ordered alphabetically above.

return (resultTemp + b) % b;
}
resultTemp = select((resultTemp + b) % b, resultTemp,
(a < 0. && b < 0.) || (a >= 0. && b > 0.));
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the line breaking rule? Follow clang-format?

Copy link

@gyagp gyagp left a comment

Choose a reason for hiding this comment

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

LGTM with one nit

continue;
}
const checkNaNSnippet =
useVec4 ? CHECK_NAN_SNIPPET_VEC4 : CHECK_NAN_SNIPPET;
Copy link

Choose a reason for hiding this comment

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

This is a bit strange to have a new variable whose name is the same as one of conditions. Can we just use "useVec4 ? CHECK_NAN_SNIPPET_VEC4 : CHECK_NAN_SNIPPET" directly?

Copy link
Contributor

Choose a reason for hiding this comment

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

While it's not the case here, sometimes clang-format behaves poorly on ${expression}. To reiterate my previous point, personally I prefer the ${identifier} style, or macro expansion in terms of C/C++.

Copy link

Choose a reason for hiding this comment

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

clang-format behaves poorly on ${}, no matter it's expression or identifier. We can now leave it as is.


export function getBinaryOpString(
type: BinaryOpType, useVec4?: boolean): string {
// NaN-sensitive ops
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps "sensitive"/"insensitive" is not the right word here, but I'm not sure what could be better.

Copy link

Choose a reason for hiding this comment

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

Maybe "Ops with NaN check" and "Ops without NaN check"?

Copy link
Contributor Author

@qjia7 qjia7 left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @gyagp, @hujiajie, and @xhcao)


tfjs-backend-webgpu/src/binary_op_util.ts line 114 at r1 (raw file):

Previously, hujiajie (Jiajie Hu) wrote…

What's the line breaking rule? Follow clang-format?

I break it manually since it's too long.


tfjs-backend-webgpu/src/binary_op_util.ts line 187 at r1 (raw file):

Previously, gyagp (Yang Gu) wrote…

Maybe "Ops with NaN check" and "Ops without NaN check"?

Done.


tfjs-backend-webgpu/src/binary_op_util.ts line 213 at r1 (raw file):

Previously, gyagp (Yang Gu) wrote…

This is a bit strange to have a new variable whose name is the same as one of conditions. Can we just use "useVec4 ? CHECK_NAN_SNIPPET_VEC4 : CHECK_NAN_SNIPPET" directly?

Done.

@qjia7 qjia7 requested review from gyagp and hujiajie February 10, 2023 02:45
@hujiajie
Copy link
Contributor

Thanks but sorry my brain bandwidth is a little exhausted, since the patch seems to be squeezing several changes into one. I would like to resort to others' feedback.

Copy link
Contributor

@xhcao xhcao left a comment

Choose a reason for hiding this comment

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

LGTM

@gyagp gyagp merged commit 13f5df2 into tensorflow:master Feb 10, 2023
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.

4 participants