[AutoDiff upstream] Add @differentiable
ASTScope support.
#29171
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@differentiable
attributes may containwhere
clauses referencinggeneric parameters from an outer scope, just like
@_specialize
attributes.@differentiable
attribute where clauses may refer to generic parameters fromsome generic context, just like
@_specialize
attribute.Without special ASTScope support for
@differentiable
attributes,ASTScopeLookup.cpp logic tries to resolve the generic parameter
DeclName
s inwhere
clauses based on source location alone(
ASTScopeImpl::findChildContaining
) and fails.The fix is to add a special
DifferentiableAttributeScope
, mimickingSpecializeAttributeScope
. Every@differentiable
attribute has its own scope,derived from the declaration on which it is declared. Unlike
@_specialize
,@differentiable
may also be declared onAbstractStorageDecl
declarations(subscripts and variables).
Upstreams #27451.
Progress towards TF-828: upstream
@differentiable
attribute type-checking.@differentiable
attribute type-checking mega-patch: #29091Tests exist on
tensorflow
branch and will be upstreamed later.Currently, not enough code has been upstreamed for meaningful testing.