Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

build: enable building X10 support with SPM #1176

Merged
merged 2 commits into from
Jan 6, 2021

Conversation

compnerd
Copy link
Contributor

@compnerd compnerd commented Jan 5, 2021

Enable building the Swift interfaces for X10 with SPM. This effectively
hard-enables X10 support in TensorFlow as SPM does not provide
configuration.

In order to accomplish this, we need to create symbolic links to sources
in order to merge the x10 sources into the TensorFlow module. It is
not possible to simply move the sources to reflect this structure due to
out-of-tree use cases.

@@ -50,6 +50,10 @@ let package = Package(
"PythonKit",
"CTensorFlow",
.product(name: "Numerics", package: "swift-numerics"),
],
swiftSettings: [
.define("USING_X10_BACKEND"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From offline discussion: it seems like we can remove the USING_X10_BACKEND flag and checks soon, since that is the only path forward for enabling SwiftPM builds for tensorflow/swift-apis.

],
swiftSettings: [
.define("USING_X10_BACKEND"),
.define("DEFAULT_BACKEND_EAGER"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's possible to eventually enable non-DEFAULT_BACKEND_EAGER builds via SwiftPM?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible, but requires an API break; I'd want such a switch to be planned (and communicated) prior to executing.

Enable building the Swift interfaces for X10 with SPM.  This effectively
hard-enables X10 support in TensorFlow as SPM does not provide
configuration.

In order to accomplish this, we need to create symbolic links to sources
in order to merge the `x10` sources into the TensorFlow module.  It is
not possible to simply move the sources to reflect this structure due to
out-of-tree use cases.
The CX10 module setup is currently very complicated.  The module is
built twice - once via bazel and incorporated into the TensorFlow
library.  The second build is built via Swift for the modules to import
the interfaces into Swift.  In order to build the swift bindings via
SPM, we need to extract the sources.  However, we cannot reorganise the
CX10 subdirectory to enable SPM to filter out just the modules.  As a
result, we create a `CX10Modules` module that is only built when
building with SPM.  CMake builds will ignore this directory, building
the modules from the CX10 directory directly as it can handle the
subdirectory layout.
@dan-zheng
Copy link
Member

dan-zheng commented Jan 6, 2021

Intentionally merging commits separately for separation of concerns.

@dan-zheng dan-zheng merged commit eebf3c7 into tensorflow:main Jan 6, 2021
@compnerd compnerd deleted the x10-spm branch January 6, 2021 00:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants