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

Commit 1aceb2d

Browse files
authored
Fix TensorFlow stdlib module compilation. (#546)
Follow-up to #540 fixing TensorFlow stdlib module compilation. - Rename `Sources/Tensor/Utilities.swift -> Sources/Tensor/TensorUtilities.swift` to fix stdlib compilation error: `filename "Utilities.swift" used twice`. - Add `#if !COMPILING_TENSORFLOW_STDLIB_MODULE` guards gating `import Tensor` declarations so that the TensorFlow module can be built as part of the stdlib. - This will no longer be necessary when TensorFlow is no longer built as part of the stdlib: #488.
1 parent 30a1071 commit 1aceb2d

File tree

6 files changed

+10
-0
lines changed

6 files changed

+10
-0
lines changed
File renamed without changes.

Sources/TensorFlow/Context.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import Darwin
1818
import Glibc
1919
#endif
2020

21+
#if !COMPILING_TENSORFLOW_STDLIB_MODULE
2122
import Tensor
23+
#endif
2224

2325
/// A value that indicates the phase of using a machine learning model.
2426
public enum LearningPhase {

Sources/TensorFlow/Exports.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#if !COMPILING_TENSORFLOW_STDLIB_MODULE
1516
// Re-export all public symbols in the Tensor library.
1617
@_exported import Tensor
18+
#endif

Sources/TensorFlow/Initializers.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#if !COMPILING_TENSORFLOW_STDLIB_MODULE
1516
import Tensor
17+
#endif
1618

1719
public extension Tensor {
1820
/// Creates a tensor with the specified shape and a single, repeated scalar value.

Sources/TensorFlow/Layers/Initialization.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#if !COMPILING_TENSORFLOW_STDLIB_MODULE
1516
import Tensor
17+
#endif
1618

1719
public typealias ParameterInitializer<Scalar: TensorFlowScalar> = (TensorShape) -> Tensor<Scalar>
1820

Sources/TensorFlow/Layers/Recurrent.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#if !COMPILING_TENSORFLOW_STDLIB_MODULE
1516
import Tensor
17+
#endif
1618

1719
/// An input to a recurrent neural network.
1820
public struct RNNCellInput<Input: Differentiable, State: Differentiable>: Differentiable {

0 commit comments

Comments
 (0)