Tensor
public final class Tensor<Element> : AnyTensor where Element : TensorNumeric
extension DynamicGraph.Tensor: _DynamicGraph_TensorGroup
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 }
-
Undocumented
Declaration
Swift
public subscript(indices: Int...) -> Element { get set }
-
Undocumented
Declaration
Swift
public func reshape( format: TensorFormat, dimensions: [Int], offset: [Int]? = nil, increments: [Int]? = nil ) -> Self
-
Create a new tensor representing the same variable but with different sizes.
Declaration
Swift
public func reshape( _ dimensionFormat: TensorDimensionFormat, offset: [Int]? = nil, increments: [Int]? = nil ) -> Self
Parameters
dimensionFormat
New format and dimensions for the tensor.
offset
Whether offset on each dimensions.
increments
The step on each dimensions.
Return Value
The new tensor with different format but the same underlying variable.
-
Transpose from axisA to axisB.
Declaration
Swift
public func transpose(_ axisA: Int, _ axisB: Int, streamContext: StreamContext? = nil) -> DynamicGraph.Tensor<Element>
-
Fill the given tensor with uniform random values.
Declaration
Swift
public func rand( _ lowerBound: Float = 0, _ upperBound: Float = 1, streamContext: StreamContext? = nil )
-
Copy the given tensor to GPU.
Declaration
Swift
public func toGPU(_ ordinal: Int = 0, streamContext: StreamContext? = nil) -> DynamicGraph.Tensor<Element>
-
Copy the given tensor to CPU.
Declaration
Swift
public func toCPU(streamContext: StreamContext? = nil) -> DynamicGraph.Tensor<Element>
-
Undocumented
Declaration
Swift
public typealias _Element = Element
-
Undocumented
Declaration
Swift
public typealias ElementNumeric = Element