Skip to content
This repository was archived by the owner on Mar 30, 2022. It is now read-only.

SIMD static functions only on S4TF toolchain #404

Closed
porterchild opened this issue Mar 12, 2020 · 5 comments
Closed

SIMD static functions only on S4TF toolchain #404

porterchild opened this issue Mar 12, 2020 · 5 comments

Comments

@porterchild
Copy link
Contributor

On the S4TF toolchain, I can use static transcendental functions on SIMD types like this:
let powSimd = SIMD2.pow(mySimd, 2)

On the normal Xcode toolchain, this is not available. A cursory exploration suggests that on the S4TF toolchain, SIMD types have been conformed to ElementaryFunctions, which is part of the Numerics library (is that true?).

Is there a way to get these functions on the normal Xcode toolchain? Are they on track to be mainlined? Are they only implemented on S4TF so far? import Numerics doesn't seem to give me those functions.

@dan-zheng
Copy link
Member

Here's some context regarding ElementaryFunctions:

ElementaryFunctions protocol and conformances were added but then removed from apple/swift master branch. It's since been moved to apple/swift-numerics.

ElementaryFunctions protocol and conformances were manually re-added to apple/swift tensorflow branch because tensorflow/swift-apis optimizers depend on it. tensorflow branch also provides ElementaryFunctions derived conformances (examples): we haven't taken time to pitch this via Swift Evolution to master branch yet.


Is there a way to get these functions on the normal Xcode toolchain? Are they on track to be mainlined? Are they only implemented on S4TF so far? import Numerics doesn't seem to give me those functions.

When ElementaryFunctions was moved from master branch to apple/swift-numerics, the SIMD{n} conformances appear to have been dropped. I asked about re-adding those conformances to apple/swift-numerics: apple/swift-numerics#103

All surprising behavior is due to ad-hoc differences between apple/swift tensorflow branch vs master branch. We should consider ways to eliminate these differences: adding apple/swift-numerics as an official dependency to tensorflow/swift-apis, pitching and upstreaming ElementaryFunctions derived conformances, etc.

@porterchild
Copy link
Contributor Author

Could you point me to the code to do this?:

ElementaryFunctions protocol and conformances were manually re-added to apple/swift tensorflow branch

Would that just be a copy paste to add manually if I want to use those functions on the regular Xcode toolchain?

@dan-zheng
Copy link
Member

Sure, here's the gyb'd code for SIMD{n}: ElementaryFunctions conformances.
Here's the expanded Swift code, I generated it locally on macOS.

Would that just be a copy paste to add manually if I want to use those functions on the regular Xcode toolchain?

Yes, I believe so. This code probably won't work with S4TF toolchains though due to redefinition errors.

@porterchild
Copy link
Contributor Author

Thanks Dan!

@dan-zheng
Copy link
Member

Closing now, since the original question is really a feature request for apple/swift-numerics: apple/swift-numerics#103.

Is there a way to get these functions on the normal Xcode toolchain? Are they on track to be mainlined? Are they only implemented on S4TF so far? import Numerics doesn't seem to give me those functions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants