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

Pushing Rust bindings forward #21533

Open
6 tasks
Chiichen opened this issue Jul 28, 2024 · 6 comments
Open
6 tasks

Pushing Rust bindings forward #21533

Chiichen opened this issue Jul 28, 2024 · 6 comments
Labels
feature request request for unsupported feature or enhancement

Comments

@Chiichen
Copy link

Chiichen commented Jul 28, 2024

There has been a long discussion about adding Rust bindings to this repository( #11992 #7231), but I've noticed that there has been little progress on the Rust bindings since the initial PR #12606 . Here are some current to-do items that I think we can have some discussion around, and I'd be glad to make some contributions to push the Rust bindings forward.

@Chiichen
Copy link
Author

I'm not sure which member of the organization I should communicate with regarding the work on Rust Binding. I just noticed that you participated in previous discussions about Rust Binding, and I wanted to see what your thoughts are on this issue. @snnn @devigned @edgchen1

@snnn snnn added the feature request request for unsupported feature or enhancement label Jul 29, 2024
@snnn
Copy link
Member

snnn commented Jul 29, 2024

@pranavsharma / @sophies927, what do you think?

@cbourjau
Copy link
Contributor

Do the binding need to live in this repository? They target the stable C-API, after all, and this project already has a behemoth of a testing infrastructure. Having the bindings live in a different repository may make their development easier.

@Chiichen
Copy link
Author

Do the binding need to live in this repository? They target the stable C-API, after all, and this project already has a behemoth of a testing infrastructure. Having the bindings live in a different repository may make their development easier.

  • Currently, there are two mainstream libraries that provide Rust bindings for onnxruntime, one is [ort](https://github.com/pykeio/ort) and the other is [onnxruntime-rs](https://github.com/nbigaouette/onnxruntime-rs)

    • For the first one ort: It provides a high level onnxruntime API. However, it doesn't provide any directly low level bindings to onnxruntime. When you use this library, you can only use the pre-built onnxruntime library, and for some platforms (such as Android), you even have to build onnxruntime yourself. This library will not help you do any build work related to onnxruntime itself (these work is usually done by libraries like onnxruntime-sys in traditional rust binding libraries to provide low-level Rust APIs based on C APIs), and this library currently has no plans to support this feature (onnxruntime build)
    • For the second one onnxruntime-rs: It is no longer maintained and the code has been moved to the current project Add rust bindings #12606
  • Regarding why we don't maintain the Rust Binding in a separate repository, I believe the main reason is that starting a project from scratch makes it difficult to ensure long-term maintenance. This issue has been discussed in Coordinating Effort around a community run organization. From the perspective of continuous maintenance, having the binding maintained by the main repository (microsoft/onnxruntime) is the most beneficial choice for the community's development. Another reason is that the current repository already includes a significant portion of the Rust Binding work (mainly from onnxruntime-rs). It seems like a good choice to further develop based on the existing code.

@devigned
Copy link
Member

devigned commented Aug 1, 2024

This library will not help you do any build work related to onnxruntime itself (these work is usually done by libraries like onnxruntime-sys in traditional rust binding libraries to provide low-level Rust APIs based on C APIs)

@Chiichen does https://github.com/pykeio/ort/tree/main/ort-sys satisfy the build / low level access you are describing?

@Chiichen
Copy link
Author

Chiichen commented Aug 2, 2024

这个库不会帮你做任何与 onnxruntime 本身相关的构建工作(这些工作通常由传统 rust 绑定库中的 onnxruntime-sys 等库来完成,以提供基于 C API 的低级 Rust API)

@Chiichenhttps://github.com/pykeio/ort/tree/main/ort-sys是否满足您描述的构建/低级访问?

No, it doesn't. I hope that when I use onnxruntime-sys, it can directly help me build onnxruntime from source code, and link it into the rust program automatically. You will find that this library(ort-sys) does not contain the source code of onnxruntime at all. Actually, It does not build onnxruntime from source code, but directly links to the built onnxruntime static library by specifying ORT_LIB_LOCATION. This means that for the user of ort, he needs to build onnxruntime separately once, although it provides some pre-built binaries, but for some platforms (i.e Android), you still need to build it yourself. I've filed an issue (pykeio/ort#246) asking if they could add similar functionality, but they clearly marked it as not planned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request request for unsupported feature or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants