Skip to content

[AutoDiff] Re-enable LoadableByAddress. #27923

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

@dan-zheng dan-zheng commented Oct 29, 2019

The LoadableByAddress transform rewrites function types. This caused
verification failures in lowered SIL for differentiable_function and
differentiable_function_extract instructions, which have precise type
verification rules.

Now, verification has been relaxed for these instructions in lowered SIL.

  • differentiable_function_extract can now have an explicit extractee type
    in lowered SIL: parsing/printing/serialization support have been added.
  • LoadableByAddress rewrites differentiable_function_extract instructions
    using explicit address-lowered function type, similar to other function
    conversion instructions.
  • Add SIL FileCheck and runtime tests.

@dan-zheng dan-zheng added the tensorflow This is for "tensorflow" branch PRs. label Oct 29, 2019
@dan-zheng dan-zheng requested review from rxwei and marcrasi October 29, 2019 04:25
if (F.getModule().getStage() == SILStage::Canonical ||
dfi->hasDerivativeFunctions()) {
// Skip lowered SIL: LoadableByAddress changes parameter/result conventions.
// TODO: Check that derivative function types match excluding
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: robust verification here should be aware of the lowered SIL stage and check that address-lowered SIL function types match.

In the meantime, we could use a custom function for recursively checking SIL function type equality, ignoring parameter/result conventions. SILFunctionType::isABICompatibleWith is not suitable because it checks parameter/result conventions and returns an opaque ABICompatibilityCheckResult.

@dan-zheng
Copy link
Contributor Author

Checking if tests pass.
Also running extended test suite (tensorflow/swift-apis, tensorflow/swift-models, etc).

@dan-zheng
Copy link
Contributor Author

@swift-ci Please test tensorflow

Copy link
Contributor

@rxwei rxwei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes to what identifies a SIL instruction should be reflected in its syntax.

differentiable_function_extract [...] [...] %foo : $(T) -> T as $(@in T) -> @out T

@dan-zheng dan-zheng force-pushed the enable-loadable-by-address branch from 331d8a6 to c23f208 Compare October 29, 2019 18:24
@marcrasi
Copy link

Nice! I have no additional comments on this.

@dan-zheng dan-zheng force-pushed the enable-loadable-by-address branch 2 times, most recently from 39849ea to da3e68c Compare October 29, 2019 20:48
The LoadableByAddress transform rewrites function types. This caused
verification failures in lowered SIL for `differentiable_function` and
`differentiable_function_extract` instructions, which have precise type
verification rules.

Now, verification has been relaxed for these instructions in lowered SIL.

- `differentiable_function_extract` can now have an explicit extractee type
  in lowered SIL: parsing/printing/serialization support have been added.
- LoadableByAddress rewrites `differentiable_function_extract` instructions
  using explicit address-lowered function type, similar to other function
  conversion instructions.
- Add SIL FileCheck and runtime tests.
@dan-zheng dan-zheng force-pushed the enable-loadable-by-address branch from da3e68c to cadc7c1 Compare October 29, 2019 22:30
Copy link
Contributor

@rxwei rxwei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@dan-zheng
Copy link
Contributor Author

@swift-ci Please test tensorflow

@dan-zheng
Copy link
Contributor Author

@swift-ci Please test tensorflow linux

@dan-zheng
Copy link
Contributor Author

Confirmed that the extended test suite passed: tensorflow/swift-apis, tensorflow/swift-models, etc.

@dan-zheng dan-zheng merged commit d23fa02 into swiftlang:tensorflow Oct 30, 2019
@dan-zheng dan-zheng deleted the enable-loadable-by-address branch October 30, 2019 01:26
@rxwei
Copy link
Contributor

rxwei commented Oct 30, 2019

The next step is to resolve cases where an original value's value category mismatches that of its corresponding tangent value.

dan-zheng added a commit to dan-zheng/swift that referenced this pull request Nov 5, 2019
LoadableByAddress was re-enabled by default on tensorflow branch
in swiftlang#27923.

IRGen tests no longer require an explicit `-enable-large-loadable-types` flag.
dan-zheng added a commit that referenced this pull request Nov 5, 2019
LoadableByAddress was re-enabled by default on tensorflow branch
in #27923.

IRGen tests no longer require an explicit `-enable-large-loadable-types` flag.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tensorflow This is for "tensorflow" branch PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants