Follow-up of #2993
Reproducible Example
import torch
import pytest
@pytest.mark.parametrize(
"op", [
torch.ops.aten.rand_like,
torch.ops.aten.randint_like,
torch.ops.aten.randn_like,
]
)
def test_x_like(op: torch._ops.OpOverloadPacket):
class Model(torch.nn.Module):
def forward(self, x):
return op(x, memory_format=torch.preserve_format)
torch.onnx.export(
Model(),
(torch.randn(10, 10),),
"{op.__name__}.onnx",
input_names=["input"],
output_names=["output"],
dynamo=True,
)
if __name__ == "__main__":
pytest.main([__file__])
Follow-up of #2993
Reproducible Example