Skip to content
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
de8fdbd
Moved a couple of tensor initializers to swift-apis.
eaplatanios Apr 19, 2019
06b96c0
Moved the activation functions to swift-apis.
eaplatanios Apr 19, 2019
dcd46be
Minor edit.
eaplatanios Apr 19, 2019
7a957cc
Moved the log-softmax VJP to swift-apis.
eaplatanios Apr 19, 2019
75f7039
Moved some tensor initializers to swift-apis.
eaplatanios Apr 20, 2019
a897918
Moved some more stuff to swift-apis.
eaplatanios Apr 20, 2019
da184a8
Moved some more stuff to swift-apis.
eaplatanios Apr 20, 2019
cde450e
Moved some more stuff to swift-apis.
eaplatanios Apr 20, 2019
a878600
Removed the now-redundant 'Ops.swift' file.
eaplatanios Apr 20, 2019
e790f78
Moved the gradient helper methods to swift-apis.
eaplatanios Apr 20, 2019
93041e0
Moved the tensor tests to swift-apis.
eaplatanios Apr 20, 2019
d988084
Brought back the tensor APItests.
eaplatanios Apr 20, 2019
a238b6e
Added support for the TensorFlow op.
eaplatanios Apr 20, 2019
d759e24
Bug fix.
eaplatanios Apr 20, 2019
944d7f6
Bug fix.
eaplatanios Apr 20, 2019
12ec483
Updated the swift-apis dependency.
eaplatanios Apr 21, 2019
97d0ea8
Merged upstream changes.
eaplatanios Apr 21, 2019
993c972
Minor edit.
eaplatanios Apr 21, 2019
aa72c70
Added support for 'Dataset.repeated(count:)' since '#tfop' does not w…
eaplatanios Apr 21, 2019
4f8c2ca
Added support for prefetched datasets.
eaplatanios Apr 22, 2019
98e5704
Moved the dataset ops to swift-apis.
eaplatanios Apr 23, 2019
df0ec40
Removed the now-redundant 'ArrayOps.swift' file.
eaplatanios Apr 23, 2019
ce4dfd3
Changes to support the new swift-bindings.
eaplatanios Apr 23, 2019
701e31d
Updated the 'TensorArrayProtocol' and its automatic derivation implem…
eaplatanios Apr 23, 2019
a5fcdc2
Bug fixes.
eaplatanios Apr 24, 2019
22fed17
Minor edits.
eaplatanios Apr 24, 2019
2de2d2b
Addressed Dan's comments regarding the 'TensorArrayProtocol' derived …
eaplatanios Apr 24, 2019
93e335a
Minor bug fix.
eaplatanios Apr 24, 2019
6a79ac8
Minor edit.
eaplatanios Apr 24, 2019
5890133
Enhancements to 'TensorArrayProtocol'.
eaplatanios Apr 24, 2019
baed6e3
TensorFlow/TensorFlowCore refactoring.
eaplatanios Apr 25, 2019
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
39 changes: 39 additions & 0 deletions stdlib/public/TensorFlow/ArrayOps.swift
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,43 @@ public extension Raw {
}
return out
}

/// Unpacks a tensor into `numSplit` tensors along one dimension.
///
/// - Parameters:
/// - value: The tensor to unpack.
/// - num: The number of tensors to unpack.
/// - axis: The dimension along which to unpack. Must be in the range
/// `[-rank(value), rank(value))`.
///
/// - Returns: Tensors whose shape matches that of `value` without the `axis` dimension.
@inlinable @inline(__always)
static func unpack<T: TensorFlowScalar>(
value: Tensor<T>,
num: Int64,
axis: Int64
) -> [Tensor<T>] {
let s: CTFStatus = TF_NewStatus()
defer { TF_DeleteStatus(s) }
let op: CTFEOp = TFE_NewOp(_ExecutionContext.global.eagerContext, "Unpack", s)
defer { TFE_DeleteOp(op) }
let _ = _TFCOpAddInputFromTensorGroup(op, value, s)
TFE_OpSetAttrInt(op, "num", num)
TFE_OpSetAttrType(op, "T", T.tensorFlowDataType._cDataType)
TFE_OpSetAttrInt(op, "axis", axis)
var count: Int32 = Int32(num)
let buffer: UnsafeMutablePointer<CTensorHandle> =
UnsafeMutablePointer.allocate(capacity: Int(count))
defer { buffer.deallocate() }
_TFCEagerExecute(op, UnsafeMutablePointer<CTensorHandle?>(buffer), &count, s)
checkOk(s)

var out: [Tensor<T>] = []
var cursor = buffer
for _ in 0..<num {
out.append(Tensor<T>(handle: TensorHandle(_owning: cursor.pointee)))
cursor = cursor.advanced(by: 1)
}
return out
}
}
7 changes: 1 addition & 6 deletions stdlib/public/TensorFlow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ list(APPEND swift_stdlib_compile_flags "-DCOMPILING_TENSORFLOW_MODULE")

set(SOURCES
CompilerRuntime.swift
CompositeMath.swift
Dataset.swift
DataTypes.swift
Execution.swift
Gradients.swift
Ops.swift
ShapedArray.swift
StringOps.swift
StringTensor.swift
Expand All @@ -50,9 +47,7 @@ set(SOURCES
Utilities.swift
ArrayOps.swift
Threading.swift
ExecuteOp.swift.gyb
# NumPy bridging for `ShapedArray` and `Tensor`.
PythonConversion.swift)
ExecuteOp.swift.gyb)

# Copy TensorFlow bindings file, if it exists.
if (TENSORFLOW_SWIFT_BINDINGS)
Expand Down
51 changes: 0 additions & 51 deletions stdlib/public/TensorFlow/CompositeMath.swift

This file was deleted.

Loading