Skip to content

Commit 6e559ab

Browse files
author
Marc Rasi
committed
rename nondiff => noDerivative
1 parent f5677cb commit 6e559ab

File tree

14 files changed

+59
-59
lines changed

14 files changed

+59
-59
lines changed

include/swift/AST/Attr.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ TYPE_ATTR(convention)
5252
TYPE_ATTR(noescape)
5353
TYPE_ATTR(escaping)
5454
TYPE_ATTR(differentiable)
55-
TYPE_ATTR(nondiff)
55+
TYPE_ATTR(noDerivative)
5656

5757
// SIL-specific attributes
5858
TYPE_ATTR(block_storage)

include/swift/AST/Types.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ class ParameterTypeFlags {
17781778
NonEphemeral = 1 << 2,
17791779
OwnershipShift = 3,
17801780
Ownership = 7 << OwnershipShift,
1781-
NonDifferentiable = 1 << 7,
1781+
NoDerivative = 1 << 7,
17821782
NumBits = 7
17831783
};
17841784
OptionSet<ParameterFlags> value;
@@ -1793,17 +1793,17 @@ class ParameterTypeFlags {
17931793
}
17941794

17951795
ParameterTypeFlags(bool variadic, bool autoclosure, bool nonEphemeral,
1796-
ValueOwnership ownership, bool nonDifferentiable)
1796+
ValueOwnership ownership, bool noDerivative)
17971797
: value((variadic ? Variadic : 0) | (autoclosure ? AutoClosure : 0) |
17981798
(nonEphemeral ? NonEphemeral : 0) |
17991799
uint8_t(ownership) << OwnershipShift |
1800-
(nonDifferentiable ? NonDifferentiable : 0)) {}
1800+
(noDerivative ? NoDerivative : 0)) {}
18011801

18021802
/// Create one from what's present in the parameter type
18031803
inline static ParameterTypeFlags
18041804
fromParameterType(Type paramTy, bool isVariadic, bool isAutoClosure,
18051805
bool isNonEphemeral, ValueOwnership ownership,
1806-
bool isNonDifferentiable);
1806+
bool isNoDerivative);
18071807

18081808
bool isNone() const { return !value; }
18091809
bool isVariadic() const { return value.contains(Variadic); }
@@ -1812,7 +1812,7 @@ class ParameterTypeFlags {
18121812
bool isInOut() const { return getValueOwnership() == ValueOwnership::InOut; }
18131813
bool isShared() const { return getValueOwnership() == ValueOwnership::Shared;}
18141814
bool isOwned() const { return getValueOwnership() == ValueOwnership::Owned; }
1815-
bool isNonDifferentiable() const { return value.contains(NonDifferentiable); }
1815+
bool isNoDerivative() const { return value.contains(NoDerivative); }
18161816

18171817
ValueOwnership getValueOwnership() const {
18181818
return ValueOwnership((value.toRaw() & Ownership) >> OwnershipShift);
@@ -1855,10 +1855,10 @@ class ParameterTypeFlags {
18551855
: value - ParameterTypeFlags::NonEphemeral);
18561856
}
18571857

1858-
ParameterTypeFlags withNonDifferentiable(bool nonDifferentiable) const {
1858+
ParameterTypeFlags withNoDerivative(bool noDerivative) const {
18591859
return ParameterTypeFlags(
1860-
nonDifferentiable ? value | ParameterTypeFlags::NonDifferentiable
1861-
: value - ParameterTypeFlags::NonDifferentiable);
1860+
noDerivative ? value | ParameterTypeFlags::NoDerivative
1861+
: value - ParameterTypeFlags::NoDerivative);
18621862
}
18631863

18641864
bool operator ==(const ParameterTypeFlags &other) const {
@@ -1929,7 +1929,7 @@ class YieldTypeFlags {
19291929
/*autoclosure*/ false,
19301930
/*nonEphemeral*/ false,
19311931
getValueOwnership(),
1932-
/*nonDifferentiable*/ false);
1932+
/*noDerivative*/ false);
19331933
}
19341934

