Files
swift-mirror/test/AutoDiff/compiler_crashers_fixed/tf1315-pullback-subset-parameter-thunk-generation.swift
Dan Zheng 07f632acaa [AutoDiff] NFC: document test suite. (#35194)
Add README files explaining the differentiable programming test suite.

Add lit.local.cfg files so individual tests do not need to add
`REQUIRES: asserts` in these directories:

- test/AutoDiff/compiler_crashers
- test/AutoDiff/compiler_crashers_fixed

Motivation: it is important for compiler crasher tests to require assertions
enabled, because many of these tests crash on compiler assertions.
2020-12-23 07:19:19 -05:00

27 lines
734 B
Swift

// RUN: %target-swift-frontend -emit-sil %s
// TF-1315: Pullback subset thunk generation crash due to unmapped parameter
// index for `inout` differentiability parameters.
import _Differentiation
func foo(_ x: Int, _ y: Float, _ z: inout Float) {}
@derivative(of: foo, wrt: (y, z))
func vjpFoo(_ x: Int, _ y: Float, _ z: inout Float) -> (
value: Void, pullback: (inout Float) -> Float
) {
fatalError()
}
@differentiable
func TF_1315(_ x: Float) -> Float {
var x = x
// The call to `foo` below triggers pullback subset parameter thunk generation.
// `foo` original function type: `(Int, Float, inout Float) -> ()`
// Actual parameter indices: 1, 2
// Desired parameter indices: 2
foo(1, 2, &x)
return x
}