Skip to content
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()
}