-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[webgl] Donot release tensor texture at reading #6932
Conversation
67e9f05
to
2092b59
Compare
15be4a4
to
c92eb52
Compare
c92eb52
to
8cacb0a
Compare
b0b690b
to
becf731
Compare
@qjia7 @xhcao @haoyunfeix @gyagp PTAL |
const {texture, dtype, texShape, usage, isPacked, slice} = | ||
this.texData.get(dataId); | ||
const key = slice && slice.origDataId || dataId; | ||
const refCount = this.dataRefCount.get(key); | ||
|
||
if (refCount > 1) { | ||
// When reading a tensor which has been shallow sliced, do nothing. | ||
if (slice == null && isRead) { |
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.
It seems that we shouldn't call releaseGPUData for read. Otherwise, for shallowSlice
tensor, we always meet problems like below case: (tensor.data()
and tensor.dispose()
will decrease tensor's ref count twice for the same tensor. If this tensor has a shallow sliced tensor, we will meet problem when access the shallow tensor's content since the underlying texture has been released.).
@lina128 @ping, can we just simply remove releaseGPUData there to fix this issue?
|
||
// Dispose b, but the texture should still remain on the GPU | ||
// since c points to it. | ||
b.dispose(); |
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.
Does your fix still work if you call await b.data(); b.dispose()
?
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.
yes
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: 0 of 1 approvals obtained (waiting on @axinging, @lina128, and @ping)
tfjs-backend-webgl/src/backend_webgl.ts
line 699 at r1 (raw file):
Previously, qjia7 (Jiajia Qin) wrote…
It seems that we shouldn't call releaseGPUData for read. Otherwise, for
shallowSlice
tensor, we always meet problems like below case: (tensor.data()
andtensor.dispose()
will decrease tensor's ref count twice for the same tensor. If this tensor has a shallow sliced tensor, we will meet problem when access the shallow tensor's content since the underlying texture has been released.).@lina128 @ping, can we just simply remove releaseGPUData there to fix this issue?
I agree that more robust approach will be to remove releaseGPUData from
convertAndCacheOnCPU call.
@axinging can you check if that approach also make your new tests pass? thanks
If simply do not release at reading, there has two test case need to be changed: BTW, I tested with with all e2e models, they all get passed. so I think both solution have small impact. |
becf731
to
48fb734
Compare
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.
LGTM, thanks.
@pyu10055, PTAL |
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 1 of 2 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: complete! 2 of 1 approvals obtained (waiting on @axinging, @lina128, @ping, and @qjia7)
Bug: #6920
This change is