Skip to content

Commit 91bd7aa

Browse files
eaplataniosrxwei
authored andcommitted
---
yaml --- r: 340971 b: refs/heads/rxwei-patch-1 c: dd2067a h: refs/heads/master i: 340969: b6ce719 340967: 2aedf0e
1 parent e440103 commit 91bd7aa

File tree

8 files changed

+32
-11
lines changed

8 files changed

+32
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-08-18-a: b10b1fce14385faa6d44f6b933e95
10151015
refs/heads/rdar-43033749-fix-batch-mode-no-diags-swift-5.0-branch: a14e64eaad30de89f0f5f0b2a782eed7ecdcb255
10161016
refs/heads/revert-19006-error-bridging-integer-type: 8a9065a3696535305ea53fe9b71f91cbe6702019
10171017
refs/heads/revert-19050-revert-19006-error-bridging-integer-type: ecf752d54b05dd0a20f510f0bfa54a3fec3bcaca
1018-
refs/heads/rxwei-patch-1: 50850df5b1a501508228137984a62db49b5c1c00
1018+
refs/heads/rxwei-patch-1: dd2067ab0c0e035bd8b421777a4a6030c04e6dd5
10191019
refs/heads/shahmishal-patch-1: e58ec0f7488258d42bef51bc3e6d7b3dc74d7b2a
10201020
refs/heads/typelist-existential: 4046359efd541fb5c72d69a92eefc0a784df8f5e
10211021
refs/tags/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-08-20-a: 4319ba09e4fb8650ee86061075c74a016b6baab9

branches/rxwei-patch-1/include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,6 +2843,8 @@ ERROR(diff_params_clause_no_inferred_parameters,PointsToFirstBadToken,
28432843
"no differentiation parameters could be inferred; must differentiate "
28442844
"with respect to at least one parameter conforming to 'Differentiable'",
28452845
())
2846+
ERROR(diff_params_clause_inout_argument,none,
2847+
"'inout' parameters (%0) cannot be differentiated with respect to", (Type))
28462848
ERROR(diff_params_clause_cannot_diff_wrt_objects_or_existentials,none,
28472849
"class objects and protocol existentials (%0) cannot be differentiated "
28482850
"with respect to", (Type))

branches/rxwei-patch-1/include/swift/AST/Types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ class alignas(1 << TypeAlignInBits) TypeBase {
274274
TypeBase(const TypeBase&) = delete;
275275
void operator=(const TypeBase&) = delete;
276276

277-
/// This union contains to the ASTContext for canonical types, and is
277+
/// This union contains the ASTContext for canonical types, and is
278278
/// otherwise lazily populated by ASTContext when the canonical form of a
279279
/// non-canonical type is requested. The disposition of the union is stored
280280
/// outside of the union for performance. See Bits.TypeBase.IsCanonical.

branches/rxwei-patch-1/include/swift/SIL/SILFunction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ class SILFunction
580580
}
581581

582582
/// Returns true if the function has parameters that are consumed by the
583-
// callee.
583+
/// callee.
584584
bool hasOwnedParameters() const {
585585
for (auto &ParamInfo : getLoweredFunctionType()->getParameters()) {
586586
if (ParamInfo.isConsumed())

branches/rxwei-patch-1/lib/AST/AutoDiff.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ void AutoDiffParameterIndices::getSubsetParameterTypes(
199199
for (unsigned paramIndex : range(curryLevel->getNumParams()))
200200
if (parameters[parameterIndexOffset + paramIndex])
201201
paramTypes.push_back(
202-
curryLevel->getParams()[paramIndex].getPlainType());
202+
curryLevel->getParams()[paramIndex].getOldType());
203203
}
204204
}
205205

