Skip to content

[Specialized Kernel] Update yaml syntax to use kernel instead of dispatch #104070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
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
5 changes: 3 additions & 2 deletions test/edge/custom_ops.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- func: custom::add_3.out(Tensor a, Tensor b, Tensor c, *, Tensor(a!) out) -> Tensor(a!)
dispatch:
CPU: custom::add_3_out
kernels:
- arg_meta: null
kernel_name: custom::add_3_out
13 changes: 10 additions & 3 deletions torchgen/executorch/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ def parse_et_yaml(
et_kernel = extract_kernel_fields(es)

# Remove ET specific fields from entries for BC compatibility
for entry in es:
for field in ET_FIELDS:
entry.pop(field, None)
strip_et_fields(es)

native_yaml = parse_native_yaml(
path,
Expand All @@ -142,3 +140,12 @@ def parse_et_yaml(
loaded_yaml=es,
)
return native_yaml.native_functions, et_kernel


def strip_et_fields(es: object) -> None:
"""Given a loaded yaml representing a list of operators,
remove ET specific fields from every entries for BC compatibility
"""
for entry in es: # type: ignore[attr-defined]
for field in ET_FIELDS:
entry.pop(field, None)