MCPcopy Create free account
hub / github.com/LMCache/LMCache / build_common_cpp

Function build_common_cpp

setup_extensions/common_cpp.py:67–98  ·  view source on GitHub ↗

Build pure C++ extensions that do not depend on any backend. Args: profile: Resolved backend profile (or ``None``). Each spec in :data:`COMMON_EXTENSIONS` queries ``profile.extra_cxx_flags_for`` to obtain its per-extension extra flags. Returns: ``(e

(
    profile: "BuildProfile | None" = None,
)

Source from the content-addressed store, hash-verified

65
66
67def build_common_cpp(
68 profile: "BuildProfile | None" = None,
69) -> tuple[list["Extension"], dict]:
70 """Build pure C++ extensions that do not depend on any backend.
71
72 Args:
73 profile: Resolved backend profile (or ``None``). Each spec in
74 :data:`COMMON_EXTENSIONS` queries ``profile.extra_cxx_flags_for``
75 to obtain its per-extension extra flags.
76
77 Returns:
78 ``(ext_modules, cmdclass)`` tuple.
79 """
80 # Third Party
81 from torch.utils import cpp_extension
82
83 ext_modules = [
84 cpp_extension.CppExtension(
85 "lmcache." + spec.name,
86 sources=spec.sources,
87 include_dirs=spec.include_dirs,
88 extra_compile_args={
89 "cxx": (
90 (profile.extra_cxx_flags_for(spec) if profile else [])
91 + ["-O3", "-std=c++17"]
92 ),
93 },
94 )
95 for spec in COMMON_EXTENSIONS
96 ]
97 cmdclass = {"build_ext": cpp_extension.BuildExtension}
98 return ext_modules, cmdclass

Callers 1

collect_extensionsMethod · 0.90

Calls 1

extra_cxx_flags_forMethod · 0.45

Tested by

no test coverage detected