MCPcopy
hub / github.com/apache/tvm / compile

Method compile

python/tvm/relax/frontend/nn/extern.py:367–392  ·  view source on GitHub ↗

Compiles the source code in a provided directory and returns the compiled artifact.

(self, output_path: Path)

Source from the content-addressed store, hash-verified

365 return include_flags + host_flags
366
367 def compile(self, output_path: Path) -> None:
368 """Compiles the source code in a provided directory and returns the compiled artifact."""
369 with tempfile.TemporaryDirectory() as temp_dir_str:
370 temp_dir = Path(temp_dir_str)
371 source_filename = f"main{self.source_suffix}"
372 object_filename = f"main{self.output_suffix}"
373 source_path = temp_dir / source_filename
374 object_path = temp_dir / object_filename
375 with source_path.open("w", encoding="utf-8") as file:
376 file.write(self.source_code)
377 _cc.create_shared(
378 output=object_filename,
379 objects=[source_filename],
380 options=self.compile_options,
381 cc=self.compiler,
382 cwd=temp_dir,
383 ccache_env=(
384 {
385 "CCACHE_COMPILERCHECK": "content",
386 "CCACHE_NOHASHDIR": "1",
387 }
388 if shutil.which("ccache")
389 else None
390 ),
391 )
392 shutil.move(str(object_path), str(output_path))
393
394 def load(self) -> Module:
395 with tempfile.TemporaryDirectory() as temp_dir_str:

Callers 15

loadMethod · 0.95
_convert_call_tirMethod · 0.45
_compile_functionsMethod · 0.45
dynamo_capture_subgraphsFunction · 0.45
_safe_remove_dump_dirMethod · 0.45
mainFunction · 0.45
local_build_and_runFunction · 0.45
bench.pyFile · 0.45
_run_exprFunction · 0.45
test_rpc_moduleFunction · 0.45
test_rpc_moduleFunction · 0.45

Calls 2

strFunction · 0.85
writeMethod · 0.65

Tested by 15

test_rpc_moduleFunction · 0.36
test_rpc_moduleFunction · 0.36
test_sortFunction · 0.36
test_sort_npFunction · 0.36
verify_torch_dlpackFunction · 0.36
verifyFunction · 0.36
verify_batch_matmulFunction · 0.36
verifyFunction · 0.36
verifyFunction · 0.36
build_and_runFunction · 0.36