Skip to content

Conversation

@xhcao
Copy link
Contributor

@xhcao xhcao commented Dec 22, 2022

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


This change is Reviewable

const COMPLEX_MULTIPLY_IMAG = 'return areal * bimag + aimag * breal;';
const DIV = 'return a / b;';
const ELU_DER = `
let bGTEZero = f32(b > 0.);
Copy link

Choose a reason for hiding this comment

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

Suggested change
let bGTEZero = f32(b > 0.);
let bGTEZero = f32(b >= 0.);

const DIV = 'return a / b;';
const ELU_DER = `
let bGTEZero = f32(b > 0.);
return (bGTEZero * a) + (1.0 - bGTEZero) * (a * (b + 1.0));
Copy link

Choose a reason for hiding this comment

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

Use select can be simpler

`;
const ELU_DER_VEC4 = `
let bGTEZero = vec4<f32>(b >= vec4<f32>(0.));
return (bGTEZero * a) + (vec4<f32>(1.0) - bGTEZero) * (a * (b + vec4<f32>(1.0)));
Copy link

Choose a reason for hiding this comment

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

same here, please use select

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

const COMPLEX_MULTIPLY_REAL = 'return areal * breal - aimag * bimag;';
const COMPLEX_MULTIPLY_IMAG = 'return areal * bimag + aimag * breal;';
const DIV = 'return a / b;';
const ELU_DER = 'return select(a * (b + 1.0), a, 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.

I see webgl is using b >= 1.0 https://github.com/tensorflow/tfjs/blob/master/tfjs-backend-webgl/src/kernels/EluGrad.ts#L24 . However, you are using b >= 0.0. Which one is correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On webgl backend, the non PACKED and PACKED versions are different,

const ELU_DER_PACKED = `

I think the PACKED version is correct, but is not 100% sure.

Copy link

Choose a reason for hiding this comment

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

According to http://bytedeco.org/javacpp-presets/tensorflow/apidocs/org/bytedeco/tensorflow/EluGrad.html, b >= 0. is correct.
Please also fix the WebGL unpacked version, and I think we also need some test cases to cover.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed them and added case in #7251

Copy link

Choose a reason for hiding this comment

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

Thanks! Please hold this a bit until #7251 is reviewed.

Copy link
Contributor

@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.

LGTM with one nit. Thanks!

@@ -0,0 +1,38 @@
/**
* @license
* Copyright 2022 Google LLC.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: 2022 -> 2023

@qjia7 qjia7 merged commit 9f17eaa into tensorflow:master Jan 9, 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.

3 participants