brainevent.load_cpp_inline

brainevent.load_cpp_inline#

brainevent.load_cpp_inline(name, cpp_sources, functions=None, *, extra_cflags=None, extra_ldflags=None, extra_include_paths=None, build_directory=None, verbose=False, force_rebuild=False, auto_register=True, target_prefix=None)[source]#

Compile inline C++ source for CPU (or CUDA) and load the module.

This is the CPU counterpart of load_cuda_inline(). It uses the system C++ compiler (g++ / clang++) instead of nvcc, so CUDA is not required.

Parameters:
  • name (str) – Module name (used for caching and FFI target naming).

  • cpp_sources (str | list[str]) – C++ source code. Multiple strings are concatenated.

  • functions (dict[str, list[str]] | list[str] | None) –

    Dict form (explicit): {"func": ["arg", "ret", ...]} — same arg_spec tokens as load_cuda_inline().

    List form (auto-detect): ["func"] — the arg_spec is inferred from the C++ signature. const BE::Tensor"arg", non-const BE::Tensor"ret".

    None (annotation): functions are discovered from // @BE function_name annotations in the source code.

  • extra_cflags (list[str] | None) – Additional compiler / linker flags and include paths.

  • extra_ldflags (list[str] | None) – Additional compiler / linker flags and include paths.

  • extra_include_paths (list[str] | None) – Additional compiler / linker flags and include paths.

  • build_directory (str | None) – Override the build directory.

  • verbose (bool) – Print the full compiler command.

  • force_rebuild (bool) – Skip cache and recompile.

  • auto_register (bool) – Automatically register FFI targets as "<prefix>.<func>".

  • target_prefix (str | None) – Prefix for auto-registered FFI targets. Defaults to name.

  • platform (str) – Target platform passed to jax.ffi.register_ffi_target. Default: "cpu".

Return type:

CompiledModule