AnyTensor
public class AnyTensor
extension DynamicGraph.AnyTensor: CustomStringConvertible
extension DynamicGraph.AnyTensor: DynamicGraph_AnyTensor
extension DynamicGraph.AnyTensor: DynamicGraph.AnyTensorGroup
extension DynamicGraph.AnyTensor: DynamicGraph_Any
A type-erased tensor variable.
-
Declaration
Swift
public var grad: AnyTensor?
-
Declaration
Swift
public var graph: DynamicGraph { get }
-
Declaration
Swift
public var requiresGrad: Bool { get set }
-
Declaration
Swift
public required init(_ tensor: AnyTensor)
-
Declaration
Swift
public var dimensions: [Int] { get }
-
Declaration
Swift
public var kind: DeviceKind { get }
-
Declaration
Swift
public var format: TensorFormat { get }
-
Declaration
Swift
public var increments: [Int] { get }
-
A constant tensor can only be used as input, you cannot compute gradients for a constant tensor.
Declaration
Swift
public var isConstant: Bool { get }
-
Compute gradients from this tensor to the source tensors.
Declaration
Swift
public func backward<S: Sequence>(to tensors: S, streamContext: StreamContext? = nil) where S.Element: DynamicGraph.AnyTensor
Parameters
to
The source tensors to this tensor.
streamContext
The stream context to perform such operation.
-
Compute gradients from this tensor to the source tensor.
Declaration
Swift
public func backward(to tensor: DynamicGraph.AnyTensor, streamContext: StreamContext? = nil)
Parameters
to
The source tensor to this tensor.
streamContext
The stream context to perform such operation.
-
Declaration
Swift
public func reshaped( 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 reshaped( _ 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.
-
Declaration
Swift
public var description: String { get }
-
Declaration
Swift
public static func downcasting(from: DynamicGraph_Any) -> DynamicGraph_AnyTensor
-
Declaration
Swift
public typealias AnyTensor = DynamicGraph.AnyTensor
-
Declaration
Swift
public static func exec( cmd: ccv_nnc_cmd_t, hint: ccv_nnc_hint_t, inputs: [AnyTensor?], outputSize: Int32, streamContext: StreamContext? ) -> [AnyTensor]
-
Declaration
Swift
public static func exec( cmd: ccv_nnc_cmd_t, hint: ccv_nnc_hint_t, inputs: [AnyTensor?], outputs: [AnyTensor], streamContext: StreamContext? )
-
Declaration
Swift
public static func evaluate( model: OpaquePointer, isTest: Bool, dataParallel: inout Int?, inputs: [AnyTensor?], outputSize: Int32, streamContext: StreamContext? ) -> [AnyTensor]