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

Commit a215cc6

Browse files
committed
build: add a submodule for CX10 handling just the modules
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.
1 parent e03ad18 commit a215cc6

File tree

6 files changed

+23
-0
lines changed

6 files changed

+23
-0
lines changed

Package.swift

+4
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,16 @@ let package = Package(
4343
.target(
4444
name: "CTensorFlow",
4545
dependencies: []),
46+
.target(
47+
name: "CX10Modules",
48+
dependencies: []),
4649
.target(
4750
name: "TensorFlow",
4851
dependencies: [
4952
"Tensor",
5053
"PythonKit",
5154
"CTensorFlow",
55+
"CX10Modules",
5256
.product(name: "Numerics", package: "swift-numerics"),
5357
],
5458
swiftSettings: [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../CX10/device_wrapper.h
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../CX10/module.modulemap
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../CX10/xla_tensor_tf_ops.h
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../CX10/xla_tensor_wrapper.h

Sources/CX10Modules/shim.c

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
extern int _;

0 commit comments

Comments
 (0)