fc52f79ed3dda250875b3ce9f3c241b80d643ef3,pytext/models/module.py,,create_module,#Any#,23
Before Change
shared_module_key = getattr(module_config, "shared_module_key", None)
typed_shared_module_key = (shared_module_key, type(module_config))
load_path = getattr(module_config, "load_path", None)
is_torchscript_load_path = load_path and zipfile.is_zipfile(
PathManager.get_local_path(load_path)
)
module = SHARED_MODULE_REGISTRY.get(typed_shared_module_key)
if not module:
if is_torchscript_load_path:
with PathManager.open(load_path, "rb") as load_file:
module = torch.jit.load(load_file)
else:
module = create_fn(module_config, *args, **kwargs)
name = type(module).__name__
After Change
with PathManager.open(load_path, "rb") as load_file:
loaded_module = torch.load(load_file, map_location="cpu")
if isinstance(loaded_module, dict):
// Loaded module is a state dict
module = create_fn(module_config, *args, **kwargs)
module.load_state_dict(loaded_module)
else:
// Loaded module is a torchscripted module
module = loaded_module
name = type(module).__name__
print(f"Loaded state of module {name} from {load_path} ...")
else:
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 6
Instances
Project Name: facebookresearch/pytext
Commit Name: fc52f79ed3dda250875b3ce9f3c241b80d643ef3
Time: 2020-07-07
Author: mikaell@fb.com
File Name: pytext/models/module.py
Class Name:
Method Name: create_module
Project Name: richzhang/colorization-pytorch
Commit Name: 9ba91fa13cbb1e7bc4069e46469b34abb5ca4869
Time: 2018-05-22
Author: tongzhou.wang.1994@gmail.com
File Name: models/base_model.py
Class Name: BaseModel
Method Name: load_networks