torch.mutation ================== user_input_mutation ^^^^^^^^^^^^^^^^^^^ .. note:: Tags: :doc:`torch.mutation ` Support Level: SUPPORTED Original source code: .. code-block:: python import torch class UserInputMutation(torch.nn.Module): """ Directly mutate user input in forward """ def forward(self, x): x.mul_(2) return x.cos() Result: .. code-block:: ExportedProgram: class GraphModule(torch.nn.Module): def forward(self, l_x_: "f32[3, 2]"): mul: "f32[3, 2]" = torch.ops.aten.mul.Tensor(l_x_, 2); l_x_ = None cos: "f32[3, 2]" = torch.ops.aten.cos.default(mul) return (mul, cos) Graph signature: ExportGraphSignature(input_specs=[InputSpec(kind=, arg=TensorArgument(name='l_x_'), target=None)], output_specs=[OutputSpec(kind=, arg=TensorArgument(name='mul'), target='l_x_'), OutputSpec(kind=, arg=TensorArgument(name='cos'), target=None)]) Range constraints: {} Equality constraints: []