-
Notifications
You must be signed in to change notification settings - Fork 0
Migrate iOS app demo #6
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
How is it different than this? https://github.com/pytorch-labs/executorch-examples/blob/main/apple/ExecuTorchDemo/README.md |
The structure of https://github.com/pytorch-labs/executorch-examples/blob/main/apple/ExecuTorchDemo/README.md (let's call it ExecuTorchDemo README) is different from the original docs which are reflected in the PyTorch page. I followed the structure and comments of the original docs and the PyTorch page, which match. E.g.: ExecuTorch README directly states to clone the ExecuTorch GitHub repo under Models and Labels section. Plus other comments like the first line welcoming the user as in the PyTorch demo docs page. |
@nil-is-all any updates here since we last talked? |
Hi @mergennachin, I made the changes for the export script, and edited the "export model" section, and completed other changes such as adding instructions for swiftPM package and editing the directory paths. Seems PyTorch was deprecated for intel macbooks, so I am looking to test this out before pushing on GitHub. |
Any updates @nil-is-all ? We're not making this repo public until your change. |
Any updates @nil-is-all ? |
@mergennachin sorry for the delay in response. I faced an issue while installing torch from source, posted it on #support channel in our Discord server too. Seems it is an open issue. I get the new mac tomorrow. While looking at ways to install, if it does not succeed, I will setup the mac and run local test tomorrow. |
Any updates @nil-is-all ? We need to finalize this ASAP Please use this directory https://github.com/pytorch-labs/executorch-examples/tree/main/mv2 |
Hey @mergennachin, been posting my current status on Discord. There is a current issue with the MPS Backend model which fails with a dim_order check. @digantdesai opened a new issue related to this. I tried pushing the xcodeproj for the other two backend models by commenting out for MPS, but the current code expects all 3 backends, which @shoumikhin stated on discord. I'm awaiting his response on what changes to make to currently test just for the XNNPack and CoreML, as well as other comments I have posted in the #executorch-just-works Discord channel. TL:DR - ready to locally test on xcode, all pre-requisites met and models exported other than MPS Backend. |
Also @mergennachin, are we not using MobileNetV3? Your comment here also reiterated using this structure for mv3 |
mv3/apple/ExecuTorchDemo/export.py
Outdated
@@ -0,0 +1,48 @@ | |||
#!/usr/bin/env python |
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.
move this file to mv3/python/export.py
mv3/apple/ExecuTorchDemo/README.md
Outdated
```bash | ||
import torch | ||
import torchvision.models as models | ||
from executorch.backends.apple.coreml.partition import CoreMLPartitioner | ||
from executorch.backends.apple.mps.partition import MPSPartitioner | ||
from executorch.exir.backend.backend_details import CompileSpec | ||
from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner | ||
from executorch.exir import to_edge_transform_and_lower | ||
import ssl | ||
import certifi | ||
|
||
|
||
def main() -> None: | ||
model = models.mobilenet_v3_small(weights="DEFAULT").eval() | ||
sample_inputs = (torch.randn(1, 3, 224, 224),) | ||
|
||
et_program_coreml = to_edge_transform_and_lower( | ||
torch.export.export(model, sample_inputs), | ||
partitioner=[CoreMLPartitioner()], | ||
).to_executorch() | ||
|
||
et_program_mps = to_edge_transform_and_lower( | ||
torch.export.export(model, sample_inputs), | ||
partitioner=[MPSPartitioner([CompileSpec("use_fp16", bytes([True]))])], | ||
).to_executorch() | ||
|
||
et_program_xnnpack = to_edge_transform_and_lower( | ||
torch.export.export(model, sample_inputs), | ||
partitioner=[XnnpackPartitioner()], | ||
).to_executorch() |
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.
no need to copy paste the whole code, just reference to the export.py file
Are we moving the app or duplicating it? |
The initial idea was to move from executorch/examples to here. The former directory has already been shifted to executorch-examples/apple/ExecuTorchDemo. Once this is up, executorch-examples/apple/ExecuTorchDemo can be removed. |
@nil-is-all please don't duplicate. do the movement atomically. do 'git mv' command so that it preserves history. |
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.
Do 'git mv' instead of copying.
@mergennachin just to confirm the final directory, do I git mv the current |
a626921
to
139392c
Compare
author Nikhil Viswanath Sivakumar <68182521+nil-is-all@users.noreply.github.com> 1741841357 -0500 committer Nikhil Viswanath Sivakumar <nikhilviswanath@meta.com> 1745433893 -0500 Migrate iOS Demo App parent 5021c18 author Nikhil Viswanath Sivakumar <68182521+nil-is-all@users.noreply.github.com> 1741841357 -0500 committer Nikhil Viswanath Sivakumar <nikhilviswanath@meta.com> 1745433648 -0500 Migrate iOS Demo App Migrate iOS app demo as README.md Reproduced https://github.com/pytorch/executorch/tree/main/examples/demo-apps/apple_ios/ExecuTorchDemo and added last line in docs to point to this GitHub repo Changed file path to executorch-examples/mv3/apple/MobileNetV3Demo/README.md Changed directory and made changes after local testing Final directory: executorch-examples/mv3/apple/ExecuTorchDemo Changes from [current demo](https://pytorch.org/executorch/main/demo-apps-ios.html#): 1) Check Swift Package Manager version under Prerequisites 2) Export Model - export.py for backends 3) Directory changes in Final Steps Files for iOS MV3 Demo App export script for MV3.pte and XNNPack, CoreML, MPS backends Update README.md Rename mv3/apple/ExecuTorchDemo/export.py to mv3/apple/ExecuTorchDemo/python/export.py Removed export.py code block from README.md Added code formatting for Clone the Demo App subsection added snapshot url Delete mv3/apple/ExecuTorchDemo/ExecuTorchDemo/Resources/Models/MobileNet directory atomically migrated apple/ExecuTorch to mv3/apple/ExecuTorchDemo Updated directory structure to have python in mv3 folder fixed typo in .gitignore Update project.pbxproj to pin to 0.6.0 (#11) MV2 cpp and python example (#13) Update README.md (#12) * Update README.md * Update README.md fix directory and resolve conflicts MV2 cpp and python example (#13) Update .gitignore (#17)
139392c
to
a6d2321
Compare
Reproduced https://github.com/pytorch/executorch/tree/main/examples/demo-apps/apple_ios/ExecuTorchDemo and added last line in docs to point to this GitHub repo