@frozen
public struct ShapedArray<Scalar> : _ShapedArrayProtocol
extension ShapedArray: RandomAccessCollection, MutableCollection
extension ShapedArray: CustomStringConvertible
extension ShapedArray: CustomPlaygroundDisplayConvertible
extension ShapedArray: CustomReflectable
extension ShapedArray: ExpressibleByArrayLiteral where Scalar: TensorFlowScalar
extension ShapedArray: Equatable where Scalar: Equatable
extension ShapedArray: Hashable where Scalar: Hashable
extension ShapedArray: Codable where Scalar: Codable
ShapedArray
is a multi-dimensional array. It has a shape, which has type [Int]
and defines
the array dimensions, and uses a TensorBuffer
internally as storage.
-
The dimensions of the array.
Declaration
public private(set) var shape: [Int] { get }
-
The number of dimensions of the array.
Declaration
public var rank: Int { get }
-
The total number of scalars in the array.
Declaration
public var scalarCount: Int { get }
-
Creates a
ShapedArray
with the same shape and scalars as the specified instance.Declaration
public init(_ other: ShapedArray)
-
Creates a
ShapedArray
with the specified shape and contiguous scalars in row-major order.Precondition
The number of scalars must equal the product of the dimensions of the shape.Declaration
public init(shape: [Int], scalars: [Scalar])
-
Creates a
ShapedArray
with the specified shape and sequence of scalars in row-major order.Precondition
The number of scalars must equal the product of the dimensions of the shape.Declaration
public init<S>(shape: [Int], scalars: S) where Scalar == S.Element, S : Sequence
-
Creates a
ShapedArray
from a scalar value.Declaration
public init(_ scalar: Scalar)
-
Creates a
ShapedArray
with the specified shape and a single, repeated scalar value.Declaration
@available(*, deprecated, renamed: "init(repeating:shape:﹚") public init(shape: [Int], repeating repeatedValue: Scalar)
Parameters
shape
The shape of the
ShapedArray
.repeatedValue
The scalar value to repeat.
-
Creates a
ShapedArray
with the specified shape and a single, repeated scalar value.Declaration
public init(repeating repeatedValue: Scalar, shape: [Int])
Parameters
repeatedValue
The scalar value to repeat.
shape
The shape of the
ShapedArray
. -
Declaration
public typealias Index = Int
-
Declaration
public typealias Element = ShapedArraySlice<Scalar>
-
Declaration
public typealias SubSequence = ShapedArraySlice<Scalar>
-
Declaration
public var indices: Range<Int> { get }
-
Declaration
public var startIndex: Int { get }
-
Declaration
public var endIndex: Int { get }
-
Access the element array specified by an index in the leading dimension.
Declaration
public subscript(index: Int) -> Element { get set }
Parameters
index
Index of the element array.
-
Access the subarray specified by a contiguous range of indices.
Declaration
public subscript(bounds: Range<Int>) -> SubSequence { get set }
Parameters
bounds
Contiguous range of indices.
-
Calls a closure with a pointer to the array’s contiguous storage.
Declaration
public func withUnsafeBufferPointer<Result>( _ body: (UnsafeBufferPointer<Scalar>) throws -> Result ) rethrows -> Result
Parameters
body
A closure with an
UnsafeBufferPointer
parameter that points to the contiguous storage for the array. If no such storage exists, it is created. If body has a return value, that value is also used as the return value for thewithUnsafeBufferPointer(_:)
method. The pointer argument is valid only for the duration of the method’s execution. -
Calls the given closure with a pointer to the array’s mutable contiguous storage.
Declaration
public mutating func withUnsafeMutableBufferPointer<Result>( _ body: (inout UnsafeMutableBufferPointer<Scalar>) throws -> Result ) rethrows -> Result
Parameters
body
A closure with an
UnsafeMutableBufferPointer
parameter that points to the contiguous storage for the array. If no such storage exists, it is created. If body has a return value, that value is also used as the return value for thewithUnsafeMutableBufferPointer(_:)
method. The pointer argument is valid only for the duration of the method’s execution. -
A textual representation of this
ShapedArray
.Note
usefullDescription
for a non-pretty-printed description showing all scalars.Declaration
public var description: String { get }
-
Declaration
public var playgroundDescription: Any { get }
-
Declaration
public var customMirror: Mirror { get }
-
Declaration
public typealias ArrayLiteralElement = _TensorElementLiteral<Scalar>
-
Declaration
public init(arrayLiteral elements: _TensorElementLiteral<Scalar>...)
-
Declaration
public static func == (lhs: ShapedArray, rhs: ShapedArray) -> Bool
-
Declaration
public func hash(into hasher: inout Hasher)
-
Declaration
public init(from decoder: Decoder) throws
-
Declaration
public func encode(to encoder: Encoder) throws
-
Declaration
init(owning cTensor: CTensor)
-
Declaration
@inline(never) init(cTensorHandle: CTensorHandle)