DynamicGraph
public final class DynamicGraph
A dynamic graph is a workspace for computations. All tensor variables can be tracked from a dynamic graph.
-
A type-erased tensor variable.
See moreDeclaration
Swift
public class AnyTensorextension DynamicGraph.AnyTensor: CustomStringConvertibleextension DynamicGraph.AnyTensor: CustomDebugStringConvertibleextension DynamicGraph.AnyTensor: DynamicGraph_Anyextension DynamicGraph.AnyTensor: DynamicGraph.AnyTensorGroup -
A typed tensor variable.
See moreDeclaration
Swift
public final class Tensor<Element> : AnyTensor where Element : TensorNumericextension DynamicGraph.Tensor: DynamicGraph.TensorGroup -
Declaration
Swift
public let cGraph: OpaquePointer -
The workspace size for executions. This is helpful when execute models, which will use this to tune the optimal kernel.
Declaration
Swift
public var workspaceSize: Int -
Declaration
Swift
public var maxConcurrency: StreamContext.Concurrency { get set } -
Declaration
Swift
public init() -
Type-aware group of tensors.
See moreDeclaration
Swift
public struct Group<Element> : RandomAccessCollection where Element : DynamicGraph.AnyTensorextension DynamicGraph.Group: DynamicGraph.AnyGroupextension DynamicGraph.Group: DynamicGraph_Any where Element: DynamicGraph.AnyTensorextension DynamicGraph.Group: DynamicGraph.AnyTensorGroup where Element: DynamicGraph.AnyTensorextension DynamicGraph.Group: DynamicGraph.TensorGroup where Element: DynamicGraph.TensorGroup, Element: DynamicGraph.AnyTensor -
Declaration
Swift
public enum LogLevel -
Set the log level on a dynamic graph.
Declaration
Swift
public static var logLevel: LogLevel { get set } -
Set the seed for global context.
Declaration
Swift
public static func setSeed(_ seed: UInt32) -
Create a synchronization point with the underlying stream context.
Declaration
Swift
public func joined() -
The watermark for in-flight Metal operations.
Declaration
Swift
public static var queueWatermark: Int { get set } -
Set whether to enable profiler or not.
Declaration
Swift
public static func setProfiler(_ on: Bool) -
Statistics about the graph.
See moreDeclaration
Swift
public struct Statistics -
Collect statistics from a dynamic graph. It computes how many variables and computations are still tracked. If you have memory leaks, this is useful to track down that.
Declaration
Swift
public var statistics: Statistics { get } -
Declaration
Swift
extension DynamicGraph.WeakAnyTensor: Hashable -
Create a placeholder variable. It doesn’t have shape and can only be used as output.
Declaration
Swift
public func variable() -> AnyTensor -
Create a placeholder constant. It doesn’t have shape and can only be used as output.
Declaration
Swift
public func constant() -> AnyTensor -
Create a new variable from an existing tensor.
Declaration
Swift
public func variable<Element>(_ tensor: NNC.Tensor<Element>) -> Tensor<Element> where Element : TensorNumericParameters
tensorThe existing tensor.
Return Value
Created new tensor variable.
-
Create a new constant from an existing tensor.
Declaration
Swift
public func constant<Element>(_ tensor: NNC.Tensor<Element>) -> Tensor<Element> where Element : TensorNumericParameters
tensorThe existing tensor.
Return Value
Created new tensor constant.
-
Declaration
Swift
public func variable<Element: TensorNumeric>( _ device: DeviceKind, format: TensorFormat, shape: TensorShape, of: Element.Type = Element.self ) -> Tensor<Element> -
Declaration
Swift
public func constant<Element: TensorNumeric>( _ device: DeviceKind, format: TensorFormat, shape: TensorShape, of: Element.Type = Element.self ) -> Tensor<Element> -
Declaration
Swift
public func variable<Element: TensorNumeric>( _ device: DeviceKind, _ shapeFormat: TensorShapeFormat, of: Element.Type = Element.self ) -> Tensor<Element> -
Declaration
Swift
public func constant<Element: TensorNumeric>( _ device: DeviceKind, _ shapeFormat: TensorShapeFormat, of: Element.Type = Element.self ) -> Tensor<Element> -
Declaration
Swift
public func variable<T>(like: T) -> T where T : DynamicGraph_TensorGroup -
Declaration
Swift
public func constant<T>(like: T) -> T where T : DynamicGraph_TensorGroup -
Turn off gradient tracking within the given closure. This may be useful during testing, we can make more aggressive optimizations if the gradient tracking is off.
Declaration
Swift
public func withNoGrad<Result>(_ closure: () throws -> Result) rethrows -> Result -
Perform operations on a given stream within the closure. Each operation can take a stream context parameter, however, that often error-prune. This method make sure all operations within the closure will be dispatched to the given stream context, making it easier to organize.
Declaration
Swift
public func withStream<Result>(_ streamContext: StreamContext, _ closure: () throws -> Result) rethrows -> Result -
Perform garbage collection. This will be done automatically when GPU memory at pressure. Do it manually helps to identify actual memory leaks.
Declaration
Swift
public func garbageCollect() -
Declaration
Swift
public struct EnableBits : OptionSet, CaseIterable -
Set system-wide flag.
Declaration
Swift
public static var flags: EnableBits { get set } -
Declaration
Swift
public typealias AnyTensorGroup = DynamicGraph_AnyTensorGroup -
Declaration
Swift
public typealias AnyGroup = DynamicGraph_AnyGroup -
A key-value based parameter store.
See moreDeclaration
Swift
public struct Store -
Declaration
Swift
public enum OpenError : Error -
Open the store from a file.
Declaration
Parameters
filePathThe file path for the store.
flagsThe flags for the opening store. Default to truncateWhenClose.
externalStoreThe external store for tensor data, in case we have tensors stored externally (a.k.a. outside of the SQLite database).
chunkSizeAlign each tensor to a certain chunk size.
procedureWhen the store is open, you can access it from this closure.
Return Value
Wether this store can be successfully open or not.
-
Declaration
Swift
public typealias TensorGroup = DynamicGraph_TensorGroup
DynamicGraph Class Reference