diff --git a/Package.swift b/Package.swift index e489eccd4..a963094a6 100644 --- a/Package.swift +++ b/Package.swift @@ -43,13 +43,21 @@ let package = Package( .target( name: "CTensorFlow", dependencies: []), + .target( + name: "CX10Modules", + dependencies: []), .target( name: "TensorFlow", dependencies: [ "Tensor", "PythonKit", "CTensorFlow", + "CX10Modules", .product(name: "Numerics", package: "swift-numerics"), + ], + swiftSettings: [ + .define("USING_X10_BACKEND"), + .define("DEFAULT_BACKEND_EAGER"), ]), .target( name: "Experimental", diff --git a/Sources/CX10Modules/include/device_wrapper.h b/Sources/CX10Modules/include/device_wrapper.h new file mode 120000 index 000000000..c565cd3ed --- /dev/null +++ b/Sources/CX10Modules/include/device_wrapper.h @@ -0,0 +1 @@ +../../CX10/device_wrapper.h \ No newline at end of file diff --git a/Sources/CX10Modules/include/module.modulemap b/Sources/CX10Modules/include/module.modulemap new file mode 120000 index 000000000..1892e1e82 --- /dev/null +++ b/Sources/CX10Modules/include/module.modulemap @@ -0,0 +1 @@ +../../CX10/module.modulemap \ No newline at end of file diff --git a/Sources/CX10Modules/include/xla_tensor_tf_ops.h b/Sources/CX10Modules/include/xla_tensor_tf_ops.h new file mode 120000 index 000000000..e14658de2 --- /dev/null +++ b/Sources/CX10Modules/include/xla_tensor_tf_ops.h @@ -0,0 +1 @@ +../../CX10/xla_tensor_tf_ops.h \ No newline at end of file diff --git a/Sources/CX10Modules/include/xla_tensor_wrapper.h b/Sources/CX10Modules/include/xla_tensor_wrapper.h new file mode 120000 index 000000000..1f14d0ce9 --- /dev/null +++ b/Sources/CX10Modules/include/xla_tensor_wrapper.h @@ -0,0 +1 @@ +../../CX10/xla_tensor_wrapper.h \ No newline at end of file diff --git a/Sources/CX10Modules/shim.c b/Sources/CX10Modules/shim.c new file mode 100644 index 000000000..449151799 --- /dev/null +++ b/Sources/CX10Modules/shim.c @@ -0,0 +1,15 @@ +// Copyright 2019 The TensorFlow Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +extern int _; diff --git a/Sources/TensorFlow/Core/Device.swift b/Sources/TensorFlow/Core/Device.swift deleted file mode 100644 index cb985823a..000000000 --- a/Sources/TensorFlow/Core/Device.swift +++ /dev/null @@ -1,35 +0,0 @@ -/// A device on which `Tensor`s can be allocated. -/// -/// Currently, this is a stub because TensorFlow transfers tensors between devices on demand. -public struct Device { - public static var `default`: Device { Device() } - public static var defaultTFEager: Device { Device() } - - /// Backend used to dispatch the tensor operations. - public enum Backend { - case TF_EAGER - - fileprivate var shortName: String { - switch self { - case .TF_EAGER: return "TF_EAGER" - } - } - } -} - -extension Tensor { - /// The device on which `self` is allocated. - public var device: Device { - @_semantics("autodiff.nonvarying") - get { - return Device() - } - } -} - -extension _Raw { - static func toDevice(_ x: Tensor, _ device: Device) -> Tensor { - // TODO: Actually copy to device... - return x - } -} diff --git a/Sources/TensorFlow/X10/APIs/CrossReplicaSum.swift b/Sources/TensorFlow/X10/APIs/CrossReplicaSum.swift new file mode 120000 index 000000000..75326de1b --- /dev/null +++ b/Sources/TensorFlow/X10/APIs/CrossReplicaSum.swift @@ -0,0 +1 @@ +../../../x10/swift_bindings/apis/CrossReplicaSum.swift \ No newline at end of file diff --git a/Sources/TensorFlow/X10/APIs/DeviceScope.swift b/Sources/TensorFlow/X10/APIs/DeviceScope.swift new file mode 120000 index 000000000..b0f9117b6 --- /dev/null +++ b/Sources/TensorFlow/X10/APIs/DeviceScope.swift @@ -0,0 +1 @@ +../../../x10/swift_bindings/apis/DeviceScope.swift \ No newline at end of file diff --git a/Sources/TensorFlow/X10/APIs/RawOpsManual.swift b/Sources/TensorFlow/X10/APIs/RawOpsManual.swift new file mode 120000 index 000000000..591bb2ae4 --- /dev/null +++ b/Sources/TensorFlow/X10/APIs/RawOpsManual.swift @@ -0,0 +1 @@ +../../../x10/swift_bindings/apis/RawOpsManual.swift \ No newline at end of file diff --git a/Sources/TensorFlow/X10/Device.swift b/Sources/TensorFlow/X10/Device.swift new file mode 120000 index 000000000..46dc06205 --- /dev/null +++ b/Sources/TensorFlow/X10/Device.swift @@ -0,0 +1 @@ +../../x10/swift_bindings/Device.swift \ No newline at end of file diff --git a/Sources/TensorFlow/X10/RawOpsXLAGenerated.swift b/Sources/TensorFlow/X10/RawOpsXLAGenerated.swift new file mode 120000 index 000000000..092ebabda --- /dev/null +++ b/Sources/TensorFlow/X10/RawOpsXLAGenerated.swift @@ -0,0 +1 @@ +../../x10/swift_bindings/RawOpsXLAGenerated.swift \ No newline at end of file diff --git a/Sources/TensorFlow/X10/XLAScalarType.swift b/Sources/TensorFlow/X10/XLAScalarType.swift new file mode 120000 index 000000000..9e13e7567 --- /dev/null +++ b/Sources/TensorFlow/X10/XLAScalarType.swift @@ -0,0 +1 @@ +../../x10/swift_bindings/XLAScalarType.swift \ No newline at end of file diff --git a/Sources/TensorFlow/X10/XLATensor.swift b/Sources/TensorFlow/X10/XLATensor.swift new file mode 120000 index 000000000..a356e0ff8 --- /dev/null +++ b/Sources/TensorFlow/X10/XLATensor.swift @@ -0,0 +1 @@ +../../x10/swift_bindings/XLATensor.swift \ No newline at end of file