Skip to content

Commit 4d7b64e

Browse files
support function + method variants
Differential Revision: D75006941 Pull Request resolved: #10974
1 parent e365e15 commit 4d7b64e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

codegen/gen.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,14 @@ def __call__(self, f: NativeFunction) -> str | None:
134134
if not self.selector.is_root_operator(f"{f.namespace}::{f.func.name}"):
135135
return None
136136

137-
if Variant.function not in f.variants and Variant.method in f.variants:
138-
is_method_variant = True
139-
140-
# only valid remaining case is only function is in f.variants
141-
elif not (Variant.function in f.variants and Variant.method not in f.variants):
137+
if Variant.function not in f.variants and Variant.method not in f.variants:
142138
raise Exception( # noqa: TRY002
143-
f"Can't handle native function {f.func} with the following variant specification {f.variants}."
139+
f"Expected one of function or method to be in variants for {f.func.name}"
144140
)
145141

142+
if Variant.function not in f.variants and Variant.method in f.variants:
143+
is_method_variant = True
144+
146145
sig: CppSignature | ExecutorchCppSignature = (
147146
CppSignatureGroup.from_native_function(
148147
f, method=False, fallback_binding=f.manual_cpp_binding

0 commit comments

Comments
 (0)