Skip to content

Commit

Permalink
Reorganize src/exo directory to frontend, core, rewrite, and backend (
Browse files Browse the repository at this point in the history
  • Loading branch information
yamaguchi1024 authored Oct 21, 2024
1 parent 5d03fc7 commit 9a75499
Show file tree
Hide file tree
Showing 53 changed files with 107 additions and 108 deletions.
2 changes: 1 addition & 1 deletion apps/x86/conv/conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from exo import *
from exo.libs.externs import *
from exo.platforms.x86 import *
from exo.syntax import *
from exo.frontend.syntax import *
from exo.stdlib.scheduling import *


Expand Down
2 changes: 1 addition & 1 deletion apps/x86/sgemm/sgemm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from exo import *
from exo.libs.memories import DRAM_STATIC
from exo.platforms.x86 import *
from exo.syntax import *
from exo.frontend.syntax import *
from exo.stdlib.scheduling import *
from exo.stdlib.stdlib import *

Expand Down
30 changes: 15 additions & 15 deletions src/exo/API.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@
from pathlib import Path
from typing import Optional, Union, List

import exo.LoopIR_scheduling as scheduling
from exo.LoopIR_scheduling import SchedulingError
import exo.rewrite.LoopIR_scheduling as scheduling
from exo.rewrite.LoopIR_scheduling import SchedulingError

from .API_types import ProcedureBase, ExoType
from . import LoopIR as LoopIR
from .LoopIR_compiler import run_compile, compile_to_strings
from .configs import Config
from .boundscheck import CheckBounds
from .memory import Memory
from .parse_fragment import parse_fragment
from .pattern_match import match_pattern
from .prelude import *
from .new_eff import Check_Aliasing
from .core import LoopIR as LoopIR
from .backend.LoopIR_compiler import run_compile, compile_to_strings
from .core.configs import Config
from .frontend.boundscheck import CheckBounds
from .core.memory import Memory
from .frontend.parse_fragment import parse_fragment
from .frontend.pattern_match import match_pattern
from .core.prelude import *
from .rewrite.new_eff import Check_Aliasing

# Moved to new file
from .proc_eqv import decl_new_proc, derive_proc, assert_eqv_proc, check_eqv_proc
from .pyparser import get_ast_from_python, Parser, get_src_locals
from .typecheck import TypeChecker
from .core.proc_eqv import decl_new_proc, derive_proc, assert_eqv_proc, check_eqv_proc
from .frontend.pyparser import get_ast_from_python, Parser, get_src_locals
from .frontend.typecheck import TypeChecker

from . import API_cursors as C
from . import internal_cursors as IC
from .core import internal_cursors as IC

# --------------------------------------------------------------------------- #
# --------------------------------------------------------------------------- #
Expand Down
18 changes: 9 additions & 9 deletions src/exo/API_cursors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@

from . import API # TODO: remove this circular import
from .API_types import ExoType, loopir_type_to_exotype
from .LoopIR import LoopIR
from .configs import Config
from .memory import Memory
from .core.LoopIR import LoopIR
from .core.configs import Config
from .core.memory import Memory

from . import internal_cursors as C
from .pattern_match import match_pattern
from .prelude import Sym
from .core import internal_cursors as C
from .frontend.pattern_match import match_pattern
from .core.prelude import Sym

# expose this particular exception as part of the API
from .internal_cursors import InvalidCursorError
from .LoopIR_pprint import _print_cursor
from .LoopIR_scheduling import SchedulingError
from .core.internal_cursors import InvalidCursorError
from .core.LoopIR_pprint import _print_cursor
from .rewrite.LoopIR_scheduling import SchedulingError


# --------------------------------------------------------------------------- #
Expand Down
16 changes: 8 additions & 8 deletions src/exo/API_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

from .API import Procedure
import exo.API_cursors as PC
from .LoopIR import LoopIR, T
import exo.LoopIR_scheduling as scheduling
from .core.LoopIR import LoopIR, T
import exo.rewrite.LoopIR_scheduling as scheduling
from .API_types import ExoType

from .LoopIR_unification import DoReplace, UnificationError
from .configs import Config
from .memory import Memory
from .parse_fragment import parse_fragment
from .prelude import *
from . import internal_cursors as ic
from .rewrite.LoopIR_unification import DoReplace, UnificationError
from .core.configs import Config
from .core.memory import Memory
from .frontend.parse_fragment import parse_fragment
from .core.prelude import *
from .core import internal_cursors as ic


def is_subclass_obj(x, cls):
Expand Down
2 changes: 1 addition & 1 deletion src/exo/API_types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from enum import Enum, auto
from .LoopIR import LoopIR, T
from .core.LoopIR import LoopIR, T


class ProcedureBase:
Expand Down
10 changes: 5 additions & 5 deletions src/exo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
config,
ExoType,
)
from .LoopIR_scheduling import SchedulingError
from .parse_fragment import ParseFragmentError
from .configs import Config
from .memory import Memory, DRAM
from .extern import Extern
from .rewrite.LoopIR_scheduling import SchedulingError
from .frontend.parse_fragment import ParseFragmentError
from .core.configs import Config
from .core.memory import Memory, DRAM
from .core.extern import Extern

