Add implementation for resizeBilinear gradient. #996
Conversation
This now also has a GPU implementation! |
Reviewed 7 of 7 files at r1. src/kernels/backend_cpu.ts, line 1499 at r1 (raw file):
keep row column notation. Since y and x are reserved for input tensor and output tensor. src/kernels/backend_cpu.ts, line 1514 at r1 (raw file):
Try to use direct flat indexing into the values (avoid calling .get) to speed it up. See https://reviewable.io/reviews/tensorflow/tfjs-core/995 for how conv2d got 100x faster. src/kernels/webgl/resize_bilinear_backprop_gpu.ts, line 78 at r1 (raw file):
extract in a variable src/kernels/webgl/resize_bilinear_backprop_gpu.ts, line 79 at r1 (raw file):
in conv2d gpu we do dyR/dyC and row and column in dy. src/ops/image_ops.ts, line 61 at r1 (raw file):
Don't save the result. Use shape from dy src/ops/image_ops.ts, line 67 at r1 (raw file):
make result a function that gets called by someone else. That is src/ops/image_ops.ts, line 69 at r1 (raw file):
no need to pass y, which means no need you have Comments from Reviewable |
Review status: all files reviewed at latest revision, 7 unresolved discussions, some commit checks failed. src/ops/resize_bilinear_test.ts, line 179 at r1 (raw file):
const size = [4, 4];
const alignCorners = false;
const g = tf.grad(image => tf.image.resizeBilinear(image, size, alignCorners));
g(image, dy); Comments from Reviewable |
Ready for re-review Review status: 1 of 7 files reviewed at latest revision, 8 unresolved discussions, some commit checks failed. src/kernels/backend_cpu.ts, line 1499 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Done. src/kernels/backend_cpu.ts, line 1514 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Not yet done. If this PR looks good i'd like to try do that in a separate PR (just so that this one doesn't delay in the mean time). src/kernels/webgl/resize_bilinear_backprop_gpu.ts, line 78 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Done. src/kernels/webgl/resize_bilinear_backprop_gpu.ts, line 79 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Done. src/ops/image_ops.ts, line 61 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Done. src/ops/image_ops.ts, line 67 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Done. src/ops/image_ops.ts, line 69 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Done. src/ops/resize_bilinear_test.ts, line 179 at r1 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Done. Comments from Reviewable |
Reviewed 6 of 6 files at r2. Comments from Reviewable |
Also fixes a bug in resizeBilinear.
This change is