Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Better check for TDModule #1248

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tensordict/nn/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,10 +1069,12 @@ def __init__(
except Exception:
raise ValueError(self._OUT_KEY_ERR)

if type(module) is type or not callable(module):
if type(module) is type or (method is None and not callable(module)):
raise ValueError(
f"Module {module} if type {type(module)} is not callable. "
f"Typical accepted types are nn.Module or TensorDictModule."
f"Typical accepted types are nn.Module or TensorDictModule. "
f"If you need to call a specific method from your module, pass the "
f"`method` keyword argument to the TensorDictModule constructor."
)
self.out_keys = out_keys
self.in_keys = in_keys
Expand Down
Loading