public struct TensorShape : ExpressibleByArrayLiteral

A struct representing the shape of a tensor.

TensorShape is a thin wrapper around an array of integers that represent shape dimensions. All tensor types use TensorShape to represent their shape.

  • Initialize with an array of dimensions. The rank of the tensor is the length of the array.

    Declaration

    public init(_ dimensions: [Int32])

    Parameters

    dimensions

    The shape dimensions.

  • Initialize with an array literal representing the shape dimensions. The rank of the tensor is the number of dimensions.

    Declaration

    public init(arrayLiteral elements: Int32...)

    Parameters

    dimensions

    The shape dimensions.

  • Initialize with variadic elements representing the shape dimensions. The rank of the tensor is the number of elements.

    Declaration

    public init(_ elements: Int32...)

    Parameters

    dimensions

    The shape dimensions.

  • The rank of the shape.

    Declaration

    public var rank: Int32 { get }
  • The size of the shape as a contiguously stored array.

    Declaration

    public var contiguousSize: Int32 { get }
  • Declaration

    var count: Int32 { get }
  • Declaration

    var indices: Range<Int32> { get }
  • Declaration

    var startIndex: Int32 { get }
  • Declaration

    var endIndex: Int32 { get }
  • Access the size of the i-th dimension.

    Declaration

    subscript(index: Int32) -> Int32 { get set }

    Parameters

    index

    The index of a dimension.

  • Access the size of the i-th dimension.

    Declaration

    subscript(bounds: Range<Int32>) -> TensorShape { get set }

    Parameters

    index

    The index of a dimension.

  • Declaration

    public static func == (lhs: TensorShape, rhs: TensorShape) -> Bool