From 798dab862eff869834c18f8a9318be2cff01937d Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Mon, 14 Dec 2020 16:07:52 -0800 Subject: [PATCH] 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` or `Float` instead of `Double`). Explicitly convert the types. --- Tests/TensorFlowTests/LayerTests.swift | 2 +- Tests/TensorFlowTests/OperatorTests/MathTests.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/TensorFlowTests/LayerTests.swift b/Tests/TensorFlowTests/LayerTests.swift index fabb135fc..00032bc01 100644 --- a/Tests/TensorFlowTests/LayerTests.swift +++ b/Tests/TensorFlowTests/LayerTests.swift @@ -6846,7 +6846,7 @@ final class LayerTests: XCTestCase { let epsilon: Float = 0.001 let bnLayer = BatchNorm(featureCount: 5, axis: 1, epsilon: epsilon) // Test inference before any training. - assertEqual(bnLayer.inferring(from: x), x / TensorFlow.sqrt(1 + epsilon), accuracy: 1e-5) + assertEqual(bnLayer.inferring(from: x), x / TensorFlow.sqrt(Tensor(1 + epsilon)), accuracy: 1e-5) // Perform one training step, updating the running mean and variance. Context.local.learningPhase = .training _ = bnLayer(x) // This line is important and cannot be removed. diff --git a/Tests/TensorFlowTests/OperatorTests/MathTests.swift b/Tests/TensorFlowTests/OperatorTests/MathTests.swift index d07489a7d..8338d51dd 100644 --- a/Tests/TensorFlowTests/OperatorTests/MathTests.swift +++ b/Tests/TensorFlowTests/OperatorTests/MathTests.swift @@ -307,13 +307,13 @@ final class MathOperatorTests: XCTestCase { } func testIsInfinite() { - let x = Tensor([1, 2, 3, 4, log(0.0)]) + let x = Tensor([1, 2, 3, 4, Float(log(0.0))]) let y = x.isInfinite XCTAssertEqual(y, Tensor([false, false, false, false, true])) } func testIsNaN() { - let x = Tensor([1, 2, 3, 4, log(-5.0)]) + let x = Tensor([1, 2, 3, 4, Float(log(-5.0))]) let y = x.isNaN XCTAssertEqual(y, Tensor([false, false, false, false, true])) }