Skip to content

Commit 81c2f84

Browse files
committed
Merge branch 'tensorflow' of github.com:apple/swift into parameter-indices
2 parents e7d2d81 + 5cd2b00 commit 81c2f84

File tree

76 files changed

+355
-1778
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+355
-1778
lines changed

docs/SIL.rst

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5555,36 +5555,6 @@ Extracts the original function or an associated function from the given
55555555
``@differentiable`` function at a specific differentiation order. It must be
55565556
provided with an extractee: ``[original]``, ``[jvp]`` or ``[vjp]``.
55575557

5558-
.. SWIFT_ENABLE_TENSORFLOW
5559-
5560-
Graph Program Extraction
5561-
~~~~~~~~~~~~~~~~~~~~~~~~
5562-
5563-
graph_op
5564-
````````
5565-
::
5566-
5567-
sil-instruction ::= 'graph_op' string-literal
5568-
'(' (sil-operand (',' sil-operand)*)? ')'
5569-
('{' (sil-graph-op-attr (',' sil-graph-op-attr)*)? '}')?
5570-
':' sil-type (',' sil-type)*
5571-
sil-graph-op-attr ::= sil-identifier ':' sil-symbolic-value
5572-
sil-symbolic-value ::= i[0-9]+ int-literal |
5573-
f(32|64) float-literal |
5574-
sil-type |
5575-
'[' (sil-symbolic-value (',' sil-symbolic-value)*)? ']'
5576-
5577-
%add = graph_op "tf.Add"(%x : $Tensor<Float>, %y : $Tensor<Float>) \
5578-
{T: $Float} : $Tensor<Float>
5579-
5580-
Represents a graph program operation.
5581-
5582-
``graph_op`` instructions have a name, zero or more operands, zero or more
5583-
attributes (an identifier and SIL constant value), and one or more result
5584-
types.
5585-
5586-
This instruction is only valid in raw SIL and is rewritten and extracted by the
5587-
graph program extraction passes (debastraction, partitioning, graph lowering).
55885558

55895559
Assertion configuration
55905560
~~~~~~~~~~~~~~~~~~~~~~~

include/swift/AST/ASTContext.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,6 @@ class ASTContext final {
495495
/// has been imported. Otherwise, this returns null.
496496
StructDecl *getTensorDataTypeDecl() const;
497497

498-
/// Retrieve the type for Swift._AutoDiffTape.
499-
CanType getAutoDiffTapeType() const;
500-
501498
/// Retrieve the type Swift.Never.
502499
CanType getNeverType() const;
503500

include/swift/AST/Attr.def

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,12 +418,10 @@ DECL_ATTR(differentiating, Differentiating,
418418
SIMPLE_DECL_ATTR(compilerEvaluable, CompilerEvaluable,
419419
OnAccessor | OnFunc | OnConstructor | OnSubscript,
420420
/* Not serialized */ 89)
421-
SIMPLE_DECL_ATTR(TensorFlowGraph, TensorFlowGraph,
422-
OnFunc, 90)
423421
SIMPLE_DECL_ATTR(_fieldwiseDifferentiable, FieldwiseDifferentiable,
424-
OnNominalType | UserInaccessible, 91)
422+
OnNominalType | UserInaccessible, 90)
425423
SIMPLE_DECL_ATTR(noDerivative, NoDerivative,
426-
OnVar, 92)
424+
OnVar, 91)
427425

428426
#undef TYPE_ATTR
429427
#undef DECL_ATTR_ALIAS

include/swift/AST/Builtins.def

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -555,25 +555,6 @@ BUILTIN_MISC_OPERATION(WillThrow, "willThrow", "", Special)
555555
/// poundAssert has type (Builtin.Int1, Builtin.RawPointer) -> ().
556556
BUILTIN_MISC_OPERATION(PoundAssert, "poundAssert", "", Special)
557557

