Skip to content

Implement load_into for SharedPtrDataLoader and add test (#11562) #11707

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Tanish2101
Copy link

Summary:
Implemented the load_into method for SharedPtrDataLoader to support copying preallocated buffer data into a target buffer. This enables use cases where mutable model state has a meaningful initial value (e.g., on-device training or serialized read-before-write data).

Fixes
Fixes #11562

Test plan:
Added a unit test in shared_ptr_data_loader_test.cpp to verify that load_into():

  1. Copies the correct data for valid offset/size.
  2. Fails properly on invalid requests (e.g., out-of-bounds reads).

Copy link

pytorch-bot bot commented Jun 15, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/11707

Note: Links to docs will display an error until the docs builds have been completed.

❌ 6 New Failures

As of commit fea2310 with merge base 56392aa (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot
Copy link
Contributor

Hi @Tanish2101!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@Tanish2101
Copy link
Author

@pytorchbot label "release notes: none"

@pytorch-bot pytorch-bot bot added the release notes: none Do not include this in the release notes label Jun 15, 2025
@Tanish2101 Tanish2101 closed this Jun 15, 2025
@Tanish2101 Tanish2101 reopened this Jun 15, 2025
@Tanish2101
Copy link
Author

Hi @JacobSzwejbka, I created a PR for this issue. This is the first time I am contributing to executorch. Please Let me know if there are any changes required.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 15, 2025
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@mergennachin
Copy link
Contributor

Hi @Tanish2101

Thank you for the contribution. Looks like @keyprocedure has started the PR for the same task (#11654)

@Tanish2101
Copy link
Author

I have implemented the load_into() function for shared_ptr data loader so the implementation done by @keyprocedure for mmap data loader is sufficient? means there is no need for seperate implementation for shared_ptr ?

@mergennachin

@Tanish2101
Copy link
Author

So now what should I do? means should I close the pull request which I have created for this issue? Let me know @mergennachin


ET_NODISCARD executorch::runtime::Result<size_t> size() const override {
return size_;
}

ET_NODISCARD executorch::runtime::Error SharedPtrDataLoader::load_into(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you merge the declaration and implementation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: none Do not include this in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement load_into for the shared_ptr data loader
4 participants