From 47bd05ec407dc404a6ace8675ab3b4e410c2a6a8 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Wed, 22 Jan 2025 20:47:29 -0800 Subject: [PATCH 1/2] [IR] handle with external data path is empty or in the same dir as model --- onnxscript/ir/external_data.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/onnxscript/ir/external_data.py b/onnxscript/ir/external_data.py index 6e89951e7..cd66c1559 100644 --- a/onnxscript/ir/external_data.py +++ b/onnxscript/ir/external_data.py @@ -246,7 +246,10 @@ def convert_tensors_to_external( """ path = os.path.join(base_dir, relative_path) # Check if file path is valid, and create subsequent subdirectories within the path if they don't exist - os.makedirs(os.path.dirname(path), exist_ok=True) + dir_path = os.path.dirname(path) + if dir_path: + # Skip makedirs if dir_path is empty + os.makedirs(dir_path, exist_ok=True) # Check if output path exists. Load pre-existing external data if it does. if os.path.exists(path): From 14f22870881ad844c7738a711bf2acca11cc8e4f Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Thu, 23 Jan 2025 08:07:13 -0800 Subject: [PATCH 2/2] Remove call --- onnxscript/ir/external_data.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/onnxscript/ir/external_data.py b/onnxscript/ir/external_data.py index cd66c1559..87524899f 100644 --- a/onnxscript/ir/external_data.py +++ b/onnxscript/ir/external_data.py @@ -245,11 +245,6 @@ def convert_tensors_to_external( should match the input tensor order. """ path = os.path.join(base_dir, relative_path) - # Check if file path is valid, and create subsequent subdirectories within the path if they don't exist - dir_path = os.path.dirname(path) - if dir_path: - # Skip makedirs if dir_path is empty - os.makedirs(dir_path, exist_ok=True) # Check if output path exists. Load pre-existing external data if it does. if os.path.exists(path):