Store
public struct Store
A key-value based parameter store.
-
Declaration
Swift
public struct OpenFlag : OptionSet
-
Read a type-erased tensor from the store.
Declaration
Swift
public func read(_ key: String) -> NNC.AnyTensor?
Parameters
key
The key corresponding to that particular tensor.
-
Read a tensor from the store into tensor variable from dynamic graph.
Declaration
Swift
@discardableResult public func read(_ key: String, variable: DynamicGraph_Any) -> Bool
Parameters
key
The key corresponding to that particular tensor.
variable
The tensor variable to be initialized with.
-
Declaration
Swift
public enum ModelReaderResult
-
Read parameters into a given model.
Declaration
Swift
public func read( _ key: String, model: Model, reader: ((String, DataType, TensorFormat, TensorShape) -> ModelReaderResult)? = nil )
Parameters
key
The key corresponding to a particular model.
model
The model to be initialized with parameters from a given key.
reader
You can customize your reader to load parameter with a different name etc.
-
Read parameters into a given model builder.
Declaration
Swift
public func read(_ key: String, model: AnyModelBuilder)
Parameters
key
The key corresponding to a particular model.
model
The model builder to be initialized with parameters from a given key.
-
Write a tensor to the store.
Declaration
Swift
public func write(_ key: String, tensor: NNC.AnyTensor)
Parameters
key
The key corresponding to a particular tensor.
tensor
The tensor to be persisted.
-
Write a tensor variable to the store.
Declaration
Swift
public func write(_ key: String, variable: DynamicGraph_Any)
Parameters
key
The key corresponding to a particular tensor.
variable
The tensor variable to be persisted.
-
Write a model to the store.
Declaration
Swift
public func write(_ key: String, model: Model)
Parameters
key
The key corresponding to a particular model.
model
The model where its parameters to be persisted.
-
Write a model builder to the store.
Declaration
Swift
public func write(_ key: String, model: AnyModelBuilder)
Parameters
key
The key corresponding to a particular model builder.
-
Retrieve a list of all tensors in this file. This reads from the disk and could take some time to finish.
Declaration
Swift
public var keys: [String] { get }
-
Remove one tensor by its key.
Declaration
Swift
public func remove(_ key: String)
-
Remove all tensors from the store. This also vacuums the store to minimize its size.
Declaration
Swift
public func removeAll()