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

Remove TensorProtocol. #559

Merged
merged 1 commit into from
Nov 16, 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
14 changes: 2 additions & 12 deletions Sources/TensorFlow/Core/Tensor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public protocol AnyTensor {
/// The generic parameter `Scalar` describes the type of scalars in the tensor (such as `Int32`,
/// `Float`, etc).
@frozen
public struct Tensor<Scalar: TensorFlowScalar>: TensorProtocol {
public struct Tensor<Scalar: TensorFlowScalar> {
/// The underlying `TensorHandle`.
/// - Note: `handle` is public to allow user defined ops, but should not normally be used.
public let handle: TensorHandle<Scalar>
Expand Down Expand Up @@ -348,18 +348,8 @@ extension Tensor where Scalar: TensorFlowFloatingPoint {
/// during the conversion from an array literal to a `Tensor`, and is purely
/// for implementation purposes.
@frozen
public struct _TensorElementLiteral<Scalar>: TensorProtocol where Scalar: TensorFlowScalar {
public struct _TensorElementLiteral<Scalar> where Scalar: TensorFlowScalar {
@usableFromInline let tensor: Tensor<Scalar>

@inlinable
public var handle: TensorHandle<Scalar> {
return tensor.handle
}

@inlinable
public init(handle: TensorHandle<Scalar>) {
tensor = Tensor(handle: handle)
}
}

extension _TensorElementLiteral: ExpressibleByBooleanLiteral
Expand Down
9 changes: 4 additions & 5 deletions Sources/TensorFlow/Core/TensorGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,21 +240,20 @@ extension _TensorElementLiteral: TensorGroup {
return [Scalar.tensorFlowDataType]
}

public var _tensorHandles: [_AnyTensorHandle] { [self.handle.handle] }
public var _tensorHandles: [_AnyTensorHandle] { tensor._tensorHandles }

public func _unpackTensorHandles(into address: UnsafeMutablePointer<CTensorHandle>?) {
address!.initialize(to: handle._cTensorHandle)
tensor._unpackTensorHandles(into: address)
}

public init(_owning tensorHandles: UnsafePointer<CTensorHandle>?) {
self.init(handle: TensorHandle(_owning: tensorHandles!.pointee))
tensor = Tensor(_owning: tensorHandles)
}

public init<C: RandomAccessCollection>(
_handles: C
) where C.Element: _AnyTensorHandle {
precondition(_handles.count == 1)
self.init(handle: TensorHandle(handle: _handles[_handles.startIndex]))
tensor = Tensor(_handles: _handles)
}
}

Expand Down
26 changes: 0 additions & 26 deletions Sources/TensorFlow/Core/TensorProtocol.swift

This file was deleted.