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

Commit a1b6606

Browse files
authored
Relax Tensor initializer generic requirements. (#1061)
`Tensor` initializers taking scalars require that scalars are `Collection` instead of `RandomAccessCollection`.
1 parent 5d98153 commit a1b6606

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/TensorFlow/Core/Tensor.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ extension Tensor {
242242

243243
/// Creates a 1D tensor from scalars.
244244
@inlinable
245-
public init<C: RandomAccessCollection>(
245+
public init<C: Collection>(
246246
_ vector: C, on device: Device = .default
247247
) where C.Element == Scalar {
248248
#if USING_X10_BACKEND
@@ -384,7 +384,7 @@ extension Tensor {
384384
/// - shape: The shape of the tensor.
385385
/// - scalars: The scalar contents of the tensor.
386386
/// - Precondition: The product of the dimensions of the shape must equal the number of scalars.
387-
public init<C: RandomAccessCollection>(
387+
public init<C: Collection>(
388388
shape: TensorShape, scalars: C, on device: Device = .default
389389
) where C.Element == Scalar {
390390
precondition(

0 commit comments

Comments
 (0)