Skip to content
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

Improve assertAndGetBroadcastShape #7413

Merged
merged 2 commits into from
Feb 24, 2023
Merged

Conversation

Linchenn
Copy link
Collaborator

@Linchenn Linchenn commented Feb 24, 2023

According to https://jsbench.me/bmlehvit9v/1, push is far faster than unshift.

image
assertAndGetBroadcastShape2 is after this PR.

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.


This change is Reviewable

Copy link
Member

@mattsoulanille mattsoulanille left a comment

Choose a reason for hiding this comment

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

LGTM. This does not appear to be using push() anymore, and instead is using array indexing. I assume this is faster than push() since it doesn't need to resize the array every so often.

Copy link
Collaborator Author

@Linchenn Linchenn left a comment

Choose a reason for hiding this comment

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

Yes, even if I remove reverse(), this is still 20% faster than push() way.

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

@Linchenn Linchenn merged commit 8173c01 into tensorflow:master Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants