Pass in .so name via lower setting (#103968) (#104015)

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/103968

Differential Revision: D46922444

Pull Request resolved: https://github.com/pytorch/pytorch/pull/104015
Approved by: https://github.com/desertfire
diff --git a/torch/_inductor/codecache.py b/torch/_inductor/codecache.py
index d549148..043bb8f 100644
--- a/torch/_inductor/codecache.py
+++ b/torch/_inductor/codecache.py
@@ -714,7 +714,11 @@
             lock_dir = get_lock_dir()
             lock = FileLock(os.path.join(lock_dir, key + ".lock"), timeout=LOCK_TIMEOUT)
             with lock:
-                output_so = f"{input_path[:-4]}.so"
+                output_so_dir = input_path[:-4]
+                if not os.path.exists(output_so_dir):
+                    os.makedirs(output_so_dir, exist_ok=False)
+                so_name = f"{config.dll_name}.so"
+                output_so = os.path.join(output_so_dir, so_name)
                 if not os.path.exists(output_so):
                     cmd = cpp_compile_command(
                         input=input_path,
diff --git a/torch/_inductor/config.py b/torch/_inductor/config.py
index 5a57aa3..4ee33c5 100644
--- a/torch/_inductor/config.py
+++ b/torch/_inductor/config.py
@@ -51,6 +51,9 @@
 # enable reordering pass
 reordering = True
 
+# inductor engine name
+dll_name = "inductor_engine.so"
+
 # enable slow autotuning passes to select algorithms
 max_autotune = os.environ.get("TORCHINDUCTOR_MAX_AUTOTUNE") == "1"