load_model_from_path() — pytorch Function Reference
Architecture documentation for the load_model_from_path() function in common.py from the pytorch codebase.
Entity Profile
Dependency Diagram
graph TD 6233fde7_853e_8fb3_0ae6_703b798d8c5d["load_model_from_path()"] c9be2096_e6d7_2374_ad2e_a6e33f435ada["run()"] c9be2096_e6d7_2374_ad2e_a6e33f435ada -->|calls| 6233fde7_853e_8fb3_0ae6_703b798d8c5d ce8fd365_4112_b289_9c73_7345d5e35203["RuntimeError()"] 6233fde7_853e_8fb3_0ae6_703b798d8c5d -->|calls| ce8fd365_4112_b289_9c73_7345d5e35203 style 6233fde7_853e_8fb3_0ae6_703b798d8c5d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
benchmarks/dynamo/common.py lines 285–320
def load_model_from_path(path_and_class_str):
configs = {}
for kvstr in path_and_class_str.split(","):
k, v = kvstr.split(":")
configs[k] = v
for name in ["path", "class"]:
if name not in configs:
raise RuntimeError(
"Invalid --only arguments. Check help message for the correct format"
)
path = configs["path"]
class_name = configs["class"]
if path[:1] != "/":
raise RuntimeError(
"Use absolute path since dynamo may change the current working directory which makes using relative path tricky"
)
spec = importlib.util.spec_from_file_location("module_name", path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
model_class = getattr(module, class_name)
if not issubclass(model_class, torch.nn.Module):
raise AssertionError(
f"expected {class_name} to be a subclass of torch.nn.Module, got {model_class}"
)
model = model_class()
if not hasattr(model, "get_example_inputs"):
raise AssertionError(
f"expected model {class_name} to have get_example_inputs method"
)
inputs = model.get_example_inputs()
return model, inputs
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does load_model_from_path() do?
load_model_from_path() is a function in the pytorch codebase.
What does load_model_from_path() call?
load_model_from_path() calls 1 function(s): RuntimeError.
What calls load_model_from_path()?
load_model_from_path() is called by 1 function(s): run.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free