Skip to content

[TF] Remove @convention(tensorflow) and @TensorFlowGraph. #24722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions include/swift/AST/Attr.def
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,10 @@ DECL_ATTR(differentiating, Differentiating,
SIMPLE_DECL_ATTR(compilerEvaluable, CompilerEvaluable,
OnAccessor | OnFunc | OnConstructor | OnSubscript,
/* Not serialized */ 89)
SIMPLE_DECL_ATTR(TensorFlowGraph, TensorFlowGraph,
OnFunc, 90)
SIMPLE_DECL_ATTR(_fieldwiseDifferentiable, FieldwiseDifferentiable,
OnNominalType | UserInaccessible, 91)
OnNominalType | UserInaccessible, 90)
SIMPLE_DECL_ATTR(noDerivative, NoDerivative,
OnVar, 92)
OnVar, 91)

#undef TYPE_ATTR
#undef DECL_ATTR_ALIAS
Expand Down
9 changes: 0 additions & 9 deletions include/swift/AST/Builtins.def
Original file line number Diff line number Diff line change
Expand Up @@ -555,15 +555,6 @@ BUILTIN_MISC_OPERATION(WillThrow, "willThrow", "", Special)
/// poundAssert has type (Builtin.Int1, Builtin.RawPointer) -> ().
BUILTIN_MISC_OPERATION(PoundAssert, "poundAssert", "", Special)

// SWIFT_ENABLE_TENSORFLOW
/// tensorflowSend_X has type <T> (T) -> (). The X in the name is an integer
/// ID number that allows matching sends and receives.
BUILTIN_MISC_OPERATION(TensorFlowSend, "tensorflowSend", "", Special)

/// tensorflowReceive_X has type <T> () -> T. The X in the name is an integer
/// ID number that allows matching sends and receives.
BUILTIN_MISC_OPERATION(TensorFlowReceive, "tensorflowReceive", "", Special)

#undef BUILTIN_MISC_OPERATION

