[caffe2] use AddNAlreadyReserved() when serializing blobs#53400
Closed
simpkins wants to merge 2 commits intogh/simpkins/3/basefrom
Closed
[caffe2] use AddNAlreadyReserved() when serializing blobs#53400simpkins wants to merge 2 commits intogh/simpkins/3/basefrom
simpkins wants to merge 2 commits intogh/simpkins/3/basefrom
Conversation
This is a reland of D26617038 after rebasing onto D26802576. Optimize the blob serialization code by using `AddNAlreadyReserved()` when serializing tensor data, rather than making N separate `Add()` calls. `AddNAlreadyReserved()` is a simple addition operation, while each `Add()` call checks to see if it needs to reserve new space, and then updates the element data, which is unnecessary in this case. Differential Revision: [D26853941](https://our.internmc.facebook.com/intern/diff/D26853941/) [ghstack-poisoned]
Contributor
💊 CI failures summary and remediationsAs of commit 2ae6940 (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions to the (internal) Dr. CI Users group. |
This was referenced Mar 5, 2021
This is a reland of D26617038 after rebasing onto D26802576. Optimize the blob serialization code by using `AddNAlreadyReserved()` when serializing tensor data, rather than making N separate `Add()` calls. `AddNAlreadyReserved()` is a simple addition operation, while each `Add()` call checks to see if it needs to reserve new space, and then updates the element data, which is unnecessary in this case. Differential Revision: [D26853941](https://our.internmc.facebook.com/intern/diff/D26853941/) [ghstack-poisoned]
This was referenced Mar 10, 2021
Contributor
|
This pull request has been merged in 99d7c8f. |
xsacha
pushed a commit
to xsacha/pytorch
that referenced
this pull request
Mar 31, 2021
) Summary: Pull Request resolved: pytorch#53400 This is a reland of D26617038 (pytorch@b4a8d98) after rebasing onto D26802576 (pytorch@f595ba1). Optimize the blob serialization code by using `AddNAlreadyReserved()` when serializing tensor data, rather than making N separate `Add()` calls. `AddNAlreadyReserved()` is a simple addition operation, while each `Add()` call checks to see if it needs to reserve new space, and then updates the element data, which is unnecessary in this case. ghstack-source-id: 123567030 Test Plan: This appears to improve raw serialization performance by 30 to 35% for float, double, and int64_t types which use this function. This improvement appears relatively consistent across large and small tensor sizes. Reviewed By: mraway Differential Revision: D26853941 fbshipit-source-id: 4ccaa5bc1dd7f7864068d71a0cde210c699cbdba
laurentdupin
pushed a commit
to laurentdupin/pytorch
that referenced
this pull request
Apr 24, 2026
) Summary: Pull Request resolved: pytorch#53400 This is a reland of D26617038 (pytorch@aff01bc) after rebasing onto D26802576 (pytorch@2fad0d9). Optimize the blob serialization code by using `AddNAlreadyReserved()` when serializing tensor data, rather than making N separate `Add()` calls. `AddNAlreadyReserved()` is a simple addition operation, while each `Add()` call checks to see if it needs to reserve new space, and then updates the element data, which is unnecessary in this case. ghstack-source-id: 123567030 Test Plan: This appears to improve raw serialization performance by 30 to 35% for float, double, and int64_t types which use this function. This improvement appears relatively consistent across large and small tensor sizes. Reviewed By: mraway Differential Revision: D26853941 fbshipit-source-id: 4ccaa5bc1dd7f7864068d71a0cde210c699cbdba
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack:
This is a reland of D26617038 after rebasing onto D26802576.
Optimize the blob serialization code by using
AddNAlreadyReserved()whenserializing tensor data, rather than making N separate
Add()calls.AddNAlreadyReserved()is a simple addition operation, while eachAdd()call checks to see if it needs to reserve new space, and then updates the
element data, which is unnecessary in this case.
Differential Revision: D26853941