Skip to content

Commit a1c4b68

Browse files
authored
[AutoDiff] Remove @differentiable(jvp:vjp:) parsing logic. (#30604)
Remove logic for parsing and diagnosing `jvp:` and `vjp:` arguments for `@differentiable` attribute. No logic remains for handling those arguments. Follow-up to TF-1001.
1 parent 7811f53 commit a1c4b68

File tree

3 files changed

+5
-69
lines changed

3 files changed

+5
-69
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,14 +1586,10 @@ ERROR(attr_differentiable_expected_parameter_list,PointsToFirstBadToken,
15861586
"expected a list of parameters to differentiate with respect to", ())
15871587
ERROR(attr_differentiable_use_wrt_not_withrespectto,none,
15881588
"use 'wrt:' to specify parameters to differentiate with respect to", ())
1589-
ERROR(attr_differentiable_expected_label,none,"expected 'wrt:' or 'where'", ())
1589+
ERROR(attr_differentiable_expected_label,none,
1590+
"expected 'wrt:' or 'where' in '@differentiable' attribute", ())
15901591
ERROR(attr_differentiable_unexpected_argument,none,
15911592
"unexpected argument '%0' in '@differentiable' attribute", (StringRef))
1592-
// TODO(TF-893): Remove this error after the 0.8 release.
1593-
ERROR(attr_differentiable_jvp_vjp_deprecated_error,none,
1594-
"'jvp:' and 'vjp:' arguments in '@differentiable' attribute are "
1595-
"deprecated; use '@derivative' attribute for derivative registration "
1596-
"instead", ())
15971593

15981594
// differentiation `wrt` parameters clause
15991595
ERROR(expected_colon_after_label,PointsToFirstBadToken,

lib/Parse/ParseDecl.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -971,12 +971,6 @@ bool Parser::parseDifferentiableAttributeArguments(
971971
if (isIdentifier(Tok, "wrt")) {
972972
return false;
973973
}
974-
// Diagnose deprecated 'jvp' and 'vjp'.
975-
if (isIdentifier(Tok, "jvp") || isIdentifier(Tok, "vjp")) {
976-
diagnose(Tok.getLoc(),
977-
diag::attr_differentiable_jvp_vjp_deprecated_error);
978-
return true;
979-
}
980974
diagnose(Tok, diag::attr_differentiable_expected_label);
981975
return true;
982976
};
@@ -1018,13 +1012,6 @@ bool Parser::parseDifferentiableAttributeArguments(
10181012
return errorAndSkipUntilConsumeRightParen(*this, AttrName);
10191013
}
10201014

1021-
// Diagnose deprecated 'jvp' and 'vjp'.
1022-
if (isIdentifier(Tok, "jvp") || isIdentifier(Tok, "vjp")) {
1023-
diagnose(Tok.getLoc(),
1024-
diag::attr_differentiable_jvp_vjp_deprecated_error);
1025-
return errorAndSkipUntilConsumeRightParen(*this, AttrName);
1026-
}
1027-
10281015
// If parser has not advanced and token is not 'where' or ')', emit error.
10291016
if (Tok.getLoc() == startingLoc && Tok.isNot(tok::kw_where, tok::r_paren)) {
10301017
diagnose(Tok, diag::attr_differentiable_expected_label);

test/AutoDiff/Parse/differentiable_attr_parse.swift

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -180,56 +180,9 @@ func slope5(_ x: Float) -> Float {
180180
return 5 * x
181181
}
182182

183-
// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
184-
@differentiable(jvp: foo)
183+
// Test removed `jvp:' and 'vjp:' arguments.
184+
// expected-error @+1 {{expected 'wrt:' or 'where' in '@differentiable' attribute}}
185+
@differentiable(jvp: foo, vjp: foo)
185186
func bar(_ x: Float, _: Float) -> Float {
186187
return 1 + x
187188
}
188-
189-
// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
190-
@differentiable(vjp: foo)
191-
func bar(_ x: Float, _: Float) -> Float {
192-
return 1 + x
193-
}
194-
195-
// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
196-
@differentiable(vjp: foo, jvp: foo)
197-
func bar(_ x: Float, _: Float) -> Float {
198-
return 1 + x
199-
}
200-
201-
// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
202-
@differentiable(wrt: (self, x, y), jvp: foo)
203-
func bar(_ x: Float, _ y: Float) -> Float {
204-
return 1 + x
205-
}
206-
207-
// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
208-
@differentiable(wrt: (self, x, y), vjp: foo)
209-
func bar(_ x: Float, _ y: Float) -> Float {
210-
return 1 + x
211-
}
212-
213-
// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
214-
@differentiable(wrt: (self, x, y), jvp: foo, vjp: foo)
215-
func bar(_ x: Float, _ y: Float) -> Float {
216-
return 1 + x
217-
}
218-
219-
// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
220-
@differentiable(wrt: (x), jvp: foo where T : FloatingPoint)
221-
func bar<T : Numeric>(_ x: T, _: T) -> T {
222-
return 1 + x
223-
}
224-
225-
// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
226-
@differentiable(wrt: (x), vjp: foo where T : FloatingPoint)
227-
func bar<T : Numeric>(_ x: T, _: T) -> T {
228-
return 1 + x
229-
}
230-
231-
// expected-error @+1 {{'jvp:' and 'vjp:' arguments in '@differentiable' attribute are deprecated}}
232-
@differentiable(wrt: (x), jvp: foo, vjp: foo where T : FloatingPoint)
233-
func bar<T : Numeric>(_ x: T, _: T) -> T {
234-
return 1 + x
235-
}

0 commit comments

Comments
 (0)