MCPcopy Create free account
hub / github.com/pytorch/executorch / compute_native_function_declaration

Function compute_native_function_declaration

codegen/gen.py:372–390  ·  view source on GitHub ↗
(
    g: NativeFunctionsGroup | NativeFunction, kernel_index: ETKernelIndex
)

Source from the content-addressed store, hash-verified

370
371@with_native_function_and_index # type: ignore[arg-type]
372def compute_native_function_declaration(
373 g: NativeFunctionsGroup | NativeFunction, kernel_index: ETKernelIndex
374) -> list[str]:
375 assert isinstance(g, NativeFunction)
376 sig = ExecutorchCppSignature.from_native_function(f=g)
377 metadata_list = kernel_index.get_kernels(g).values()
378 if metadata_list is None:
379 return []
380
381 # for kernels in lean mode, we declare two versions, one with context and one without.
382 # In the end we will cleanup the unused one.
383 def gen_decl(metadata: BackendMetadata, include_context: bool) -> str:
384 return f"{sig.decl(name=metadata.kernel, include_context=include_context)};"
385
386 return [
387 gen_decl(metadata, include_context)
388 for include_context in [False, True]
389 for metadata in metadata_list
390 ]
391
392
393def gen_functions_declarations(

Callers

nothing calls this directly

Calls 4

gen_declFunction · 0.85
from_native_functionMethod · 0.80
valuesMethod · 0.80
get_kernelsMethod · 0.80

Tested by

no test coverage detected