Skip to content

[AutoDiff] Improve invalid stored property projection diagnostics. #32497

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

Conversation

dan-zheng
Copy link
Contributor

Add a request that resolves the "tangent stored property" corresponding to an
original stored property in a Differentiable-conforming type.

Improve non-differentiability diagnostics regarding invalid stored
property projection instructions:
struct_extract, struct_element_addr, ref_element_addr.

Diagnose the following cases:

  • Original property's type does not conform to Differentiable.
  • Base type's TangentVector is not a struct.
  • Tangent property not found: base type's TangentVector does not have a
    stored property with the same name as the original property.
  • Tangent property's type is not equal to the original property's
    TangentVector type.
  • Tangent property is not a stored property.

Previously, these cases were undiagnosed and crashed with assertion/verification failures.

Resolves TF-969 and TF-970.

Make `recordValueIfActive` short-circuit, returning true on error.
Remove booleans tracking whether diagnostics have been emitted.
Add request that resolves the "tangent stored property" corresponding to an
original stored property in a `Differentiable`-conforming type.

Enables better non-differentiability differentiation transform diagnostics.
Use TangentStoredPropertyRequest in differentiation transform.

Improve non-differentiability diagnostics regarding invalid stored
property projection instructions:
`struct_extract`, `struct_element_addr`, `ref_element_addr`.

Diagnose the following cases:
- Original property's type does not conform to `Differentiable`.
- Base type's `TangentVector` is not a struct.
- Tangent property not found: base type's `TangentVector` does not have a
  stored property with the same name as the original property.
- Tangent property's type is not equal to the original property's
  `TangentVector` type.
- Tangent property is not a stored property.

Resolves TF-969 and TF-970.
@dan-zheng dan-zheng requested review from rxwei and marcrasi June 22, 2020 17:24
@dan-zheng
Copy link
Contributor Author

@swift-ci Please smoke test

@dan-zheng dan-zheng merged commit 0717ba4 into swiftlang:master Jun 22, 2020
@dan-zheng dan-zheng deleted the autodiff-tangent-stored-property branch June 22, 2020 23:52
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