Skip to content

Commit 9886b63

Browse files
authored
[AutoDiff] Rename 'AutoDiffIndexSubset' to 'IndexSubset'. (#27615)
Per @DougGregor's review comment (#27555 (comment)), `AutoDiffIndexSubset` data structure could have a more general name. We rename it to `IndexSubset` and move it to its own file.
1 parent ced939b commit 9886b63

26 files changed

+506
-480
lines changed

include/swift/AST/ASTContext.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ namespace swift {
109109
class TypeAliasDecl;
110110
class VarDecl;
111111
class UnifiedStatsReporter;
112-
// SWIFT_ENABLE_TENSORFLOW
113-
class AutoDiffIndexSubset;
112+
class IndexSubset;
114113
class VectorSpace;
115114
class DifferentiableAttr;
116115

@@ -280,8 +279,7 @@ class ASTContext final {
280279
/// Cache of `@differentiable` attributes keyed by parameter indices. This
281280
/// helps us diagnose multiple `@differentiable`s that are with respect to the
282281
/// same set of parameters.
283-
llvm::DenseMap<std::pair<Decl *, AutoDiffIndexSubset *>,
284-
DifferentiableAttr *>
282+
llvm::DenseMap<std::pair<Decl *, IndexSubset *>, DifferentiableAttr *>
285283
DifferentiableAttrs;
286284

287285
private:

include/swift/AST/Attr.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,7 @@ class DifferentiableAttr final
15521552
/// specified.
15531553
FuncDecl *VJPFunction = nullptr;
15541554
/// The differentiation parameters' indices, resolved by the type checker.
1555-
AutoDiffIndexSubset *ParameterIndices = nullptr;
1555+
IndexSubset *ParameterIndices = nullptr;
15561556
/// The trailing where clause (optional).
15571557
TrailingWhereClause *WhereClause = nullptr;
15581558
/// The generic signature for autodiff derivative functions. Resolved by the
@@ -1571,7 +1571,7 @@ class DifferentiableAttr final
15711571

15721572
explicit DifferentiableAttr(ASTContext &context, bool implicit,
15731573
SourceLoc atLoc, SourceRange baseRange,
1574-
bool linear, AutoDiffIndexSubset *indices,
1574+
bool linear, IndexSubset *indices,
15751575
Optional<DeclNameWithLoc> jvp,
15761576
Optional<DeclNameWithLoc> vjp,
15771577
GenericSignature *derivativeGenericSignature);
@@ -1587,7 +1587,7 @@ class DifferentiableAttr final
15871587

15881588
static DifferentiableAttr *create(ASTContext &context, bool implicit,
15891589
SourceLoc atLoc, SourceRange baseRange,
1590-
bool linear, AutoDiffIndexSubset *indices,
1590+
bool linear, IndexSubset *indices,
15911591
Optional<DeclNameWithLoc> jvp,
15921592
Optional<DeclNameWithLoc> vjp,
15931593
GenericSignature *derivativeGenSig);
@@ -1602,10 +1602,10 @@ class DifferentiableAttr final
16021602
/// registered VJP.
16031603
Optional<DeclNameWithLoc> getVJP() const { return VJP; }
16041604

1605-
AutoDiffIndexSubset *getParameterIndices() const {
1605+
IndexSubset *getParameterIndices() const {
16061606
return ParameterIndices;
16071607
}
1608-
void setParameterIndices(AutoDiffIndexSubset *pi) {
1608+
void setParameterIndices(IndexSubset *pi) {
16091609
ParameterIndices = pi;
16101610
}
16111611

@@ -1681,7 +1681,7 @@ class DifferentiatingAttr final
16811681
/// The number of parsed parameters specified in 'wrt:'.
16821682
unsigned NumParsedParameters = 0;
16831683
/// The differentiation parameters' indices, resolved by the type checker.
1684-
AutoDiffIndexSubset *ParameterIndices = nullptr;
1684+
IndexSubset *ParameterIndices = nullptr;
16851685

16861686
explicit DifferentiatingAttr(ASTContext &context, bool implicit,
16871687
SourceLoc atLoc, SourceRange baseRange,
@@ -1691,7 +1691,7 @@ class DifferentiatingAttr final
16911691
explicit DifferentiatingAttr(ASTContext &context, bool implicit,
16921692
SourceLoc atLoc, SourceRange baseRange,
16931693
DeclNameWithLoc original, bool linear,
1694-
AutoDiffIndexSubset *indices);
1694+
IndexSubset *indices);
16951695

16961696
public:
16971697
static DifferentiatingAttr *create(ASTContext &context, bool implicit,
@@ -1702,7 +1702,7 @@ class DifferentiatingAttr final
17021702
static DifferentiatingAttr *create(ASTContext &context, bool implicit,
17031703
SourceLoc atLoc, SourceRange baseRange,
17041704
DeclNameWithLoc original, bool linear,
1705-
AutoDiffIndexSubset *indices);
1705+
IndexSubset *indices);
17061706

17071707
DeclNameWithLoc getOriginal() const { return Original; }
17081708

@@ -1723,10 +1723,10 @@ class DifferentiatingAttr final
17231723
return NumParsedParameters;
17241724
}
17251725

1726-
AutoDiffIndexSubset *getParameterIndices() const {
1726+
IndexSubset *getParameterIndices() const {
17271727
return ParameterIndices;
17281728
}
1729-
void setParameterIndices(AutoDiffIndexSubset *pi) {
1729+
void setParameterIndices(IndexSubset *pi) {
17301730
ParameterIndices = pi;
17311731
}
17321732

@@ -1757,7 +1757,7 @@ class TransposingAttr final
17571757
/// The number of parsed parameters specified in 'wrt:'.
17581758
unsigned NumParsedParameters = 0;
17591759
/// The differentiation parameters' indices, resolved by the type checker.
1760-
AutoDiffIndexSubset *ParameterIndexSubset = nullptr;
1760+
IndexSubset *ParameterIndexSubset = nullptr;
17611761

17621762
explicit TransposingAttr(ASTContext &context, bool implicit,
17631763
SourceLoc atLoc, SourceRange baseRange,
@@ -1767,7 +1767,7 @@ class TransposingAttr final
17671767
explicit TransposingAttr(ASTContext &context, bool implicit,
17681768
SourceLoc atLoc, SourceRange baseRange,
17691769
TypeRepr *baseType, DeclNameWithLoc original,
1770-
AutoDiffIndexSubset *indices);
1770+
IndexSubset *indices);
17711771

17721772
public:
17731773
static TransposingAttr *create(ASTContext &context, bool implicit,
@@ -1778,7 +1778,7 @@ class TransposingAttr final
17781778
static TransposingAttr *create(ASTContext &context, bool implicit,
17791779
SourceLoc atLoc, SourceRange baseRange,
17801780
TypeRepr *baseType, DeclNameWithLoc original,
1781-
AutoDiffIndexSubset *indices);
1781+
IndexSubset *indices);
17821782

17831783
TypeRepr *getBaseType() const { return BaseType; }
17841784
DeclNameWithLoc getOriginal() const { return Original; }
@@ -1798,10 +1798,10 @@ class TransposingAttr final
17981798
return NumParsedParameters;
17991799
}
18001800

1801-
AutoDiffIndexSubset *getParameterIndexSubset() const {
1801+
IndexSubset *getParameterIndexSubset() const {
18021802
return ParameterIndexSubset;
18031803
}
1804-
void setParameterIndices(AutoDiffIndexSubset *pi) {
1804+
void setParameterIndices(IndexSubset *pi) {
18051805
ParameterIndexSubset = pi;
18061806
}
18071807

0 commit comments

Comments
 (0)