forked from tinygrad/tinygrad
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f50d40014c | ||
|
|
15c936db01 |
@@ -1,34 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# Sticky PR comment via the REST API: find an existing comment containing MARKER and PATCH it, or POST a new one.
|
||||
# Works on GitHub and Gitea (stdlib only, replaces marocchino/sticky-pull-request-comment which needs GraphQL).
|
||||
# Env vars: GITHUB_TOKEN, GITHUB_API_URL, GITHUB_REPOSITORY (set by the runner), PR_NUMBER, MARKER, and BODY_FILE or MESSAGE.
|
||||
import json, os, sys, urllib.request
|
||||
|
||||
api, repo = os.environ["GITHUB_API_URL"], os.environ["GITHUB_REPOSITORY"]
|
||||
pr, marker = os.environ["PR_NUMBER"], os.environ["MARKER"]
|
||||
body = open(os.environ["BODY_FILE"]).read() if os.environ.get("BODY_FILE") else os.environ["MESSAGE"]
|
||||
|
||||
if not body.strip():
|
||||
print("comment body is empty, not posting")
|
||||
sys.exit(0)
|
||||
|
||||
def req(url, method="GET", payload=None):
|
||||
r = urllib.request.Request(url, data=None if payload is None else json.dumps(payload).encode(), method=method,
|
||||
headers={"Authorization": f"token {os.environ['GITHUB_TOKEN']}", "Accept": "application/json", "Content-Type": "application/json"})
|
||||
return json.load(urllib.request.urlopen(r))
|
||||
|
||||
# find the latest sticky comment (paginate, 100 comments per page)
|
||||
existing, page = None, 1
|
||||
while True:
|
||||
comments = req(f"{api}/repos/{repo}/issues/{pr}/comments?per_page=100&page={page}")
|
||||
stickies = [c for c in comments if marker in (c.get("body") or "")]
|
||||
if stickies: existing = stickies[-1]
|
||||
if not comments or len(comments) < 100: break
|
||||
page += 1
|
||||
|
||||
if existing is not None and existing["body"] == body:
|
||||
print("comment is already up to date")
|
||||
sys.exit(0)
|
||||
url = f"{api}/repos/{repo}/issues/comments/{existing['id']}" if existing is not None else f"{api}/repos/{repo}/issues/{pr}/comments"
|
||||
resp = req(url, 'PATCH' if existing is not None else 'POST', {'body': body})
|
||||
print(f"{'updated' if existing is not None else 'created'} comment {resp['id']}")
|
||||
@@ -26,14 +26,14 @@ jobs:
|
||||
- name: Check whether branch is up-to-date
|
||||
id: brstat
|
||||
run: |
|
||||
# fetch master from the base repo (tinygrad/tinygrad on GitHub, the mirror on Gitea), not the PR head remote
|
||||
git fetch "${{ github.event.pull_request.base.repo.clone_url }}" master
|
||||
git remote add tinygrad https://github.com/tinygrad/tinygrad
|
||||
git fetch tinygrad master
|
||||
echo "${{ github.event.pull_request.head.sha }}"
|
||||
git rev-list --left-right --count FETCH_HEAD...${{ github.event.pull_request.head.sha }} | awk '{print "Behind "$1" - Ahead "$2""}'
|
||||
count=$(git rev-list --left-right --count FETCH_HEAD...${{ github.event.pull_request.head.sha }} | awk '{print $1}')
|
||||
git rev-list --left-right --count tinygrad/master...${{ github.event.pull_request.head.sha }} | awk '{print "Behind "$1" - Ahead "$2""}'
|
||||
count=$(git rev-list --left-right --count tinygrad/master...${{ github.event.pull_request.head.sha }} | awk '{print $1}')
|
||||
if [ $count -gt 0 ]
|
||||
then
|
||||
echo "Current branch is behind ${{ github.event.pull_request.base.repo.full_name }} master branch!"
|
||||
echo "Current branch is behind tinygrad master branch!"
|
||||
echo "stat=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "stat=false" >> "$GITHUB_OUTPUT"
|
||||
@@ -75,13 +75,13 @@ jobs:
|
||||
python sz.py "$BASE" "$PR" > loc_content.txt
|
||||
- name: Comment Code Line Diff
|
||||
continue-on-error: false
|
||||
env:
|
||||
uses: marocchino/sticky-pull-request-comment@v3
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
MARKER: "### Changes"
|
||||
BODY_FILE: loc_content.txt
|
||||
# note: run the script from the base checkout, never from the PR checkout
|
||||
run: python3 "$GITHUB_WORKSPACE/base/.github/workflows/sticky_comment.py"
|
||||
ignore_empty: true
|
||||
skip_unchanged: true
|
||||
recreate: true
|
||||
path: loc_content.txt
|
||||
|
||||
rebase:
|
||||
name: Core Library Line Difference
|
||||
@@ -91,14 +91,12 @@ jobs:
|
||||
needs: checkbranch
|
||||
if: needs.checkbranch.outputs.branchstat == 'true'
|
||||
steps:
|
||||
# pull_request_target: a plain checkout gets the base repo, so no PR code is executed
|
||||
- uses: actions/checkout@v6
|
||||
- name: Comment Rebase
|
||||
continue-on-error: false
|
||||
env:
|
||||
uses: marocchino/sticky-pull-request-comment@v3
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
MARKER: "line count difference bot is disabled"
|
||||
MESSAGE: |
|
||||
This branch currently is behind ${{ github.event.pull_request.base.repo.full_name }} master. The line count difference bot is disabled.
|
||||
run: python3 .github/workflows/sticky_comment.py
|
||||
skip_unchanged: true
|
||||
recreate: true
|
||||
message: |
|
||||
This branch currently is behind tinygrad/master. The line count difference bot is disabled.
|
||||
|
||||
@@ -125,8 +125,7 @@ def do_devectorize(b:UOp):
|
||||
# broadcasting needs to be already unpacked, Invalid matches any dtype and shape
|
||||
if not all(x.shape == b.shape or x.base.is_invalid for x in b.src): return None
|
||||
src = []
|
||||
for idx in itertools.product(*[range(x) for x in b.shape]):
|
||||
idx_c = [UOp.const(i) for i in idx]
|
||||
for idx_c in itertools.product(*[[UOp.const(i) for i in range(x)] for x in b.shape]):
|
||||
src.append(b.replace(dtype=None, src=tuple(x.base if x.base.is_invalid else x.index(*idx_c) for x in b.src)))
|
||||
return UOp.stack(*src).reshape(b.shape) if b.op is not Ops.STORE else UOp.group(*src)
|
||||
|
||||
@@ -330,10 +329,7 @@ def full_rewrite_to_sink(ast:UOp, ren:Renderer, optimize:bool=True) -> UOp:
|
||||
sink = graph_rewrite(sink, symbolic_simple+pm_expand_broadcast+pm_add_loads, name="*** expand broadcast / add loads")
|
||||
|
||||
# devectorize
|
||||
sink = graph_rewrite(sink, symbolic_simple+devectorizer2, ctx=ren, name="devectorize2")
|
||||
|
||||
# simplify indexing
|
||||
sink = graph_rewrite(sink, indexing_simplify, name="simplify load/store indexing")
|
||||
sink = graph_rewrite(sink, symbolic_simple+devectorizer2+indexing_simplify, ctx=ren, name="devectorize2")
|
||||
|
||||
# some coalescing misses without this
|
||||
sink = graph_rewrite(sink, sym, name="early symbolic")
|
||||
|
||||
@@ -620,5 +620,3 @@ class count:
|
||||
cur = self.n
|
||||
self.n += self.step
|
||||
return cur
|
||||
|
||||
# test change for the szdiff bot
|
||||
|
||||
Reference in New Issue
Block a user