mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-07 21:13:41 +08:00
22a8575199
Keep official openpilot ancestry and dependency licenses. Store resources directly in Git, remove LFS setup requirements, and leave the downloadable big model outside the source tree.
20 lines
661 B
Python
20 lines
661 B
Python
# opt opinionatedly transforms an ast into an optimized ast using either heuristics or beam search
|
|
from __future__ import annotations
|
|
from enum import Enum, auto
|
|
from dataclasses import dataclass
|
|
|
|
class OptOps(Enum):
|
|
TC = auto(); SPLIT = auto(); PADTO = auto(); SWAP = auto() # noqa: E702
|
|
def __lt__(self, x:OptOps): return self.value < x.value
|
|
|
|
@dataclass(frozen=True, order=True)
|
|
class Opt:
|
|
op: OptOps
|
|
axis: int|None = None
|
|
arg: int|tuple|None = None
|
|
def __repr__(self): return f"Opt(op={self.op}, axis={self.axis}, arg={self.arg})"
|
|
|
|
class KernelOptError(Exception): pass
|
|
def check(cond:bool, msg:str=""):
|
|
if not cond: raise KernelOptError(msg)
|