Commit 9247a879 authored by Lei Wang's avatar Lei Wang Committed by LeiWang1999
Browse files

[Enhancement] Include Metadata (LayoutMap etc.) into hashing (#570)

- Modified the serialization of function scripts in both KernelCache and AutoTunerCache to include metadata by setting `show_meta=True` in `cloudpickle.dumps()`. This change enhances the hash key generation for kernel configurations, improving cache accuracy and consistency.
parent 37d0dead
...@@ -8,7 +8,6 @@ def _check(original, transformed): ...@@ -8,7 +8,6 @@ def _check(original, transformed):
func = original func = original
mod = tvm.IRModule.from_expr(func.with_attr("global_symbol", "main")) mod = tvm.IRModule.from_expr(func.with_attr("global_symbol", "main"))
mod = tl.transform.FrontendLegalize()(mod) mod = tl.transform.FrontendLegalize()(mod)
print(mod.script())
tvm.ir.assert_structural_equal(mod["main"], transformed.with_attr("global_symbol", "main"), tvm.ir.assert_structural_equal(mod["main"], transformed.with_attr("global_symbol", "main"),
True) True)
......
...@@ -91,7 +91,7 @@ class KernelCache: ...@@ -91,7 +91,7 @@ class KernelCache:
str: SHA256 hash key for the kernel configuration. str: SHA256 hash key for the kernel configuration.
""" """
self.execution_backend = execution_backend self.execution_backend = execution_backend
func_binary = cloudpickle.dumps(func.script()) func_binary = cloudpickle.dumps(func.script(show_meta=True))
key_data = { key_data = {
"version": __version__, "version": __version__,
"func": sha256(func_binary).hexdigest(), # Use SHA256 to generate hash key "func": sha256(func_binary).hexdigest(), # Use SHA256 to generate hash key
......
...@@ -86,7 +86,7 @@ class AutoTunerCache: ...@@ -86,7 +86,7 @@ class AutoTunerCache:
Returns: Returns:
str: SHA256 hash key for the kernel configuration. str: SHA256 hash key for the kernel configuration.
""" """
func_binary = cloudpickle.dumps(func.script()) func_binary = cloudpickle.dumps(func.script(show_meta=True))
key_data = { key_data = {
"version": __version__, "version": __version__,
"func": sha256(func_binary).hexdigest(), # Use SHA256 to generate hash key "func": sha256(func_binary).hexdigest(), # Use SHA256 to generate hash key
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment