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

ensure webgl backend read downloads converted typedarray #1382

Merged
merged 3 commits into from
Nov 7, 2018

Conversation

tafsiri
Copy link
Contributor

@tafsiri tafsiri commented Nov 7, 2018

Fixes a bug where async downloading of a tensor that was uploaded to the GPU would always return a Float32Array.

BUG


This change is Reviewable

@tafsiri tafsiri requested a review from nsthorat November 7, 2018 20:42
Copy link
Contributor Author

@tafsiri tafsiri left a 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 @nsthorat)


src/kernels/backend_webgl.ts, line 341 at r1 (raw file):

          bufferOrTexture, texShape[0], texShape[1]);
    }
    this.cacheOnCPU(dataId, vals);

What would folks think about having cacheOnCPU return the value that gets cached. (i.e. texData.values) since it might do some transformation on it? Might make it easier to predict what it does from skimming. Or calling it convertAndCacheOnCPU or something like that.

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: 0 of 1 approvals obtained (waiting on @tafsiri and @nsthorat)


src/kernels/backend_webgl.ts, line 341 at r1 (raw file):

Previously, tafsiri (Yannick Assogba) wrote…

What would folks think about having cacheOnCPU return the value that gets cached. (i.e. texData.values) since it might do some transformation on it? Might make it easier to predict what it does from skimming. Or calling it convertAndCacheOnCPU or something like that.

Yeah that sounds great, stamping but go ahead with that.

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.

Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @tafsiri)


src/kernels/backend_webgl.ts, line 338 at r2 (raw file):

          bufferOrTexture, texShape[0], texShape[1]);
    }
    const dTypeVals: TypedArray = this.convertAndCacheOnCPU(dataId, vals);

you shouldn't have to explicitly type this as TypedArray

also just call this values?

Copy link
Contributor Author

@tafsiri tafsiri left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @tafsiri and @nsthorat)


src/kernels/backend_webgl.ts, line 338 at r2 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

you shouldn't have to explicitly type this as TypedArray

also just call this values?

We already have a values above. and vals is already on cpu, so i went with dTypeVals to indicate it has the right dtype (though its really the typed array type). Thoughts?

I'll drop the explicit typing, i had put it in as an extra signal to the diff between vals and dtypeValues.

@tafsiri tafsiri merged commit 0e01701 into master Nov 7, 2018
@dsmilkov dsmilkov deleted the async-download-int32 branch November 20, 2018 16:10
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