Skip to content

Commit c6847cd

Browse files
authored
---
yaml --- r: 262107 b: refs/heads/tensorflow c: 146a111 h: refs/heads/master i: 262105: cacac72 262103: bb8659d
1 parent c7a7ff7 commit c6847cd

20 files changed

+2
-945
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a: 22f738a831d43aff2b9c9773bcb65
818818
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a: 7d98cc16689baba5c8a3b90a9329bdcc1a12b4e9
819819
refs/heads/cherr42: a566ad54b073c2c56ac0a705d0a5bed9743135a5
820820
"refs/heads/codable_test_comment_fix": fc8f6824f7f347e1e8db55bff62db385c5728b5a
821-
refs/heads/tensorflow: 041a1fd63b0fdb26a742e44f45aab1f10558df51
821+
refs/heads/tensorflow: 146a111948a849e1c7bb17ad5505a8e303bc582a
822822
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-11-a: 8126fd7a652e2f70ad6d76505239e34fb2ef3e1a
823823
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-12-a: b3fd3dd84df6717f2e2e9df58c6d7e99fed57086
824824
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-13-a: 71135119579039dc321c5f65d870050fe36efda2

branches/tensorflow/include/swift/AST/DiagnosticsParse.def

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,14 +1254,6 @@ ERROR(expr_typeof_expected_rparen,PointsToFirstBadToken,
12541254
ERROR(expr_dynamictype_deprecated,PointsToFirstBadToken,
12551255
"'.dynamicType' is deprecated. Use 'type(of: ...)' instead", ())
12561256

1257-
// Adjoint expressions.
1258-
ERROR(expr_adjoint_expected_function_name,PointsToFirstBadToken,
1259-
"expected function name within '#adjoint` expression", ())
1260-
ERROR(expr_expected_lparen,none,
1261-
"expected '(' in '%0' expression", (StringRef))
1262-
ERROR(expr_expected_rparen,none,
1263-
"expected ')' in '%0' expression", (StringRef))
1264-
12651257
//------------------------------------------------------------------------------
12661258
// MARK: Attribute-parsing diagnostics
12671259
//------------------------------------------------------------------------------

branches/tensorflow/include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -739,25 +739,6 @@ NOTE(object_literal_resolve_import,none,
739739
// TensorFlow op literal
740740
ERROR(invalid_tfop,none, "%0", (StringRef))
741741

742-
// '#adjoint(...)' expression for automatic differentiation
743-
ERROR(adjoint_expr_original_base_type_unresolved,none,
744-
"could not resolve base type %0 of original function in #adjoint "
745-
"expression", (TypeLoc))
746-
ERROR(adjoint_expr_original_not_func_decl,none,
747-
"#adjoint expression can only be applied to function declarations, but %0"
748-
"is not a function declaration", (DeclName))
749-
ERROR(adjoint_expr_original_func_decl_unresolved,none,
750-
"original function declaration could not be resolved", ())
751-
ERROR(adjoint_expr_original_no_valid_differentiable_attr,none,
752-
"the original function %0 does not declare a valid @differentiable "
753-
"attribute", (DeclName))
754-
ERROR(adjoint_expr_original_overload_not_found,none,
755-
"could not find original function %0 with valid @differentiable "
756-
"attribute in #adjoint expression", (DeclName))
757-
ERROR(adjoint_expr_ambiguous_original_function_identifier,none,
758-
"ambiguous or overloaded original function identifier %0 cannot be used "
759-
"in #adjoint expression", (DeclName))
760-
761742
ERROR(use_local_before_declaration,none,
762743
"use of local variable %0 before its declaration", (DeclName))
763744
ERROR(unsupported_existential_type,none,

branches/tensorflow/include/swift/AST/Expr.h

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,6 @@ class alignas(8) Expr {
344344
NumArgLabels : 16
345345
);
346346

347-
// SWIFT_ENABLE_TENSORFLOW
348-
SWIFT_INLINE_BITFIELD(AdjointExpr, Expr, 2,
349-
FunctionRefKind : 2
350-
);
351-
352347
enum { NumCheckedCastKindBits = 4 };
353348
SWIFT_INLINE_BITFIELD(CheckedCastExpr, Expr, NumCheckedCastKindBits,
354349
CastKind : NumCheckedCastKindBits
@@ -3833,64 +3828,6 @@ class DynamicTypeExpr : public Expr {
38333828
}
38343829
};
38353830

3836-
// SWIFT_ENABLE_TENSORFLOW
3837-
/// The `#adjoint(...)` expression returns the declared adjoint of functions
3838-
/// with the `@differentiable(reverse, ...)` attribute.
3839-
class AdjointExpr : public Expr {
3840-
private:
3841-
SourceLoc Loc, LParenLoc;
3842-
// The original function name.
3843-
DeclName OriginalName;
3844-
DeclNameLoc OriginalNameLoc;
3845-
// The base type of the original function.
3846-
// This is non-null only when the original function is not top-level (i.e. it
3847-
// is an instance/static method).
3848-
TypeLoc BaseType;
3849-
// The resolved adjoint function declaration.
3850-
ConcreteDeclRef AdjointFunction = nullptr;
3851-
SourceLoc RParenLoc;
3852-
3853-
explicit AdjointExpr(SourceLoc loc, SourceLoc lParenLoc,
3854-
DeclName originalName, DeclNameLoc originalNameLoc,
3855-
TypeLoc baseType, SourceLoc rParenLoc)
3856-
: Expr(ExprKind::Adjoint, /*Implicit*/ false), Loc(loc),
3857-
LParenLoc(lParenLoc), OriginalName(originalName),
3858-
OriginalNameLoc(originalNameLoc), BaseType(baseType),
3859-
RParenLoc(rParenLoc) {
3860-
Bits.AdjointExpr.FunctionRefKind =
3861-
static_cast<unsigned>(FunctionRefKind::Unapplied);
3862-
}
3863-
3864-
public:
3865-
static AdjointExpr *create(ASTContext &ctx, SourceLoc loc,
3866-
SourceLoc lParenLoc, DeclName originalName,
3867-
DeclNameLoc originalNameLoc, TypeRepr *baseType,
3868-
SourceLoc rParenLoc);
3869-
3870-
DeclName getOriginalName() const { return OriginalName; }
3871-
DeclNameLoc getOriginalNameLoc() const { return OriginalNameLoc; }
3872-
TypeLoc getBaseType() const { return BaseType; }
3873-
3874-
ConcreteDeclRef getAdjointFunction() { return AdjointFunction; }
3875-
void setAdjointFunction(ConcreteDeclRef ref) { AdjointFunction = ref; }
3876-
3877-
SourceRange getSourceRange() const { return SourceRange(Loc, RParenLoc); }
3878-
3879-
/// Retrieve the kind of function reference.
3880-
FunctionRefKind getFunctionRefKind() const {
3881-
return static_cast<FunctionRefKind>(Bits.AdjointExpr.FunctionRefKind);
3882-
}
3883-
3884-
/// Set the kind of function reference.
3885-
void setFunctionRefKind(FunctionRefKind refKind) {
3886-
Bits.AdjointExpr.FunctionRefKind = static_cast<unsigned>(refKind);
3887-
}
3888-
3889-
static bool classof(const Expr *E) {
3890-
return E->getKind() == ExprKind::Adjoint;
3891-
}
3892-
};
3893-
38943831
/// An expression referring to an opaque object of a fixed type.
38953832
/// /// Opaque value expressions occur when a particular value within the AST
38963833
/// needs to be re-used without being re-evaluated or for a value that is

branches/tensorflow/include/swift/AST/ExprNodes.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ EXPR(ObjCSelector, Expr)
192192
EXPR(KeyPath, Expr)
193193
UNCHECKED_EXPR(KeyPathDot, Expr)
194194
// SWIFT_ENABLE_TENSORFLOW
195-
EXPR(Adjoint, Expr)
196195
EXPR(PoundAssert, Expr)
197196
LAST_EXPR(PoundAssert)
198197

branches/tensorflow/include/swift/Parse/Parser.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,9 +1242,6 @@ class Parser {
12421242
ParserResult<Expr> parseExprConfiguration();
12431243
ParserResult<Expr> parseExprStringLiteral();
12441244
ParserResult<Expr> parseExprTypeOf();
1245-
/// SWIFT_ENABLE_TENSORFLOW
1246-
ParserResult<Expr> parseExprGradientBody(ExprKind kind);
1247-
ParserResult<Expr> parseExprAdjoint();
12481245

12491246
StringRef copyAndStripUnderscores(StringRef text);
12501247

branches/tensorflow/lib/AST/ASTDumper.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,22 +1863,6 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
18631863
PrintWithColorRAII(OS, ParenthesisColor) << ')';
18641864
}
18651865

1866-
// SWIFT_ENABLE_TENSORFLOW
1867-
void visitAdjointExpr(AdjointExpr *E) {
1868-
printCommon(E, "adjoint_expr");
1869-
PrintWithColorRAII(OS, TypeReprColor) << " base_type='";
1870-
if (auto *baseRepr = E->getBaseType().getTypeRepr())
1871-
baseRepr->print(PrintWithColorRAII(OS, TypeReprColor).getOS());
1872-
else
1873-
PrintWithColorRAII(OS, TypeReprColor) << "<<NULL>>";
1874-
PrintWithColorRAII(OS, TypeReprColor) << "'";
1875-
PrintWithColorRAII(OS, IdentifierColor) << " original_name='"
1876-
<< E->getOriginalName() << "'";
1877-
PrintWithColorRAII(OS, ExprModifierColor)
1878-
<< " function_ref=" << getFunctionRefKindStr(E->getFunctionRefKind());
1879-
PrintWithColorRAII(OS, ParenthesisColor) << ')';
1880-
}
1881-
18821866
void visitObjectLiteralExpr(ObjectLiteralExpr *E) {
18831867
printCommon(E, "object_literal")
18841868
<< " kind='" << E->getLiteralKindPlainName() << "'";

branches/tensorflow/lib/AST/ASTWalker.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -455,11 +455,6 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
455455
return E;
456456
}
457457

458-
// SWIFT_ENABLE_TENSORFLOW
459-
Expr *visitAdjointExpr(AdjointExpr *E) {
460-
return E;
461-
}
462-
463458
Expr *visitObjectLiteralExpr(ObjectLiteralExpr *E) {
464459
HANDLE_SEMANTIC_EXPR(E);
465460

branches/tensorflow/lib/AST/Expr.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,6 @@ ConcreteDeclRef Expr::getReferencedDecl() const {
366366
NO_REFERENCE(KeyPath);
367367
NO_REFERENCE(KeyPathDot);
368368
// SWIFT_ENABLE_TENSORFLOW
369-
NO_REFERENCE(Adjoint);
370369
NO_REFERENCE(PoundAssert);
371370

372371
#undef SIMPLE_REFERENCE
@@ -537,8 +536,6 @@ bool Expr::canAppendPostfixExpression(bool appendingPostfixOperator) const {
537536
case ExprKind::MagicIdentifierLiteral:
538537
case ExprKind::ObjCSelector:
539538
case ExprKind::KeyPath:
540-
// SWIFT_ENABLE_TENSORFLOW
541-
case ExprKind::Adjoint:
542539
return true;
543540

544541
case ExprKind::ObjectLiteral:
@@ -1170,15 +1167,6 @@ packSingleArgument(ASTContext &ctx, SourceLoc lParenLoc, ArrayRef<Expr *> args,
11701167
return arg;
11711168
}
11721169

1173-
// SWIFT_ENABLE_TENSORFLOW
1174-
AdjointExpr *
1175-
AdjointExpr::create(ASTContext &ctx, SourceLoc loc, SourceLoc lParenLoc,
1176-
DeclName originalName, DeclNameLoc originalNameLoc,
1177-
TypeRepr *baseType, SourceLoc rParenLoc) {
1178-
return new (ctx) AdjointExpr(loc, lParenLoc, originalName, originalNameLoc,
1179-
TypeLoc(baseType, Type()), rParenLoc);
1180-
}
1181-
11821170
ObjectLiteralExpr::ObjectLiteralExpr(SourceLoc PoundLoc, LiteralKind LitKind,
11831171
Expr *Arg,
11841172
ArrayRef<Identifier> argLabels,

branches/tensorflow/lib/Parse/ParseExpr.cpp

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,10 +1697,6 @@ ParserResult<Expr> Parser::parseExprPrimary(Diag<> ID, bool isExprBasic) {
16971697
return parseExprCollection();
16981698

16991699
// SWIFT_ENABLE_TENSORFLOW
1700-
case tok::pound_adjoint:
1701-
return parseExprAdjoint();
1702-
break;
1703-
17041700
case tok::pound_assert:
17051701
return parseExprPoundAssert();
17061702
break;
@@ -3520,84 +3516,6 @@ Parser::parsePlatformVersionConstraintSpec() {
35203516
}
35213517

35223518
// SWIFT_ENABLE_TENSORFLOW
3523-
/// parseQualifiedDeclName
3524-
///
3525-
/// qualified-decl-name:
3526-
/// type-identifier? unqualified-decl-name
3527-
/// type-identifier:
3528-
/// identifier generic-args? ('.' identifier generic-args?)*
3529-
///
3530-
/// Parses an optional base type, followed by a declaration name.
3531-
/// Returns true on error (if function decl name could not be parsed).
3532-
static bool parseQualifiedDeclName(Parser &P, Diag<> nameParseError,
3533-
TypeRepr *&baseType, DeclName &name,
3534-
DeclNameLoc &nameLoc) {
3535-
// If the current token is an identifier or `Self` or `Any`, then attempt to
3536-
// parse the base type. Otherwise, base type is null.
3537-
bool canParseBaseType = false;
3538-
{
3539-
Parser::BacktrackingScope backtrack(P);
3540-
canParseBaseType = P.canParseTypeIdentifier();
3541-
}
3542-
if (canParseBaseType)
3543-
baseType =
3544-
P.parseTypeIdentifier(/*isParsingQualifiedDeclName*/ true).getPtrOrNull();
3545-
else
3546-
baseType = nullptr;
3547-
3548-
// If base type was parsed and has at least one component, then there was a
3549-
// dot before the current token.
3550-
bool afterDot = false;
3551-
if (baseType) {
3552-
if (auto ident = dyn_cast<IdentTypeRepr>(baseType)) {
3553-
auto components = ident->getComponentRange();
3554-
afterDot = std::distance(components.begin(), components.end()) > 0;
3555-
}
3556-
}
3557-
name = P.parseUnqualifiedDeclName(afterDot, nameLoc, nameParseError,
3558-
/*allowOperators*/ true,
3559-
/*allowZeroArgCompoundNames*/ true);
3560-
// The base type is optional, but the final unqualified decl name is not.
3561-
// If name could not be parsed, return true for error.
3562-
if (!name) return true;
3563-
return false;
3564-
}
3565-
3566-
/// SWIFT_ENABLE_TENSORFLOW
3567-
/// parseExprAdjoint
3568-
/// expr-adjoint: '#adjoint' '(' qualified-decl-name ')'
3569-
ParserResult<Expr> Parser::parseExprAdjoint() {
3570-
SyntaxParsingContext AdjointContext(SyntaxContext, SyntaxKind::AdjointExpr);
3571-
3572-
SourceLoc poundLoc = consumeToken(tok::pound_adjoint);
3573-
SourceLoc lParenLoc, rParenLoc;
3574-
3575-
auto errorAndSkipToEnd = [&]() -> ParserResult<Expr> {
3576-
skipUntilDeclStmtRBrace(tok::r_paren);
3577-
rParenLoc = Tok.is(tok::r_paren) ? consumeToken() : PreviousLoc;
3578-
return makeParserResult<Expr>(new (Context)
3579-
ErrorExpr(SourceRange(poundLoc, rParenLoc)));
3580-
};
3581-
3582-
if (parseToken(tok::l_paren, lParenLoc, diag::expr_expected_lparen,
3583-
"#adjoint"))
3584-
return errorAndSkipToEnd();
3585-
// Parse original function.
3586-
TypeRepr *baseType;
3587-
DeclName originalName;
3588-
DeclNameLoc originalNameLoc;
3589-
if (parseQualifiedDeclName(*this, diag::expr_adjoint_expected_function_name,
3590-
baseType, originalName, originalNameLoc))
3591-
return errorAndSkipToEnd();
3592-
if (parseToken(tok::r_paren, rParenLoc, diag::expr_expected_rparen,
3593-
"#adjoint"))
3594-
return errorAndSkipToEnd();
3595-
return makeParserResult<Expr>(
3596-
AdjointExpr::create(Context, poundLoc, lParenLoc, originalName,
3597-
originalNameLoc, baseType, rParenLoc));
3598-
}
3599-
3600-
/// SWIFT_ENABLE_TENSORFLOW
36013519
/// expr-pound-assert:
36023520
/// '#assert' '(' expr ',' string_literal ')'
36033521
ParserResult<Expr> Parser::parseExprPoundAssert() {

branches/tensorflow/lib/SILGen/SILGenExpr.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,6 @@ namespace {
457457
RValue visitAbstractClosureExpr(AbstractClosureExpr *E, SGFContext C);
458458
RValue visitInterpolatedStringLiteralExpr(InterpolatedStringLiteralExpr *E,
459459
SGFContext C);
460-
// SWIFT_ENABLE_TENSORFLOW
461-
RValue visitAdjointExpr(AdjointExpr *E, SGFContext C);
462460
RValue visitObjectLiteralExpr(ObjectLiteralExpr *E, SGFContext C);
463461
RValue visitEditorPlaceholderExpr(EditorPlaceholderExpr *E, SGFContext C);
464462
RValue visitObjCSelectorExpr(ObjCSelectorExpr *E, SGFContext C);
@@ -2728,43 +2726,6 @@ visitInterpolatedStringLiteralExpr(InterpolatedStringLiteralExpr *E,
27282726
return visit(E->getSemanticExpr(), C);
27292727
}
27302728

2731-
// SWIFT_ENABLE_TENSORFLOW
2732-
RValue RValueEmitter::
2733-
visitAdjointExpr(AdjointExpr *E, SGFContext C) {
2734-
ConcreteDeclRef adjointFunc = E->getAdjointFunction();
2735-
FuncDecl *adjointDecl = cast<FuncDecl>(adjointFunc.getDecl());
2736-
SILLocation loc(adjointDecl);
2737-
SILDeclRef adjointDeclRef(adjointDecl);
2738-
2739-
// If adjoint is an instance method, mark as curried.
2740-
if (adjointDecl->isInstanceMember()) {
2741-
adjointDeclRef = adjointDeclRef.asCurried();
2742-
}
2743-
auto adjointInfo = SGF.getConstantInfo(adjointDeclRef);
2744-
2745-
// Convert function ref to thick function type.
2746-
if (!adjointDecl->isStatic()) {
2747-
auto resultTy = E->getType()->getCanonicalType();
2748-
ManagedValue result =
2749-
SGF.emitClosureValue(loc, adjointDeclRef, resultTy,
2750-
adjointFunc.getSubstitutions());
2751-
return RValue(SGF, loc, resultTy, result);
2752-
}
2753-
// Otherwise, apply metatype to static adjoint method.
2754-
SILValue ref = SGF.emitGlobalFunctionRef(loc, adjointDeclRef, adjointInfo);
2755-
auto subs = adjointFunc.getSubstitutions();
2756-
auto baseMeta = adjointInfo.SILFnType->substGenericArgs(SGF.SGM.M, subs)
2757-
->getSelfParameter().getType();
2758-
auto metatype = SGF.B.createMetatype(loc, SGF.getLoweredType(baseMeta));
2759-
auto partialApplyTy = SGF.B.getPartialApplyResultType(
2760-
adjointInfo.getSILType(), 1, SGF.getModule(), subs,
2761-
ParameterConvention::Direct_Guaranteed);
2762-
auto apply = SGF.B.createPartialApply(loc, ref, ref->getType(),
2763-
subs, { metatype }, partialApplyTy);
2764-
ManagedValue adjointValue = SGF.emitManagedRValueWithCleanup(apply);
2765-
return RValue(SGF, E, adjointValue);
2766-
}
2767-
27682729
RValue RValueEmitter::
27692730
visitObjectLiteralExpr(ObjectLiteralExpr *E, SGFContext C) {
27702731
// SWIFT_ENABLE_TENSORFLOW

branches/tensorflow/lib/Sema/CSApply.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2338,35 +2338,6 @@ namespace {
23382338
llvm_unreachable("Unhandled MagicIdentifierLiteralExpr in switch.");
23392339
}
23402340

2341-
// SWIFT_ENABLE_TENSORFLOW
2342-
Expr *visitAdjointExpr(AdjointExpr *expr) {
2343-
auto locator = cs.getConstraintLocator(expr);
2344-
auto adjointDeclRef = expr->getAdjointFunction();
2345-
auto adjointDecl = cast<FuncDecl>(adjointDeclRef.getDecl());
2346-
2347-
// If adjoint is within a type context (it is an instance/static method),
2348-
// use member locator.
2349-
if (adjointDecl->getInnermostTypeContext())
2350-
locator = cs.getConstraintLocator(expr, ConstraintLocator::Member);
2351-
2352-
// If adjoint has generic signature, calculate substitutions and update
2353-
// adjoint decl ref with them.
2354-
SubstitutionMap substitutions;
2355-
if (auto genSig = adjointDecl->getGenericSignature()) {
2356-
substitutions = solution.computeSubstitutions(genSig, locator);
2357-
expr->setAdjointFunction(
2358-
ConcreteDeclRef(adjointDecl, substitutions));
2359-
}
2360-
2361-
auto selected = solution.getOverloadChoice(locator);
2362-
auto simplifiedType = simplifyType(selected.openedFullType);
2363-
// For static methods, return result of curried method.
2364-
if (adjointDecl->isStatic())
2365-
simplifiedType = simplifiedType->castTo<AnyFunctionType>()->getResult();
2366-
cs.setType(expr, simplifiedType);
2367-
return expr;
2368-
}
2369-
23702341
// SWIFT_ENABLE_TENSORFLOW
23712342
Expr *visitTFOp(ObjectLiteralExpr *expr) {
23722343
auto &ctx = cs.TC.Context;

0 commit comments

Comments
 (0)