Skip to content

Commit cfae072

Browse files
committed
[AutoDiff] Handle materializing adjoints with non-differentiable fields
Fixes #66522
1 parent 36bfbd6 commit cfae072

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/SILOptimizer/Differentiation/AdjointValue.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//===--- AdjointValue.cpp - Helper class for differentiation ----*- C++
2-
//-*---===//
1+
//===--- AdjointValue.h - Helper class for differentiation ----*- C++ -*---===//
32
//
43
// This source file is part of the Swift.org open source project
54
//
@@ -68,4 +67,4 @@ void swift::autodiff::AdjointValue::print(llvm::raw_ostream &s) const {
6867
s << "]";
6968
break;
7069
}
71-
}
70+
}

lib/SILOptimizer/Differentiation/PullbackCloner.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ class PullbackCloner::Implementation final
430430
}
431431
case AdjointValueKind::AddElement: {
432432
auto baseAdjoint = val;
433+
assert(baseAdjoint.getType().is<TupleType>() ||
434+
baseAdjoint.getType().getStructOrBoundGenericStruct() != nullptr);
433435

434436
// Current adjoint may be made up of layers of `AddElement` adjoints.
435437
// We can iteratively gather the list of elements to add instead of making

0 commit comments

Comments
 (0)