Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compiler & torch-frontend] unify default cache dir to ~/.byteir #423

Merged
merged 2 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions compiler/python/byteir/dialects/cat/ait_cache.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import os
import json
import fcntl
import tempfile

from shutil import copyfile, copymode

HOME_DIR = os.getenv("HOME")
if HOME_DIR == None:
HOME_DIR = "/tmp/"
DEFAULT_CACHE_DIR = os.path.join(HOME_DIR, ".byteir_cache/ait_cache/")
if HOME_DIR is None:
HOME_DIR = tempfile.gettempdir()
DEFAULT_CACHE_DIR = os.path.join(HOME_DIR, ".byteir", "ait_cache")
CACHE_FILE_NAME = "ait_global_cache.json"
IDX_KEY = "byteir_ait_cache_auto_increment_idx"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,11 @@ def _get_tmp_dir() -> str:
Get the toplevel temporary directory for storing compiled graphs.
"""
if ByteIRFxGraphCache.base_cache_dir is None:
sanitized_username = re.sub(r'[\\/:*?"<>|]', "_",
getpass.getuser())
ByteIRFxGraphCache.base_cache_dir = os.path.join(
tempfile.gettempdir(),
"byteir_" + sanitized_username,
)
HOME_DIR = os.getenv("HOME")
if HOME_DIR is None:
HOME_DIR = tempfile.gettempdir()
ByteIRFxGraphCache.base_cache_dir = os.path.join(HOME_DIR, ".byteir", "fx_cache")
os.makedirs(ByteIRFxGraphCache.base_cache_dir, exist_ok=True)
#return os.path.join(ByteIRFxGraphCache.base_cache_dir, "byre")
return ByteIRFxGraphCache.base_cache_dir

@staticmethod
Expand Down
Loading