public struct Tensor<Scalar> : TensorProtocol where Scalar : AccelerableByTensorFlow
Tensor
is a multidimensional array used for computation. It is a wrapper
around a TensorHandle
.

The underlying
TensorHandle
.Note
handle
is public to allow user defined ops, but should not normally be used otherwise.Declaration
public let handle: TensorHandle<Scalar>

Declaration
public init(handle: TensorHandle<Scalar>)

Perform an elementwise type conversion from a
Bool
tensor.Declaration
init(_ other: Tensor<Bool>)

Declaration
public typealias ScalarElement = Scalar

Declaration
public typealias Dimensionality = TensorShape

Declaration
public init(dimensionality: TensorShape, repeating repeatedValue: Scalar)

Adds two tensors and produces their sum.
Note
+
supports broadcasting.Declaration
public static func + (lhs: Tensor, rhs: Tensor) > Tensor

Subtracts one tensor from another and produces their difference.
Note

supports broadcasting.Declaration
public static func  (lhs: Tensor, rhs: Tensor) > Tensor

Multiplies two tensors and produces their product.
Note
*
supports broadcasting.Declaration
public static func * (lhs: Tensor, rhs: Tensor) > Tensor

Adds the scalar to every scalar of the tensor and produces the sum.
Declaration
public static func + (lhs: Scalar, rhs: Tensor) > Tensor

Adds the scalar to every scalar of the tensor and produces the sum.
Declaration
public static func + (lhs: Tensor, rhs: Scalar) > Tensor

Subtracts the scalar from every scalar of the tensor and produces the difference.
Declaration
public static func  (lhs: Scalar, rhs: Tensor) > Tensor

Subtracts the scalar from every scalar of the tensor and produces the difference.
Declaration
public static func  (lhs: Tensor, rhs: Scalar) > Tensor

Multiplies the scalar with every scalar of the tensor and produces the product.
Declaration
public static func * (lhs: Scalar, rhs: Tensor) > Tensor

Multiplies the scalar with every scalar of the tensor and produces the product.
Declaration
public static func * (lhs: Tensor, rhs: Scalar) > Tensor

Adds two tensors and stores the result in the lefthandside variable.
Note
+=
supports broadcasting.Declaration
static func += (lhs: inout Tensor, rhs: Tensor)

Adds the scalar to every scalar of the tensor and stores the result in the lefthandside variable.
Declaration
static func += (lhs: inout Tensor, rhs: Scalar)

Subtracts the second tensor from the first and stores the result in the lefthandside variable.
Note
=
supports broadcasting.Declaration
static func = (lhs: inout Tensor, rhs: Tensor)

Subtracts the scalar from every scalar of the tensor and stores the result in the lefthandside variable.
Declaration
static func = (lhs: inout Tensor, rhs: Scalar)

Multiplies two tensors and stores the result in the lefthandside variable.
Note
*=
supports broadcasting.Declaration
static func *= (lhs: inout Tensor, rhs: Tensor)

Multiplies the scalar with every scalar of the tensor and stores the result in the lefthandside variable.
Declaration
static func *= (lhs: inout Tensor, rhs: Scalar)

Returns the quotient of dividing the first tensor by the second.
Note
/
supports broadcasting.Declaration
static func / (lhs: Tensor, rhs: Tensor) > Tensor

Returns the quotient of dividing the scalar by the tensor, broadcasting the scalar.
Declaration
static func / (lhs: Scalar, rhs: Tensor) > Tensor

Returns the quotient of dividing the tensor by the scalar, broadcasting the scalar.
Declaration
static func / (lhs: Tensor, rhs: Scalar) > Tensor

Divides the first tensor by the second and stores the quotient in the lefthandside variable.
Declaration
static func /= (lhs: inout Tensor, rhs: Tensor)

Divides the tensor by the scalar, broadcasting the scalar, and stores the quotient in the lefthandside variable.
Declaration
static func /= (lhs: inout Tensor, rhs: Scalar)

Returns the remainder of dividing the first tensor by the second.
Note
%
supports broadcasting.Declaration
static func % (lhs: Tensor, rhs: Tensor) > Tensor

Returns the remainder of dividing the tensor by the scalar, broadcasting the scalar.
Declaration
static func % (lhs: Tensor, rhs: Scalar) > Tensor

Returns the remainder of dividing the scalar by the tensor, broadcasting the scalar.
Declaration
static func % (lhs: Scalar, rhs: Tensor) > Tensor

Divides the first tensor by the second and stores the remainder in the lefthandside variable.
Declaration
static func %= (lhs: inout Tensor, rhs: Tensor)

Divides the tensor by the scalar and stores the remainder in the lefthandside variable.
Declaration
static func %= (lhs: inout Tensor, rhs: Scalar)

Performs matrix multiplication between two tensors and produces the result.
Declaration
static func • (lhs: Tensor, rhs: Tensor) > Tensor

Computes
lhs < rhs
elementwise.Note
<
supports broadcasting.Declaration
static func < (lhs: Tensor, rhs: Tensor) > Tensor<Bool>

Computes
lhs < rhs
, broadcastingrhs
.Declaration
static func < (lhs: Tensor, rhs: Scalar) > Tensor<Bool>

Computes
lhs < rhs
, broadcastinglhs
.Declaration
static func < (lhs: Scalar, rhs: Tensor) > Tensor<Bool>

Computes
lhs <= rhs
elementwise.Note
<=
supports broadcasting.Declaration
static func <= (lhs: Tensor, rhs: Tensor) > Tensor<Bool>

Computes
lhs <= rhs
, broadcastingrhs
.Declaration
static func <= (lhs: Tensor, rhs: Scalar) > Tensor<Bool>

Computes
lhs <= rhs
, broadcastingrhs
.Declaration
static func <= (lhs: Scalar, rhs: Tensor) > Tensor<Bool>

Computes
lhs > rhs
elementwise.Note
>
supports broadcasting.Declaration
static func > (lhs: Tensor, rhs: Tensor) > Tensor<Bool>

Computes
lhs <= rhs
, broadcastingrhs
.Declaration
static func > (lhs: Tensor, rhs: Scalar) > Tensor<Bool>

Computes
lhs <= rhs
, broadcastinglhs
.Declaration
static func > (lhs: Scalar, rhs: Tensor) > Tensor<Bool>

Computes
lhs >= rhs
elementwise.Note
>=
supports broadcasting.Declaration
static func >= (lhs: Tensor, rhs: Tensor) > Tensor<Bool>

Computes
lhs >= rhs
, broadcastingrhs
.Declaration
static func >= (lhs: Tensor, rhs: Scalar) > Tensor<Bool>

Computes
lhs >= rhs
, broadcastinglhs
.Declaration
static func >= (lhs: Scalar, rhs: Tensor) > Tensor<Bool>

Computes
self == other
elementwise.Note
elementsEqual
supports broadcasting.Declaration
func elementsEqual(_ other: Tensor) > Tensor<Bool>

Computes
self == other
elementwise, broadcastingother
.Declaration
func elementsEqual(_ other: Scalar) > Tensor<Bool>

Computes
self != other
elementwise.Note
elementsNotEqual
supports broadcasting.Declaration
func elementsNotEqual(_ other: Tensor) > Tensor<Bool>

Computes
self != other
elementwise, broadcastingother
.Declaration
func elementsNotEqual(_ other: Scalar) > Tensor<Bool>

Performs a logical NOT operation elementwise.
Declaration
prefix static func ! (x: Tensor) > Tensor

Performs a logical AND operation elementwise.
Note
&&
supports broadcasting.Declaration
static func && (lhs: Tensor, rhs: Tensor) > Tensor

Performs a logical AND operation elementwise, broadcasting
rhs
.Declaration
static func && (lhs: Tensor, rhs: Scalar) > Tensor

Performs a logical AND operation elementwise, broadcasting
lhs
.Declaration
static func && (lhs: Scalar, rhs: Tensor) > Tensor

Performs a logical OR operation elementwise.
Note

supports broadcasting.Declaration
static func  (lhs: Tensor, rhs: Tensor) > Tensor

Performs a logical OR operation elementwise, broadcasting
rhs
.Declaration
static func  (lhs: Tensor, rhs: Scalar) > Tensor

Performs a logical OR operation elementwise, broadcasting
lhs
.Declaration
static func  (lhs: Scalar, rhs: Tensor) > Tensor

Returns a transposed tensor, with dimensions permuted in the specified order.
Declaration
func transposed( withPermutations permutations: Tensor<Int32> ) > Tensor

Returns a transposed tensor, with dimensions permuted in the specified order.
Declaration
func transposed(withPermutations permutations: Int32...) > Tensor

Returns a transposed tensor, with dimensions permuted in reverse order.
Declaration
func transposed() > Tensor

Concatenates tensors along the first dimension.
Precondition
The tensors must have the same shape, except for the leading dimension.Declaration
func concatenated(with other: Tensor) > Tensor

Concatenates tensors along the specified axis.
Precondition
The tensors must have the same dimensions, except for the specified axis.Precondition
The axis must be in the rangerank..<rank
.Declaration
func concatenated(with other: Tensor, alongAxis axis: Int32) > Tensor

Concatenation operator.
Note
++
is a custom operator that does not exist in Swift, but does in Haskell/Scala. Its addition is not an insignificant language change and may be controversial. The existence/naming of++
will be discussed during a later API design phase.Declaration
static func ++ (lhs: Tensor, rhs: Tensor) > Tensor

Computes the negation of the specified tensor elementwise.
Declaration
prefix static func  (rhs: Tensor) > Tensor

Declaration
func squared() > Tensor

Returns a new tensor containing elements from either
left
orright
, depending on the elements ofself
.self
acts as a amsk that chooses, based on the value at each scalar, whether the corresponding scalar in the output should be taken fromleft
(iftrue
) orright
(iffalse
).Precondition
left
andright
must have the same shape. Ifleft
andright
are scalar, thenself
must also be scalar. Ifleft
andright
have rank greater than or equal to 1, thenself
must be either have the same shape asleft
or be a 1DTensor
such thatself.scalarCount == left[0]
.Declaration
public func selecting<T>(_ left: Tensor<T>, _ right: Tensor<T>) > Tensor<T> where T : AccelerableByTensorFlow

Declaration
public func selecting<T>(_ left: T, _ right: Tensor<T>) > Tensor<T> where T : AccelerableByTensorFlow

Declaration
public func selecting<T>(_ left: Tensor<T>, _ right: T) > Tensor<T> where T : AccelerableByTensorFlow

Declaration
public func selecting<T>(_ left: T, _ right: T) > Tensor<T> where T : AccelerableByTensorFlow

Declaration
func all() > Bool

Declaration
func any() > Bool

Performs a logical AND operation along the specified axes. The reduced dimensions are removed.
Precondition
Each value inaxes
must be in the rangerank..<rank
.Declaration
func all(squeezingAxes axes: Int32...) > Tensor
Parameters
axes
The dimensions to reduce.

Performs a logical AND operation along the specified axes. The reduced dimensions are removed.
Precondition
Each value inaxes
must be in the rangerank..<rank
.Declaration
func any(squeezingAxes axes: Int32...) > Tensor
Parameters
axes
The dimensions to reduce.

Performs a logical AND operation along the specified axes. The reduced dimensions are retained with value 1.
Precondition
Each value inaxes
must be in the rangerank..<rank
.Declaration
func all(alongAxes axes: Int32...) > Tensor
Parameters
axes
The dimensions to reduce.

Performs a logical OR operation along the specified axes. The reduced dimensions are retained with value 1.
Precondition
Each value inaxes
must be in the rangerank..<rank
.Declaration
func any(alongAxes axes: Int32...) > Tensor
Parameters
axes
The dimensions to reduce.

Declaration
func min() > Scalar

Declaration
func max() > Scalar

Returns the maximum values along the specified axes. The reduced dimensions are removed.
Precondition
Each value inaxes
must be in the rangerank..<rank
.Declaration
func max(squeezingAxes axes: Int32...) > Tensor
Parameters
axes
The dimensions to reduce.

Returns the minimum values along the specified axes. The reduced dimensions are removed.
Precondition
Each value inaxes
must be in the rangerank..<rank
.Declaration
func min(squeezingAxes axes: Int32...) > Tensor
Parameters
axes
The dimensions to reduce.

Returns the indices of the maximum values along the specified axes. The reduced dimensions are removed.
Precondition
Each value inaxes
must be in the rangerank..<rank
.Declaration
func argmax(squeezingAxis axis: Int32) > Tensor<Int32>
Parameters
axes
The dimensions to reduce.

Returns the indices of the minimum values along the specified axes. The reduced dimensions are removed.
Precondition
Each value inaxes
must be in the rangerank..<rank
.Declaration
func argmin(squeezingAxis axis: Int32) > Tensor<Int32>
Parameters
axes
The dimensions to reduce.

Returns the minimum along the specified axes. The reduced dimensions are retained with value 1.
Precondition
Each value inaxes
must be in the rangerank..<rank
.Declaration
func min(alongAxes axes: Int32...) > Tensor
Parameters
axes
The dimensions to reduce.

Returns the minimum along the specified axes. The reduced dimensions are retained with value 1.
Precondition
Each value inaxes
must be in the rangerank..<rank
.Declaration
func max(alongAxes axes: Int32...) > Tensor
Parameters
axes
The dimensions to reduce.

Returns the index of the maximum value of the flattened scalars.
Declaration
func argmax() > Int32

Returns the index of the minimum value of the flattened scalars.
Declaration
func argmin() > Int32

Declaration
func mean() > Scalar

Declaration
func sum() > Scalar

Returns the arithmetic mean along the specified axes. The reduced dimensions are removed.
Precondition
Each value inaxes
must be in the rangerank...rank
.Declaration
func mean(squeezingAxes axes: Int32...) > Tensor
Parameters
axes
The dimensions to reduce.

Returns the sum along the specified axes. The reduced dimensions are removed.
Precondition
Each value inaxes
must be in the rangerank...rank
.Declaration
func sum(squeezingAxes axes: Int32...) > Tensor
Parameters
axes
The dimensions to reduce.

Returns the arithmetic mean along the specified axes. The reduced dimensions are retained with value 1.
Precondition
Each value inaxes
must be in the rangerank..<rank
.Declaration
func mean(alongAxes axes: Int32...) > Tensor
Parameters
axes
The dimensions to reduce.

Returns the arithmetic mean along the specified axes. The reduced dimensions are retained with value 1.
Precondition
Each value inaxes
must be in the rangerank..<rank
.Declaration
func sum(alongAxes axes: Int32...) > Tensor
Parameters
axes
The dimensions to reduce.

The rank of the tensor, represented as a
Tensor<Int32>
.Declaration
var rankTensor: Tensor<Int32> { get }

The dimensions of the tensor, represented as a
Tensor<Int32>
.Declaration
var shapeTensor: Tensor<Int32> { get }

The number of scalars in the tensor, represented as a
Tensor<Int32>
.Declaration
var scalarCountTensor: Tensor<Int32> { get }

Declaration
func broadcast(toShape shape: Tensor<Int32>) > Tensor

Declaration
func broadcast(to shape: TensorShape) > Tensor

Broadcast to the same shape as the specified
Tensor
.Precondition
The specified shape must be compatible for broadcasting.Declaration
func broadcast<OtherScalar>(like other: Tensor<OtherScalar>) > Tensor where OtherScalar : AccelerableByTensorFlow

Declaration
func unbroadcast(toShape otherShape: Tensor<Int32>) > Tensor

Declaration
func unbroadcast<OtherScalar>(like other: Tensor<OtherScalar>) > Tensor where OtherScalar : AccelerableByTensorFlow

Declaration
func unbroadcast(to shape: TensorShape) > Tensor

Returns a padded tensor according to the specified padding sizes.
Declaration
func padded( forSizes sizes: @autoclosure () > [(before: Int32, after: Int32)], with value: Scalar = 0 ) > Tensor

Access the element tensor specified by an index in the leading dimension.
Declaration
subscript(index: Int32) > Tensor { get }
Parameters
index
Index of the element tensor.

Access the subdimensional tensor at the specified list of indices.
Note
this function is more efficient than usingsubscript(index:)
multiple times because this produces a single GatherNd op (compared with multiple Gather ops).Declaration
subscript(indices: Int32...) > Tensor { get }
Parameters
indices
List of indices.

Access the subtensor specified by a contiguous range of indices.
Declaration
subscript(bounds: Range<Int32>) > Tensor { get }
Parameters
bounds
Contiguous range of indices.

Extracts a slice from the tensor defined by lower and upper bounds for each dimension.
Declaration
func slice(lowerBounds: [Int32], upperBounds: [Int32]) > Tensor
Parameters
lowerBounds
The lower bounds at each dimension.
upperBounds
The upper bounds at each dimension.

Declaration
func batchNormalized( alongAxis axis: Int32, offset: Scalar = 0, scale: Scalar = 1, epsilon: Scalar = 0.001 ) > Tensor

Computes a 2D convolution using
self
as input, with the specified filter, strides, and padding.Precondition
self
must have rank 4.Precondition
filter
must have rank 4.Declaration
func convolved2D( withFilter filter: Tensor, strides: (Int32, Int32, Int32, Int32), padding: Padding ) > Tensor
Parameters
filter
The convolution filter.
strides
The strides of the sliding filter for each dimension of the input.
padding
The padding for the operation.

