Skip to content

Commit ed4fede

Browse files
committed
Add test
1 parent b009d3a commit ed4fede

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

tests/py/dynamo/lowering/test_complex_rewrite.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import pytest
3535
import torch
3636
import torch.nn as nn
37-
3837
from torch_tensorrt.dynamo._settings import CompilationSettings
3938
from torch_tensorrt.dynamo.lowering.passes.complex_graph_rewrite import (
4039
complex_graph_detection,
@@ -1230,3 +1229,22 @@ def forward(self, z):
12301229
return torch.cat([a * b, b * a], dim=1)
12311230

12321231
_check_op(M(), (torch.randn(3, 4, dtype=torch.complex64),), "split_mul_cat")
1232+
1233+
1234+
# ===========================================================================
1235+
# 11. None-valued placeholder (optional/None input)
1236+
# ===========================================================================
1237+
1238+
1239+
@pytest.mark.unit
1240+
def test_none_placeholder():
1241+
"""opt=None — a present-but-None placeholder must survive metadata re-prop."""
1242+
1243+
class M(nn.Module):
1244+
def forward(self, z, opt):
1245+
out = z * z # complex op triggers the rewrite + metadata re-prop
1246+
if opt is not None:
1247+
out = out + opt
1248+
return out
1249+
1250+
_check_op(M(), (_z(), None), "none_placeholder")

0 commit comments

Comments
 (0)