Skip to content

[AutoDiff] Remove @differentiable(jvp:vjp:) parsing logic. #30604

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions include/swift/AST/DiagnosticsParse.def
Original file line number Diff line number Diff line change
Expand Up @@ -1586,14 +1586,10 @@ ERROR(attr_differentiable_expected_parameter_list,PointsToFirstBadToken,
"expected a list of parameters to differentiate with respect to", ())
ERROR(attr_differentiable_use_wrt_not_withrespectto,none,
"use 'wrt:' to specify parameters to differentiate with respect to", ())
ERROR(attr_differentiable_expected_label,none,"expected 'wrt:' or 'where'", ())
ERROR(attr_differentiable_expected_label,none,
"expected 'wrt:' or 'where' in '@differentiable' attribute", ())
ERROR(attr_differentiable_unexpected_argument,none,
"unexpected argument '%0' in '@differentiable' attribute", (StringRef))
// TODO(TF-893): Remove this error after the 0.8 release.
ERROR(attr_differentiable_jvp_vjp_deprecated_error,none,
"'jvp:' and 'vjp:' arguments in '@differentiable' attribute are "
"deprecated; use '@derivative' attribute for derivative registration "
"instead", ())

// differentiation `wrt` parameters clause
ERROR(expected_colon_after_label,PointsToFirstBadToken,
Expand Down
13 changes: 0 additions & 13 deletions lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,12 +971,6 @@ bool Parser::parseDifferentiableAttributeArguments(
if (isIdentifier(Tok, "wrt")) {
return false;
}
// Diagnose deprecated 'jvp' and 'vjp'.
if (isIdentifier(Tok, "jvp") || isIdentifier(Tok, "vjp")) {
diagnose(Tok.getLoc(),
diag::attr_differentiable_jvp_vjp_deprecated_error);
return true;
}
diagnose(Tok, diag::attr_differentiable_expected_label);
return true;
};
Expand Down Expand Up @@ -1018,13 +1012,6 @@ bool Parser::parseDifferentiableAttributeArguments(
return errorAndSkipUntilConsumeRightParen(*this, AttrName);
}

// Diagnose deprecated 'jvp' and 'vjp'.
if (isIdentifier(Tok, "jvp") || isIdentifier(Tok, "vjp")) {
diagnose(Tok.getLoc(),
diag::attr_differentiable_jvp_vjp_deprecated_error);
return errorAndSkipUntilConsumeRightParen(*this, AttrName);
}

// If parser has not advanced and token is not 'where' or ')', emit error.
if (Tok.getLoc() == startingLoc && Tok.isNot(tok::kw_where, tok::r_paren)) {
diagnose(Tok, diag::attr_differentiable_expected_label);
Expand Down
53 changes: 3 additions & 50 deletions test/AutoDiff/Parse/differentiable_attr_parse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,56 +180,9 @@ func slope5(_ x: Float) -> Float {
return 5 * x
}

// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
@differentiable(jvp: foo)
// Test removed `jvp:' and 'vjp:' arguments.
// expected-error @+1 {{expected 'wrt:' or 'where' in '@differentiable' attribute}}
@differentiable(jvp: foo, vjp: foo)
func bar(_ x: Float, _: Float) -> Float {
return 1 + x
}

// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
@differentiable(vjp: foo)
func bar(_ x: Float, _: Float) -> Float {
return 1 + x
}

// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
@differentiable(vjp: foo, jvp: foo)
func bar(_ x: Float, _: Float) -> Float {
return 1 + x
}

// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
@differentiable(wrt: (self, x, y), jvp: foo)
func bar(_ x: Float, _ y: Float) -> Float {
return 1 + x
}

// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
@differentiable(wrt: (self, x, y), vjp: foo)
func bar(_ x: Float, _ y: Float) -> Float {
return 1 + x
}

// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
@differentiable(wrt: (self, x, y), jvp: foo, vjp: foo)
func bar(_ x: Float, _ y: Float) -> Float {
return 1 + x
}

// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
@differentiable(wrt: (x), jvp: foo where T : FloatingPoint)
func bar<T : Numeric>(_ x: T, _: T) -> T {
return 1 + x
}

// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
@differentiable(wrt: (x), vjp: foo where T : FloatingPoint)
func bar<T : Numeric>(_ x: T, _: T) -> T {
return 1 + x
}

// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
@differentiable(wrt: (x), jvp: foo, vjp: foo where T : FloatingPoint)
func bar<T : Numeric>(_ x: T, _: T) -> T {
return 1 + x
}