/// Builtins for instrumentation added by sanitizers during SILGen.
Expand Down
15 changes: 0 additions & 15 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -2781,21 +2781,6 @@ ERROR(compiler_evaluable_forbidden_type,none,
ERROR(compiler_evaluable_ref_non_compiler_evaluable,none,
"@compilerEvaluable functions may not reference non-@compilerEvaluable functions", ())

// @TensorFlowGraph attribute
ERROR(tf_graph_attr_top_level_only,none,
"@TensorFlowGraph can only be applied to top-level functions", ())
ERROR(tf_graph_deprecated_please_remove,none,
"@TensorFlowGraph has no effect and is deprecated. Please remove.", ())
ERROR(tf_graph_attr_function_tensorflow_value_only,none,
"@TensorFlowGraph can only be applied to functions whose parameters and "
"return values are TensorFlow values or aggregates of TensorFlow "
"values", ())
ERROR(tf_graph_attr_no_generic_functions,none,
"@TensorFlowGraph cannot be applied to generic functions", ())
ERROR(tf_graph_attr_no_functions_with_captures,none,
"@TensorFlowGraph cannot be applied to functions that capture values",
())

// @noDerivative attribute
ERROR(noderivative_only_on_stored_properties_in_differentiable_structs,none,
"'@noDerivative' is only allowed on stored properties in structure types "
Expand Down
16 changes: 0 additions & 16 deletions include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -2661,10 +2661,6 @@ enum class SILFunctionTypeRepresentation : uint8_t {

/// A closure invocation function that has not been bound to a context.
Closure,

// SWIFT_ENABLE_TENSORFLOW
/// A TensorFlow function pointer.
TensorFlow,
};

/// Can this calling convention result in a function being called indirectly
Expand All @@ -2676,8 +2672,6 @@ inline bool canBeCalledIndirectly(SILFunctionTypeRepresentation rep) {
case SILFunctionTypeRepresentation::CFunctionPointer:
case SILFunctionTypeRepresentation::Block:
case SILFunctionTypeRepresentation::Closure:
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionTypeRepresentation::TensorFlow:
return false;
case SILFunctionTypeRepresentation::ObjCMethod:
case SILFunctionTypeRepresentation::Method:
Expand All @@ -2702,8 +2696,6 @@ getSILFunctionLanguage(SILFunctionTypeRepresentation rep) {
case SILFunctionTypeRepresentation::Method:
case SILFunctionTypeRepresentation::WitnessMethod:
case SILFunctionTypeRepresentation::Closure:
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionTypeRepresentation::TensorFlow:
return SILFunctionLanguage::Swift;
}

Expand Down Expand Up @@ -2935,8 +2927,6 @@ class AnyFunctionType : public TypeBase {
case SILFunctionTypeRepresentation::Thin:
case SILFunctionTypeRepresentation::CFunctionPointer:
case SILFunctionTypeRepresentation::Closure:
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionTypeRepresentation::TensorFlow:
return false;
case SILFunctionTypeRepresentation::ObjCMethod:
case SILFunctionTypeRepresentation::Method:
Expand All @@ -2959,8 +2949,6 @@ class AnyFunctionType : public TypeBase {
case SILFunctionTypeRepresentation::WitnessMethod:
case SILFunctionTypeRepresentation::CFunctionPointer:
case SILFunctionTypeRepresentation::Closure:
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionTypeRepresentation::TensorFlow:
return false;
}

Expand Down Expand Up @@ -3808,8 +3796,6 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
case Representation::Thin:
case Representation::CFunctionPointer:
case Representation::Closure:
// SWIFT_ENABLE_TENSORFLOW
case Representation::TensorFlow:
return false;
case Representation::ObjCMethod:
case Representation::Method:
Expand All @@ -3832,8 +3818,6 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
case Representation::Method:
case Representation::WitnessMethod:
case Representation::Closure:
// SWIFT_ENABLE_TENSORFLOW
case Representation::TensorFlow:
return false;
}

Expand Down
2 changes: 0 additions & 2 deletions include/swift/SIL/ApplySite.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ class ApplySite {
case SILFunctionTypeRepresentation::ObjCMethod:
case SILFunctionTypeRepresentation::WitnessMethod:
case SILFunctionTypeRepresentation::Closure:
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionTypeRepresentation::TensorFlow:
return true;
case SILFunctionTypeRepresentation::Block:
case SILFunctionTypeRepresentation::Thick:
Expand Down
4 changes: 0 additions & 4 deletions include/swift/SILOptimizer/PassManager/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ namespace swift {
/// Run all SIL passes for -Onone on module \p M.
void runSILPassesForOnone(SILModule &M);

// SWIFT_ENABLE_TENSORFLOW
/// Run the partioning pass for TensorFlow operations.
void runSILTFPartitionPass(SILModule &M);

/// Run the SIL ownership eliminator pass on \p M.
bool runSILOwnershipEliminatorPass(SILModule &M);

Expand Down
5 changes: 0 additions & 5 deletions include/swift/Serialization/ModuleFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ enum class FunctionTypeRepresentation : uint8_t {
Block,
Thin,
CFunctionPointer,
// SWIFT_ENABLE_TENSORFLOW
TensorFlow,
};
using FunctionTypeRepresentationField = BCFixed<4>;

Expand All @@ -192,9 +190,6 @@ enum class SILFunctionTypeRepresentation : uint8_t {
Block,
Thin,
CFunctionPointer,
// SWIFT_ENABLE_TENSORFLOW
TensorFlow,

FirstSIL = 8,
Method = FirstSIL,
ObjCMethod,
Expand Down
2 changes: 0 additions & 2 deletions lib/AST/ASTDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ getSILFunctionTypeRepresentationString(SILFunctionType::Representation value) {
case SILFunctionType::Representation::Thick: return "thick";
case SILFunctionType::Representation::Block: return "block";
case SILFunctionType::Representation::CFunctionPointer: return "c";
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionType::Representation::TensorFlow: return "tensorflow";
case SILFunctionType::Representation::Thin: return "thin";
case SILFunctionType::Representation::Method: return "method";
case SILFunctionType::Representation::ObjCMethod: return "objc_method";
Expand Down
2 changes: 0 additions & 2 deletions lib/AST/ASTMangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1405,8 +1405,6 @@ void ASTMangler::appendImplFunctionType(SILFunctionType *fn) {
switch (fn->getRepresentation()) {
case SILFunctionTypeRepresentation::Thick:
case SILFunctionTypeRepresentation::Thin:
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionTypeRepresentation::TensorFlow:
break;
case SILFunctionTypeRepresentation::Block:
OpArgs.push_back('B');
Expand Down
8 changes: 0 additions & 8 deletions lib/AST/ASTPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3837,10 +3837,6 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
case SILFunctionType::Representation::CFunctionPointer:
Printer << "c";
break;
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionType::Representation::TensorFlow:
Printer << "tensorflow";
break;
case SILFunctionType::Representation::Method:
Printer << "method";
break;
Expand Down Expand Up @@ -3890,10 +3886,6 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
case SILFunctionType::Representation::CFunctionPointer:
Printer << "c";
break;
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionType::Representation::TensorFlow:
Printer << "tensorflow";
break;
case SILFunctionType::Representation::Method:
Printer << "method";
break;
Expand Down
19 changes: 0 additions & 19 deletions lib/AST/Builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,21 +975,6 @@ static ValueDecl *getGetObjCTypeEncodingOperation(ASTContext &Context,
}

// SWIFT_ENABLE_TENSORFLOW
static ValueDecl *getTensorFlowSend(ASTContext &Context, Identifier Id) {
// <T> (T) -> ()
BuiltinGenericSignatureBuilder builder(Context);
builder.addParameter(makeGenericParam());
builder.setResult(makeConcrete(Context.TheEmptyTupleType));
return builder.build(Id);
}

static ValueDecl *getTensorFlowReceive(ASTContext &Context, Identifier Id) {
// <T> () -> (T)
BuiltinGenericSignatureBuilder builder(Context);
builder.setResult(makeGenericParam());
return builder.build(Id);
}

static ValueDecl *getAutoDiffApplyAssociatedFunction(
ASTContext &Context, Identifier Id, AutoDiffAssociatedFunctionKind kind,
unsigned arity, unsigned order, bool rethrows) {
Expand Down Expand Up @@ -2069,10 +2054,6 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
return getUnsafeGuaranteedEnd(Context, Id);

// SWIFT_ENABLE_TENSORFLOW
case BuiltinValueKind::TensorFlowSend:
return getTensorFlowSend(Context, Id);
case BuiltinValueKind::TensorFlowReceive:
return getTensorFlowReceive(Context, Id);
case BuiltinValueKind::AutoDiffApply:
llvm_unreachable("Handled above");

Expand Down
12 changes: 0 additions & 12 deletions lib/IRGen/GenCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ llvm::CallingConv::ID irgen::expandCallingConv(IRGenModule &IGM,
case SILFunctionTypeRepresentation::CFunctionPointer:
case SILFunctionTypeRepresentation::ObjCMethod:
case SILFunctionTypeRepresentation::Block:
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionTypeRepresentation::TensorFlow:
return llvm::CallingConv::C;

case SILFunctionTypeRepresentation::Method:
Expand Down Expand Up @@ -1078,8 +1076,6 @@ void SignatureExpansion::expandExternalSignatureTypes() {
paramTys.push_back(clangCtx.VoidPtrTy);
break;

// SWIFT_ENABLE_TENSORFLOW
case SILFunctionTypeRepresentation::TensorFlow:
case SILFunctionTypeRepresentation::CFunctionPointer:
// No implicit arguments.
break;
Expand Down Expand Up @@ -1374,8 +1370,6 @@ void SignatureExpansion::expandParameters() {
case SILFunctionType::Representation::ObjCMethod:
case SILFunctionType::Representation::Thin:
case SILFunctionType::Representation::Closure:
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionType::Representation::TensorFlow:
return FnType->hasErrorResult();

case SILFunctionType::Representation::Thick:
Expand Down Expand Up @@ -1887,8 +1881,6 @@ Callee::Callee(CalleeInfo &&info, const FunctionPointer &fn,
case SILFunctionTypeRepresentation::Thin:
case SILFunctionTypeRepresentation::Closure:
case SILFunctionTypeRepresentation::CFunctionPointer:
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionTypeRepresentation::TensorFlow:
assert(!FirstData && !SecondData);
break;
}
Expand All @@ -1903,8 +1895,6 @@ llvm::Value *Callee::getSwiftContext() const {
case SILFunctionTypeRepresentation::CFunctionPointer:
case SILFunctionTypeRepresentation::Thin:
case SILFunctionTypeRepresentation::Closure:
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionTypeRepresentation::TensorFlow:
return nullptr;

case SILFunctionTypeRepresentation::WitnessMethod:
Expand Down Expand Up @@ -2765,8 +2755,6 @@ void CallEmission::setArgs(Explosion &original, bool isOutlined,

case SILFunctionTypeRepresentation::Closure:
case SILFunctionTypeRepresentation::Method:
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionTypeRepresentation::TensorFlow:
case SILFunctionTypeRepresentation::Thin:
case SILFunctionTypeRepresentation::Thick: {
// Check for value arguments that need to be passed indirectly.
Expand Down
2 changes: 0 additions & 2 deletions lib/IRGen/GenClangType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,6 @@ clang::CanQualType GenClangType::visitSILFunctionType(CanSILFunctionType type) {
kind = CFunctionPointer;
break;

// SWIFT_ENABLE_TENSORFLOW
case SILFunctionType::Representation::TensorFlow:
case SILFunctionType::Representation::Thick:
case SILFunctionType::Representation::Thin:
case SILFunctionType::Representation::Method:
Expand Down
4 changes: 0 additions & 4 deletions lib/IRGen/GenFunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,6 @@ const TypeInfo *TypeConverter::convertFunctionType(SILFunctionType *T) {
case SILFunctionType::Representation::ObjCMethod:
case SILFunctionType::Representation::CFunctionPointer:
case SILFunctionType::Representation::Closure:
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionType::Representation::TensorFlow:
return ThinFuncTypeInfo::create(CanSILFunctionType(T),
IGM.FunctionPtrTy,
IGM.getPointerSize(),
Expand Down Expand Up @@ -547,8 +545,6 @@ getFuncSignatureInfoForLowered(IRGenModule &IGM, CanSILFunctionType type) {
case SILFunctionType::Representation::WitnessMethod:
case SILFunctionType::Representation::ObjCMethod:
case SILFunctionType::Representation::Closure:
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionType::Representation::TensorFlow:
return ti.as<ThinFuncTypeInfo>();
case SILFunctionType::Representation::Thick:
return ti.as<FuncTypeInfo>();
Expand Down
2 changes: 0 additions & 2 deletions lib/IRGen/GenProto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2190,8 +2190,6 @@ bool irgen::hasPolymorphicParameters(CanSILFunctionType ty) {
case SILFunctionTypeRepresentation::Closure:
return ty->isPolymorphic();

// SWIFT_ENABLE_TENSORFLOW
case SILFunctionTypeRepresentation::TensorFlow:
case SILFunctionTypeRepresentation::CFunctionPointer:
case SILFunctionTypeRepresentation::ObjCMethod:
// May be polymorphic at the SIL level, but no type metadata is actually
Expand Down
6 changes: 0 additions & 6 deletions lib/IRGen/IRGenSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2190,8 +2190,6 @@ Callee LoweredValue::getCallee(IRGenFunction &IGF,
return getSwiftFunctionPointerCallee(IGF, functionValue, selfValue,
std::move(calleeInfo), false);

// SWIFT_ENABLE_TENSORFLOW
case SILFunctionType::Representation::TensorFlow:
case SILFunctionType::Representation::CFunctionPointer:
assert(!selfValue && "C function pointer has self?");
return getCFunctionPointerCallee(IGF, functionValue,
Expand Down Expand Up @@ -2245,8 +2243,6 @@ static CallEmission getCallEmissionForLoweredValue(IRGenSILFunction &IGF,
break;
}

// SWIFT_ENABLE_TENSORFLOW
case SILFunctionType::Representation::TensorFlow:
case SILFunctionType::Representation::ObjCMethod:
case SILFunctionType::Representation::Thick:
case SILFunctionType::Representation::Block:
Expand Down Expand Up @@ -2476,8 +2472,6 @@ getPartialApplicationFunction(IRGenSILFunction &IGF, SILValue v,
case LoweredValue::Kind::FunctionPointer: {
llvm::Value *context = nullptr;
switch (fnType->getRepresentation()) {
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionTypeRepresentation::TensorFlow:
case SILFunctionTypeRepresentation::CFunctionPointer:
case SILFunctionTypeRepresentation::Block:
case SILFunctionTypeRepresentation::ObjCMethod:
Expand Down
4 changes: 0 additions & 4 deletions lib/IRGen/MetadataRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2054,8 +2054,6 @@ namespace {
case SILFunctionType::Representation::ObjCMethod:
case SILFunctionType::Representation::CFunctionPointer:
case SILFunctionType::Representation::Closure:
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionType::Representation::TensorFlow:

// A thin function looks like a plain pointer.
// FIXME: Except for extra inhabitants?
Expand Down Expand Up @@ -2268,8 +2266,6 @@ namespace {
case SILFunctionType::Representation::ObjCMethod:
case SILFunctionType::Representation::CFunctionPointer:
case SILFunctionType::Representation::Closure:
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionType::Representation::TensorFlow:

// A thin function looks like a plain pointer.
// FIXME: Except for extra inhabitants?
Expand Down
4 changes: 0 additions & 4 deletions lib/SIL/Bridging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ Type TypeConverter::getLoweredBridgedType(AbstractionPattern pattern,
SILFunctionTypeRepresentation rep,
BridgedTypePurpose purpose) {
switch (rep) {
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionTypeRepresentation::TensorFlow:
case SILFunctionTypeRepresentation::Thick:
case SILFunctionTypeRepresentation::Thin:
case SILFunctionTypeRepresentation::Method:
Expand Down Expand Up @@ -189,8 +187,6 @@ Type TypeConverter::getLoweredCBridgedType(AbstractionPattern pattern,
case SILFunctionType::Representation::ObjCMethod:
case SILFunctionType::Representation::WitnessMethod:
case SILFunctionType::Representation::Closure:
// SWIFT_ENABLE_TENSORFLOW
case SILFunctionTypeRepresentation::TensorFlow:
return t;
case SILFunctionType::Representation::Thick: {
// Thick functions (TODO: conditionally) get bridged to blocks.
Expand Down
3 changes: 0 additions & 3 deletions lib/SIL/OperandOwnership.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1058,9 +1058,6 @@ CONSTANT_OWNERSHIP_BUILTIN(Any, MustBeLive, ZExtOrBitCast)
CONSTANT_OWNERSHIP_BUILTIN(Any, MustBeLive, ZeroInitializer)
CONSTANT_OWNERSHIP_BUILTIN(Any, MustBeLive, Swift3ImplicitObjCEntrypoint)
CONSTANT_OWNERSHIP_BUILTIN(Any, MustBeLive, PoundAssert)
// SWIFT_ENABLE_TENSORFLOW
CONSTANT_OWNERSHIP_BUILTIN(Any, MustBeLive, TensorFlowSend)
CONSTANT_OWNERSHIP_BUILTIN(Any, MustBeLive, TensorFlowReceive)
#undef CONSTANT_OWNERSHIP_BUILTIN

// Builtins that should be lowered to SIL instructions so we should never see
Expand Down
Loading