558-
// SWIFT_ENABLE_TENSORFLOW
559-
/// tensorflowSend_X has type <T> (T) -> (). The X in the name is an integer
560-
/// ID number that allows matching sends and receives.
561-
BUILTIN_MISC_OPERATION(TensorFlowSend, "tensorflowSend", "", Special)
562-
563-
/// tensorflowReceive_X has type <T> () -> T. The X in the name is an integer
564-
/// ID number that allows matching sends and receives.
565-
BUILTIN_MISC_OPERATION(TensorFlowReceive, "tensorflowReceive", "", Special)
566-
567-
// Automatic differentiation builtins.
568-
/// autodiffCreateTape has type <T> () -> Builtin.AutoDiffTape<T>.
569-
BUILTIN_MISC_OPERATION(AutoDiffCreateTape, "autodiffCreateTape", "", Special)
570-
/// autodiffPushToTape has type <T> (Builtin.AutoDiffTape<T>, T, Builtin.Word) -> ().
571-
BUILTIN_MISC_OPERATION(AutoDiffPushToTape, "autodiffPushToTape", "", Special)
572-
/// autodiffPopFromTape has type <T> (Builtin.AutoDiffTape<T>, Builtin.Word) -> T.
573-
BUILTIN_MISC_OPERATION(AutoDiffPopFromTape, "autodiffPopFromTape", "", Special)
574-
/// autodiffDestroyTape has type <T> (Builtin.AutoDiffTape<T>) -> ().
575-
BUILTIN_MISC_OPERATION(AutoDiffDestroyTape, "autodiffDestroyTape", "", Special)
576-
577558
#undef BUILTIN_MISC_OPERATION
578559

579560
/// Builtins for instrumentation added by sanitizers during SILGen.

include/swift/AST/DiagnosticsSIL.def

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -248,59 +248,6 @@ NOTE(constexpr_called_from, none, "when called from here", ())
248248
NOTE(constexpr_not_evaluable, none,
249249
"expression not evaluable as constant here", ())
250250

