mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-07 17:15:29 +00:00
Override ORTModule named_modules to support extra arg (#7954)
This commit is contained in:
parent
1cc896c8ae
commit
f38200e209
1 changed files with 4 additions and 2 deletions
|
|
@ -182,10 +182,12 @@ class ORTModule(torch.nn.Module):
|
|||
|
||||
yield from self._module_metadata.original_module.modules()
|
||||
|
||||
def named_modules(self, memo: Optional[Set['Module']] = None, prefix: str = ''):
|
||||
def named_modules(self, *args, **kwargs):
|
||||
"""Override original method to delegate execution to the original PyTorch user module"""
|
||||
|
||||
yield from self._module_metadata.original_module.named_modules(memo, prefix)
|
||||
# PyTorch >1.8.1 has an extra arg remove_duplicate that is not present in 1.8.1
|
||||
# To support both, use args and kwargs (since user can call the method with only positional args or kwargs)
|
||||
yield from self._module_metadata.original_module.named_modules(*args, **kwargs)
|
||||
|
||||
def add_module(self, name: str, module: Optional['Module']) -> None:
|
||||
"""Raises a NotImplementedError exception since ORTModule does not support adding modules to it"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue