Skip to content

Commit 18dacf7

Browse files
Jack-Khuupytorchmergebot
authored andcommitted
[Specialized Kernel] Update yaml syntax to use kernel instead of dispatch (#104070)
Based on this [code search](https://fburl.com/code/gjcnw8ly) (*.yaml with `dispatch: CPU:`), update all files found to use ``` kernels: - arg_meta: None kernel_name: ``` instead of ``` dispatch: CPU: ``` --- ## Code changes: - `fbcode/executorch/codegen/tools/gen_oplist.py` - Strip ET specific fields prior to calling parse_native_yaml_struct --- ## Files edited that are not `*functions.yaml` or `custom_ops.yaml` - fbcode/executorch/kernels/optimized/optimized.yaml - fbcode/executorch/kernels/quantized/quantized.yaml - fbcode/executorch/kernels/test/custom_kernel_example/my_functions.yaml --- ## Found Files that were not edited **Dispatched to more than just CPU** - fbcode/caffe2/aten/src/ATen/native/native_functions.yaml - xplat/caffe2/aten/src/ATen/native/native_functions.yaml - xros/third-party/caffe2/caffe2/aten/src/ATen/native/native_functions.yaml **Grouped ops.yaml path** - fbcode/on_device_ai/Assistant/Jarvis/min_runtime/operators/ops.yaml --- **Design Doc:** https://docs.google.com/document/d/1gq4Wz2R6verKJ2EFseLyPdAF0wqomnCrVDDJpRkYsRw/edit?kh_source=GDOCS#heading=h.8raqyft9y50 Differential Revision: [D46952067](https://our.internmc.facebook.com/intern/diff/D46952067/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D46952067/)! Pull Request resolved: #104070 Approved by: https://github.com/larryliu0820
1 parent 95707ac commit 18dacf7

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

test/edge/custom_ops.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
- func: custom::add_3.out(Tensor a, Tensor b, Tensor c, *, Tensor(a!) out) -> Tensor(a!)
2-
dispatch:
3-
CPU: custom::add_3_out
2+
kernels:
3+
- arg_meta: null
4+
kernel_name: custom::add_3_out

torchgen/executorch/parse.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ def parse_et_yaml(
130130
et_kernel = extract_kernel_fields(es)
131131

132132
# Remove ET specific fields from entries for BC compatibility
133-
for entry in es:
134-
for field in ET_FIELDS:
135-
entry.pop(field, None)
133+
strip_et_fields(es)
136134

137135
native_yaml = parse_native_yaml(
138136
path,
@@ -142,3 +140,12 @@ def parse_et_yaml(
142140
loaded_yaml=es,
143141
)
144142
return native_yaml.native_functions, et_kernel
143+
144+
145+
def strip_et_fields(es: object) -> None:
146+
"""Given a loaded yaml representing a list of operators,
147+
remove ET specific fields from every entries for BC compatibility
148+
"""
149+
for entry in es: # type: ignore[attr-defined]
150+
for field in ET_FIELDS:
151+
entry.pop(field, None)

0 commit comments

Comments
 (0)