Skip to content

Commit 8fa3d2f

Browse files
authored
Add regression test for #59467 (#60158)
* Add S4TF crasher test * Unbreak the test Co-authored-by: Philip Turner <philipturner.AR@gmail.com> Resolves #59467
1 parent 0fdba62 commit 8fa3d2f

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %target-swift-frontend -emit-ir -g -primary-file %s %S/Inputs/59467-failed-to-reconstruct-type-second.swift -module-name TensorFlow
2+
3+
import _Differentiation
4+
5+
@_semantics("autodiff.nonvarying")
6+
func withoutDerivative() -> Tensor {
7+
fatalError()
8+
}
9+
10+
func BatchNorm_doInference(
11+
_ input: Tensor
12+
) -> Tensor {
13+
withoutDerivative()
14+
}
15+
16+
@differentiable(reverse)
17+
func BatchNorm_callAsFunction(_ input: Tensor) -> Tensor {
18+
BatchNorm_doInference(input)
19+
}
20+
21+
@differentiable(reverse)
22+
func LayerNorm_callAsFunction(_ input: Tensor) -> Tensor {
23+
rsqrt(input)
24+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import _Differentiation
2+
3+
struct Tensor: Differentiable {}
4+
5+
// `Tensor` could be defined in this test case's primary file and the crash
6+
// would still happen. All that matters is that `LayerNorm_callAsFunction` and
7+
// `rsqrt` are defined in separate files.
8+
9+
@differentiable(reverse)
10+
func rsqrt( _ x: Tensor) -> Tensor {
11+
fatalError()
12+
}
13+
14+
@derivative(of: rsqrt)
15+
func _vjpRsqrt(_ x: Tensor) -> (
16+
value: Tensor, pullback: (Tensor.TangentVector) -> (Tensor.TangentVector)
17+
) {
18+
fatalError()
19+
}

0 commit comments

Comments
 (0)