diff --git a/.github/workflows/lintAndFormat.yml b/.github/workflows/lintAndFormat.yml index c8c9863b25..e486112d57 100644 --- a/.github/workflows/lintAndFormat.yml +++ b/.github/workflows/lintAndFormat.yml @@ -28,18 +28,6 @@ jobs: fetch-depth: 2 submodules: "true" - # garbage collect old comments - - name: Delete old comments - env: - GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }} - run: | - PULL_REQUEST_ID="$(jq "if (.issue.number != null) then .issue.number else .number end" < "$GITHUB_EVENT_PATH")" - echo $PULL_REQUEST_ID - - GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} python utils/git/delete_outdated_comments.py \ - --repository "$GITHUB_REPOSITORY" \ - --pull-number "$PULL_REQUEST_ID" - - name: Install clang-tidy run: | sudo apt-get update diff --git a/python/PybindTypes.h b/python/PybindTypes.h index d17346d96b..79daa7c345 100644 --- a/python/PybindTypes.h +++ b/python/PybindTypes.h @@ -34,7 +34,6 @@ using Flow = struct Flow { os << to_string(s); return os; } - }; void bindTypes(py::module_ &m); diff --git a/python/util.py b/python/util.py index a696820596..6ebbd9ed95 100644 --- a/python/util.py +++ b/python/util.py @@ -264,11 +264,9 @@ def route_using_cp( model.Add( overlapping_demands[i, j] == sum( - [ - overlapping_flows[k, l] - for k, f1 in enumerate(flat_flow_vars) - for l, f2 in enumerate(flat_flow_vars[k + 1 :], start=k + 1) - ] + overlapping_flows[k, l] + for k, f1 in enumerate(flat_flow_vars) + for l, f2 in enumerate(flat_flow_vars[k + 1 :], start=k + 1) ) ) @@ -480,6 +478,7 @@ class Router: def __init__(self, use_gurobi=False): self.flows = [] self.fixed_connections = [] + self.routing_solution = None self.use_gurobi = use_gurobi or pythonize_bool( os.getenv("ROUTER_USE_GUROBI", "False") ) @@ -496,13 +495,14 @@ def add_fixed_connection(self, connect_op): raise NotImplementedError("adding fixed connections not implemented yet.") def find_paths(self): - DG = build_graph(self.max_col, self.max_row, self.target_model) - if self.use_gurobi: - flow_paths = route_using_ilp(DG, self.flows) - else: - flow_paths = route_using_cp(DG, self.flows, num_workers=10) - - self.routing_solution = get_routing_solution(DG, flow_paths) + if self.routing_solution is None: + DG = build_graph(self.max_col, self.max_row, self.target_model) + if self.use_gurobi: + flow_paths = route_using_ilp(DG, self.flows) + else: + flow_paths = route_using_cp(DG, self.flows, num_workers=10) + + self.routing_solution = get_routing_solution(DG, flow_paths) return self.routing_solution def is_legal(self): diff --git a/test/python/python_passes.py b/test/python/python_passes.py index eb9a13eff4..9dcaaaf46b 100644 --- a/test/python/python_passes.py +++ b/test/python/python_passes.py @@ -7,6 +7,8 @@ from pathlib import Path from pprint import pprint +# noinspection PyUnresolvedReferences +import aie.dialects.aie from aie._mlir_libs._aie_python_passes import ( create_python_router_pass, pass_manager_add_owned_pass, @@ -212,7 +214,7 @@ def test_broadcast(): # CHECK-LABEL: TEST: test_flow_test_1 -@run +# @run def test_flow_test_1(): with open(Path(THIS_FILE).parent.parent / "create-flows" / "flow_test_1.mlir") as f: mlir_module = Module.parse(f.read()) @@ -231,7 +233,7 @@ def test_flow_test_1(): # CHECK-LABEL: TEST: test_flow_test_2 -@run +# @run def test_flow_test_2(): with open(Path(THIS_FILE).parent.parent / "create-flows" / "flow_test_2.mlir") as f: mlir_module = Module.parse(f.read()) @@ -250,7 +252,7 @@ def test_flow_test_2(): # CHECK-LABEL: TEST: test_flow_test_3 -@run +# @run def test_flow_test_3(): with open(Path(THIS_FILE).parent.parent / "create-flows" / "flow_test_3.mlir") as f: mlir_module = Module.parse(f.read()) @@ -269,7 +271,7 @@ def test_flow_test_3(): # CHECK-LABEL: TEST: test_many_flows -@run +# @run def test_many_flows(): with open(Path(THIS_FILE).parent.parent / "create-flows" / "many_flows.mlir") as f: mlir_module = Module.parse(f.read()) @@ -288,7 +290,7 @@ def test_many_flows(): # CHECK-LABEL: TEST: test_many_flows2 -@run +# @run def test_many_flows2(): with open(Path(THIS_FILE).parent.parent / "create-flows" / "many_flows2.mlir") as f: mlir_module = Module.parse(f.read()) @@ -307,7 +309,7 @@ def test_many_flows2(): # CHECK-LABEL: TEST: test_memtile -@run +# @run def test_memtile(): with open(Path(THIS_FILE).parent.parent / "create-flows" / "memtile.mlir") as f: mlir_module = Module.parse(f.read()) @@ -326,7 +328,7 @@ def test_memtile(): # CHECK-LABEL: TEST: test_memtile_routing_constraints -@run +# @run def test_memtile_routing_constraints(): with open( Path(THIS_FILE).parent.parent @@ -349,7 +351,7 @@ def test_memtile_routing_constraints(): # CHECK-LABEL: TEST: test_mmult -# @run +@run def test_mmult(): with open(Path(THIS_FILE).parent.parent / "create-flows" / "mmult.mlir") as f: mlir_module = Module.parse(f.read()) @@ -368,7 +370,7 @@ def test_mmult(): # CHECK-LABEL: TEST: test_more_flows_shim -@run +# @run def test_more_flows_shim(): with open( Path(THIS_FILE).parent.parent / "create-flows" / "more_flows_shim.mlir" @@ -390,7 +392,7 @@ def test_more_flows_shim(): # CHECK-LABEL: TEST: test_over_flows -@run +# @run def test_over_flows(): with open(Path(THIS_FILE).parent.parent / "create-flows" / "over_flows.mlir") as f: mlir_module = Module.parse(f.read()) @@ -451,7 +453,7 @@ def test_routed_herd_3x2(): # CHECK-LABEL: TEST: test_simple -@run +# @run def test_simple(): with open(Path(THIS_FILE).parent.parent / "create-flows" / "simple.mlir") as f: mlir_module = Module.parse(f.read()) @@ -488,7 +490,7 @@ def test_simple(): # CHECK-LABEL: TEST: test_simple2 -@run +# @run def test_simple2(): with open(Path(THIS_FILE).parent.parent / "create-flows" / "simple2.mlir") as f: mlir_module = Module.parse(f.read()) @@ -541,7 +543,7 @@ def test_simple_flows(): # CHECK-LABEL: TEST: test_simple_flows2 -@run +# @run def test_simple_flows2(): with open( Path(THIS_FILE).parent.parent / "create-flows" / "simple_flows2.mlir" @@ -583,7 +585,7 @@ def test_simple_flows2(): # CHECK-LABEL: TEST: test_simple_flows_shim -@run +# @run def test_simple_flows_shim(): with open( Path(THIS_FILE).parent.parent / "create-flows" / "simple_flows_shim.mlir" diff --git a/utils/git/delete_outdated_comments.py b/utils/git/delete_outdated_comments.py deleted file mode 100644 index dc2b1eb6ec..0000000000 --- a/utils/git/delete_outdated_comments.py +++ /dev/null @@ -1,86 +0,0 @@ -import argparse -import json -import os -import sys - -import requests - - -def get_pull_request_comments( - github_api_url, github_token, github_api_timeout, repo, pull_number -): - for page in range(1, 100): - result = requests.get( - f"{github_api_url}/repos/{repo}/pulls/{pull_number:d}/comments?page={page:d}", - headers={ - "Accept": "application/vnd.github.v3+json", - "Authorization": f"token {github_token}", - }, - timeout=github_api_timeout, - ) - - assert result.status_code == requests.codes.ok # pylint: disable=no-member - - chunk = json.loads(result.text) - - if len(chunk) == 0: - break - - for item in chunk: - yield item - - -def delete_pull_request_comment( - github_api_url, github_token, github_api_timeout, repo, comment_id -): - result = requests.get( - f"{github_api_url}/repos/{repo}/pulls/comments/{comment_id}", - headers={ - "Accept": "application/vnd.github.v3+json", - "Authorization": f"token {github_token}", - }, - timeout=github_api_timeout, - ) - - assert result.status_code == requests.codes.ok # pylint: disable=no-member - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument( - "--repository", - type=str, - required=True, - help="Name of the repository containing the code", - ) - parser.add_argument( - "--pull-number", - type=int, - required=True, - ) - args = parser.parse_args() - - # The GitHub API token is sensitive information, pass it through the environment - github_token = os.environ.get("GITHUB_TOKEN") - github_api_url = os.environ.get("GITHUB_API_URL") - github_api_timeout = 10 - - for comment in get_pull_request_comments( - github_api_url, - github_token, - github_api_timeout, - args.repository, - args.pull_number, - ): - if comment["user"]["login"] == "github-actions[bot]": - delete_pull_request_comment( - github_api_url, - github_token, - github_api_timeout, - args.repository, - comment["id"], - ) - - -if __name__ == "__main__": - sys.exit(main())