Skip to content

Added test to check for Variable warning. #2610

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

Merged
merged 1 commit into from
Nov 14, 2022
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
13 changes: 13 additions & 0 deletions tests/linen/linen_transforms_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,19 @@ def _helper(self):
with self.assertRaises(errors.TransformedMethodReturnValueError):
b.apply({}, jnp.ones(2))

def test_returned_variable_warning(self):
class Bar(nn.Module):
@nn.compact
def __call__(self, x):
f = self._helper()
return f(x)
@nn.jit
def _helper(self):
return nn.Variable(None, None, None)
b = Bar()
with self.assertRaises(errors.TransformedMethodReturnValueError):
b.apply({}, jnp.ones(2))

def test_nowrap(self):
class Bar(nn.Module):
@nn.compact
Expand Down