branches/rxwei-patch-1/lib/SILOptimizer/Mandatory/Differentiation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ class PullbackInfo {
465465
break;
466466
default:
467467
// When the original function has external linkage, we create an internal
468-
// struct for use by our own module. This is neccessary for cross-cell
468+
// struct for use by our own module. This is necessary for cross-cell
469469
// differentiation in Jupyter.
470470
// TODO: Add a test in the compiler that exercises a similar situation as
471471
// cross-cell differentiation in Jupyter.
@@ -729,7 +729,7 @@ void DifferentiationInvoker::print(llvm::raw_ostream &os) const {
729729
}
730730

731731
// Check whether the given requirements are satisfied, with the given
732-
// subsitution map and in the given module.
732+
// substitution map and in the given module.
733733
static bool checkRequirementsSatisfied(
734734
ArrayRef<Requirement> requirements, SubstitutionMap substMap,
735735
SILFunction *original, ModuleDecl *swiftModule) {
@@ -2002,7 +2002,7 @@ emitAssociatedFunctionReference(
20022002
auto *minimalAttr =
20032003
context.lookUpMinimalDifferentiableAttr(originalFn, desiredIndices);
20042004
if (!minimalAttr) {
2005-
// If the function is intentionally marked as being opauqe to
2005+
// If the function is intentionally marked as being opaque to
20062006
// differentiation, then we should not create a task for it.
20072007
if (originalFn->hasSemanticsAttr("autodiff.opaque")) {
20082008
context.emitNondifferentiabilityError(original, invoker,

branches/rxwei-patch-1/lib/Sema/TypeCheckAttr.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2980,17 +2980,24 @@ static bool checkDifferentiationParameters(
29802980
SmallVector<Type, 4> wrtParamTypes;
29812981
indices->getSubsetParameterTypes(functionType, wrtParamTypes);
29822982
for (unsigned i : range(wrtParamTypes.size())) {
2983+
SourceLoc loc = parsedWrtParams.empty()
2984+
? attrLoc
2985+
: parsedWrtParams[i].getLoc();
29832986
auto wrtParamType = wrtParamTypes[i];
2987+
if (wrtParamType->is<InOutType>()) {
2988+
TC.diagnose(
2989+
loc,
2990+
diag::diff_params_clause_inout_argument,
2991+
wrtParamType);
2992+
return true;
2993+
}
29842994
if (!wrtParamType->hasTypeParameter())
29852995
wrtParamType = wrtParamType->mapTypeOutOfContext();
29862996
if (derivativeGenEnv)
29872997
wrtParamType =
29882998
derivativeGenEnv->mapTypeIntoContext(wrtParamType);
29892999
else
29903000
wrtParamType = AFD->mapTypeIntoContext(wrtParamType);
2991-
SourceLoc loc = parsedWrtParams.empty()
2992-
? attrLoc
2993-
: parsedWrtParams[i].getLoc();
29943001
// Parameter cannot have a class or existential type.
29953002
if ((!wrtParamType->hasTypeParameter() &&
29963003
wrtParamType->isAnyClassReferenceType()) ||
@@ -3085,7 +3092,7 @@ void AttributeChecker::visitDifferentiableAttr(DifferentiableAttr *attr) {
30853092
}
30863093

30873094
// Start type-checking the arguments of the @differentiable attribute. This
3088-
// covers 'wrt:', 'jvp:', and 'vjp:', all of which are optional.
3095+
// covers 'wrt:', 'jvp:', 'vjp:', and 'where', all of which are optional.
30893096

30903097
// Handle 'where' clause, if it exists.
30913098
// - Resolve attribute where clause requirements and store in the attribute

branches/rxwei-patch-1/test/AutoDiff/differentiable_attr_type_checking.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,3 +853,15 @@ func two8(x: Float, y: Float) -> Float {
853853
func two9(x: Float, y: Float) -> Float {
854854
return x + y
855855
}
856+
857+
// Inout 'wrt:' arguments.
858+
859+
@differentiable(wrt: y) // expected-error {{cannot differentiate void function 'inout1(x:y:)'}}
860+
func inout1(x: Float, y: inout Float) -> Void {
861+
let _ = x + y
862+
}
863+
864+
@differentiable(wrt: y) // expected-error {{'inout' parameters ('inout Float') cannot be differentiated with respect to}}
865+
func inout2(x: Float, y: inout Float) -> Float {
866+
let _ = x + y
867+
}

0 commit comments

Comments
 (0)