-
Notifications
You must be signed in to change notification settings - Fork 2k
maintain single id tensor for each tensor list and tensor array #3479
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
Conversation
lina128
left a comment
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 @lina128 and @pyu10055)
tfjs-converter/src/executor/tensor_list.ts, line 104 at r1 (raw file):
assertShapesMatchAllowUndefinedSize( elementShape, this.elementShape, 'TensorList shape mismatch: '); // return tidy(() => {
Remove.
tfjs-converter/src/executor/tensor_list.ts, line 129 at r1 (raw file):
assertShapesMatchAllowUndefinedSize( tensor.shape, elementShape, 'TensorList shape mismatch: '); return tensor.reshape(elementShape);
Can we simply return tensor?
tfjs-converter/src/executor/tensor_list.ts, line 245 at r1 (raw file):
} return tidy(() => {
Can we also remove the reshape and tidy here?
tfjs-converter/src/executor/tensor_list.ts, line 269 at r1 (raw file):
} return tidy(() => {
Can we also remove the tidy and reshape?
pyu10055
left a comment
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 @lina128)
tfjs-converter/src/executor/tensor_list.ts, line 104 at r1 (raw file):
Previously, lina128 (Na Li) wrote…
Remove.
I have reverted the change, I think we still need to do the reshape, since the elementShape is an input, we need to honor that.
tfjs-converter/src/executor/tensor_list.ts, line 129 at r1 (raw file):
Previously, lina128 (Na Li) wrote…
Can we simply return tensor?
same reason as above.
tfjs-converter/src/executor/tensor_list.ts, line 245 at r1 (raw file):
Previously, lina128 (Na Li) wrote…
Can we also remove the reshape and tidy here?
same reason as above.
tfjs-converter/src/executor/tensor_list.ts, line 269 at r1 (raw file):
Previously, lina128 (Na Li) wrote…
Can we also remove the tidy and reshape?
same.
lina128
left a comment
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 @lina128 and @pyu10055)
tfjs-converter/src/executor/tensor_list.ts, line 104 at r1 (raw file):
Previously, pyu10055 (Ping Yu) wrote…
I have reverted the change, I think we still need to do the reshape, since the elementShape is an input, we need to honor that.
But you have asserted elementShape === this.elementShape. This is basically saying I only allow the elementShape to be the tensor's original elementShape. So below logic is correct, but is unnecessary?
tfjs-converter/src/executor/tensor_list.ts, line 53 at r2 (raw file):
*/ constructor( readonly tensors: Tensor[], readonly elementShape: number[],
Should we check whether the tensors truly have the elementShape and elementDtype?
lina128
left a comment
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 @lina128 and @pyu10055)
tfjs-converter/src/executor/tensor_list.ts, line 245 at r1 (raw file):
Previously, pyu10055 (Ping Yu) wrote…
same reason as above.
Either way, should we keep consistent with tensor_array.ts? https://github.com/tensorflow/tfjs/blob/master/tfjs-converter/src/executor/tensor_array.ts#L205
pyu10055
left a comment
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 @lina128)
tfjs-converter/src/executor/tensor_list.ts, line 104 at r1 (raw file):
Previously, lina128 (Na Li) wrote…
But you have asserted elementShape === this.elementShape. This is basically saying I only allow the elementShape to be the tensor's original elementShape. So below logic is correct, but is unnecessary?
the check is compatible, they don't have to be exactly the same.
tfjs-converter/src/executor/tensor_list.ts, line 245 at r1 (raw file):
Previously, lina128 (Na Li) wrote…
Either way, should we keep consistent with tensor_array.ts? https://github.com/tensorflow/tfjs/blob/master/tfjs-converter/src/executor/tensor_array.ts#L205
TensorArray is slightly different, since there is no target tensor shape for any of these ops.
tfjs-converter/src/executor/tensor_list.ts, line 53 at r2 (raw file):
Previously, lina128 (Na Li) wrote…
Should we check whether the tensors truly have the elementShape and elementDtype?
good point.
lina128
left a comment
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:
complete! 1 of 1 approvals obtained (waiting on @lina128 and @pyu10055)
tfjs-converter/src/executor/tensor_list.ts, line 104 at r1 (raw file):
Previously, pyu10055 (Ping Yu) wrote…
the check is compatible, they don't have to be exactly the same.
Ah, I see. So the original size may have -1, the passed in elementShape gives the actual shape. Thanks for the explanation.
This will reduce tensor creation and possible tensor data read.
To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.
This change is