You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using an inout parameter from an enclosing function within a nested differentiable function, two different assertions can be triggered. In the following single-file reproducer:
an assertion is produced of "(newCapacity >= capacity), function extendingCapacity, file /Users/bradlarson/Development/BradLarson2/swift-source/swift/lib/AST/IndexSubset.cpp, line 72".
In the following, slightly more complicated single-file reproducer:
import _Differentiation
func outerFunc(value:inoutFloat)->(Float,(Float)->Float){@differentiable(reverse, wrt: param)func innerFunc(param:Float, other:Float)->Float{
value += param * other
return param * other * 2.0
}@differentiable(reverse)func curriedFunc(param:Float)->Float{returninnerFunc(param: param, other: 3.0)}letvalAndPullback=valueWithPullback(at: value, of: curriedFunc)return(value + valAndPullback.value, valAndPullback.pullback)}
an assertion of "Pullback value type is not ABI-compatible with the returned pullback type" is generated. Both assertion failures have occurred with toolchains since the start of the year, so I don't believe this is a new regression.
The full stack traces of the two assertion failures are as follows:
The issue occurs for @differentiable nested declarations with captures, whose wrt: clause is a subset of differentiability parameters.
I asked if the issue is blocking. Brad mentioned it's possible to work around the issue using local variables, which is alright but may incur extra TangentVector copies.
Thorough handling of capture info and partially applied differentiable functions (so that IndexSubset::extendingCapacity hacks are no longer needed) seems non-trivial.
I think a reasonable fix could be an ad-hoc but tasteful check (like existing ones) before the assertion failure. @BradLarson mentioned he may have time to take a look.
The second issue was fixed. Let us keep this bug open until slightly better solution will be delivered for the first issue (currently it's a workaround with TODO)
Additional Detail from JIRA
md5: 5d119c20bc93637cdd9b92802993c67c
Issue Description:
When using an inout parameter from an enclosing function within a nested differentiable function, two different assertions can be triggered. In the following single-file reproducer:
an assertion is produced of "(newCapacity >= capacity), function extendingCapacity, file /Users/bradlarson/Development/BradLarson2/swift-source/swift/lib/AST/IndexSubset.cpp, line 72".
In the following, slightly more complicated single-file reproducer:
an assertion of "Pullback value type is not ABI-compatible with the returned pullback type" is generated. Both assertion failures have occurred with toolchains since the start of the year, so I don't believe this is a new regression.
The full stack traces of the two assertion failures are as follows:
and
The text was updated successfully, but these errors were encountered: