Tensor
public final class Tensor<Element> : AnyTensor where Element : TensorNumeric
extension DynamicGraph.Tensor: DynamicGraph.TensorGroup
A typed tensor variable.
-
Get the underlying tensor. If not available, create one.
Declaration
Swift
public var rawValue: NNC.Tensor<Element> { get }
-
Declaration
Swift
public subscript(indices: Int...) -> Element { get set }
-
Declaration
Swift
public var typeErased: AnyTensor { get }
-
Declaration
Swift
public subscript(ranges: [Range<Int>], streamContext streamContext: StreamContext?) -> DynamicGraph.Tensor<Element>
-
Declaration
Swift
@inlinable public subscript(ranges: Range<Int>..., streamContext streamContext: StreamContext?) -> DynamicGraph.Tensor<Element>
-
Declaration
Swift
@inlinable public subscript(range: Range<Int>, streamContext streamContext: StreamContext?) -> DynamicGraph.Tensor<Element>
-
Declaration
Swift
@inlinable public subscript(i0: Int, range: Range<Int>, streamContext streamContext: StreamContext?) -> DynamicGraph.Tensor<Element>
-
Declaration
Swift
@inlinable public subscript(i0: Int, i1: Int, range: Range<Int>, streamContext streamContext: StreamContext?) -> DynamicGraph.Tensor<Element>
-
Declaration
Swift
@inlinable public subscript(i0: Int, i1: Int, i2: Int, range: Range<Int>, streamContext streamContext: StreamContext? ) -> DynamicGraph.Tensor<Element>
-
Declaration
Swift
@inlinable public subscript(i0: Int, i1: Int, i2: Int, i3: Int, range: Range<Int>, streamContext streamContext: StreamContext? ) -> DynamicGraph.Tensor<Element>
-
Declaration
Swift
@inlinable public subscript(i0: Int, i1: Int, i2: Int, i3: Int, i4: Int, range: Range<Int>, streamContext streamContext: StreamContext? ) -> DynamicGraph.Tensor< Element >
-
Declaration
Swift
@inlinable public subscript(i0: Int, i1: Int, i2: Int, i3: Int, i4: Int, i5: Int, range: Range<Int>, streamContext streamContext: StreamContext? ) -> DynamicGraph.Tensor<Element>
-
Declaration
Swift
@inlinable public subscript(i0: Int, i1: Int, i2: Int, i3: Int, i4: Int, i5: Int, i6: Int, range: Range<Int>, streamContext streamContext: StreamContext? ) -> DynamicGraph.Tensor<Element>
-
Declaration
Swift
@inlinable public subscript(range: UnboundedRange, streamContext streamContext: StreamContext?) -> DynamicGraph.Tensor<Element>
-
Declaration
Swift
@inlinable public subscript(i0: Int, range: UnboundedRange, streamContext streamContext: StreamContext?) -> DynamicGraph.Tensor<Element>
-
Declaration
Swift
@inlinable public subscript(i0: Int, i1: Int, range: UnboundedRange, streamContext streamContext: StreamContext? ) -> DynamicGraph.Tensor<Element>
-
Declaration
Swift
@inlinable public subscript(i0: Int, i1: Int, i2: Int, range: UnboundedRange, streamContext streamContext: StreamContext? ) -> DynamicGraph.Tensor<Element>
-
Declaration
Swift
@inlinable public subscript(i0: Int, i1: Int, i2: Int, i3: Int, range: UnboundedRange, streamContext streamContext: StreamContext? ) -> DynamicGraph.Tensor<Element>
-
Declaration
Swift
@inlinable public subscript(i0: Int, i1: Int, i2: Int, i3: Int, i4: Int, range: UnboundedRange, streamContext streamContext: StreamContext? ) -> DynamicGraph.Tensor< Element >
-
Declaration
Swift
@inlinable public subscript(i0: Int, i1: Int, i2: Int, i3: Int, i4: Int, i5: Int, range: UnboundedRange, streamContext streamContext: StreamContext? ) -> DynamicGraph.Tensor<Element>
-
Declaration
Swift
@inlinable public subscript(i0: Int, i1: Int, i2: Int, i3: Int, i4: Int, i5: Int, i6: Int, range: UnboundedRange, streamContext streamContext: StreamContext? ) -> DynamicGraph.Tensor<Element>
-
Transpose from axisA to axisB.
Declaration
Swift
public func transposed(_ axisA: Int, _ axisB: Int, streamContext: StreamContext?) -> DynamicGraph.Tensor<Element>
-
Fill the given tensor with uniform random values.
Declaration
Swift
public func rand( _ range: ClosedRange<Float>, streamContext: StreamContext? )
-
Fill the given tensor with normal-distributed random values.
Declaration
Swift
public func randn( std: Float, mean: Float, streamContext: StreamContext? )
-
Copy the given tensor to GPU.
Declaration
Swift
public func toGPU(_ ordinal: Int, streamContext: StreamContext?) -> DynamicGraph.Tensor<Element>
-
Copy the given tensor to CPU.
Declaration
Swift
public func toCPU(streamContext: StreamContext?) -> DynamicGraph.Tensor<Element>
-
Fill the given tensor with a value.
Declaration
Swift
public func full(_ value: Float, streamContext: StreamContext?)
-
Interpolate from this tensor to the other tensor.
Declaration
Swift
public func lerp( _ weight: Float, to: DynamicGraph.Tensor<Element>, streamContext: StreamContext? )
-
Clamp the given tensor between two values.
Declaration
Swift
public func clamp(_ range: ClosedRange<Float>, streamContext: StreamContext?)
-
Clamp the given tensor with a lower bound.
Declaration
Swift
public func clamp(_ range: PartialRangeFrom<Float>, streamContext: StreamContext?)
-
Clamp the given tensor with an upper bound.
Declaration
Swift
public func clamp(_ range: PartialRangeThrough<Float>, streamContext: StreamContext?)
-
Detach current tensor from the graph. Afterwards, it is always “isConstant” and cannot requiresGrad.
Declaration
Swift
public func detach()
-
Clamp the given tensor between two values.
Declaration
Swift
public func clamped(_ range: ClosedRange<Float>, streamContext: StreamContext?) -> DynamicGraph.Tensor<Element>
-
Clamp the given tensor with a lower bound.
Declaration
Swift
public func clamped(_ range: PartialRangeFrom<Float>, streamContext: StreamContext?) -> DynamicGraph.Tensor<Element>
-
Clamp the given tensor with an upper bound.
Declaration
Swift
public func clamped(_ range: PartialRangeThrough<Float>, streamContext: StreamContext?) -> DynamicGraph.Tensor<Element>
-
Make a copy of the existing tensor.
Declaration
Swift
public func copied(streamContext: StreamContext?) -> DynamicGraph.Tensor<Element>
-
Only make a copy of the existing tensor if it is not contiguous in memory.
Declaration
Swift
public func contiguous(streamContext: StreamContext?) -> DynamicGraph.Tensor<Element>
-
Reduce along a given dimension.
Declaration
Swift
public func reduced(_ op: ReduceOp, axis: [Int], streamContext: StreamContext?) -> DynamicGraph.Tensor<Element>
-
Scale the given tensor with a constant inplace.
Declaration
Swift
public func scale(by a: Float, streamContext: StreamContext?)
-
Scale the given tensor with a constant.
Declaration
Swift
public func scaled(by a: Float, streamContext: StreamContext?) -> Self
-
Apply softmax activation to the given tensor inplace.
Declaration
Swift
public func softmax(streamContext: StreamContext?)
-
Apply ReLU activation to the given tensor inplace.
Declaration
Swift
public func ReLU(streamContext: StreamContext?)
-
Apply sigmoid activation to the given tensor inplace.
Declaration
Swift
public func sigmoid(streamContext: StreamContext?)
-
Apply tanh activation to the given tensor inplace.
Declaration
Swift
public func tanh(streamContext: StreamContext?)
-
Apply swish activation to the given tensor inplace.
Declaration
Swift
public func swish(streamContext: StreamContext?)
-
Explicitly do conversion between types.
Declaration
Swift
public convenience init(from input: DynamicGraph.AnyTensor, streamContext: StreamContext? = nil)
-
Declaration
Swift
public func chunked(_ numberOfChunks: Int, axis: Int, streamContext: StreamContext?) -> [DynamicGraph.Tensor<Element>]
-
Declaration
Swift
public typealias ElementNumeric = Element