Skip to content

Commit 0233973

Browse files
authored
---
yaml --- r: 277438 b: refs/heads/tensorflow-merge c: c9683d5 h: refs/heads/master
1 parent bb9f5c0 commit 0233973

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-10-29-a: 1b087071edaea398480fb778e
11241124
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-10-30-a: 8bc9e108e1480d9217299984e428c601c7aaac75
11251125
refs/tags/swift-4.2.1-RELEASE: 02a6ca969ea1387475b6caeb69c31186df7d30b6
11261126
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-11-01-a: 3b0299288f8287094b9ef587f46df54f42a347af
1127-
refs/heads/tensorflow-merge: 9511f404ceae43fdaa91263a396716a22b17f9e0
1127+
refs/heads/tensorflow-merge: c9683d5d231b0b9102803f6155218dfd33b0726e
11281128
refs/heads/TensorFlowLite: b91446471276e37bbfe64767c875f3c7f7102954
11291129
refs/heads/ad-side-effects: 19e0c0de1f59b0929c381925df2e8c72cdf4a728
11301130
refs/heads/add-test-for-asan-compiler-crash: 3cdeecffb47bf28707b299fa2b5bdf0769a4a826

branches/tensorflow-merge/lib/SIL/SILFunctionBuilder.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,25 @@ void SILFunctionBuilder::addFunctionAttributes(SILFunction *F,
7373
// - Non-getter accessors (setters, modifiers, etc).
7474
// - Default argument generator functions.
7575
// - Thunks. Those are currently handled in SILGenThunk.cpp.
76-
if ((!isa<AccessorDecl>(decl) || dyn_cast<AccessorDecl>(decl)->isGetter()) &&
76+
if ((!isa<AccessorDecl>(decl) || cast<AccessorDecl>(decl)->isGetter()) &&
7777
constant.kind != SILDeclRef::Kind::DefaultArgGenerator &&
7878
!constant.autoDiffAssociatedFunctionIdentifier &&
79+
!constant.isStoredPropertyInitializer() &&
7980
!constant.isThunk()) {
8081
for (auto *A : Attrs.getAttributes<DifferentiableAttr>()) {
81-
auto *DA = cast<DifferentiableAttr>(A);
8282
std::string jvpName, vjpName;
8383
// Get JVP/VJP names.
84-
if (auto *jvpFn = DA->getJVPFunction())
84+
if (auto *jvpFn = A->getJVPFunction())
8585
jvpName = SILDeclRef(jvpFn).mangle();
86-
if (auto *vjpFn = DA->getVJPFunction())
86+
if (auto *vjpFn = A->getVJPFunction())
8787
vjpName = SILDeclRef(vjpFn).mangle();
8888
// Get lowered argument indices.
89-
auto paramIndices = DA->getParameterIndices();
90-
auto loweredIndices = paramIndices->getLowered(
89+
auto paramIndices = A->getParameterIndices();
90+
auto loweredParamIndices = paramIndices->getLowered(
9191
decl->getInterfaceType()->castTo<AnyFunctionType>());
92-
SILAutoDiffIndices indices(/*source*/ 0, loweredIndices);
92+
SILAutoDiffIndices indices(/*source*/ 0, loweredParamIndices);
9393
auto silDiffAttr = SILDifferentiableAttr::create(
94-
M, indices, DA->getRequirements(), M.allocateCopy(jvpName),
94+
M, indices, A->getRequirements(), M.allocateCopy(jvpName),
9595
M.allocateCopy(vjpName));
9696
F->addDifferentiableAttr(silDiffAttr);
9797
}

branches/tensorflow-merge/test/AutoDiff/differentiable_attr_silgen.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -emit-silgen -verify %s | %FileCheck %s
1+
// RUN: %target-swift-frontend -emit-silgen -enable-testing -verify %s | %FileCheck %s
22

33
//===----------------------------------------------------------------------===//
44
// Normal types
@@ -155,4 +155,12 @@ extension DiffComputedProp : Differentiable {
155155
}
156156

157157
// CHECK-LABEL: DiffComputedProp.computedProp.getter
158-
// CHECK-NEXT: sil {{.*}} [differentiable source 0 wrt 0 jvp @computedPropJVP vjp @computedPropVJP]
158+
// CHECK-NEXT: [differentiable source 0 wrt 0 jvp @computedPropJVP vjp @computedPropVJP]
159+
160+
public struct MyLayer: Differentiable {
161+
@differentiable
162+
var x: Float = 10
163+
}
164+
165+
// CHECK-LABEL: initialization expression of MyLayer.x
166+
// CHECK-NEXT: sil [transparent] @$s26differentiable_attr_silgen7MyLayerV1xSfvpfi : $@convention(thin) () -> Float

0 commit comments

Comments
 (0)