from . import stdlib

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
from dataclasses import dataclass
from pathlib import Path

from .LoopIR import LoopIR, LoopIR_Do, get_writes_of_stmts, T, CIR
from .configs import ConfigError
from ..core.LoopIR import LoopIR, LoopIR_Do, get_writes_of_stmts, T, CIR
from ..core.configs import ConfigError
from .mem_analysis import MemoryAnalysis
from .memory import MemGenError, Memory, DRAM, StaticMemory
from ..core.memory import MemGenError, Memory, DRAM, StaticMemory
from .parallel_analysis import ParallelAnalysis
from .prec_analysis import PrecisionAnalysis
from .prelude import *
from ..core.prelude import *
from .win_analysis import WindowAnalysis
from .range_analysis import IndexRangeEnvironment
from ..rewrite.range_analysis import IndexRangeEnvironment


def sanitize_str(s):
Expand Down
Empty file added src/exo/backend/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions src/exo/mem_analysis.py → src/exo/backend/mem_analysis.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections import ChainMap
from .LoopIR import LoopIR
from ..core.LoopIR import LoopIR

from .memory import Memory
from ..core.memory import Memory


# --------------------------------------------------------------------------- #
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .LoopIR import LoopIR, LoopIR_Rewrite
from ..core.LoopIR import LoopIR, LoopIR_Rewrite

from .new_eff import Check_ParallelizeLoop
from ..rewrite.new_eff import Check_ParallelizeLoop


class ParallelAnalysis(LoopIR_Rewrite):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .LoopIR import LoopIR, LoopIR_Rewrite, T
from ..core.LoopIR import LoopIR, LoopIR_Rewrite, T

# --------------------------------------------------------------------------- #
# --------------------------------------------------------------------------- #
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .LoopIR import LoopIR, T, LoopIR_Rewrite
from ..core.LoopIR import LoopIR, T, LoopIR_Rewrite

