compiler#
Kernel compilation helpers for building PyTorch extensions.
Selected through eval_config.kernel_compiler. Task authors normally do not use these
directly: see kernelfoundry.TestBase.compile_torch_extension() for the high-level
interface called from a task’s build method.
Functions
File extension for a loadable Python extension module ( |
|
|
Locate the extension module a compiler just produced in |
Classes
|
Abstract base class for kernel compilers. |
|
Compiler class for SYCL programs using the Intel icpx compiler. |
|
Compiler class using the torch cpp_extension compiler. |
- kernelfoundry.compiler.extension_suffix() str[source]#
File extension for a loadable Python extension module (
.soon Linux and macOS,.pydon Windows).
- kernelfoundry.compiler.find_built_extension(build_dir: str | PathLike, extension_name: str) Path[source]#
Locate the extension module a compiler just produced in
build_dir. Search by extension sincetorch.utils.cpp_extension.loadwrites<name>.soon Linux but<name>.pydon Windows.- Raises:
FileNotFoundError – If no extension module is present
- class kernelfoundry.compiler.BaseKernelCompiler(extension_name: str, src: str, build_dir: str, gpu_arch: str, timeout: int = 120, verbose: bool = False)[source]#
Abstract base class for kernel compilers.
- __init__(extension_name: str, src: str, build_dir: str, gpu_arch: str, timeout: int = 120, verbose: bool = False)[source]#
Initialize the Compiler.
- Parameters:
extension_name (str) – Name of the PyTorch extension to build.
src (str) – Path to the source file.
build_dir (str) – Directory to store the compiled outputs.
gpu_arch (str) – GPU architecture string.
timeout (int) – Timeout for each compilation step in seconds.
verbose (bool) – Whether to enable verbose output.
- class kernelfoundry.compiler.TorchCompiler(extension_name: str, src: str, build_dir: str, gpu_arch: str, timeout: int = 120, verbose: bool = False)[source]#
Compiler class using the torch cpp_extension compiler.
- LOAD_FAILED_RETURNCODE = 87#
Exit code the build subprocess uses when the sources compiled but the module would not import. Distinct from 1 so the caller can tell the two failures apart; see compile().