Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Fix a bug with slice in webgl backend #1655

Merged
merged 2 commits into from
Mar 30, 2019
Merged

Fix a bug with slice in webgl backend #1655

merged 2 commits into from
Mar 30, 2019

Conversation

dsmilkov
Copy link
Contributor

@dsmilkov dsmilkov commented Mar 30, 2019

Fixing a bug in the WebGL backend where we can release a texture upon reading it, regardless of whether it was sliced or not. In js code:

const a = tf.tensor([1, 2]);
const b = a.slice([0]);
await a.read(); // Would release the texture to the manager.
await b.read(); // Would still work by chance since it holds the pointer to the `WebGLTexture` and the texture manager hasn't reused it yet.

The fix removes all direct calls to this.releaseTexture() and wraps releaseTexture() in a smarter this.releaseGPUData() which will check if there are sliced tensors depending on it before releasing.

Added a unit test that reproduced the issue and is now passing.

BUG


This change is Reviewable

@dsmilkov dsmilkov requested a review from nsthorat March 30, 2019 16:04
Copy link
Contributor

@nsthorat nsthorat left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @nsthorat)

@dsmilkov dsmilkov changed the title Fix a bug (memory leak) with slice Fix a bug with slice in webgl backend Mar 30, 2019
@dsmilkov dsmilkov merged commit b5660e2 into master Mar 30, 2019
@dsmilkov dsmilkov deleted the fix-bug-slice branch March 30, 2019 17:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants