| // RUN: %target-swift-emit-sil %s |
| // REQUIRES: asserts |
| |
| // TF-962: Ownership verification error in pullback function generated by the |
| // differentiation transform. |
| // Multiple consuming uses for tuple-typed adjoint value: |
| // - `destructure_tuple` (from `PullbackEmitter::visitTupleInst`) |
| // - `destroy_value` (for pullback temporary values) |
| |
| // Key: `Tensor` and `Tensor.TangentVector` must both be non-trivial. |
| struct Tensor: Differentiable { |
| var x: [Float] = [] |
| } |
| |
| @differentiable |
| func TF_962(_ x: Tensor) -> Tensor { |
| let tup = (x, x) |
| if true {} |
| return tup.0 |
| } |
| |
| // Function: 'AD__$s4main6TF_962yAA6TensorVADF__pullback_src_0_wrt_0' |
| // Found over consume?! |
| // Value: %81 = argument of bb7 : $(Tensor.TangentVector, Tensor.TangentVector) // users: %154, %84 |
| // User: destroy_value %81 : $(Tensor.TangentVector, Tensor.TangentVector) // id: %154 |
| // Block: bb7 |