-
Notifications
You must be signed in to change notification settings - Fork 950
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 4 files at r1.
Reviewable status: 0 of 1 approvals obtained (waiting on @nsthorat and @dsmilkov)
src/kernels/webgl/complex_abs_gpu.ts, line 32 at r1 (raw file):
float imag = getImagAtOutCoords(); setOutput(sqrt(real * real + imag * imag));
vec2 v = vec2(real, imag)
setOutput(dot(v, v))
src/ops/unary_ops_test.ts, line 142 at r1 (raw file):
Math.sqrt(0 * 0 + 3 * 3), Math.sqrt(1 * 1 + 0 * 0), Math.sqrt(2 * 2 + -1 * -1) ]);
add couple more unit tests for different ranks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 1 approvals obtained (waiting on @nsthorat and @dsmilkov)
src/kernels/webgl/complex_abs_gpu.ts, line 32 at r1 (raw file):
Previously, dsmilkov (Daniel Smilkov) wrote…
vec2 v = vec2(real, imag)
setOutput(dot(v, v))
forgot sqrt()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 1 approvals obtained (waiting on @nsthorat)
src/kernels/webgl/complex_abs_gpu.ts, line 32 at r1 (raw file):
vec2 v = vec2(real, imag)
Nice. Done.
src/ops/unary_ops_test.ts, line 142 at r1 (raw file):
Previously, dsmilkov (Daniel Smilkov) wrote…
add couple more unit tests for different ranks
Done
…into complexabs
There's also a length() function in GLSL ES 1.00. It might be slightly faster and also avoid some fringe cases of float32 underflow ( |
That's a great point @DirkToewe. Want to send a PR? |
We hide this behind tf.abs.
y = sqrt(real ^ 2 + imag ^ 2)
This change is