8000 [executorch][codegen] support function + method variants. by JacobSzwejbka · Pull Request #153651 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[executorch][codegen] support function + method variants. #153651

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 6 additions & 7 deletions torchgen/gen_executorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,19 @@ class ComputeFunction:
is_custom_op: Callable[[NativeFunction], bool]

@method_with_native_function
def __call__(self, f: NativeFunction) -> str | None:
def __call__(self, f: NativeFunction) -> str | None:
is_method_variant = False
if not self.selector.is_root_operator(f"{f.namespace}::{f.func.name}"):
return None

if Variant.function not in f.variants and Variant.method in f.variants:
is_method_variant = True

# only valid remaining case is only function is in f.variants
elif not (Variant.function in f.variants and Variant.method not in f.variants):
if Variant.function not in f.variants and Variant.method not in f.variants:
raise Exception( # noqa: TRY002
f"Can't handle native function {f.func} with the following variant specification {f.variants}."
f"Expected one of function or method to be in variants for {f.func.name}"
)

if Variant.function not in f.variants and Variant.method in f.variants:
is_method_variant = True

sig: CppSignature | ExecutorchCppSignature = (
CppSignatureGroup.from_native_function(
f, method=False, fallback_binding=f.manual_cpp_binding
Expand Down
Loading
0