-
Notifications
You must be signed in to change notification settings - Fork 943
Avoid disposing intermediate tensor in grad #1013
Avoid disposing intermediate tensor in grad #1013
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.
Thanks for looking into this!
src/tensor_test.ts
Outdated
const x = tf.tensor1d([2, 3]); | ||
const data = gg(x).dataSync(); | ||
|
||
expect(data[0]).toEqual(12); |
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.
Please use the same syntax for checking both data[0] and data[1]
Review status: 0 of 2 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed. src/gradients.ts, line 146 at r1 (raw file):
ah this is going to introduce a memory leak, but your obversation is absolutely correct. Can you do this with a tf.tidy() instead of the dispose? src/tensor_test.ts, line 1103 at r1 (raw file): Previously, bileschi (Stanley Bileschi) wrote…
You should use expectArraysClose. This method can assert a tensor and a vanilla JS array have the same values. Comments from Reviewable |
Review status: 0 of 2 files reviewed at latest revision, 2 unresolved discussions, some commit checks failed. src/gradients.ts, line 146 at r1 (raw file): Previously, nsthorat (Nikhil Thorat) wrote…
To be clearer:
Comments from Reviewable |
0666775
to
022180e
Compare
Reviewed 1 of 2 files at r1. Comments from Reviewable |
Reviewed 1 of 2 files at r2. src/tensor_test.ts, line 1093 at r2 (raw file):
can you move this test outside of the Comments from Reviewable |
Review status: 1 of 2 files reviewed at latest revision, 3 unresolved discussions, some commit checks failed. src/tensor_test.ts, line 1093 at r2 (raw file): Previously, dsmilkov (Daniel Smilkov) wrote…
Oh, good catch. I'm wondering why the test keeps failing. Thanks I'm going to fix it. Comments from Reviewable |
1109618
to
c361ee2
Compare
Purpose
Fix tensorflow/tfjs#227.
As well as other ops,
grad
should not dispose intermediate result. We should be able to calldispose
explicitly or usetidy
in such case.This change is