19351935
bool operator ==(const YieldTypeFlags &other) const {
@@ -2801,8 +2801,8 @@ class AnyFunctionType : public TypeBase {
28012801
/// Whether the parameter is marked '@_nonEphemeral'
28022802
bool isNonEphemeral() const { return Flags.isNonEphemeral(); }
28032803

2804-
/// Whether the parameter is marked '@nondiff'.
2805-
bool isNonDifferentiable() const { return Flags.isNonDifferentiable(); }
2804+
/// Whether the parameter is marked '@noDerivative'.
2805+
bool isNoDerivative() const { return Flags.isNoDerivative(); }
28062806

28072807
ValueOwnership getValueOwnership() const {
28082808
return Flags.getValueOwnership();
@@ -5699,7 +5699,7 @@ inline TupleTypeElt TupleTypeElt::getWithType(Type T) const {
56995699
/// Create one from what's present in the parameter decl and type
57005700
inline ParameterTypeFlags ParameterTypeFlags::fromParameterType(
57015701
Type paramTy, bool isVariadic, bool isAutoClosure, bool isNonEphemeral,
5702-
ValueOwnership ownership, bool isNonDifferentiable) {
5702+
ValueOwnership ownership, bool isNoDerivative) {
57035703
// FIXME(Remove InOut): The last caller that needs this is argument
57045704
// decomposition. Start by enabling the assertion there and fixing up those
57055705
// callers, then remove this, then remove
@@ -5710,7 +5710,7 @@ inline ParameterTypeFlags ParameterTypeFlags::fromParameterType(
57105710
ownership = ValueOwnership::InOut;
57115711
}
57125712
return {isVariadic, isAutoClosure, isNonEphemeral, ownership,
5713-
isNonDifferentiable};
5713+
isNoDerivative};
57145714
}
57155715

57165716
inline const Type *BoundGenericType::getTrailingObjectsPointer() const {

lib/AST/ASTPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2476,8 +2476,8 @@ static void printParameterFlags(ASTPrinter &printer, PrintOptions options,
24762476
ParameterTypeFlags flags, bool escaping) {
24772477
if (!options.excludeAttrKind(TAK_autoclosure) && flags.isAutoClosure())
24782478
printer << "@autoclosure ";
2479-
if (!options.excludeAttrKind(TAK_nondiff) && flags.isNonDifferentiable())
2480-
printer << "@nondiff ";
2479+
if (!options.excludeAttrKind(TAK_noDerivative) && flags.isNoDerivative())
2480+
printer << "@noDerivative ";
24812481

24822482
switch (flags.getValueOwnership()) {
24832483
case ValueOwnership::Default:

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6038,7 +6038,7 @@ AnyFunctionType::Param ParamDecl::toFunctionParam(Type type) const {
60386038
auto flags = ParameterTypeFlags::fromParameterType(
60396039
type, isVariadic(), isAutoClosure(), isNonEphemeral(),
60406040
getValueOwnership(),
6041-
/*isNonDifferentiable*/ false);
6041+
/*isNoDerivative*/ false);
60426042
return AnyFunctionType::Param(type, label, flags);
60436043
}
60446044

lib/AST/TypeRepr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ void AttributedTypeRepr::printAttrs(ASTPrinter &Printer,
298298
Printer.printSimpleAttr("@autoclosure") << " ";
299299
if (hasAttr(TAK_escaping))
300300
Printer.printSimpleAttr("@escaping") << " ";
301-
if (hasAttr(TAK_nondiff))
302-
Printer.printSimpleAttr("@nondiff") << " ";
301+
if (hasAttr(TAK_noDerivative))
302+
Printer.printSimpleAttr("@noDerivative") << " ";
303303

304304
if (hasAttr(TAK_differentiable)) {
305305
if (Attrs.isLinear()) {

lib/Sema/TypeCheckType.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,19 +2309,19 @@ Type TypeResolver::resolveAttributedType(TypeAttributes &attrs,
23092309
attrs.convention = None;
23102310
}
23112311

2312-
if (attrs.has(TAK_nondiff)) {
2312+
if (attrs.has(TAK_noDerivative)) {
23132313
if (!Context.LangOpts.EnableExperimentalDifferentiableProgramming) {
2314-
diagnose(attrs.getLoc(TAK_nondiff),
2314+
diagnose(attrs.getLoc(TAK_noDerivative),
23152315
diag::experimental_differentiable_programming_disabled);
23162316
} else if (!isParam) {
2317-
// @nondiff is only valid on parameters.
2318-
diagnose(attrs.getLoc(TAK_nondiff),
2317+
// @noDerivative is only valid on parameters.
2318+
diagnose(attrs.getLoc(TAK_noDerivative),
23192319
(isVariadicFunctionParam
23202320
? diag::attr_not_on_variadic_parameters
23212321
: diag::attr_only_on_parameters_of_differentiable),
2322-
"@nondiff");
2322+
"@noDerivative");
23232323
}
2324-
attrs.clearAttribute(TAK_nondiff);
2324+
attrs.clearAttribute(TAK_noDerivative);
23252325
}
23262326

23272327
// In SIL, handle @opened (n), which creates an existential archetype.
@@ -2441,22 +2441,22 @@ bool TypeResolver::resolveASTFunctionTypeParams(
24412441
break;
24422442
}
24432443

2444-
bool nondiff = false;
2444+
bool noDerivative = false;
24452445
if (auto *attrTypeRepr = dyn_cast<AttributedTypeRepr>(eltTypeRepr)) {
2446-
if (attrTypeRepr->getAttrs().has(TAK_nondiff)) {
2446+
if (attrTypeRepr->getAttrs().has(TAK_noDerivative)) {
24472447
if (!isDifferentiable &&
24482448
Context.LangOpts.EnableExperimentalDifferentiableProgramming)
24492449
diagnose(eltTypeRepr->getLoc(),
2450-
diag::attr_only_on_parameters_of_differentiable, "@nondiff")
2450+
diag::attr_only_on_parameters_of_differentiable, "@noDerivative")
24512451
.highlight(eltTypeRepr->getSourceRange());
24522452
else
2453-
nondiff = true;
2453+
noDerivative = true;
24542454
}
24552455
}
24562456

24572457
auto paramFlags = ParameterTypeFlags::fromParameterType(
24582458
ty, variadic, autoclosure, /*isNonEphemeral*/ false, ownership,
2459-
nondiff);
2459+
noDerivative);
24602460
elements.emplace_back(ty, Identifier(), paramFlags);
24612461
}
24622462

lib/Serialization/Deserialization.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4673,13 +4673,13 @@ class swift::TypeDeserializer {
46734673

46744674
IdentifierID labelID;
46754675
TypeID typeID;
4676-
bool isVariadic, isAutoClosure, isNonEphemeral, isNonDifferentiable;
4676+
bool isVariadic, isAutoClosure, isNonEphemeral, isNoDerivative;
46774677
unsigned rawOwnership;
46784678
decls_block::FunctionParamLayout::readRecord(scratch, labelID, typeID,
46794679
isVariadic, isAutoClosure,
46804680
isNonEphemeral,
46814681
rawOwnership,
4682-
isNonDifferentiable);
4682+
isNoDerivative);
46834683

46844684
auto ownership =
46854685
getActualValueOwnership((serialization::ValueOwnership)rawOwnership);
@@ -4694,7 +4694,7 @@ class swift::TypeDeserializer {
46944694
MF.getIdentifier(labelID),
46954695
ParameterTypeFlags(isVariadic, isAutoClosure,
46964696
isNonEphemeral, *ownership,
4697-
isNonDifferentiable));
4697+
isNoDerivative));
46984698
}
46994699

47004700
if (!isGeneric) {

lib/Serialization/ModuleFormat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5252
/// describe what change you made. The content of this comment isn't important;
5353
/// it just ensures a conflict if two people change the module format.
5454
/// Don't worry about adhering to the 80-column limit for this line.
55-
const uint16_t SWIFTMODULE_VERSION_MINOR = 525; // function parameter nondiff
55+
const uint16_t SWIFTMODULE_VERSION_MINOR = 525; // function parameter noDerivative
5656

5757
/// A standard hash seed used for all string hashes in a serialized module.
5858
///
@@ -899,7 +899,7 @@ namespace decls_block {
899899
BCFixed<1>, // autoclosure?
900900
BCFixed<1>, // non-ephemeral?
901901
ValueOwnershipField, // inout, shared or owned?
902-
BCFixed<1> // nondifferentiable?
902+
BCFixed<1> // noDerivative?
903903
>;
904904

905905
using MetatypeTypeLayout = BCRecordLayout<

lib/Serialization/Serialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3932,7 +3932,7 @@ class Serializer::TypeSerializer : public TypeVisitor<TypeSerializer> {
39323932
S.addDeclBaseNameRef(param.getLabel()),
39333933
S.addTypeRef(param.getPlainType()), paramFlags.isVariadic(),
39343934
paramFlags.isAutoClosure(), paramFlags.isNonEphemeral(), rawOwnership,
3935-
paramFlags.isNonDifferentiable());
3935+
paramFlags.isNoDerivative());
39363936
}
39373937
}
39383938

test/AutoDiff/ModuleInterface/differentiation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ public func a(f: @differentiable (Float) -> Float) {}
77
public func b(f: @differentiable(linear) (Float) -> Float) {}
88
// CHECK: public func b(f: @differentiable(linear) (Swift.Float) -> Swift.Float)
99

10-
public func c(f: @differentiable (Float, @nondiff Float) -> Float) {}
11-
// CHECK: public func c(f: @differentiable (Swift.Float, @nondiff Swift.Float) -> Swift.Float)
10+
public func c(f: @differentiable (Float, @noDerivative Float) -> Float) {}
11+
// CHECK: public func c(f: @differentiable (Swift.Float, @noDerivative Swift.Float) -> Swift.Float)

test/AutoDiff/Parse/differentiable_func_type.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ let b: @differentiable(linear) (Float) -> Float // okay
88
// CHECK: (pattern_named 'b'
99
// CHECK-NEXT: (type_attributed attrs=@differentiable(linear)
1010

11-
let c: @differentiable (Float, @nondiff Float) -> Float // okay
11+
let c: @differentiable (Float, @noDerivative Float) -> Float // okay
1212
// CHECK: (pattern_named 'c'
1313
// CHECK-NEXT: (type_attributed attrs=@differentiable
1414
// CHECK-NEXT: (type_function
1515
// CHECK-NEXT: (type_tuple
1616
// CHECK-NEXT: (type_ident
1717
// CHECK-NEXT: (component id='Float' bind=none))
18-
// CHECK-NEXT: (type_attributed attrs=@nondiff
18+
// CHECK-NEXT: (type_attributed attrs=@noDerivative
1919
// CHECK-NEXT: (type_ident
2020
// CHECK-NEXT: (component id='Float' bind=none)))
2121
// CHECK-NEXT: (type_ident

test/AutoDiff/Sema/differentiable_features_disabled.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ let _: @differentiable (Float) -> Float
55

66
// expected-error @+2 {{differentiable programming is an experimental feature that is currently disabled}}
77
// expected-error @+1 {{differentiable programming is an experimental feature that is currently disabled}}
8-
let _: @differentiable (Float, @nondiff Float) -> Float
8+
let _: @differentiable (Float, @noDerivative Float) -> Float
99

1010
// expected-error @+1 {{differentiable programming is an experimental feature that is currently disabled}}
11-
let _: (Float, @nondiff Float) -> Float
11+
let _: (Float, @noDerivative Float) -> Float
1212

1313
// expected-error @+1 {{differentiable programming is an experimental feature that is currently disabled}}
14-
let _: @nondiff Float
14+
let _: @noDerivative Float

test/AutoDiff/Sema/differentiable_func_type.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ let _: @differentiable Float
55

66
let _: @differentiable (Float) -> Float
77

8-
// expected-error @+1 {{'@nondiff' may only be used on parameters of '@differentiable' function types}}
9-
let _: @nondiff Float
8+
// expected-error @+1 {{'@noDerivative' may only be used on parameters of '@differentiable' function types}}
9+
let _: @noDerivative Float
1010

11-
// expected-error @+1 {{'@nondiff' may only be used on parameters of '@differentiable' function types}}
12-
let _: (Float) -> @nondiff Float
11+
// expected-error @+1 {{'@noDerivative' may only be used on parameters of '@differentiable' function types}}
12+
let _: (Float) -> @noDerivative Float
1313

14-
// expected-error @+1 {{'@nondiff' may only be used on parameters of '@differentiable' function types}}
15-
let _: @differentiable (Float) -> @nondiff Float
14+
// expected-error @+1 {{'@noDerivative' may only be used on parameters of '@differentiable' function types}}
15+
let _: @differentiable (Float) -> @noDerivative Float
1616

17-
// expected-error @+1 {{'@nondiff' may only be used on parameters of '@differentiable' function types}}
18-
let _: (@nondiff Float) -> Float
17+
// expected-error @+1 {{'@noDerivative' may only be used on parameters of '@differentiable' function types}}
18+
let _: (@noDerivative Float) -> Float
1919

20-
// expected-error @+2 {{'@nondiff' may only be used on parameters of '@differentiable' function types}}
21-
// expected-error @+1 {{'@nondiff' must not be used on variadic parameters}}
22-
let _: (Float, @nondiff Float...) -> Float
20+
// expected-error @+2 {{'@noDerivative' may only be used on parameters of '@differentiable' function types}}
21+
// expected-error @+1 {{'@noDerivative' must not be used on variadic parameters}}
22+
let _: (Float, @noDerivative Float...) -> Float
2323

24-
let _: @differentiable (@nondiff Float, Float) -> Float
24+
let _: @differentiable (@noDerivative Float, Float) -> Float
2525

26-
// expected-error @+1 {{'@nondiff' must not be used on variadic parameters}}
27-
let _: @differentiable (Float, @nondiff Float...) -> Float
26+
// expected-error @+1 {{'@noDerivative' must not be used on variadic parameters}}
27+
let _: @differentiable (Float, @noDerivative Float...) -> Float

test/AutoDiff/Serialization/differentiation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ func a(_ f: @differentiable (Float) -> Float) {}
1111
func b(_ f: @differentiable(linear) (Float) -> Float) {}
1212
// CHECK: func b(_ f: @differentiable(linear) (Float) -> Float)
1313

14-
func c(_ f: @differentiable (Float, @nondiff Float) -> Float) {}
15-
// CHECK: func c(_ f: @differentiable (Float, @nondiff Float) -> Float)
14+
func c(_ f: @differentiable (Float, @noDerivative Float) -> Float) {}
15+
// CHECK: func c(_ f: @differentiable (Float, @noDerivative Float) -> Float)

0 commit comments

Comments
 (0)