Conversation
|
@ricky122-5 It's only for Galley scheduler, right? Let's mention it in the title. |
I designed it just for Galley because of the request to add functional dependencies / database style scheduling in the future. I think it could be reused for the default scheduler but it's a tradeoff for sure between compile time and runtime performance. |
|
@ricky122-5 If a part of it can be reused then we should think of some abstraction, and have suitable rep finder for Galley and default scheduler. |
|
This PR does do the default scheduler as well. |
willow-ahrens
left a comment
There was a problem hiding this comment.
copy-paste this file: https://github.com/finch-tensor/finch-tensor-lite/blob/main/src/finchlite/autoschedule/formatter.py, and modify it to make a "HeuristicFormatter" object that gives the "ftype" constructor function the "suitableRep" object.
willow-ahrens
left a comment
There was a problem hiding this comment.
- Move all code except format_selector.py into autoscheduler.py
- Add SparseRepeatData
- Add SequentialRead, SequentialWrite, RandomRead, RandomWrite capability traits.
- Add a formatter pass based on joels new formatter structure (copy paste formatter.py)
mtsokol
left a comment
There was a problem hiding this comment.
Just some code-style comments to match the rest of codebase.
| if isinstance(tns, ExtrudeData): | ||
| return ExtrudeData(child) | ||
| if isinstance(tns, SparseData): | ||
| return SparseData(child) | ||
| if isinstance(tns, RepeatData): | ||
| return RepeatData(child) | ||
| if isinstance(tns, DenseData): | ||
| return DenseData(child) |
There was a problem hiding this comment.
Let's use pattern matching everywhere there's an isinstance on a dataclass
| if any(isinstance(arg, HollowData) for arg in args): | ||
| return _map_rep_def_hollow(f, args) | ||
| if any(isinstance(arg, SparseData) for arg in args): | ||
| return _map_rep_def_sparse(f, args) | ||
| if any(isinstance(arg, DenseData) for arg in args): | ||
| return _map_rep_def_dense(f, args) | ||
| if any(isinstance(arg, RepeatData) for arg in args): | ||
| return _map_rep_def_repeat(f, args) | ||
| if any(isinstance(arg, ExtrudeData) for arg in args): | ||
| return _map_rep_def_extrude(f, args) |
| def collapse_rep(rep: Representation) -> Representation: | ||
| if isinstance(rep, ElementData): | ||
| return rep | ||
| if isinstance(rep, HollowData): |
| """ | ||
| Predict the representation of the result of the query expression. | ||
| """ | ||
| if isinstance(ex, Alias): |
| return 1 + self.lvl.ndims() | ||
|
|
||
|
|
||
| @dataclass |
There was a problem hiding this comment.
Can all dataclasses be frozen=True?
| ) | ||
|
|
||
|
|
||
| class SmartLogicFormatter(LogicFormatter): |
| """ | ||
|
|
||
|
|
||
| class RandomRead(SequentialRead): |
| logger = logging.LoggerAdapter(logging.getLogger(__name__), extra=LOG_LOGIC_POST_OPT) | ||
|
|
||
|
|
||
| class LogicFormatter(LogicLoader): |
|
|
||
| logger = logging.LoggerAdapter(logging.getLogger(__name__), extra=LOG_LOGIC_POST_OPT) | ||
|
|
||
|
|
There was a problem hiding this comment.
no-op logic formatter abstract class
| return [] | ||
|
|
||
| formats = [] | ||
|
|
| @@ -0,0 +1,52 @@ | |||
| from enum import Enum | |||
|
|
|||
|
|
|||
| case _: | ||
| raise ValueError(f"Unrecognized expression kind: {type(ex)}") | ||
|
|
||
| def _handle_reorder_mapjoin(self, ex: Reorder) -> Representation: |
|
LogicFormatter -> DefaultLogicFormatter merge smartformatter into suitable_rep.py |
#262
Python port of Finch.jl's Suitable Rep func, with extensive tests.