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

Commit bf04e1f

Browse files
authored
Switched from using 'Raw.add' to using 'Raw.addV2'. (#433)
1 parent 4547df8 commit bf04e1f

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

Sources/TensorFlow/Core/Tensor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ extension Tensor: AdditiveArithmetic where Scalar: Numeric {
510510
@inlinable
511511
@differentiable(vjp: _vjpAdd(lhs:rhs:) where Scalar: TensorFlowFloatingPoint)
512512
public static func + (lhs: Tensor, rhs: Tensor) -> Tensor {
513-
Raw.add(lhs, rhs)
513+
Raw.addV2(lhs, rhs)
514514
}
515515

516516
/// Subtracts one tensor from another and produces their difference.

Tests/TensorFlowTests/LazyTensorExplicitTraceTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class LazyTensorExplicitTraceTests: XCTestCase {
3434
XCTAssertEqual(trace.description,
3535
"""
3636
lazyTrace_2(%0: float) -> (%1) {
37-
%1 = Add[T: float](%0, %0)
37+
%1 = AddV2[T: float](%0, %0)
3838
}
3939
""")
4040
let outputs = runTrace(trace: trace, input: Tensor<Float>(10.0))
@@ -55,7 +55,7 @@ final class LazyTensorExplicitTraceTests: XCTestCase {
5555
%2 = Const[dtype: int32, value: 4]()
5656
%3 = Mul[T: int32](%1, %2)
5757
%4 = Const[dtype: float, value: 3.0]()
58-
%5 = Add[T: float](%0, %4)
58+
%5 = AddV2[T: float](%0, %4)
5959
}
6060
""")
6161
let outputs = runTrace(
@@ -78,7 +78,7 @@ final class LazyTensorExplicitTraceTests: XCTestCase {
7878
"""
7979
lazyTrace_4(%0: float) -> (%3) {
8080
%1 = Const[dtype: float, value: 10.0]()
81-
%2 = Add[T: float](%1, %1)
81+
%2 = AddV2[T: float](%1, %1)
8282
%3 = Mul[T: float](%0, %2)
8383
}
8484
""")
@@ -127,7 +127,7 @@ final class LazyTensorExplicitTraceTests: XCTestCase {
127127
"""
128128
lazyTrace_3(%0: float) -> (%2) {
129129
%1 = Const[dtype: float, value: 9.0]()
130-
%2 = Add[T: float](%1, %0)
130+
%2 = AddV2[T: float](%1, %0)
131131
}
132132
""")
133133
let outputs = runTrace(trace: trace, input: Tensor<Float>(4.0))

Tests/TensorFlowTests/LazyTensorTFFunctionBuilderTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ final class LazyTensorTFFunctionBuilderTests : XCTestCase {
6767
tfFunction(w, "sequence")!.description,
6868
"""
6969
70-
sequence(placeholder_0:float, placeholder_1:float, placeholder_2:float) -> (add_4:float) {
70+
sequence(placeholder_0:float, placeholder_1:float, placeholder_2:float) -> (addv2_4:float) {
7171
Mul_3 = Mul[T=float](placeholder_1, placeholder_2)
72-
Add_4 = Add[T=float](placeholder_0, Mul_3:z:0)
73-
return add_4 = Add_4:z:0
72+
AddV2_4 = AddV2[T=float](placeholder_0, Mul_3:z:0)
73+
return addv2_4 = AddV2_4:z:0
7474
}
7575
7676
""")

Tests/TensorFlowTests/LazyTensorTraceTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ final class LazyTensorTraceTests: XCTestCase {
4040
%1 = Const[dtype: float, value: 2.0]()
4141
%2 = Const[dtype: float, value: 3.0]()
4242
%3 = Mul[T: float](%1, %2)
43-
%4 = Add[T: float](%0, %3)
43+
%4 = AddV2[T: float](%0, %3)
4444
}
4545
""")
4646
}
@@ -60,9 +60,9 @@ final class LazyTensorTraceTests: XCTestCase {
6060
lazyTrace_8() -> (%4, %5, %7) {
6161
%0 = Const[dtype: float, value: 10.0]()
6262
%1 = Const[dtype: float, value: 2.0]()
63-
%2 = Add[T: float](%0, %1)
63+
%2 = AddV2[T: float](%0, %1)
6464
%3 = Const[dtype: float, value: 3.0]()
65-
%4 = Add[T: float](%2, %3)
65+
%4 = AddV2[T: float](%2, %3)
6666
%5 = Mul[T: float](%4, %3)
6767
%6 = Sub[T: float](%4, %3)
6868
%7 = Div[T: float](%5, %6)
@@ -76,9 +76,9 @@ final class LazyTensorTraceTests: XCTestCase {
7676
lazyTrace_6() -> (%4, %5) {
7777
%0 = Const[dtype: float, value: 10.0]()
7878
%1 = Const[dtype: float, value: 2.0]()
79-
%2 = Add[T: float](%0, %1)
79+
%2 = AddV2[T: float](%0, %1)
8080
%3 = Const[dtype: float, value: 3.0]()
81-
%4 = Add[T: float](%2, %3)
81+
%4 = AddV2[T: float](%2, %3)
8282
%5 = Mul[T: float](%4, %3)
8383
}
8484
""")
@@ -97,10 +97,10 @@ final class LazyTensorTraceTests: XCTestCase {
9797
lazyTrace_6() -> (%2, %5) {
9898
%0 = Const[dtype: float, value: 1.0]()
9999
%1 = Const[dtype: float, value: 2.0]()
100-
%2 = Add[T: float](%0, %1)
100+
%2 = AddV2[T: float](%0, %1)
101101
%3 = Const[dtype: float, value: 3.0]()
102102
%4 = Const[dtype: float, value: 4.0]()
103-
%5 = Add[T: float](%3, %4)
103+
%5 = AddV2[T: float](%3, %4)
104104
}
105105
""")
106106
}
@@ -116,7 +116,7 @@ final class LazyTensorTraceTests: XCTestCase {
116116
"""
117117
lazyTrace_2() -> (%1) {
118118
%0 = Const[dtype: float, value: 5.0]()
119-
%1 = Add[T: float](%0, %0)
119+
%1 = AddV2[T: float](%0, %0)
120120
}
121121
""")
122122
let mul = addOrMul(/*useAdd:*/false, a)
@@ -182,7 +182,7 @@ final class LazyTensorTraceTests: XCTestCase {
182182
lazyTrace_3() -> (%2) {
183183
%0 = Const[dtype: float, value: 1.0]()
184184
%1 = Const[dtype: float, value: 2.0]()
185-
%2 = Add[T: float](%0, %1)
185+
%2 = AddV2[T: float](%0, %1)
186186
}
187187
""")
188188
XCTAssertEqual(y.scalarized(), 3.0)

0 commit comments

Comments
 (0)