251-
// SWIFT_ENABLE_TENSORFLOW
252-
// TensorFlow Support Diagnostics.
253-
ERROR(tf_internal_error, none,
254-
"internal error: %0", (StringRef))
255-
ERROR(tfop_invalid_tfop, none,
256-
"#tfop invalid: %0", (StringRef))
257-
ERROR(tfop_incorrect_definition, none,
258-
"tfop function doesn't align with TensorFlow op definition:\n%0",
259-
(StringRef))
260-
ERROR(tfop_value_no_send_receive, none,
261-
"value cannot be used by non-TensorFlow API", ())
262-
ERROR(tf_multiple_device, none,
263-
"device configuration specified multiple times", ())
264-
NOTE(tf_multiple_device_prev, none,
265-
"previous configuration is specified here", ())
266-
ERROR(tf_lowering_error, none,
267-
"internal error generating TensorFlow graph:\n%0", (StringRef))
268-
ERROR(tf_lowering_unknown_op, none,
269-
"op named '%0' is not registered in TensorFlow", (StringRef))
270-
ERROR(tf_convention_tf_host_code_not_allowed, none,
271-
"host code is not allowed in a TensorFlow function", ())
272-
ERROR(tf_no_captures_in_tf_functions, none,
273-
"TensorFlow functions cannot capture values", ())
274-
275-
WARNING(tf_value_implicitly_copied_to_accel, none,
276-
"%0 implicitly copied to the accelerator, use .toAccelerator() to make "
277-
"transfer explicit",
278-
(StringRef))
279-
WARNING(tf_value_implicitly_copied_to_accel_always, none,
280-
"%0 always cause a copy to the accelerator, use .toAccelerator() to make "
281-
"transfer explicit",
282-
(StringRef))
283-
284-
WARNING(tf_value_implicitly_copied_to_host, none,
285-
"value implicitly copied to the host, use .toHost() to make "
286-
"transfer explicit",
287-
())
288-
289-
NOTE(tf_value_used_here, none,
290-
"value used here", ())
291-
ERROR(tf_op_misuse, none,
292-
"%0", (StringRef))
293-
NOTE(tf_op_misuse_note, none,
294-
"%0", (StringRef))
295-
296-
ERROR(tf_op_result_generic,none,
297-
"cannot extract TensorFlow result into type %0, because %0 contains "
298-
"unbound generic parameters", (Type))
299-
ERROR(tf_op_result_not_value_or_aggregate,none,
300-
"cannot extract TensorFlow result into type %0, because %0 is not a "
301-
"TensorFlow value type or an aggregate of TensorFlow value types",
302-
(Type))
303-
304251
// Control flow diagnostics.
305252
ERROR(missing_return,none,
306253
"missing return in a %select{function|closure}1 expected to return %0",

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -736,10 +736,6 @@ NOTE(object_literal_resolve_import,none,
736736
"import %0 to use '%1' as the default %2 literal type",
737737
(StringRef, StringRef, StringRef))
738738

739-
// SWIFT_ENABLE_TENSORFLOW
740-
// TensorFlow op literal
741-
ERROR(invalid_tfop,none, "%0", (StringRef))
742-
743739
ERROR(use_local_before_declaration,none,
744740
"use of local variable %0 before its declaration", (DeclName))
745741
ERROR(unsupported_existential_type,none,
@@ -2781,21 +2777,6 @@ ERROR(compiler_evaluable_forbidden_type,none,
27812777
ERROR(compiler_evaluable_ref_non_compiler_evaluable,none,
27822778
"@compilerEvaluable functions may not reference non-@compilerEvaluable functions", ())
27832779

2784-
// @TensorFlowGraph attribute
2785-
ERROR(tf_graph_attr_top_level_only,none,
2786-
"@TensorFlowGraph can only be applied to top-level functions", ())
2787-
ERROR(tf_graph_deprecated_please_remove,none,
2788-
"@TensorFlowGraph has no effect and is deprecated. Please remove.", ())
2789-
ERROR(tf_graph_attr_function_tensorflow_value_only,none,
2790-
"@TensorFlowGraph can only be applied to functions whose parameters and "
2791-
"return values are TensorFlow values or aggregates of TensorFlow "
2792-
"values", ())
2793-
ERROR(tf_graph_attr_no_generic_functions,none,
2794-
"@TensorFlowGraph cannot be applied to generic functions", ())
2795-
ERROR(tf_graph_attr_no_functions_with_captures,none,
2796-
"@TensorFlowGraph cannot be applied to functions that capture values",
2797-
())
2798-
27992780
// @noDerivative attribute
28002781
ERROR(noderivative_only_on_stored_properties_in_differentiable_structs,none,
28012782
"'@noDerivative' is only allowed on stored properties in structure types "

include/swift/AST/Expr.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,13 +1154,6 @@ class ObjectLiteralExpr final
11541154
return static_cast<LiteralKind>(Bits.ObjectLiteralExpr.LitKind);
11551155
}
11561156

1157-
// SWIFT_ENABLE_TENSORFLOW
1158-
/// Return true if this object literal is the #tfop(...) op descriptor for
1159-
/// TensorFlow.
1160-
bool isTFOp() const {
1161-
return getLiteralKind() == LiteralKind::tfop;
1162-
}
1163-
11641157
Expr *getArg() const { return Arg; }
11651158
void setArg(Expr *arg) { Arg = arg; }
11661159

include/swift/AST/KnownProtocols.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ PROTOCOL(TensorArrayProtocol)
8585
PROTOCOL(TensorGroup)
8686
PROTOCOL_(TensorFlowDataTypeCompatible)
8787
PROTOCOL(TensorProtocol)
88-
PROTOCOL(TensorSendableReceivable)
8988
PROTOCOL(VectorNumeric)
9089
// TODO(TF-213): Remove underscore `Differentiable` protocols.
9190
PROTOCOL(__Differentiable)
@@ -111,8 +110,6 @@ EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByUnicodeScalarLiteral, "UnicodeScala
111110
EXPRESSIBLE_BY_LITERAL_PROTOCOL_(ExpressibleByColorLiteral, "_ColorLiteralType", true)
112111
EXPRESSIBLE_BY_LITERAL_PROTOCOL_(ExpressibleByImageLiteral, "_ImageLiteralType", true)
113112
EXPRESSIBLE_BY_LITERAL_PROTOCOL_(ExpressibleByFileReferenceLiteral, "_FileReferenceLiteralType", true)
114-
// SWIFT_ENABLE_TENSORFLOW
115-
EXPRESSIBLE_BY_LITERAL_PROTOCOL_(ExpressibleByTensorFlowOp, "_ExpressibleByTensorFlowOp", true)
116113

117114
BUILTIN_EXPRESSIBLE_BY_LITERAL_PROTOCOL_(ExpressibleByBuiltinBooleanLiteral)
118115
BUILTIN_EXPRESSIBLE_BY_LITERAL_PROTOCOL_(ExpressibleByBuiltinExtendedGraphemeClusterLiteral)

include/swift/AST/KnownStdlibTypes.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,4 @@ KNOWN_STDLIB_TYPE_DECL(KeyedEncodingContainer, NominalTypeDecl, 1)
8282
KNOWN_STDLIB_TYPE_DECL(KeyedDecodingContainer, NominalTypeDecl, 1)
8383
KNOWN_STDLIB_TYPE_DECL(RangeReplaceableCollection, ProtocolDecl, 1)
8484

85-
// SWIFT_ENABLE_TENSORFLOW
86-
KNOWN_STDLIB_TYPE_DECL(_AutoDiffTape, ClassDecl, 1)
87-
8885
#undef KNOWN_STDLIB_TYPE_DECL

include/swift/AST/Types.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,10 +2661,6 @@ enum class SILFunctionTypeRepresentation : uint8_t {
26612661

26622662
/// A closure invocation function that has not been bound to a context.
26632663
Closure,
2664-
2665-
// SWIFT_ENABLE_TENSORFLOW
2666-
/// A TensorFlow function pointer.
2667-
TensorFlow,
26682664
};
26692665

26702666
/// Can this calling convention result in a function being called indirectly
@@ -2676,8 +2672,6 @@ inline bool canBeCalledIndirectly(SILFunctionTypeRepresentation rep) {
26762672
case SILFunctionTypeRepresentation::CFunctionPointer:
26772673
case SILFunctionTypeRepresentation::Block:
26782674
case SILFunctionTypeRepresentation::Closure:
2679-
// SWIFT_ENABLE_TENSORFLOW
2680-
case SILFunctionTypeRepresentation::TensorFlow:
26812675
return false;
26822676
case SILFunctionTypeRepresentation::ObjCMethod:
26832677
case SILFunctionTypeRepresentation::Method:
@@ -2702,8 +2696,6 @@ getSILFunctionLanguage(SILFunctionTypeRepresentation rep) {
27022696
case SILFunctionTypeRepresentation::Method:
27032697
case SILFunctionTypeRepresentation::WitnessMethod:
27042698
case SILFunctionTypeRepresentation::Closure:
2705-
// SWIFT_ENABLE_TENSORFLOW
2706-
case SILFunctionTypeRepresentation::TensorFlow:
27072699
return SILFunctionLanguage::Swift;
27082700
}
27092701

@@ -2935,8 +2927,6 @@ class AnyFunctionType : public TypeBase {
29352927
case SILFunctionTypeRepresentation::Thin:
29362928
case SILFunctionTypeRepresentation::CFunctionPointer:
29372929
case SILFunctionTypeRepresentation::Closure:
2938-
// SWIFT_ENABLE_TENSORFLOW
2939-
case SILFunctionTypeRepresentation::TensorFlow:
29402930
return false;
29412931
case SILFunctionTypeRepresentation::ObjCMethod:
29422932
case SILFunctionTypeRepresentation::Method:
@@ -2959,8 +2949,6 @@ class AnyFunctionType : public TypeBase {
29592949
case SILFunctionTypeRepresentation::WitnessMethod:
29602950
case SILFunctionTypeRepresentation::CFunctionPointer:
29612951
case SILFunctionTypeRepresentation::Closure:
2962-
// SWIFT_ENABLE_TENSORFLOW
2963-
case SILFunctionTypeRepresentation::TensorFlow:
29642952
return false;
29652953
}
29662954

@@ -3808,8 +3796,6 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
38083796
case Representation::Thin:
38093797
case Representation::CFunctionPointer:
38103798
case Representation::Closure:
3811-
// SWIFT_ENABLE_TENSORFLOW
3812-
case Representation::TensorFlow:
38133799
return false;
38143800
case Representation::ObjCMethod:
38153801
case Representation::Method:
@@ -3832,8 +3818,6 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
38323818
case Representation::Method:
38333819
case Representation::WitnessMethod:
38343820
case Representation::Closure:
3835-
// SWIFT_ENABLE_TENSORFLOW
3836-
case Representation::TensorFlow:
38373821
return false;
38383822
}
38393823

include/swift/Runtime/AutoDiff.h

Lines changed: 0 additions & 48 deletions
This file was deleted.

include/swift/Runtime/RuntimeFunctions.def

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,31 +1320,6 @@ FUNCTION(IntToFloat64, swift_intToFloat64, SwiftCC,
13201320
ARGS(SizeTy->getPointerTo(), SizeTy),
13211321
ATTRS(NoUnwind, ReadOnly))
13221322

1323-
// SWIFT_ENABLE_TENSORFLOW
1324-
// OpaqueValue *swift_autodiffCreateTape();
1325-
FUNCTION(AutoDiffCreateTape, swift_autodiffCreateTape, C_CC,
1326-
RETURNS(OpaquePtrTy),
1327-
ARGS(TypeMetadataPtrTy),
1328-
ATTRS(NoUnwind))
1329-
1330-
// void swift_autodiffDestroyTape(OpaqueValue *tape);
1331-
FUNCTION(AutoDiffDestroyTape, swift_autodiffDestroyTape, C_CC,
1332-
RETURNS(VoidTy),
1333-
ARGS(OpaquePtrTy),
1334-
ATTRS(NoUnwind))
1335-
1336-
// void swift_autodiffPushToTape(OpaqueValue *tape, OpaqueValue *value);
1337-
FUNCTION(AutoDiffPushToTape, swift_autodiffPushToTape, C_CC,
1338-
RETURNS(VoidTy),
1339-
ARGS(OpaquePtrTy, OpaquePtrTy),
1340-
ATTRS(NoUnwind))
1341-
1342-
// OpaqueValue *swift_autodiffPopFromTape(OpaqueValue *tape);
1343-
FUNCTION(AutoDiffPopFromTape, swift_autodiffPopFromTape, C_CC,
1344-
RETURNS(OpaquePtrTy),
1345-
ARGS(OpaquePtrTy),
1346-
ATTRS(NoUnwind))
1347-
13481323
// SWIFT_ENABLE_TENSORFLOW
13491324
//===----------------------------------------------------------------------===//
13501325
// - MARK: Runtime functions issued by IRGen in dynamic compilation mode.

include/swift/SIL/ApplySite.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ class ApplySite {
196196
case SILFunctionTypeRepresentation::ObjCMethod:
197197
case SILFunctionTypeRepresentation::WitnessMethod:
198198
case SILFunctionTypeRepresentation::Closure:
199-
// SWIFT_ENABLE_TENSORFLOW
200-
case SILFunctionTypeRepresentation::TensorFlow:
201199
return true;
202200
case SILFunctionTypeRepresentation::Block:
203201
case SILFunctionTypeRepresentation::Thick:

include/swift/SILOptimizer/PassManager/Passes.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ namespace swift {
4242
/// Run all SIL passes for -Onone on module \p M.
4343
void runSILPassesForOnone(SILModule &M);
4444

45-
// SWIFT_ENABLE_TENSORFLOW
46-
/// Run the partioning pass for TensorFlow operations.
47-
void runSILTFPartitionPass(SILModule &M);
48-
4945
/// Run the SIL ownership eliminator pass on \p M.
5046
bool runSILOwnershipEliminatorPass(SILModule &M);
5147

0 commit comments

Comments
 (0)