mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
[inductor] fix CompiledArtifact.load path on Windows. (#160268)
fix CompiledArtifact.load path on Windows. Pull Request resolved: https://github.com/pytorch/pytorch/pull/160268 Approved by: https://github.com/ezyang
This commit is contained in:
@ -29,6 +29,7 @@ from torch._inductor.codecache import (
|
||||
TensorMetadata,
|
||||
TensorMetadataAndValues,
|
||||
)
|
||||
from torch._inductor.cpp_builder import normalize_path_separator
|
||||
from torch._inductor.custom_graph_pass import (
|
||||
CustomGraphModulePass,
|
||||
CustomGraphPass,
|
||||
@ -1806,7 +1807,9 @@ class TestStandaloneCompile(TestCase):
|
||||
assert not kwargs
|
||||
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
path = os.path.join(temp_dir, "compiled_artifact.bin")
|
||||
path = normalize_path_separator(
|
||||
os.path.join(temp_dir, "compiled_artifact.bin")
|
||||
)
|
||||
|
||||
with fresh_cache():
|
||||
compiled_artifact = torch._inductor.standalone_compile(gm, args)
|
||||
|
@ -10,6 +10,7 @@ from typing import Any, Callable, Literal, Optional, TYPE_CHECKING
|
||||
|
||||
import torch.fx
|
||||
from torch._dynamo.utils import dynamo_timed
|
||||
from torch._inductor.cpp_builder import normalize_path_separator
|
||||
from torch._inductor.cudagraph_utils import BoxedDeviceIndex
|
||||
from torch._inductor.runtime.cache_dir_utils import temporary_cache_dir
|
||||
from torch._inductor.utils import BoxedBool, InputType
|
||||
@ -116,6 +117,7 @@ class CompiledArtifact:
|
||||
def load(
|
||||
*, path: str, format: Literal["binary", "unpacked"] = "binary"
|
||||
) -> CompiledArtifact:
|
||||
path = normalize_path_separator(path)
|
||||
with dynamo_timed("CompiledArtifact.load"):
|
||||
if format == "binary":
|
||||
# can't assert that it is a file since it might not exist yet
|
||||
|
Reference in New Issue
Block a user