Skip to content

Commit 4762f67

Browse files
eaplataniosrxwei
authored andcommitted
[TF] Removed 'HackyTensorflowMigrationSupport'. (#25147)
Removed `HackyTensorflowMigrationSupport.swift`. Friend PR: tensorflow/swift-apis#139.
1 parent 7665dd9 commit 4762f67

File tree

9 files changed

+60
-92
lines changed

9 files changed

+60
-92
lines changed

include/swift/AST/KnownIdentifiers.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ IDENTIFIER(withArguments)
118118
IDENTIFIER(withKeywordArguments)
119119

120120
// SWIFT_ENABLE_TENSORFLOW
121+
IDENTIFIER(TensorFlow)
121122
// KeyPathIterable
122123
IDENTIFIER(AllKeyPaths)
123124
IDENTIFIER(allKeyPaths)

include/swift/AST/KnownProtocols.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ PROTOCOL(FloatingPoint)
8383
PROTOCOL(KeyPathIterable)
8484
PROTOCOL(TensorArrayProtocol)
8585
PROTOCOL(TensorGroup)
86+
PROTOCOL_(TensorFlowDataTypeCompatible)
87+
PROTOCOL(TensorProtocol)
8688
PROTOCOL(VectorNumeric)
8789
PROTOCOL(Differentiable)
8890

lib/AST/ASTContext.cpp

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -809,19 +809,62 @@ CanType ASTContext::getAnyObjectType() const {
809809

810810
// SWIFT_ENABLE_TENSORFLOW
811811

812-
/// Retrieve the decl for TensorDataType.
812+
/// Retrieve the decl for TensorFlow.TensorHandle iff the TensorFlow module has
813+
/// been imported. Otherwise, this returns null.
814+
ClassDecl *ASTContext::getTensorHandleDecl() const {
815+
if (getImpl().TensorHandleDecl)
816+
return getImpl().TensorHandleDecl;
817+
818+
// See if the TensorFlow module was imported. If not, return null.
819+
auto tfModule = getLoadedModule(Id_TensorFlow);
820+
if (!tfModule)
821+
return nullptr;
822+
823+
SmallVector<ValueDecl *, 1> results;
824+
tfModule->lookupValue({ }, getIdentifier("TensorHandle"),
825+
NLKind::UnqualifiedLookup, results);
826+
827+
for (auto result : results)
828+
if (auto CD = dyn_cast<ClassDecl>(result))
829+
return getImpl().TensorHandleDecl = CD;
830+
return nullptr;
831+
}
832+
833+
/// Retrieve the decl for TensorFlow.TensorShape iff the TensorFlow module has
834+
/// been imported. Otherwise, this returns null.
835+
StructDecl *ASTContext::getTensorShapeDecl() const {
836+
if (getImpl().TensorShapeDecl)
837+
return getImpl().TensorShapeDecl;
838+
839+
// See if the TensorFlow module was imported. If not, return null.
840+
auto tfModule = getLoadedModule(Id_TensorFlow);
841+
if (!tfModule)
842+
return nullptr;
843+
844+
SmallVector<ValueDecl *, 1> results;
845+
tfModule->lookupValue({}, getIdentifier("TensorShape"),
846+
NLKind::UnqualifiedLookup, results);
847+
848+
for (auto result : results)
849+
if (auto CD = dyn_cast<StructDecl>(result))
850+
return getImpl().TensorShapeDecl = CD;
851+
return nullptr;
852+
}
853+
854+
/// Retrieve the decl for TensorFlow.TensorDataType iff the TensorFlow module has
855+
/// been imported. Otherwise, this returns null.
813856
StructDecl *ASTContext::getTensorDataTypeDecl() const {
814857
if (getImpl().TensorDataTypeDecl)
815858
return getImpl().TensorDataTypeDecl;
816859

817-
// See if the Stdlib module was imported. If not, return null.
818-
auto stdlibModule = getStdlibModule();
819-
if (!stdlibModule)
860+
// See if the TensorFlow module was imported. If not, return null.
861+
auto tfModule = getLoadedModule(Id_TensorFlow);
862+
if (!tfModule)
820863
return nullptr;
821864

822865
SmallVector<ValueDecl *, 1> results;
823-
stdlibModule->lookupValue({}, getIdentifier("TensorDataType"),
824-
NLKind::UnqualifiedLookup, results);
866+
tfModule->lookupValue({}, getIdentifier("TensorDataType"),
867+
NLKind::UnqualifiedLookup, results);
825868

826869
for (auto result : results)
827870
if (auto CD = dyn_cast<StructDecl>(result))
@@ -905,6 +948,10 @@ ProtocolDecl *ASTContext::getProtocol(KnownProtocolKind kind) const {
905948
// SWIFT_ENABLE_TENSORFLOW
906949
case KnownProtocolKind::TensorArrayProtocol:
907950
case KnownProtocolKind::TensorGroup:
951+
case KnownProtocolKind::TensorFlowDataTypeCompatible:
952+
case KnownProtocolKind::TensorProtocol:
953+
M = getLoadedModule(Id_TensorFlow);
954+
break;
908955
default:
909956
M = getStdlibModule();
910957
break;

lib/IRGen/GenMeta.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4211,6 +4211,8 @@ SpecialProtocol irgen::getSpecialProtocolID(ProtocolDecl *P) {
42114211
case KnownProtocolKind::KeyPathIterable:
42124212
case KnownProtocolKind::TensorArrayProtocol:
42134213
case KnownProtocolKind::TensorGroup:
4214+
case KnownProtocolKind::TensorFlowDataTypeCompatible:
4215+
case KnownProtocolKind::TensorProtocol:
42144216
case KnownProtocolKind::VectorNumeric:
42154217
case KnownProtocolKind::Differentiable:
42164218
return SpecialProtocol::None;

stdlib/public/core/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ set(SWIFTLIB_ESSENTIAL
184184
StringGraphemeBreaking.swift # ORDER DEPENDENCY: Must follow UTF16.swift
185185
ValidUTF8Buffer.swift
186186
WriteBackMutableSlice.swift
187-
HackyTensorflowMigrationSupport.swift
188187
MigrationSupport.swift)
189188

190189
set(SWIFTLIB_ESSENTIAL_GYB_SOURCES

stdlib/public/core/GroupInfo.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@
176176
"AutoDiff": [
177177
"AutoDiff.swift",
178178
],
179-
"HackyTensorflowMigrationSupport": [
180-
"HackyTensorflowMigrationSupport.swift",
181-
],
182179
"Optional": [
183180
"Optional.swift"
184181
],

stdlib/public/core/HackyTensorflowMigrationSupport.swift

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

test/Index/Store/unit-one-file-multi-file-invocation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
// CHECK: [[SWIFT]]
1515
// CHECK: DEPEND START
16-
// CHECK: Record | system | Swift.String | [[MODULE]] | {{.+}}.swiftmodule_String-{{.*}}
1716
// CHECK: Record | system | Swift.Math.Floating | [[MODULE]] | {{.+}}.swiftmodule_Math_Floating-{{.*}}
17+
// CHECK: Record | system | Swift.String | [[MODULE]] | {{.+}}.swiftmodule_String-{{.*}}
1818
// CHECK: DEPEND END
1919

2020
func test1() {

utils/update_checkout/update-checkout-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@
349349
"clang-tools-extra": "swift-DEVELOPMENT-SNAPSHOT-2019-05-26-a",
350350
"libcxx": "swift-DEVELOPMENT-SNAPSHOT-2019-05-26-a",
351351
"tensorflow": "ebc41609e27dcf0998d8970e77a2e1f53e13ac86",
352-
"tensorflow-swift-apis": "1d484e1826c7d4efff6d9eb66d6eb6722ce84f12",
352+
"tensorflow-swift-apis": "835d1436a01d9261f0467bc2803cc7f6ac56ed80",
353353
"indexstore-db": "swift-DEVELOPMENT-SNAPSHOT-2019-05-26-a",
354354
"sourcekit-lsp": "swift-DEVELOPMENT-SNAPSHOT-2019-05-26-a"
355355
}

0 commit comments

Comments
 (0)