MCPcopy Create free account
hub / github.com/UbiquitousLearning/mllm / make_cpp_args

Function make_cpp_args

mllm-kernel/mllm_kernel/jit_utils/compile.py:146–167  ·  view source on GitHub ↗

Convert Python arguments to C++ template argument strings. Example: make_cpp_args(16, torch.float16) -> ["16", "fp16_t"]

(
    *args: MLLM_KERNEL_TEMPLATE_TYPE,
)

Source from the content-addressed store, hash-verified

144
145
146def make_cpp_args(
147 *args: MLLM_KERNEL_TEMPLATE_TYPE,
148) -> _MLLMKernelTemplateArgListGenerator:
149 """
150 Convert Python arguments to C++ template argument strings.
151
152 Example:
153 make_cpp_args(16, torch.float16) -> ["16", "fp16_t"]
154 """
155
156 def _convert(arg: MLLM_KERNEL_TEMPLATE_TYPE) -> str:
157 if isinstance(arg, bool):
158 return "true" if arg else "false"
159 if isinstance(arg, (int, float)):
160 return str(arg)
161 if isinstance(arg, torch.dtype):
162 return MLLM_KERNEL_TEMPLATE_DTYPE_MAP[arg]
163 raise TypeError(
164 f"Unsupported argument type for mllm kernel template: {type(arg)}"
165 )
166
167 return _MLLMKernelTemplateArgListGenerator(_convert(arg) for arg in args)
168
169
170# Path constants

Callers 1

jitFunction · 0.85

Calls 2

_convertFunction · 0.85

Tested by

no test coverage detected