Skip to content
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
2 changes: 2 additions & 0 deletions graph_net_bench/torch/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def replay_tensor(info):
np_data = np.full(shape, mean)
else:
np_data = np.random.randn(*shape) * std * 0.2 + mean
if not isinstance(np_data, np.ndarray):
np_data = np.array(np_data)
tensor = torch.from_numpy(np_data).to(dtype).to(device)
# Apply lower/upper bound constraints if present
if "min_val" in info["info"]:
Expand Down
41 changes: 15 additions & 26 deletions sqlite/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
)
from sqlalchemy.exc import IntegrityError
import os
from pathlib import Path
from huggingface_hub import HfApi

FULL_GRAPH_PATH = (
"/work/clone/GraphNet/subgraph_dataset_workspace_small10_torch_samples/full_graph"
)
TYPICAL_GRAPH_PATH = "/work/clone/GraphNet/subgraph_dataset_workspace_small10_torch_samples/typical_graph"
FUSIBLE_GRAPH_PATH = "/work/clone/GraphNet/subgraph_dataset_workspace_small10_torch_samples/fusible_graph"
SOLE_OP_GRAPH_PATH = "/work/clone/GraphNet/subgraph_dataset_workspace_small10_torch_samples/sole_op_graph"
BASE_PATH = "/work/clone/GraphNet/subgraph_dataset_workspace_small10_torch_samples"
FULL_GRAPH_PATH = f"{BASE_PATH}/full_graph"
TYPICAL_GRAPH_PATH = f"{BASE_PATH}/typical_graph"
FUSIBLE_GRAPH_PATH = f"{BASE_PATH}/fusible_graph"
SOLE_OP_GRAPH_PATH = f"{BASE_PATH}/sole_op_graph"

HF_REPO_ID = "PaddlePaddle/GraphNet"
HF_REPO_TYPE = "dataset"
Expand All @@ -34,27 +32,18 @@ def upload_to_huggingface(api: HfApi, local_path: str, repo_id: str, path_in_rep
if not os.path.exists(local_path):
print(f"Warning: Local path not found, skipping upload: {local_path}")
return

print(f"Uploading {local_path} to HF: {repo_id}/{path_in_repo} ...")
print(f"Uploading folder {local_path} to HF: {repo_id}/{path_in_repo} ...")
try:
folder_size = sum(
f.stat().st_size for f in Path(local_path).rglob("*") if f.is_file()
api.upload_folder(
folder_path=local_path,
path_in_repo=path_in_repo,
repo_id=repo_id,
repo_type=HF_REPO_TYPE,
revision=HF_BRANCH,
commit_message=f"Upload folder: {path_in_repo}",
ignore_patterns=["**/__pycache__/*", "*.pyc", ".ipynb_checkpoints/*"],
)
size_mb = folder_size / (1024 * 1024)
print(f" Size: {size_mb:.2f}MB, uploading files individually...")
for file_path in Path(local_path).rglob("*"):
if file_path.is_file():
rel_path = file_path.relative_to(local_path)
remote_path = f"{path_in_repo}/{rel_path}"
api.upload_file(
path_or_fileobj=str(file_path),
path_in_repo=remote_path,
repo_id=repo_id,
repo_type=HF_REPO_TYPE,
revision=HF_BRANCH,
commit_message=f"Upload {rel_path}",
)
print(f"Success: Uploaded {path_in_repo} ({size_mb:.2f}MB)")
print(f"Success: Folder uploaded to {path_in_repo}")
except Exception as e:
print(f"Error uploading to Hugging Face: {e}")

Expand Down