xref: /aosp_15_r20/external/pytorch/torch/_export/db/examples/tensor_setattr.py (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1# mypy: allow-untyped-defs
2import torch
3
4
5class TensorSetattr(torch.nn.Module):
6    """
7    setattr() call onto tensors is not supported.
8    """
9    def forward(self, x, attr):
10        setattr(x, attr, torch.randn(3, 2))
11        return x + 4
12
13example_args = (torch.randn(3, 2), "attr")
14tags = {"python.builtin"}
15model = TensorSetattr()
16