-
Notifications
You must be signed in to change notification settings - Fork 137
Make Element requirement in TensorArrayProtocol.init a conformance. #171
Conversation
Do you ever need to call |
@@ -35,7 +35,7 @@ public protocol TensorArrayProtocol { | |||
var _tensorHandles: [_AnyTensorHandle] { get } | |||
|
|||
init(_owning tensorHandles: UnsafePointer<CTensorHandle>?, count: Int) | |||
init<C: RandomAccessCollection>(_handles: C) where C.Element == _AnyTensorHandle | |||
init<C: RandomAccessCollection>(_handles: C) where C.Element : _AnyTensorHandle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Google Swift Style Guide recommends no whitespaces before colons in a conformance constraint.
init<C: RandomAccessCollection>(_handles: C) where C.Element : _AnyTensorHandle | |
init<C: RandomAccessCollection>(_handles: C) where C.Element: _AnyTensorHandle |
I have not needed it for the implementation of LazyTensor, but there is one use case in the test. That is why I made the following change:
Without the changes in this PR, I was not able to initialize a TensorGroup with an array of specific type, e.g., |
A |
Ah, that is right. The problem that I faced was with using an |
I see. Yeah, variance only works with a few stdlib types in Swift such as |
Related to https://bugs.swift.org/browse/TF-542