diff --git a/test/AutoDiff/compiler_crashers_fixed/59467-failed-to-reconstruct-type.swift b/test/AutoDiff/compiler_crashers_fixed/59467-failed-to-reconstruct-type.swift new file mode 100644 index 0000000000000..87109b56a4155 --- /dev/null +++ b/test/AutoDiff/compiler_crashers_fixed/59467-failed-to-reconstruct-type.swift @@ -0,0 +1,24 @@ +// RUN: %target-swift-frontend -emit-ir -g -primary-file %s %S/Inputs/59467-failed-to-reconstruct-type-second.swift -module-name TensorFlow + +import _Differentiation + +@_semantics("autodiff.nonvarying") +func withoutDerivative() -> Tensor { + fatalError() +} + +func BatchNorm_doInference( + _ input: Tensor +) -> Tensor { + withoutDerivative() +} + +@differentiable(reverse) +func BatchNorm_callAsFunction(_ input: Tensor) -> Tensor { + BatchNorm_doInference(input) +} + +@differentiable(reverse) +func LayerNorm_callAsFunction(_ input: Tensor) -> Tensor { + rsqrt(input) +} diff --git a/test/AutoDiff/compiler_crashers_fixed/Inputs/59467-failed-to-reconstruct-type-second.swift b/test/AutoDiff/compiler_crashers_fixed/Inputs/59467-failed-to-reconstruct-type-second.swift new file mode 100644 index 0000000000000..debe867f37f59 --- /dev/null +++ b/test/AutoDiff/compiler_crashers_fixed/Inputs/59467-failed-to-reconstruct-type-second.swift @@ -0,0 +1,19 @@ +import _Differentiation + +struct Tensor: Differentiable {} + +// `Tensor` could be defined in this test case's primary file and the crash +// would still happen. All that matters is that `LayerNorm_callAsFunction` and +// `rsqrt` are defined in separate files. + +@differentiable(reverse) +func rsqrt( _ x: Tensor) -> Tensor { + fatalError() +} + +@derivative(of: rsqrt) +func _vjpRsqrt(_ x: Tensor) -> ( + value: Tensor, pullback: (Tensor.TangentVector) -> (Tensor.TangentVector) +) { + fatalError() +}