-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This helps to smooth over differences between Model and AnyModelBuilder, such that applications can pass AnyModel around if they don't care about execution (such as compile(inputs:) call or (inputs:) call).
- Loading branch information
Showing
5 changed files
with
106 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
public protocol AnyModel { | ||
/** | ||
* Whether the existing model is for testing or training. | ||
*/ | ||
var testing: Bool { get set } | ||
/** | ||
* Whether to enable memory reduction for this model. The current supported memory reduction | ||
* technique is to redo datatype conversion during backward pass if needed. | ||
*/ | ||
var memoryReduction: Bool { get set } | ||
/** | ||
* Specify the maximum number of streams we need to allocate to run this model. | ||
*/ | ||
var maxConcurrency: StreamContext.Concurrency { get set } | ||
/** | ||
* Abstract representation of the stateful components from the model builder. | ||
*/ | ||
var parameters: Model.Parameters { get } | ||
/** | ||
* Shortcut for weight parameter. | ||
*/ | ||
var weight: Model.Parameters { get } | ||
/** | ||
* Shortcut for bias parameter. | ||
*/ | ||
var bias: Model.Parameters { get } | ||
/** | ||
* Broadly speaking, you can have two types of parameters, weight and bias. | ||
* You can get them in abstract fashion with this method. | ||
* | ||
* - Parameter type: Whether it is weight or bias. | ||
* - Returns: An abstract representation of parameters. | ||
*/ | ||
func parameters(for type: Model.ParametersType) -> Model.Parameters | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters