From 1df089d722b517ce0fa1b3c16cc89f775c851503 Mon Sep 17 00:00:00 2001 From: Anthony Platanios Date: Tue, 28 May 2019 18:53:02 -0400 Subject: [PATCH 1/4] Exposed some properties to help facilitate the move to swift-apis. --- stdlib/public/TensorFlow/TensorHandle.swift | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/stdlib/public/TensorFlow/TensorHandle.swift b/stdlib/public/TensorFlow/TensorHandle.swift index 352b0ae2ecb5a..22b4cc5b95405 100644 --- a/stdlib/public/TensorFlow/TensorHandle.swift +++ b/stdlib/public/TensorFlow/TensorHandle.swift @@ -143,9 +143,8 @@ internal extension TensorHandle { } } -internal extension ShapedArray where Scalar : _TensorFlowDataTypeCompatible { - @usableFromInline - @inline(never) +public extension ShapedArray where Scalar : _TensorFlowDataTypeCompatible { + @inlinable init(cTensorHandle: CTensorHandle) { internalConsistencyCheck(TFE_TensorHandleIsConcrete(cTensorHandle) != 0) let status = TF_NewStatus() @@ -164,8 +163,8 @@ internal extension ShapedArray where Scalar : _TensorFlowDataTypeCompatible { public struct ResourceHandle { let handle: _AnyTensorHandle - @usableFromInline - var _cTensorHandle: CTensorHandle { handle._cTensorHandle } + @inlinable + public var _cTensorHandle: CTensorHandle { handle._cTensorHandle } @usableFromInline init(owning cTensorHandle: CTensorHandle) { @@ -178,8 +177,8 @@ public struct ResourceHandle { public struct VariantHandle { let handle: _AnyTensorHandle - @usableFromInline - var _cTensorHandle: CTensorHandle { handle._cTensorHandle } + @inlinable + public var _cTensorHandle: CTensorHandle { handle._cTensorHandle } @usableFromInline init(owning cTensorHandle: CTensorHandle) { From 71e77efd84d5beb27c9445e8288d589eb0dadcc3 Mon Sep 17 00:00:00 2001 From: Anthony Platanios Date: Tue, 28 May 2019 18:53:58 -0400 Subject: [PATCH 2/4] Minor bug fix. --- lib/SIL/SILFunctionBuilder.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/SIL/SILFunctionBuilder.cpp b/lib/SIL/SILFunctionBuilder.cpp index f1f18ae695341..9eb8eec55efc3 100644 --- a/lib/SIL/SILFunctionBuilder.cpp +++ b/lib/SIL/SILFunctionBuilder.cpp @@ -88,6 +88,8 @@ void SILFunctionBuilder::addFunctionAttributes(SILFunction *F, vjpName = SILDeclRef(vjpFn).mangle(); // Get lowered argument indices. auto paramIndices = A->getParameterIndices(); + if (paramIndices == nullptr) + continue; auto loweredParamIndices = paramIndices->getLowered( F->getASTContext(), decl->getInterfaceType()->castTo()); From 2169a5ad7e050fcac934c4c1179e0489ed82be30 Mon Sep 17 00:00:00 2001 From: Richard Wei Date: Tue, 28 May 2019 15:58:10 -0700 Subject: [PATCH 3/4] Tweak --- lib/SIL/SILFunctionBuilder.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/SIL/SILFunctionBuilder.cpp b/lib/SIL/SILFunctionBuilder.cpp index 9eb8eec55efc3..624a5dc1707a5 100644 --- a/lib/SIL/SILFunctionBuilder.cpp +++ b/lib/SIL/SILFunctionBuilder.cpp @@ -88,8 +88,8 @@ void SILFunctionBuilder::addFunctionAttributes(SILFunction *F, vjpName = SILDeclRef(vjpFn).mangle(); // Get lowered argument indices. auto paramIndices = A->getParameterIndices(); - if (paramIndices == nullptr) - continue; + if (!paramIndices) + continue; auto loweredParamIndices = paramIndices->getLowered( F->getASTContext(), decl->getInterfaceType()->castTo()); From 397416e795f0f5f56da7cd3e3fa576535b490316 Mon Sep 17 00:00:00 2001 From: Anthony Platanios Date: Tue, 28 May 2019 19:17:17 -0400 Subject: [PATCH 4/4] Bug fix. --- stdlib/public/TensorFlow/TensorHandle.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdlib/public/TensorFlow/TensorHandle.swift b/stdlib/public/TensorFlow/TensorHandle.swift index 22b4cc5b95405..0c8bee7872685 100644 --- a/stdlib/public/TensorFlow/TensorHandle.swift +++ b/stdlib/public/TensorFlow/TensorHandle.swift @@ -161,6 +161,7 @@ public extension ShapedArray where Scalar : _TensorFlowDataTypeCompatible { /// `ResourceHandle` is the type used by ops to represent TensorFlow "resource" /// values. public struct ResourceHandle { + @usableFromInline let handle: _AnyTensorHandle @inlinable @@ -175,6 +176,7 @@ public struct ResourceHandle { /// `VariantHandle` is the type used by ops to represent TensorFlow "variant" /// values. public struct VariantHandle { + @usableFromInline let handle: _AnyTensorHandle @inlinable