Computes a 2D max pooling, with the specified kernel sizes, strides, and padding.
Declaration
func maxPooled( kernelSize: (Int32, Int32, Int32, Int32), strides: (Int32, Int32, Int32, Int32), padding: Padding ) > Tensor
Parameters
kernelSize
The dimensions of the pooling kernel.
strides
The strides of the sliding filter for each dimension of the input.
padding
The padding for the operation.

Computes a 2D average pooling, with the specified kernel sizes, strides, and padding.
Declaration
func averagePooled( kernelSize: (Int32, Int32, Int32, Int32), strides: (Int32, Int32, Int32, Int32), padding: Padding ) > Tensor
Parameters
kernelSize
The dimensions of the pooling kernel.
strides
The strides of the sliding filter for each dimension of the input.
padding
The padding for the operation.

Declaration
init(_ array: ShapedArray<Scalar>)

Mark memory transfer to accelerator.
Declaration
func toAccelerator(shape: TensorShape) > Tensor
Parameters
shape
When sending the tensor to a TF XLA device (including TPU), must specify the tensor shape as required by XLA compilation.

Mark memory transfer to accelerator.
Declaration
func toAccelerator() > Tensor

Mark memory transfer to host.
Declaration
func toHost(shape: TensorShape) > Tensor
Parameters
shape
When sending the tensor to a TF XLA device (including TPU), must specify the tensor shape as required by XLA compilation.

Mark memory transfer to host.
Declaration
func toHost() > Tensor

Perform an elementwise conversion from another
Tensor
.Declaration
init<OtherScalar>(_ other: Tensor<OtherScalar>) where OtherScalar : Numeric, OtherScalar : AccelerableByTensorFlow

Creates a tensor from a scalar value.
Declaration
init(_ value: Scalar)

Creates a tensor from an array of tensors (which may themselves be scalars).
Declaration
init(_ elements: [Tensor])

Creates a 1D tensor in from contiguous scalars in rowmajor order.
Precondition
The number of scalars must equal the product of the dimensions of the shape.Declaration
init(_ vector: [Scalar])
Parameters
vector
The scalar contents of the tensor.

Creates a 1D tensor in from contiguous scalars in rowmajor order.
Precondition
The number of scalars must equal the product of the dimensions of the shape.Declaration
init<C>(_ vector: C) where Scalar == C.Element, C : RandomAccessCollection
Parameters
vector
The scalar contents of the tensor.

Creates a tensor with the specified shape and contiguous scalars in rowmajor order.
Precondition
The number of scalars must equal the product of the dimensions of the shape.Declaration
init(shape: TensorShape, scalars: [Scalar])
Parameters
shape
The shape of the tensor.
scalars
The scalar contents of the tensor.

Creates a tensor with the specified shape and contiguous scalars in rowmajor order.
Precondition
The number of scalars must equal the product of the dimensions of the shape.Declaration
init(shape: TensorShape, scalars: UnsafeBufferPointer<Scalar>)
Parameters
shape
The shape of the tensor.
scalars
The scalar contents of the tensor.

Creates a tensor with the specified shape and contiguous scalars in rowmajor order.
Precondition
The number of scalars must equal the product of the dimensions of the shape.Declaration
init<C : RandomAccessCollection>(shape: TensorShape, scalars: C) where C.Element == Scalar
Parameters
shape
The shape of the tensor.
scalars
The scalar contents of the tensor.

Creates a tensor with the specified shape and a single, repeated value.
Declaration
init(shape: TensorShape, repeating repeatedValue: Scalar)
Parameters
shape
The dimensions of the tensor.
repeatedValue
The scalar value to repeat.

Creates a tensor by broadcasting the given scalar to a given rank with all dimensions being 1.
Declaration
init(broadcasting scalar: Scalar, rank: Int32)

The type of the elements of an array literal.
Declaration
public typealias ArrayLiteralElement = TensorElementLiteral<Scalar>

Creates a tensor initialized with the given elements.
Declaration
public init(arrayLiteral elements: TensorElementLiteral<Scalar>...)

The number of dimensions of the
Tensor
.Declaration
var rank: Int32 { get }

The dimensions of the
Tensor
.Declaration
var shape: TensorShape { get }

The number of scalars in the
Tensor
.Declaration
var scalarCount: Int32 { get }

Creates a tensor with all scalars set to zero.
Declaration
init(zeros shape: TensorShape)
Parameters
shape
The dimensions of the tensor.