# --------------------------------------------------------------------------- #
# --------------------------------------------------------------------------- #
Expand Down
File renamed without changes.
File renamed without changes.
Empty file added src/exo/core/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def _delete(self):
internal classes and modules, but not from end-user code.
"""
# TODO: refactor this; LoopIR should not be imported here
from exo.LoopIR import LoopIR
from exo.core.LoopIR import LoopIR

pass_stmt = [LoopIR.Pass(self.parent()._node.srcinfo)]
return self._replace([], empty_default=pass_stmt)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added src/exo/frontend/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions src/exo/boundscheck.py → src/exo/frontend/boundscheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import pysmt
from pysmt import shortcuts as SMT

from .LoopIR import LoopIR, T, Operator, Config
from .prelude import *
from ..core.LoopIR import LoopIR, T, Operator, Config
from ..core.prelude import *


# --------------------------------------------------------------------------- #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from collections import ChainMap

from . import pyparser
from .LoopIR import T, LoopIR_Do, LoopIR, PAST
from ..core.LoopIR import T, LoopIR_Do, LoopIR, PAST


# --------------------------------------------------------------------------- #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
from typing import Optional, Iterable
from collections import ChainMap

import exo.pyparser as pyparser
from exo.LoopIR import LoopIR, PAST
import exo.frontend.pyparser as pyparser
from exo.core.LoopIR import LoopIR, PAST

# --------------------------------------------------------------------------- #
# --------------------------------------------------------------------------- #
# Pattern Matching Errors
from exo.internal_cursors import Cursor, Node, Block
from exo.core.internal_cursors import Cursor, Node, Block


class PatternMatchError(Exception):
Expand Down
10 changes: 5 additions & 5 deletions src/exo/pyparser.py → src/exo/frontend/pyparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

from asdl_adt.validators import ValidationError

from .API_types import ProcedureBase
from .configs import Config
from .LoopIR import UAST, PAST, front_ops
from .prelude import *
from .extern import Extern
from ..API_types import ProcedureBase
from ..core.configs import Config
from ..core.LoopIR import UAST, PAST, front_ops
from ..core.prelude import *
from ..core.extern import Extern


# --------------------------------------------------------------------------- #
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/exo/typecheck.py → src/exo/frontend/typecheck.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from .LoopIR import (
from ..core.LoopIR import (
T,
UAST,
LoopIR,
LoopIR_Dependencies,
get_writeconfigs,
get_loop_iters,
)
from .extern import Extern_Typecheck_Error
from .memory import *
from ..core.extern import Extern_Typecheck_Error
from ..core.memory import *


# --------------------------------------------------------------------------- #
Expand Down
2 changes: 1 addition & 1 deletion src/exo/libs/externs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ..extern import Extern, _EErr
from exo.core.extern import Extern, _EErr


class _Sin(Extern):
Expand Down
2 changes: 1 addition & 1 deletion src/exo/libs/memories.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ..memory import Memory, DRAM, StaticMemory, MemGenError, generate_offset
from exo.core.memory import Memory, DRAM, StaticMemory, MemGenError, generate_offset


def _is_const_size(sz, c):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from collections import ChainMap
from typing import List, Tuple, Optional

from .LoopIR import (
from ..core.LoopIR import (
LoopIR,
LoopIR_Rewrite,
Alpha_Rename,
Expand Down Expand Up @@ -35,13 +35,13 @@

from .range_analysis import IndexRangeEnvironment, IndexRange, index_range_analysis

from .prelude import *
from .proc_eqv import get_strictest_eqv_proc
import exo.internal_cursors as ic
from ..core.prelude import *
from ..core.proc_eqv import get_strictest_eqv_proc
import exo.core.internal_cursors as ic
import exo.API as api
from .pattern_match import match_pattern
from .memory import DRAM
from .typecheck import check_call_types
from ..frontend.pattern_match import match_pattern
from ..core.memory import DRAM
from ..frontend.typecheck import check_call_types

from functools import partial

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from asdl_adt import ADT
from pysmt import shortcuts as SMT

from .LoopIR import (
from ..core.LoopIR import (
LoopIR,
T,
LoopIR_Do,
Expand All @@ -17,9 +17,9 @@
LoopIR_Dependencies,
)
from .LoopIR_scheduling import SchedulingError
from .prelude import *
from ..core.prelude import *
from .new_eff import Check_Aliasing
import exo.internal_cursors as ic
import exo.core.internal_cursors as ic


def _get_smt_solver():
Expand Down
Empty file added src/exo/rewrite/__init__.py
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

from asdl_adt import ADT, validators
from asdl_adt.validators import ValidationError
from .LoopIR import T, LoopIR
from .prelude import *
from ..core.LoopIR import T, LoopIR
from ..core.prelude import *

_first_run = True

Expand Down
8 changes: 4 additions & 4 deletions src/exo/new_eff.py → src/exo/rewrite/new_eff.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from enum import Enum
from itertools import chain

from .LoopIR import Alpha_Rename, SubstArgs, LoopIR_Do
from .configs import reverse_config_lookup, Config
from ..core.LoopIR import Alpha_Rename, SubstArgs, LoopIR_Do
from ..core.configs import reverse_config_lookup, Config
from .new_analysis_core import *
from .proc_eqv import get_repr_proc
from ..core.proc_eqv import get_repr_proc

# --------------------------------------------------------------------------- #
# --------------------------------------------------------------------------- #
Expand Down Expand Up @@ -1570,7 +1570,7 @@ def Shadows(a1, a2):

import inspect
import textwrap
from .API_types import ProcedureBase
from ..API_types import ProcedureBase


class SchedulingError(Exception):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from dataclasses import dataclass
from typing import Optional, Tuple

from .LoopIR import LoopIR, T, LoopIR_Compare
from ..core.LoopIR import LoopIR, T, LoopIR_Compare
from .new_eff import Check_ExprBound
from .prelude import Sym, _null_srcinfo_obj
from ..core.prelude import Sym, _null_srcinfo_obj


# TODO: we should implement a more general index analysis which
Expand Down
2 changes: 1 addition & 1 deletion src/exo/stdlib/halide_scheduling_ops.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from exo.API_cursors import *
from exo.LoopIR import get_reads_of_expr, LoopIR # TODO: get rid of this
from exo.core.LoopIR import get_reads_of_expr, LoopIR # TODO: get rid of this

from .range_analysis import bounds_inference
from .scheduling import *
Expand Down
2 changes: 1 addition & 1 deletion src/exo/stdlib/inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from exo.libs.memories import *
from exo.platforms.x86 import *
from exo.platforms.neon import *
from exo.syntax import *
from exo.frontend.syntax import *
from exo.API_cursors import *
from exo.stdlib.analysis import *

Expand Down
Loading

0 comments on commit 9a75499

Please sign in to comment.