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

Swift and/or Objective-C Bindings #8263

Open
GregoryComer opened this issue Feb 6, 2025 · 3 comments
Open

Swift and/or Objective-C Bindings #8263

GregoryComer opened this issue Feb 6, 2025 · 3 comments
Assignees
Labels
feature A request for a proper, new feature. module: ios Issues related to iOS code, build, and execution module: user experience Issues related to reducing friction for users triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Milestone

Comments

@GregoryComer
Copy link
Member

GregoryComer commented Feb 6, 2025

🚀 The feature, motivation and pitch

From experience working with internal teams, many mobile developers prefer working with higher-level languages, when possible. It would likely benefit the user experience if we can provide Swift and/or Objective-C bindings as part of framework, likely under the Apple extension. I don't have a ton of context on developer ergonomics of calling the native C++ APIs from Swift or Objective-C, so I'll defer to the experts on this (@shoumikhin). However, given that it has been requested a few times, I think it's worth evaluating having official bindings for Swift, at least.

Alternatives

No response

Additional context

No response

RFC (Optional)

No response

cc @shoumikhin @mergennachin @byjlw

@GregoryComer GregoryComer added module: ios Issues related to iOS code, build, and execution module: user experience Issues related to reducing friction for users labels Feb 6, 2025
@GregoryComer GregoryComer moved this from To triage to Ready in ExecuTorch DevX improvements Feb 6, 2025
@GregoryComer GregoryComer moved this from Ready to To triage in ExecuTorch DevX improvements Feb 6, 2025
@mergennachin
Copy link
Contributor

@GregoryComer - we do have such bindings as documented here: https://pytorch.org/executorch/stable/apple-runtime.html

What are the actual gaps?

cc @shoumikhin

@shoumikhin
Copy link
Contributor

@mergennachin I guess @GregoryComer means bindings beyond logging. As explained in the doc, we currently support only logging APis in ObjC/Swift, and what we want eventually is such native bindings for Module and Tensor too. I've been actually working on a prototype and have it working now, so that the users can write pure Swift code like:

let module = Module(filePath: "/path/to/add.pte")
let inputs = [Tensor([2]), Tensor([3])]
let outputs = try module.forward(inputs)
XCTAssertEqual(outputs[0].tensor, Tensor([5]))

@digantdesai digantdesai added triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module feature A request for a proper, new feature. labels Feb 6, 2025
@mergennachin mergennachin added this to the 0.6.0 milestone Feb 6, 2025
@mergennachin mergennachin moved this from To triage to Ready in ExecuTorch DevX improvements Feb 6, 2025
@GregoryComer
Copy link
Member Author

@shoumikhin Sounds great. native Swift APIs I think would be very nice. Some internal teams have asked for this, which was the motivation for this feature request. I think it will help reduce onboarding friction for iOS devs since it seems like many devs don't want to touch C++.

@mergennachin mergennachin moved this from Ready to In progress in ExecuTorch DevX improvements Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A request for a proper, new feature. module: ios Issues related to iOS code, build, and execution module: user experience Issues related to reducing friction for users triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
Status: In progress
Development

No branches or pull requests

4 participants