XNNPACK icon indicating copy to clipboard operation
XNNPACK copied to clipboard

[Question] Contributing a Swift Package Manager build

Open ephemer opened this issue 2 months ago • 2 comments

Hello,

I have been working on Swift Package Manager build of XNNPack, so far for Web Assembly (with options for scalar, simd, relaxed-simd). I plan to expand this to support at least arm64, maybe other targets too. Would it be interesting for the project for me to upstream this work? Or should I keep it in a fork?

The biggest potential challenge is that the downloaded deps (cpuinfo, pthreadpool, fxdiv) still need to be downloaded from somewhere, which isn't natively supported by SwiftPM unless they're also SwiftPM packages (I'm unaware of anyone vending these particular libraries currently via SwiftPM but they might exist).

Let me know what you think.

ephemer avatar Oct 06 '25 20:10 ephemer

Thanks for the offer to upload. Certainly worth consideration. Is it reasonably simple? Would it benefit from support in the main stream xnnpack github?

If its not already, each dependency should be optional, but xnnpack works best if they are available.

fbarchard avatar Oct 08 '25 02:10 fbarchard

@fbarchard thanks for getting back to me.

The least simple part about it is that it’s necessary to write out the few hundred source files (per arch) and keep them in sync with the CMake build.

The only way to avoid that duplication and manual syncing would be to write a custom parser for CMake (not preferable), or to have both CMake and SwiftPM both populate their source lists from a simpler, common format. For example, one newline-separated .txt file containing the wasmsimd-prod sources, one .txt file containing corresponding dev sources, one for wasmsimd-relaxed-prod, -dev, and so on for the other architectures.

The latter would be trivial to implement but would mean a somewhat larger change for xnnpack‘s build. I am unsure how much turnover there is in the source definitions, so I’d be fine to initially leave it as a manual duplicate and sync task for now. Let me know what you think, or who I’d need to ask about that.

I’m still actively expanding on the supports architectures etc. in my own testing, so it probably makes sense to flesh that out further before making a PR here. But let me know whether you’d prefer to see a draft sooner than later.

ephemer avatar Oct 08 '25 20:10 ephemer