Skip to content

Commit 5270390

Browse files
committed
Review: formatting changes + change github action
1 parent 0f644e9 commit 5270390

File tree

5 files changed

+26
-27
lines changed

5 files changed

+26
-27
lines changed

.github/workflows/update-ops-docs.yml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,18 @@ jobs:
2323
with:
2424
python-version: '3.x'
2525

26-
- name: Generate operations documentation
27-
run: ./scripts/create_ops_docs.py
28-
29-
- name: Check if docs/ops.md was updated
30-
id: check_changes
26+
- name: Generate operations documentation to temporary file
3127
run: |
32-
if git diff --quiet docs/ops.md; then
33-
echo "changed=false" >> $GITHUB_OUTPUT
34-
else
35-
echo "changed=true" >> $GITHUB_OUTPUT
36-
fi
28+
mkdir -p /tmp/ops_check
29+
./scripts/create_ops_docs.py /tmp/ops_check/ops.md
3730
38-
- name: Commit updated documentation
39-
if: steps.check_changes.outputs.changed == 'true' && github.event_name == 'push'
31+
- name: Check if docs/ops.md matches generated version
4032
run: |
41-
git config --local user.email "[email protected]"
42-
git config --local user.name "GitHub Action"
43-
git add docs/ops.md
44-
git commit -m "Update operations documentation from CSV files"
45-
git push
33+
if ! diff -q docs/ops.md /tmp/ops_check/ops.md; then
34+
echo "Operations documentation (docs/ops.md) is not up to date with the backend CSV files."
35+
echo "To fix: run ./scripts/create_ops_docs.py and commit the updated docs/ops.md along with your changes"
36+
echo "Differences found:"
37+
diff docs/ops.md /tmp/ops_check/ops.md || true
38+
exit 1
39+
fi
40+
echo "Operations documentation is up to date."
File renamed without changes.
File renamed without changes.

scripts/create_ops_docs.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
"""
66
import csv
77
import logging
8+
import sys
89
from pathlib import Path
910
from typing import Dict, List, Set
1011
from collections import defaultdict
1112

1213

1314
class DocsGenerator:
14-
def __init__(self, ggml_root: str):
15+
def __init__(self, ggml_root: str, output_filename: str = "ops.md"):
1516
self.ggml_root = Path(ggml_root)
1617
self.ops_dir = self.ggml_root / "docs" / "ops"
18+
self.output_filename = output_filename
1719
self.backend_support: Dict[str, Dict[str, List[bool]]] = defaultdict(
1820
lambda: defaultdict(list)
1921
)
@@ -170,7 +172,7 @@ def run(self) -> None:
170172
docs_dir = self.ggml_root / "docs"
171173
docs_dir.mkdir(exist_ok=True)
172174

173-
ops_file = docs_dir / "ops.md"
175+
ops_file = docs_dir / self.output_filename
174176
with open(ops_file, "w") as f:
175177
f.write(markdown_content)
176178

@@ -180,10 +182,14 @@ def run(self) -> None:
180182

181183

182184
def main():
183-
# Configure logging
184185
logging.basicConfig(level=logging.INFO)
185186

186-
generator = DocsGenerator(".")
187+
if len(sys.argv) > 1:
188+
output_filename = sys.argv[1]
189+
else:
190+
output_filename = "ops.md"
191+
192+
generator = DocsGenerator(".", output_filename)
187193
generator.run()
188194

189195

tests/test-backend-ops.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -819,9 +819,9 @@ struct console_printer : public printer {
819819
fflush(stdout);
820820

821821
if (result.supported) {
822-
printf("\033[1;32myes\033[0m\n");
822+
printf("\033[1;32mSUPPORTED\033[0m\n");
823823
} else {
824-
printf("\033[1;31mno\033[0m\n");
824+
printf("\033[1;31mNOT SUPPORTED\033[0m\n");
825825
}
826826
}
827827
};
@@ -1342,9 +1342,7 @@ struct test_case {
13421342
test_result result(ggml_backend_name(backend), current_op_name, vars(), "support", supported, supported,
13431343
supported ? "yes" : "no", 0.0, 0.0, 0.0, 0, 0, device_desc, backend_reg_name);
13441344

1345-
if (output_printer) {
1346-
output_printer->print_test_result(result);
1347-
}
1345+
output_printer->print_test_result(result);
13481346

13491347
return true;
13501348
}
@@ -5691,7 +5689,7 @@ static bool test_backend(ggml_backend_t backend, test_mode mode, const char * op
56915689
}
56925690

56935691
static void usage(char ** argv) {
5694-
printf("Usage: %s [mode] [-o <op>] [-b <backend>] [-p <params regex>] [--output <console|sql>]\n", argv[0]);
5692+
printf("Usage: %s [mode] [-o <op>] [-b <backend>] [-p <params regex>] [--output <console|sql|csv>]\n", argv[0]);
56955693
printf(" valid modes:\n");
56965694
printf(" - test (default, compare with CPU backend for correctness)\n");
56975695
printf(" - grad (compare gradients from backpropagation with method of finite differences)\n");

0 commit comments

Comments
 (0)