-
Notifications
You must be signed in to change notification settings - Fork 149
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
Add tensorflow/swift-apis as a SwiftPM dependency. #727
base: main
Are you sure you want to change the base?
Conversation
This enables building tensorflow/swift-models using stock toolchains from swift.org/download.
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.
The review comments are basically a styling nit.
.target(name: "ImageClassificationModels", path: "Models/ImageClassification"), | ||
.target(name: "VideoClassificationModels", path: "Models/Spatiotemporal"), | ||
.target(name: "TextModels", | ||
name: "ModelSupport", dependencies: ["TensorFlow", "STBImage"], path: "Support", |
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.
While doing this, it might be nice to format this as:
.target(
name: "ModelSupport",
dependencies: [
"TensorFlow",
"STBImage",
],
path: "Support"),
and similarly throughout. It makes it easier to read at a glance due to the one-item per line. It also makes future changes trivial to read.
I can confirm the same run failure locally: swift-linear-regression % swift run -Xswiftc -DTENSORFLOW_USE_STANDARD_TOOLCHAIN -Xcc -I/Library/tensorflow-2.4.0/usr/include -Xlinker -L/Library/tensorflow-2.4.0/usr/lib
dyld: Library not loaded: @rpath/libx10.dylib
Referenced from: /Users/Alexey_Novakov/dev/git/swift-linear-regression/.build/x86_64-apple-macosx/debug/libTensorFlow.dylib
Reason: image not found
zsh: abort swift run -Xswiftc -DTENSORFLOW_USE_STANDARD_TOOLCHAIN -Xcc -Xlinker |
That may be a different failure. _Differentiation should now load. You could try copying the libx10.dylib binary into the Swift build products folder after compiling. In addition, it should not be necessary to pass libx10 into the linker settings for |
Motivation
This enables building
tensorflow/swift-models
using stock toolchains from swift.org/download.swift build
will clone and buildtensorflow/swift-apis
as a regular SwiftPM dependency. Eventually, we would like to stop releasing custom toolchains bundled with pre-installedtensorflow/swift-apis
.Build instructions
It is possible to build
tensorflow/swift-apis
and dependencies liketensorflow/swift-models
using stock toolchains by installing pre-built X10 libraries (currently available only for macOS and Windows).After installing (e.g. to
$HOME/Library
on macOS), build with SwiftPM via the following:$ swift build -Xcc -I$HOME/Library/tensorflow-2.4.0/usr/include -Xlinker -L$HOME/Library/tensorflow-2.4.0/usr/lib -Xswiftc -DTENSORFLOW_USE_STANDARD_TOOLCHAIN
swift test
is known not to work on macOS fortensorflow/swift-apis
and dependencies due to SR-14008:Library not loaded: /usr/lib/swift/libswift_Differentiation.dylib
.Testing
Before merging, let's verify that
swift build
,swift run
, andswift test
works for swift.org/download toolchains across platforms:swift run
andswift test
currently both fail due to SR-14008: