Skip to content

Commit

Permalink
Add support for dynamic strategy change
Browse files Browse the repository at this point in the history
Signed-off-by: smajumdar <titu1994@gmail.com>
  • Loading branch information
titu1994 committed May 9, 2022
1 parent 3496141 commit 4fe248c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion nemo/collections/common/parts/adapter_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ def __init__(

# The config must have the `_target_` field pointing to the actual adapter strategy class
# which will load that strategy dynamically to this module.
self.adapter_strategy = instantiate(adapter_strategy)
if isinstance(adapter_strategy, dict) or OmegaConf.is_config(adapter_strategy):
self.adapter_strategy = instantiate(adapter_strategy)
elif isinstance(adapter_strategy, adapter_mixin_strategies.AbstractAdapterStrategy):
self.adapter_strategy = adapter_strategy
else:
raise AttributeError(f'`adapter_strategy` provided is invalid : {adapter_strategy}')

# reset parameters
self.reset_parameters()
Expand Down

0 comments on commit 4fe248c

Please sign in to comment.