Skip to content

[AutoDiff] NFC: improve debug log output. #33793

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 1 commit into from
Sep 4, 2020

Conversation

dan-zheng
Copy link
Contributor

Print value/instruction with context in non-differentiability error debug log.


Before: the source of some non-differentiability issues isn't clear.

$ swiftc test.swift
...
[AD] Diagnosing non-differentiability.
[AD] For value:
  %10 = partial_apply [callee_guaranteed] %9<τ_0_0, τ_1_0>() : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed KeyPath<τ_0_0, τ_0_1>) -> @out τ_0_1 // user: %11
[AD] With invoker:
(differentiation_invoker differentiable_function_inst=(  %11 = differentiable_function [parameters 0] [results 0] %10 : $@callee_guaranteed (@in_guaranteed τ_0_0, @guaranteed KeyPath<τ_0_0, τ_1_0>) -> @out τ_1_0 // users: %16, %12
))

After:

$ swiftc test.swift
...
[AD] Diagnosing non-differentiability.
[AD] For value:
     // function_ref swift_getAtKeyPath
  %9 = function_ref @swift_getAtKeyPath : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed KeyPath<τ_0_0, τ_0_1>) -> @out τ_0_1 // user: %10
->   %10 = partial_apply [callee_guaranteed] %9<τ_0_0, τ_1_0>() : $@convention(thin) <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0, @guaranteed KeyPath<τ_0_0, τ_0_1>) -> @out τ_0_1 // user: %11
     %11 = differentiable_function [parameters 0] [results 0] %10 : $@callee_guaranteed (@in_guaranteed τ_0_0, @guaranteed KeyPath<τ_0_0, τ_1_0>) -> @out τ_1_0 // users: %16, %12
[AD] With invoker:
(differentiation_invoker differentiable_function_inst=(  %11 = differentiable_function [parameters 0] [results 0] %10 : $@callee_guaranteed (@in_guaranteed τ_0_0, @guaranteed KeyPath<τ_0_0, τ_1_0>) -> @out τ_1_0 // users: %16, %12
))

Print value/instruction with context in non-differentiability error debug log.
@dan-zheng dan-zheng requested review from rxwei and efremale September 3, 2020 18:50
@dan-zheng
Copy link
Contributor Author

@swift-ci Please smoke test

@dan-zheng
Copy link
Contributor Author

@swift-ci Please smoke test macOS

@dan-zheng dan-zheng merged commit 1d72ec9 into swiftlang:master Sep 4, 2020
@dan-zheng dan-zheng deleted the autodiff-debug branch September 4, 2020 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants