Repository navigation
Commit 84c494c
[ET-VK][tools] Write etvk_ops_bench JSON files compactly
Pull Request resolved: #24806
## Ulterior Motive
Keeping `etvk_ops_bench` JSON files reviewable. `convolution/conv2d/cases/correctness.json` is 8,445 lines, mostly whitespace, and the conv2d epilogue correctness cases would grow it further.
## Rationale
**What**:
- Adds `format_json.py` to `benchmark_v2`. It keeps a JSON value on one line when its one-line form, not counting its key and indentation, fits in 200 characters, and lists longer objects and arrays one entry per line. An object with one entry is measured by that entry's value, so a `{"tensor": {...}}` wrapper never splits on its own. In operator cases, each case key and each operator argument gets one line.
- Reformats every JSON file under `benchmark_v2` with it: the 64 operator case files and the 13 examples.
- Adds an `ETVKJSONFORMAT` lintrunner linter for these files. `lintrunner` reports unformatted or invalid files, and `lintrunner -a` formats them.
- Replaces `fb/scripts/apply_prettier.sh`, whose Prettier layout would expand the files again. Both READMEs are updated.
**Why**: The previous layout put every tensor field and every scalar wrapper on its own line, so one 17-argument set took about 95 lines. The JSON files shrink from 87,631 to 23,727 lines with the same content; conv2d `correctness.json` goes from 8,445 to 2,214.
## Details
- Content is unchanged: every file parses to the same values, types and key order as before. Besides whitespace, 4 files re-spell float exponents (`e38` → `e+38`, `e-7` → `e-07`), which parse to the same values.
- **Lint**: lintrunner is a required check on GitHub PRs (the `lintrunner` job in `lint.yml`, which lints the PR's changed files) and the lint developers run before submitting. The linter runs `format_json.py --lintrunner`, which prints one lintrunner message per file instead of writing it:
- unformatted files get a warning with the formatted contents as the replacement;
- files that cannot be formatted get an error.
- **Rejected files**: invalid UTF-8, duplicate keys, `NaN` / `Infinity` values, numbers outside float range (such as `1e400`), and strings with no UTF-8 encoding (lone `\ud800` escapes). Without `--lintrunner`, the script exits with the file and the error, before writing that file.
- The script writes UTF-8 with `\n` line endings.
- Example operator argument set:
```json
"args_sweep": [
[
{"tensor": {"name": "input", "sizes": [1, 8, 8, 8], "dtype": "float32", "storage": "texture3d", "layout": "channels", "data": {"rand_uniform_float": [-1, 1]}}},
{"tensor": {"name": "weight", "sizes": [8, 8, 3, 3], "dtype": "float32", "storage": "constant", "layout": "channels", "data": {"rand_uniform_float": [-1, 1]}}},
null,
{"int_list": [1, 1]},
...
]
]
```
- Longer values, such as long `v_SIZES` sweep lists, list one entry per line.
- In-flight diffs that edit these files will conflict. Reformatting their side with `format_json.py` before resolving leaves only the real edits in the conflict. Line blame for the JSON files points at this commit.
Usage, from the ExecuTorch root:
```sh
lintrunner # reports unformatted JSON files among the changed files
lintrunner -a # formats them
python3 backends/vulkan/test/ops/benchmark_v2/format_json.py # every JSON file under benchmark_v2
python3 backends/vulkan/test/ops/benchmark_v2/format_json.py PATH [...] # given files, or JSON files under given directories
```
ghstack-source-id: 469036179
@exported-using-ghexport
Differential Revision: [D130231969](https://our.internmc.facebook.com/intern/diff/D130231969/)1 parent a168321 commit 84c494c
79 files changed
Lines changed: 11427 additions & 75148 deletions
File tree
- backends/vulkan/test/ops/benchmark_v2
- examples
- operators
- attention/sdpa/cases
- binary
- add/cases
- q8ta/cases
- clone/q8ta/cases
- convolution
- conv1d/cases
- conv2d/cases
- q8ta
- cases
- transposed/cases
- qw/q8csw/cases
- embedding/qw/q4gsw/cases
- gemm
- linear
- q8ta/cases
- qw
- q4gsw/cases
- q8csw/cases
- matmul/cases
- pixel_shuffle/q8ta/cases
- quantization/choose_qparams_per_row/cases
- quantize/q8ta/cases
- unary/q8ta/cases
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
692 | 692 | | |
693 | 693 | | |
694 | 694 | | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
695 | 708 | | |
696 | 709 | | |
697 | 710 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
34 | 52 | | |
35 | 53 | | |
36 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
27 | 11 | | |
28 | 12 | | |
29 | 13 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
11 | | - | |
| 9 | + | |
12 | 10 | | |
13 | 11 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
44 | 15 | | |
45 | 16 | | |
46 | 17 | | |
47 | 18 | | |
48 | 19 | | |
49 | 20 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 21 | + | |
60 | 22 | | |
61 | 23 | | |
62 | 24 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
54 | 13 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
| 14 | + | |
| 15 | + | |
71 | 16 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
31 | 16 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 17 | + | |
| 18 | + | |
40 | 19 | | |
41 | 20 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
108 | 31 | | |
109 | 32 | | |
110 | 33 | | |
0 commit comments