Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .lintrunner.toml
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,19 @@ command = [
'@{{PATHSFILE}}',
]

[[linter]]
code = 'ETVKJSONFORMAT'
include_patterns = [
'backends/vulkan/test/ops/benchmark_v2/**/*.json',
]
command = [
'python',
'backends/vulkan/test/ops/benchmark_v2/format_json.py',
'--lintrunner',
'@{{PATHSFILE}}',
]
is_formatter = true

[[linter]]
code = 'RUFF_DOCS'
include_patterns = [
Expand Down
18 changes: 18 additions & 0 deletions backends/vulkan/test/ops/benchmark_v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,30 @@ framework/ Parsing, graph setup, validation, timing, and reportin
operators/ CPU references, routes, throughput counters, and checks
<family>/.../cases/ JSON case collections by operator and quantization scheme
examples/ Small shader and operator configuration examples
format_json.py Formatter for the JSON files
```

Each expanded case runs separately. Shader variants can share one binding
interface through `shader_sweep`; operators can sweep argument sets, dtype and
storage variables, and execution routes.

## Formatting JSON files

`format_json.py` keeps a JSON value on one line when its one-line form is at
most 200 characters, not counting its key and indentation, and lists longer
objects and arrays one entry per line. An object with one entry is measured by
that entry's value. Parsed content is unchanged, and files with duplicate keys
are rejected.

The `ETVKJSONFORMAT` lintrunner linter checks these files, and `lintrunner -a`
formats them. To format without lintrunner, run the script; without paths, it
formats every JSON file under `benchmark_v2`. Other formatters, such as
Prettier on save, expand these files; format them again afterwards.

```sh
python3 backends/vulkan/test/ops/benchmark_v2/format_json.py [PATH ...]
```

## Building with CMake

From the ExecuTorch root, `build.sh` builds ExecuTorch with the Vulkan backend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,9 @@
"target_ms": 10,
"benchmark_runs": 5,
"bindings": [
{
"buffer": {
"name": "output",
"sizes": [8],
"access": "write",
"data": {"fill": 0}
}
},
{
"buffer": {
"name": "input",
"sizes": [8],
"data": {"rand_uniform_float": [-1, 1]}
}
},
{
"meta_ubo": "output",
"field": "numel"
}
{"buffer": {"name": "output", "sizes": [8], "access": "write", "data": {"fill": 0}}},
{"buffer": {"name": "input", "sizes": [8], "data": {"rand_uniform_float": [-1, 1]}}},
{"meta_ubo": "output", "field": "numel"}
],
"outputs": ["output"]
}
48 changes: 5 additions & 43 deletions backends/vulkan/test/ops/benchmark_v2/examples/conv2d.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,57 +6,19 @@
"show_memory_throughput": true,
"show_compute_throughput": true,
"max_dispatches": 512,
"sweep_variables": {
"v_DTYPE": ["float32", "float16"]
},
"sweep_variables": {"v_DTYPE": ["float32", "float16"]},
"args_sweep": [
[
{
"tensor": {
"name": "input",
"sizes": [1, 4, 4, 4],
"dtype": "v_DTYPE",
"storage": "texture3d",
"layout": "channels",
"data": {"rand_uniform_float": [-1, 1]}
}
},
{
"tensor": {
"name": "weight",
"sizes": [8, 4, 3, 3],
"dtype": "v_DTYPE",
"storage": "constant",
"layout": "width",
"data": {"rand_uniform_float": [-1, 1]}
}
},
{
"tensor": {
"name": "bias",
"sizes": [8],
"dtype": "v_DTYPE",
"storage": "constant",
"layout": "width",
"data": {"rand_uniform_float": [-1, 1]}
}
},
{"tensor": {"name": "input", "sizes": [1, 4, 4, 4], "dtype": "v_DTYPE", "storage": "texture3d", "layout": "channels", "data": {"rand_uniform_float": [-1, 1]}}},
{"tensor": {"name": "weight", "sizes": [8, 4, 3, 3], "dtype": "v_DTYPE", "storage": "constant", "layout": "width", "data": {"rand_uniform_float": [-1, 1]}}},
{"tensor": {"name": "bias", "sizes": [8], "dtype": "v_DTYPE", "storage": "constant", "layout": "width", "data": {"rand_uniform_float": [-1, 1]}}},
{"int_list": [1, 1]},
{"int_list": [1, 1]},
{"int_list": [1, 1]},
{"bool": false},
{"int_list": [0, 0]},
{"int": 1},
{
"tensor": {
"name": "output",
"sizes": [1, 8, 4, 4],
"dtype": "v_DTYPE",
"storage": "texture3d",
"layout": "channels",
"data": {"fill": 0}
}
}
{"tensor": {"name": "output", "sizes": [1, 8, 4, 4], "dtype": "v_DTYPE", "storage": "texture3d", "layout": "channels", "data": {"fill": 0}}}
]
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,67 +5,12 @@
"lwg_size": [8, 8, 1],
"sustain_s": 12,
"bindings": [
{
"texture3d": {
"name": "out",
"sizes": [1, 128, 128, 128],
"dtype": "float16",
"layout": "channels",
"access": "write",
"data": {
"fill": 0
}
}
},
{
"texture2d": {
"name": "im2col",
"sizes": [14464, 576],
"dtype": "float16",
"data": {
"rand_uniform_float": [-1, 1]
}
}
},
{
"texture2d": {
"name": "weight_packed",
"sizes": [144, 512],
"dtype": "float16",
"data": {
"rand_uniform_float": [-0.05, 0.05]
}
}
},
{
"texture2d": {
"name": "bias",
"sizes": [128],
"dtype": "float16",
"data": {
"rand_uniform_float": [-1, 1]
}
}
},
{
"meta_ubo": "out",
"field": "sizes"
}
{"texture3d": {"name": "out", "sizes": [1, 128, 128, 128], "dtype": "float16", "layout": "channels", "access": "write", "data": {"fill": 0}}},
{"texture2d": {"name": "im2col", "sizes": [14464, 576], "dtype": "float16", "data": {"rand_uniform_float": [-1, 1]}}},
{"texture2d": {"name": "weight_packed", "sizes": [144, 512], "dtype": "float16", "data": {"rand_uniform_float": [-0.05, 0.05]}}},
{"texture2d": {"name": "bias", "sizes": [128], "dtype": "float16", "data": {"rand_uniform_float": [-1, 1]}}},
{"meta_ubo": "out", "field": "sizes"}
],
"specialization_constants": [
{
"dtype": "int32",
"value": 0
}
],
"push_constants": [
{
"dtype": "int32",
"data": [144, 0, 113, 0]
},
{
"dtype": "float32",
"data": [0, 0, 0, 0]
}
]
"specialization_constants": [{"dtype": "int32", "value": 0}],
"push_constants": [{"dtype": "int32", "data": [144, 0, 113, 0]}, {"dtype": "float32", "data": [0, 0, 0, 0]}]
}
107 changes: 15 additions & 92 deletions backends/vulkan/test/ops/benchmark_v2/examples/conv2d_routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,101 +10,24 @@
"auto",
"direct",
"im2col",
{
"name": "im2col",
"options": {
"intermediate_storage": "buffer"
}
},
{
"name": "im2col",
"options": {
"intermediate_storage": "texture2d"
}
},
{
"name": "im2col",
"options": {
"intermediate_storage": "texture3d"
}
}
{"name": "im2col", "options": {"intermediate_storage": "buffer"}},
{"name": "im2col", "options": {"intermediate_storage": "texture2d"}},
{"name": "im2col", "options": {"intermediate_storage": "texture3d"}}
],
"validation_method": {
"function": "is_close",
"atol": 0.05,
"rtol": 0.01
},
"sweep_variables": {
"v_DTYPE": ["float32", "float16"]
},
"validation_method": {"function": "is_close", "atol": 0.05, "rtol": 0.01},
"sweep_variables": {"v_DTYPE": ["float32", "float16"]},
"args_sweep": [
[
{
"tensor": {
"name": "input",
"sizes": [1, 32, 32, 32],
"dtype": "v_DTYPE",
"storage": "texture3d",
"layout": "channels",
"data": {
"rand_uniform_float": [-1, 1]
}
}
},
{
"tensor": {
"name": "weight",
"sizes": [64, 32, 3, 3],
"dtype": "v_DTYPE",
"storage": "constant",
"layout": "width",
"data": {
"rand_uniform_float": [-0.05, 0.05]
}
}
},
{
"tensor": {
"name": "bias",
"sizes": [64],
"dtype": "v_DTYPE",
"storage": "constant",
"layout": "width",
"data": {
"rand_uniform_float": [-1, 1]
}
}
},
{
"int_list": [1, 1]
},
{
"int_list": [1, 1]
},
{
"int_list": [1, 1]
},
{
"bool": false
},
{
"int_list": [0, 0]
},
{
"int": 1
},
{
"tensor": {
"name": "output",
"sizes": [1, 64, 32, 32],
"dtype": "v_DTYPE",
"storage": "texture3d",
"layout": "channels",
"data": {
"fill": 0
}
}
}
{"tensor": {"name": "input", "sizes": [1, 32, 32, 32], "dtype": "v_DTYPE", "storage": "texture3d", "layout": "channels", "data": {"rand_uniform_float": [-1, 1]}}},
{"tensor": {"name": "weight", "sizes": [64, 32, 3, 3], "dtype": "v_DTYPE", "storage": "constant", "layout": "width", "data": {"rand_uniform_float": [-0.05, 0.05]}}},
{"tensor": {"name": "bias", "sizes": [64], "dtype": "v_DTYPE", "storage": "constant", "layout": "width", "data": {"rand_uniform_float": [-1, 1]}}},
{"int_list": [1, 1]},
{"int_list": [1, 1]},
{"int_list": [1, 1]},
{"bool": false},
{"int_list": [0, 0]},
{"int": 1},
{"tensor": {"name": "output", "sizes": [1, 64, 32, 32], "dtype": "v_DTYPE", "storage": "texture3d", "layout": "channels", "data": {"fill": 0}}}
]
]
}
Loading
Loading