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

Commit 798dab8

Browse files
authored
TensorFlowTests: adjust a few cases of type conversion (#1148)
When building the tests with SPM, these would fail to build due to type differences (i.e. expecting `Tensor<Float>` or `Float` instead of `Double`). Explicitly convert the types.
1 parent 5296951 commit 798dab8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Tests/TensorFlowTests/LayerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6846,7 +6846,7 @@ final class LayerTests: XCTestCase {
68466846
let epsilon: Float = 0.001
68476847
let bnLayer = BatchNorm<Float>(featureCount: 5, axis: 1, epsilon: epsilon)
68486848
// Test inference before any training.
6849-
assertEqual(bnLayer.inferring(from: x), x / TensorFlow.sqrt(1 + epsilon), accuracy: 1e-5)
6849+
assertEqual(bnLayer.inferring(from: x), x / TensorFlow.sqrt(Tensor<Float>(1 + epsilon)), accuracy: 1e-5)
68506850
// Perform one training step, updating the running mean and variance.
68516851
Context.local.learningPhase = .training
68526852
_ = bnLayer(x) // This line is important and cannot be removed.

Tests/TensorFlowTests/OperatorTests/MathTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,13 @@ final class MathOperatorTests: XCTestCase {
307307
}
308308

309309
func testIsInfinite() {
310-
let x = Tensor<Float>([1, 2, 3, 4, log(0.0)])
310+
let x = Tensor<Float>([1, 2, 3, 4, Float(log(0.0))])
311311
let y = x.isInfinite
312312
XCTAssertEqual(y, Tensor([false, false, false, false, true]))
313313
}
314314

315315
func testIsNaN() {
316-
let x = Tensor<Float>([1, 2, 3, 4, log(-5.0)])
316+
let x = Tensor<Float>([1, 2, 3, 4, Float(log(-5.0))])
317317
let y = x.isNaN
318318
XCTAssertEqual(y, Tensor([false, false, false, false, true]))
319319
}

0 commit comments

Comments
 (0)