Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion tests/unit/autogram/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
InterModuleParamReuse,
MIMOBranched,
MISOBranched,
ModelAlsoUsingSubmoduleParamsDirectly,
ModelUsingSubmoduleParamsDirectly,
ModuleReuse,
MultiInputMultiOutput,
Expand Down Expand Up @@ -190,7 +191,9 @@ def test_compute_gramian_with_weird_modules(


@mark.xfail
@mark.parametrize("architecture", [ModelUsingSubmoduleParamsDirectly])
@mark.parametrize(
"architecture", [ModelUsingSubmoduleParamsDirectly, ModelAlsoUsingSubmoduleParamsDirectly]
)
@mark.parametrize("batch_size", [1, 3, 32])
@mark.parametrize("batch_dim", [0, None])
def test_compute_gramian_unsupported_architectures(
Expand Down
16 changes: 16 additions & 0 deletions tests/utils/architectures.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,22 @@ def forward(self, input: Tensor) -> Tensor:
return input @ self.linear.weight.T + self.linear.bias


class ModelAlsoUsingSubmoduleParamsDirectly(ShapedModule):
"""
Model that uses its submodule's parameters directly but that also calls its submodule's forward.
"""

INPUT_SHAPES = (2,)
OUTPUT_SHAPES = (3,)

def __init__(self):
super().__init__()
self.linear = nn.Linear(2, 3)

def forward(self, input: Tensor) -> Tensor:
return input @ self.linear.weight.T + self.linear.bias + self.linear(input)


class _WithStringArg(nn.Module):
def __init__(self):
super().__init__()
Expand Down
Loading