Skip to content

[ExecuTorch][#9638] Introduce Protected Method Getter in Extension.Module #10384

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

Merged
merged 1 commit into from
Apr 24, 2025

Conversation

pytorchbot
Copy link
Collaborator

This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #10374 by @zhenyan-zhang-meta
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/zhenyan-zhang-meta/4/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/zhenyan-zhang-meta/4/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/main
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/zhenyan-zhang-meta/4/orig
@diff-train-skip-merge

…dule

# Context

This issue is a step of #9638. In the discussion, we want to unblock having `extension/Module` as the single source of implementation, which means that `pybindings/PyModule` should use `extension/Module` rather than its own.

Although we are decouping method getter from `pybindings` implementation, method getter itself is still needed. To keep having the method getter while not exposing it, we can create a protected method getter and confine it's usage inside child classes that we are about to create.

# Proposal

Add a protected `get_method` to `extension.Module`, taking method name string as an input.

Differential Revision: [D73473766](https://our.internmc.facebook.com/intern/diff/D73473766/)

ghstack-source-id: 279669340
Pull Request resolved: #10374
@pytorchbot pytorchbot requested a review from shoumikhin as a code owner April 23, 2025 09:36
Copy link

pytorch-bot bot commented Apr 23, 2025

🔗 Helpful Links

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

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

❌ 2 New Failures

As of commit 52346ae with merge base 95c663e (image):

NEW FAILURES - The following jobs have failed:

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

@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 Apr 23, 2025
Copy link

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@jackzhxng jackzhxng merged commit 039b843 into main Apr 24, 2025
162 of 165 checks passed
@jackzhxng jackzhxng deleted the gh/zhenyan-zhang-meta/4/orig branch April 24, 2025 00:29
@@ -302,5 +302,15 @@ runtime::Error Module::set_output(
output_tensor.mutable_data_ptr(), output_tensor.nbytes(), output_index);
}

ET_NODISCARD inline runtime::Result<Method*> Module::get_method(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to expose the Method? Can we make some ivars protected instead and let subclasses work with them directly, like this class itself?
Also, there's no get_-prefix naming convention for this class, it should be named just "method()", if really needed.

Copy link
Contributor

@zhenyan-zhang-meta zhenyan-zhang-meta Apr 24, 2025

Choose a reason for hiding this comment

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

Method is needed for a child class. I think I can move the function to the child class since the methods_ is already protected and the parent class is not using the function I introduced.

Copy link
Contributor

Choose a reason for hiding this comment

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

@shoumikhin that should my fault i misread the scope of method list as private so I asked to put the function here.
Since it is protected, making it as a child’s private function should be a better choice.

Copy link
Contributor

Choose a reason for hiding this comment

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

Now worries, you should be able to access Method via methods_.at(method_name).method in subclasses indeed.

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants