-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP and renaming/docs/removing unused interfaces
- Loading branch information
1 parent
ee213a3
commit 5e799e9
Showing
8 changed files
with
130 additions
and
97 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,26 @@ | ||
|
||
""" | ||
AbstractModel | ||
Base type for all models. From this, [`AbstractProblemInstance`](@ref)s can be constructed. | ||
See also: [`problem_instance`](@ref) | ||
""" | ||
abstract type AbstractModel end | ||
input_type(problem_instance) | ||
""" | ||
problem_instance(::AbstractModel, ::Vararg) | ||
Interface function that must be implemented for any implementation of [`AbstractModel`](@ref). This function should return a specific [`AbstractProblemInstance`](@ref) given some parameters. | ||
""" | ||
function problem_instance end | ||
Return the input type for a specific `problem_instance`. This can be a specific type or a supertype for which all child types are expected to be implemented. | ||
""" | ||
AbstractProblemInstance | ||
Base type for problem instances. An object of this type of a corresponding [`AbstractModel`](@ref) should uniquely identify a problem instance of that model. | ||
""" | ||
abstract type AbstractProblemInstance end | ||
|
||
""" | ||
input_type(problem::AbstractProblemInstance) | ||
Return the input type for a specific [`AbstractProblemInstance`](@ref). This can be a specific type or a supertype for which all child types are expected to work. | ||
For more details on the `problem_instance`, please refer to the documentation. | ||
""" | ||
function input_type end | ||
|
||
""" | ||
graph(::AbstractProblemInstance) | ||
graph(problem_instance) | ||
Generate the [`DAG`](@ref) for the given `problem_instance`. Every entry node (see [`get_entry_nodes`](@ref)) to the graph must have a name set. Implement [`input_expr`](@ref) to return a valid expression for each of those names. | ||
Generate the [`DAG`](@ref) for the given [`AbstractProblemInstance`](@ref). Every entry node (see [`get_entry_nodes`](@ref)) to the graph must have a name set. Implement [`input_expr`](@ref) to return a valid expression for each of those names. | ||
For more details on the `problem_instance`, please refer to the documentation. | ||
""" | ||
function graph end | ||
|
||
""" | ||
input_expr(instance::AbstractProblemInstance, name::String, input_symbol::Symbol) | ||
input_expr(problem_instance, name::String, input_symbol::Symbol) | ||
For the given `problem_instance`, the entry node name, and the symbol of the problem input (where a variable of type `input_type(...)` will exist), return an `Expr` that gets that specific input value from the input symbol. | ||
For the given [`AbstractProblemInstance`](@ref), the entry node name, and the symbol of the problem input (where a variable of type `input_type(...)` will exist), return an `Expr` that gets that specific input value from the input symbol. | ||
For more details on the `problem_instance`, please refer to the documentation. | ||
""" | ||
function input_expr end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,6 @@ | ||
""" | ||
FunctionCall{VAL_TYPES} | ||
AbstractScheduler | ||
Type representing a function call. Contains the function to call, argument symbols, the return symbol and the device to execute on. | ||
TODO: extend docs | ||
Abstract base type for scheduler implementations. The scheduler is used to assign each node to a device and create a topological ordering of tasks. | ||
""" | ||
mutable struct FunctionCall{VAL_T<:Tuple,FUNC_T<:Union{Function,Expr}} | ||
func::FUNC_T | ||
value_arguments::Vector{VAL_T} # tuple of value arguments for the function call, will be prepended to the other arguments | ||
arguments::Vector{Vector{Symbol}} # symbols of the inputs to the function call | ||
return_symbols::Vector{Vector{Symbol}} # the return symbols | ||
return_types::Vector{<:Type} # the return type of the function call(s); there can only be one return type since we require type stability | ||
device::AbstractDevice | ||
end | ||
|
||
function FunctionCall( | ||
func::Union{Function,Expr}, | ||
value_arguments::VAL_T, | ||
arguments::Vector{Symbol}, | ||
return_symbol::Vector{Symbol}, | ||
return_types::Vector{<:Type}, | ||
device::AbstractDevice, | ||
) where {VAL_T<:Tuple} | ||
# convenience constructor for function calls that do not use vectorization, which is most of the use cases | ||
@assert length(return_types) == 0 || length(return_types) == length(return_symbol) "number of return types $(length(return_types)) does not match the number of return symbols $(length(return_symbol))" | ||
return FunctionCall( | ||
func, [value_arguments], [arguments], [return_symbol], return_types, device | ||
) | ||
end | ||
|
||
function Base.length(fc::FunctionCall) | ||
@assert length(fc.value_arguments) == length(fc.arguments) == length(fc.return_symbols) "function call length is undefined, got $(length(fc.value_arguments)) tuples of value arguments, $(length(fc.arguments)) tuples of arguments, and $(length(return_symbols)) return symbols" | ||
return length(fc.value_arguments) | ||
end | ||
abstract type AbstractScheduler end |