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

Commit f44d890

Browse files
authored
TensorFlow: add support for importing Numerics (#1122)
Allow use of the Swift Numerics package for `ElementaryFunctions` protocol support. This is currently guarded under a flag `TENSORFLOW_USE_STANDARD_TOOLCHAIN` which allows the change to be merged in an inactive state to enable further experimentation.
1 parent 0d56023 commit f44d890

File tree

7 files changed

+21
-0
lines changed

7 files changed

+21
-0
lines changed

Sources/TensorFlow/Core/DataTypes.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
import _Differentiation
1616
import CTensorFlow
17+
#if TENSORFLOW_USE_STANDARD_TOOLCHAIN
18+
import Numerics
19+
#endif
1720

1821
/// A TensorFlow dynamic type value that can be created from types that conform to
1922
/// `TensorFlowScalar`.

Sources/TensorFlow/Layer.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
import _Differentiation
1616
import Foundation
17+
#if TENSORFLOW_USE_STANDARD_TOOLCHAIN
18+
import Numerics
19+
#endif
1720

1821
public protocol Module: EuclideanDifferentiable, KeyPathIterable
1922
where

Sources/TensorFlow/Operators/Math.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
// limitations under the License.
1414

1515
import _Differentiation
16+
#if TENSORFLOW_USE_STANDARD_TOOLCHAIN
17+
import Numerics
18+
#endif
1619

1720
infix operator .>: ComparisonPrecedence
1821
infix operator .==: ComparisonPrecedence

Sources/TensorFlow/Optimizers/MomentumBased.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
// limitations under the License.
1414

1515
import _Differentiation
16+
#if TENSORFLOW_USE_STANDARD_TOOLCHAIN
17+
import Numerics
18+
#endif
1619

1720
/// A RMSProp optimizer.
1821
///

Sources/TensorFlow/Optimizers/SGD.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
// limitations under the License.
1414

1515
import _Differentiation
16+
#if TENSORFLOW_USE_STANDARD_TOOLCHAIN
17+
import Numerics
18+
#endif
1619

1720
/// A stochastic gradient descent (SGD) optimizer.
1821
///

Sources/TensorFlow/StdlibExtensions.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
// limitations under the License.
1414

1515
import _Differentiation
16+
#if TENSORFLOW_USE_STANDARD_TOOLCHAIN
17+
import Numerics
18+
#endif
1619

1720
// MARK: - Array extensions
1821

Sources/x10/swift_bindings/optimizers/Optimizer.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
import _Differentiation
1616
import TensorFlow
17+
#if TENSORFLOW_USE_STANDARD_TOOLCHAIN
18+
import Numerics
19+
#endif
1720
@_exported import x10_optimizers_tensor_visitor_plan
1821

1922
/// State for a single step of a single weight inside an optimizer.

0 commit comments

Comments
 (0)