Skip to content

Add regression test for #59467 #60158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -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()
}