From 64bd8896609898c8d5cb6070d5c9ff3031ddbeae Mon Sep 17 00:00:00 2001 From: "Xia, Weiwen" Date: Thu, 20 Mar 2025 06:52:17 -0700 Subject: [PATCH] [Inductor][CPP] rename shim_mkldnn.h/.cpp to shim_cpu.h/.cpp (#149372) **Summary** Previous discussion is here: https://github.com/pytorch/pytorch/pull/148907#issuecomment-2712795600 Rename these files because - they may hold mkldnn-unrelated code for CPU - filenames are aligned with files for CUDA and XPU Pull Request resolved: https://github.com/pytorch/pytorch/pull/149372 Approved by: https://github.com/leslie-fang-intel, https://github.com/jgong5, https://github.com/desertfire --- build_variables.bzl | 2 +- torch/_inductor/mkldnn_ir.py | 28 +++++++++---------- .../c/{shim_mkldnn.h => shim_cpu.h} | 6 ++-- .../{shim_mkldnn.cpp => shim_cpu.cpp} | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) rename torch/csrc/inductor/aoti_torch/c/{shim_mkldnn.h => shim_cpu.h} (98%) rename torch/csrc/inductor/aoti_torch/{shim_mkldnn.cpp => shim_cpu.cpp} (99%) diff --git a/build_variables.bzl b/build_variables.bzl index 0c968121fbe..73f3f0e9d2b 100644 --- a/build_variables.bzl +++ b/build_variables.bzl @@ -472,7 +472,7 @@ inductor_core_resources = [ "torch/csrc/inductor/aoti_runner/model_container_runner.cpp", "torch/csrc/inductor/aoti_runner/model_container_runner_cpu.cpp", "torch/csrc/inductor/aoti_torch/shim_common.cpp", - "torch/csrc/inductor/aoti_torch/shim_mkldnn.cpp", + "torch/csrc/inductor/aoti_torch/shim_cpu.cpp", "torch/csrc/inductor/aoti_torch/tensor_converter.cpp", "torch/csrc/inductor/aoti_torch/mkldnn_tensor.cpp", "torch/csrc/inductor/aoti_torch/oss_proxy_executor.cpp", diff --git a/torch/_inductor/mkldnn_ir.py b/torch/_inductor/mkldnn_ir.py index cdec1e1c1d9..422b256ca96 100644 --- a/torch/_inductor/mkldnn_ir.py +++ b/torch/_inductor/mkldnn_ir.py @@ -291,7 +291,7 @@ class ConvolutionUnary(ExternKernelAlloc): ) def codegen(self, wrapper): - wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_mkldnn.h") + wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_cpu.h") super().codegen(wrapper) @classmethod @@ -349,7 +349,7 @@ class ConvolutionBinary(ExternKernelAlloc): self.cpp_constant_args = cpp_constant_args def codegen(self, wrapper): - wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_mkldnn.h") + wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_cpu.h") super().codegen(wrapper) @classmethod @@ -420,7 +420,7 @@ class ConvolutionBinaryInplace(ExternKernelAlloc): ] def codegen(self, wrapper): - wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_mkldnn.h") + wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_cpu.h") super().codegen(wrapper) def get_unbacked_symbol_defs(self) -> OrderedSet[sympy.Symbol]: @@ -489,7 +489,7 @@ class ConvolutionTransposeUnary(ExternKernelAlloc): ) def codegen(self, wrapper): - wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_mkldnn.h") + wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_cpu.h") super().codegen(wrapper) @classmethod @@ -567,7 +567,7 @@ class QConvPointWisePT2E(ExternKernelAlloc): ) def codegen(self, wrapper): - wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_mkldnn.h") + wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_cpu.h") super().codegen(wrapper) if isinstance(self.layout, Layout): self.codegen_size_asserts(wrapper) @@ -672,7 +672,7 @@ class QConvPointWiseBinaryPT2E(ExternKernelAlloc): ) def codegen(self, wrapper): - wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_mkldnn.h") + wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_cpu.h") super().codegen(wrapper) if isinstance(self.layout, Layout): self.codegen_size_asserts(wrapper) @@ -782,7 +782,7 @@ class MKLPackedLinear(ExternKernelAlloc): ) def codegen(self, wrapper): - wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_mkldnn.h") + wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_cpu.h") super().codegen(wrapper) @classmethod @@ -826,7 +826,7 @@ class LinearUnary(ExternKernelAlloc): ) def codegen(self, wrapper): - wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_mkldnn.h") + wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_cpu.h") super().codegen(wrapper) @classmethod @@ -879,7 +879,7 @@ class LinearBinary(ExternKernelAlloc): ) def codegen(self, wrapper): - wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_mkldnn.h") + wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_cpu.h") super().codegen(wrapper) @classmethod @@ -943,7 +943,7 @@ class QLinearPointwisePT2E(ExternKernelAlloc): ) def codegen(self, wrapper): - wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_mkldnn.h") + wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_cpu.h") super().codegen(wrapper) if isinstance(self.layout, Layout): @@ -1027,7 +1027,7 @@ class QLinearPointwiseBinaryPT2E(ExternKernelAlloc): ) def codegen(self, wrapper): - wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_mkldnn.h") + wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_cpu.h") super().codegen(wrapper) if isinstance(self.layout, Layout): self.codegen_size_asserts(wrapper) @@ -1225,11 +1225,11 @@ class MkldnnRnnLayer(ExternKernelAlloc): return output_ir def codegen(self, wrapper): - wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_mkldnn.h") + wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_cpu.h") return super().codegen(wrapper) -# Add this IR so that we can include shim_mkldnn.h for cpp_wrapper +# Add this IR so that we can include shim_cpu.h for cpp_wrapper class WeightInt4PackMatmul(ExternKernelAlloc): def __init__( self, @@ -1253,7 +1253,7 @@ class WeightInt4PackMatmul(ExternKernelAlloc): ) def codegen(self, wrapper): - wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_mkldnn.h") + wrapper.include_extra_header("torch/csrc/inductor/aoti_torch/c/shim_cpu.h") super().codegen(wrapper) if isinstance(self.layout, Layout): diff --git a/torch/csrc/inductor/aoti_torch/c/shim_mkldnn.h b/torch/csrc/inductor/aoti_torch/c/shim_cpu.h similarity index 98% rename from torch/csrc/inductor/aoti_torch/c/shim_mkldnn.h rename to torch/csrc/inductor/aoti_torch/c/shim_cpu.h index 00772069f0b..86f09416f9f 100644 --- a/torch/csrc/inductor/aoti_torch/c/shim_mkldnn.h +++ b/torch/csrc/inductor/aoti_torch/c/shim_cpu.h @@ -1,5 +1,5 @@ -#ifndef AOTI_TORCH_SHIM_MKLDNN -#define AOTI_TORCH_SHIM_MKLDNN +#ifndef AOTI_TORCH_SHIM_CPU +#define AOTI_TORCH_SHIM_CPU #include #include @@ -248,4 +248,4 @@ AOTI_TORCH_EXPORT AOTITorchError aoti_torch_cpu__weight_int4pack_mm_cpu_tensor( #ifdef __cplusplus } // extern "C" #endif -#endif // AOTI_TORCH_SHIM_MKLDNN +#endif // AOTI_TORCH_SHIM_CPU diff --git a/torch/csrc/inductor/aoti_torch/shim_mkldnn.cpp b/torch/csrc/inductor/aoti_torch/shim_cpu.cpp similarity index 99% rename from torch/csrc/inductor/aoti_torch/shim_mkldnn.cpp rename to torch/csrc/inductor/aoti_torch/shim_cpu.cpp index cca688cb477..153ee9e0ddb 100644 --- a/torch/csrc/inductor/aoti_torch/shim_mkldnn.cpp +++ b/torch/csrc/inductor/aoti_torch/shim_cpu.cpp @@ -1,5 +1,5 @@ -#include +#include #include #ifndef AT_PER_OPERATOR_HEADERS