mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
[AOTInductor] Add wrapper and kernel code to debug code logging (#153181)
This is a simple PR to make the AOTInductor wrapper and kernel code get output by `TORCH_COMPILE_DEBUG=1`. Pull Request resolved: https://github.com/pytorch/pytorch/pull/153181 Approved by: https://github.com/desertfire
This commit is contained in:
parent
01bb249978
commit
01cbf5a30a
|
|
@ -98,6 +98,7 @@ from .remote_cache import create_cache
|
|||
from .runtime import autotune_cache
|
||||
from .runtime.autotune_cache import AutotuneCacheBundler
|
||||
from .triton_bundler import TritonBundler
|
||||
from .virtualized import V
|
||||
|
||||
|
||||
if config.is_fbcode():
|
||||
|
|
@ -1604,6 +1605,12 @@ class AotCodeCompiler:
|
|||
specified_dir=specified_output_path,
|
||||
)
|
||||
|
||||
# Log the AOTInductor wrapper and kernel code, if needed.
|
||||
with tempfile.NamedTemporaryFile("w+") as t:
|
||||
t.writelines((wrapper_code, "\n", kernel_code, "\n"))
|
||||
t.flush()
|
||||
V.debug.output_code(t.name, extension="cpp")
|
||||
|
||||
if config.aot_inductor.package:
|
||||
generated_files.append(wrapper_path)
|
||||
if not config.aot_inductor.package_cpp_only:
|
||||
|
|
|
|||
|
|
@ -559,8 +559,8 @@ class DebugFormatter:
|
|||
dot_graph_shape=config.trace.dot_graph_shape,
|
||||
)
|
||||
|
||||
def output_code(self, filename: str) -> None:
|
||||
shutil.copy(filename, self.filename("output_code.py"))
|
||||
def output_code(self, filename: str, extension: str = "py") -> None:
|
||||
shutil.copy(filename, self.filename(f"output_code.{extension}"))
|
||||
|
||||
def log_inductor_triton_kernel_to_post_grad_node_info(
|
||||
self, filename: str = "inductor_triton_kernel_to_post_grad_nodes.json"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user