Skip to content

add SILDeclRef modifier for autodiff functions #21224

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 3 commits into from
Dec 12, 2018

Conversation

marcrasi
Copy link

Adds a new field to SILDeclRef that modifies it to refer to an autodiff function that is associated with the original one. Adds printing/parsing for it. Uses the SILDeclRef to TBDGen a public symbol that the AD pass creates.

I want to remove the "autodiff" witness table entries and replace them with normal method witness table entries that use this SILDeclRef, but I will do that in a subsequent PR.

@slavapestov, @rjmccall: This is based on some discussion that I had with @rjmccall on Friday. There's a difference: I made a new field that "modifies" the meaning of the rest of the SILDeclRef, rather than a new kind of SILDeclRef. After having played with it a bit, it seems most natural to do it this way. (It's sort of a derivation path idea, I think?) I will probably merge this quite quickly to unblock some autodiff stuff that we are working on, but we can continue the discussion and I'll eventually come back and modify things to whatever we eventually come up with.

@marcrasi marcrasi requested a review from rxwei December 11, 2018 22:39
@marcrasi
Copy link
Author

@swift-ci please test tensorflow

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

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

Ok, this makes sense.

@@ -316,6 +316,14 @@ struct SILAutoDiffIndices {
[&s](unsigned p) { s << p; }, [&s]{ s << ' '; });
s << "))";
}

std::string mangle() const {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you define a new AutoDiffMangler or similar, even if its still doing stuff like this? It will be easier to move to a real mangling in the future (which I encourage you to do).

Copy link
Author

Choose a reason for hiding this comment

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

Kind of following the example in ASTMangler? I haven't read through that and understood how it works yet, but I'll do that and then implement something like it, in a later PR.

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.

Awesome!

@marcrasi
Copy link
Author

@swift-ci please test tensorflow

1 similar comment
@marcrasi
Copy link
Author

@swift-ci please test tensorflow

@marcrasi marcrasi merged commit db52338 into swiftlang:tensorflow Dec 12, 2018
@marcrasi marcrasi deleted the sildeclref-ad branch December 12, 2018 02:08
rxwei added a commit that referenced this pull request Dec 12, 2018
marcrasi added a commit that referenced this pull request Dec 12, 2018
)

This deletes the AutoDiffAssociatedFunctionWitness from the witness table, and instead puts the autodiff associated functions in normal method witness table entries, using the autodiff SILDeclRef from #21224.
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.

3 participants