Skip to content

Commit 14085eb

Browse files
pytorchbotSS-JIA
andauthored
[ET-VK][ez] Fix to codegen caching mechanism (#12274)
This PR was created by the merge bot to help merge the original PR into the main branch. ghstack PR number: #12272 by @SS-JIA ^ Please use this as the source of truth for the PR details, comments, and reviews ghstack PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/253/base ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/253/head Merge bot PR base: https://github.com/pytorch/executorch/tree/main Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/253/orig @diff-train-skip-merge Co-authored-by: Stephen Jia <[email protected]>
1 parent 5eb14b7 commit 14085eb

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

backends/vulkan/runtime/gen_vulkan_spv.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -861,10 +861,6 @@ def generate_src_file(shader_paths_pair):
861861

862862
# Construct generated file name
863863
gen_out_path = os.path.join(output_dir, f"{src_file_name}.{out_file_ext}")
864-
# Construct path of cached generated file
865-
cached_gen_out_path = os.path.join(
866-
cache_dir, f"{src_file_name}.{out_file_ext}"
867-
)
868864

869865
# Execute codegen to generate the output file
870866
with codecs.open(src_file_fullpath, "r", encoding="utf-8") as input_file:
@@ -875,10 +871,6 @@ def generate_src_file(shader_paths_pair):
875871
with codecs.open(gen_out_path, "w", encoding="utf-8") as output_file:
876872
output_file.write(output_text)
877873

878-
if cache_dir is not None:
879-
# Store the generated file in the cache for SPIR-V compilation
880-
shutil.copyfile(gen_out_path, cached_gen_out_path)
881-
882874
def compile_spirv(shader_paths_pair):
883875
# Extract components from the input tuple
884876
# name of generated .glsl, .glslh, or .h
@@ -959,7 +951,10 @@ def compile_spirv(shader_paths_pair):
959951
else:
960952
raise RuntimeError(f"{err_msg_base} {e.stderr}") from e
961953

954+
# If compilation was successful, store the source GLSL file and the
955+
# compiled SPIR-V file in the cache for future comparison.
962956
if cache_dir is not None:
957+
shutil.copyfile(gen_out_path, cached_gen_out_path)
963958
shutil.copyfile(spv_out_path, cached_spv_out_path)
964959

965960
return (spv_out_path, gen_out_path)

0 commit comments

Comments
 (0)