Creates a tensor with all scalars set to one.
Declaration
init(ones shape: TensorShape)
Parameters
shape
The dimensions of the tensor.

Declaration
@inline(never) static func eye( rowCount: Int, columnCount: Int? = nil, batchShape: [Int]? = nil ) > Tensor

Creates a 1D tensor representing a sequence from a starting value to, but not including, an end value, stepping by the specified amount.
Declaration
init(rangeFrom start: Scalar, to end: Scalar, stride: Scalar)
Parameters
start
The starting value to use for the sequence. If the sequence contains any values, the first one is
start
.end
An end value to limit the sequence.
end
is never an element of the resulting sequence.stride
The amount to step by with each iteration.
stride
must be positive. 
Creates a onehot tensor at given indices. The locations represented by
indices
take valueonValue
(1
by default), while all other locations take valueoffValue
(0
by default). If the inputindices
is rankn
, the new tensor will have rankn+1
. The new axis is created at dimensionaxis
(by default, the new axis is appended at the end).If
indices
is a scalar, the new tensor’s shape will be a vector of lengthdepth
.If
indices
is a vector of lengthfeatures
, the output shape will be: features x depth, if axis == 1 depth x features, if axis == 0If
indices
is a matrix (batch) with shape[batch, features]
, the output shape will be: batch x features x depth, if axis == 1 batch x depth x features, if axis == 1 depth x batch x features, if axis == 0Declaration
init(oneHotAtIndices indices: Tensor<Int32>, depth: Int32, onValue: Scalar = 1, offValue: Scalar = 0, axis: Int = 1)
Parameters
indices
A
Tensor
of indices.depth
A scalar defining the depth of the one hot dimension.
onValue
A scalar defining the value at the location referred to by some index in
indices
.offValue
A scalar defining the value at a location that is not referred to by any index in
indices
.axis
The axis to fill. The default is
1
, a new innermost axis.

Creates a tensor with the specified shape, randomly sampling scalar values from a discrete uniform distribution.
Declaration
init(randomStandardUniform shape: TensorShape, state: RandomState? = nil)
Parameters
shape
The dimensions of the tensor.
state
The pseudorandom state in which the random numbers are being generated.

Creates a tensor with the specified shape, randomly sampling scalar values from a uniform distribution between 0 and 1.
Declaration
init(randomUniform shape: TensorShape, state: RandomState? = nil)
Parameters
shape
The dimensions of the tensor.
state
The pseudorandom state in which the random numbers are being generated.

Creates a tensor with the specified shape, randomly sampling scalar values from a normal distribution.
Declaration
init(randomNormal shape: TensorShape, mean: Scalar = 0, stddev: Scalar = 1, state: RandomState? = nil)
Parameters
shape
The dimensions of the tensor.
mean
The mean of the distribution.
stddev
The standard deviation of the distribution.
state
The pseudorandom state in which the random numbers are being generated.

Reshape to the shape of the specified
Tensor
.Precondition
The number of scalars matches the new shape.Declaration
func reshaped<T>(like other: Tensor<T>) > Tensor where T : AccelerableByTensorFlow

Reshape to the specified shape.
Precondition
The number of scalars matches the new shape.Declaration
func reshaped(to newShape: TensorShape) > Tensor

Reshape to the specified
Tensor
representing a shape.Precondition
The number of scalars matches the new shape.Declaration
func reshaped(toShape newShape: Tensor<Int32>) > Tensor

Return a copy of the tensor collapsed into a 1D
Tensor
, in rowmajor order.Declaration
func flattened() > Tensor

Returns a ranklifted
Tensor
with a leading dimension of 1.Declaration
func rankLifted() > Tensor

Returns a shapeexpanded
Tensor
, with a dimension of 1 inserted at the specified shape index.Declaration
func expandingShape(at shapeIndex: Int32) > Tensor

Declaration
func squeezingShape(at axes: Int32...) > Tensor

Reshape to scalar.
Precondition
The tensor has exactly one scalar.Declaration
func scalarized() > Scalar

Declaration
public static func == (lhs: Tensor, rhs: Tensor) > Bool

Declaration
public static func != (lhs: Tensor, rhs: Tensor) > Bool

Declaration
public var description: String { get }

Declaration
public var playgroundDescription: Any { get }

Declaration
public var customMirror: Mirror { get }

Declaration
var array: ShapedArray<Scalar> { get }

Declaration
var scalars: [Scalar] { get }