forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring.swift
More file actions
31 lines (24 loc) · 822 Bytes
/
Copy pathstring.swift
File metadata and controls
31 lines (24 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// RUN: %target-run-simple-swift
// REQUIRES: executable_test
// REQUIRES: swift_test_mode_optimize
//
// String Tensor tests.
import TensorFlow
import StdlibUnittest
var StringTensorTests = TestSuite("String")
StringTensorTests.test("StringComparison") {
// Const op over a String tensor cannot live on GPU.
TensorFlow.enableCPU()
let t1 = Tensor("foo")
let result1 = t1.elementsEqual(t1)
expectEqual(ShapedArray(shape: [], scalars: [true]), result1.array)
let t2 = Tensor(["foo", "bar"])
let result2 = t2.elementsEqual(t2)
expectEqual(ShapedArray(shape: [2], scalars: [true, true]),
result2.array)
let t3 = Tensor(["different", "bar"])
let result3 = t2.elementsEqual(t3)
expectEqual(ShapedArray(shape: [2], scalars: [false, true]),
result3.array)
}
runAllTests()