-
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.
* Use Problem as validation of consistency between assignment and formats * Centralize code generation * Use Problem validation before invoking code generation * Add option to CLI to choose TACO as the tensor compiler * Use Returns Result in more places
- Loading branch information
Showing
22 changed files
with
430 additions
and
212 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .compile import TensorCompiler | ||
from .format import Format, Mode | ||
from .function import evaluate, evaluate_taco, evaluate_tensora, tensor_method | ||
from .generate import TensorCompiler | ||
from .tensor import Tensor |
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,15 +1,22 @@ | ||
__all__ = ["best_algorithm"] | ||
|
||
from returns.result import Failure, Result, Success | ||
|
||
from ..format import Format | ||
from ..iteration_graph.iteration_graph import IterationGraph | ||
from . import ast | ||
from .exceptions import NoKernelFoundError | ||
from .exceptions import DiagonalAccessError, NoKernelFoundError | ||
from .to_iteration_graphs import to_iteration_graphs | ||
|
||
|
||
def best_algorithm(assignment: ast.Assignment, formats: dict[str, Format]) -> IterationGraph: | ||
match next(to_iteration_graphs(assignment, formats), None): | ||
case None: | ||
raise NoKernelFoundError() | ||
case graph: | ||
return graph | ||
def best_algorithm( | ||
assignment: ast.Assignment, formats: dict[str, Format | None] | ||
) -> Result[IterationGraph, DiagonalAccessError | NoKernelFoundError]: | ||
try: | ||
match next(to_iteration_graphs(assignment, formats), None): | ||
case None: | ||
return Failure(NoKernelFoundError()) | ||
case graph: | ||
return Success(graph) | ||
except DiagonalAccessError as e: | ||
return Failure(e) |
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,4 +1,4 @@ | ||
from . import ast | ||
from .deparse_to_taco import deparse_to_taco | ||
from .exceptions import InconsistentVariableSizeError, MutatingAssignmentError | ||
from .exceptions import InconsistentDimensionsError, MutatingAssignmentError | ||
from .parser import parse_assignment |
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
Oops, something went wrong.