Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Commit 3f5d896

Browse files
Remove deprecated 'Dataset` (#1115)
* Remove DatasetTests * Remove Dataset.swift * Move Zip2Tensor into LazyTensorExplicitTraceTests Remove Zip2Tensor reference from LazyTensorTraceTests
1 parent 2887964 commit 3f5d896

File tree

4 files changed

+40
-286
lines changed

4 files changed

+40
-286
lines changed

Sources/TensorFlow/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ add_library(TensorFlow SHARED
6060

6161
Operators/Basic.swift
6262
Operators/Comparison.swift
63-
Operators/Dataset.swift
6463
Operators/Image.swift
6564
Operators/LinearAlgebra.swift
6665
Operators/Math.swift

Sources/TensorFlow/Operators/Dataset.swift

-284
This file was deleted.

Tests/TensorFlowTests/LazyTensorExplicitTraceTests.swift

+40
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,43 @@ final class LazyTensorExplicitTraceTests: LazyTensorTestCase {
189189
("testRetainsIdenticalOutputs", testRetainsIdenticalOutputs),
190190
]
191191
}
192+
193+
/// A 2-tuple-like struct that conforms to TensorGroup that represents a tuple of 2 types conforming
194+
/// to `TensorGroup`.
195+
fileprivate struct Zip2TensorGroup<T: TensorGroup, U: TensorGroup>: TensorGroup {
196+
var first: T
197+
var second: U
198+
199+
init(_ first: T, _ second: U) {
200+
self.first = first
201+
self.second = second
202+
}
203+
204+
static var _typeList: [TensorDataType] { return T._typeList + U._typeList }
205+
206+
init(_owning tensorHandles: UnsafePointer<CTensorHandle>?) {
207+
first = .init(_owning: tensorHandles)
208+
second = .init(_owning: tensorHandles?.advanced(by: Int(T._tensorHandleCount)))
209+
}
210+
211+
func _unpackTensorHandles(into address: UnsafeMutablePointer<CTensorHandle>?) {
212+
var ptr = address
213+
first._unpackTensorHandles(into: ptr)
214+
ptr = ptr!.advanced(by: Int(first._tensorHandleCount))
215+
second._unpackTensorHandles(into: ptr)
216+
}
217+
218+
var _tensorHandles: [_AnyTensorHandle] {
219+
first._tensorHandles + second._tensorHandles
220+
}
221+
222+
init<C: RandomAccessCollection>(
223+
_handles: C
224+
) where C.Element: _AnyTensorHandle {
225+
let firstStart = _handles.startIndex
226+
let firstEnd = _handles.index(
227+
firstStart, offsetBy: Int(T._tensorHandleCount))
228+
self.first = T.init(_handles: _handles[firstStart..<firstEnd])
229+
self.second = U.init(_handles: _handles[firstEnd..<_handles.endIndex])
230+
}
231+
}

Tests/TensorFlowTests/LazyTensorTraceTests.swift

-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ final class LazyTensorTraceTests: LazyTensorTestCase {
204204
}
205205

206206
func testTraceWithFunctionAttributes() {
207-
typealias Int32Pair = Zip2TensorGroup<Tensor<Int32>, Tensor<Int32>>
208207
func thenBranch(x: Tensor<Float>) -> Tensor<Float> {
209208
return x + 10.0
210209
}

0 commit comments

Comments
 (0)