Skip to content

Commit

Permalink
docstring
Browse files Browse the repository at this point in the history
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
  • Loading branch information
crcrpar committed Jun 16, 2024
1 parent 205c29e commit d9a1275
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions thunder/core/transform_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,15 @@ def transform_trace(self, computation_trace: Trace, **kwargs):
def functionalize_inplace_ops(computation_trace: Trace) -> list[Trace]:
"""Functionalize in-place ops in ``computation_trace``.
This is a two-step function. The first step is to use the output of :func:`thunder.core.prims.copy_`'s
outputs as trace's outputs. The second step is to remove :func:`thunder.core.prims.copy_`
from :attr:`~thunder.core.symbol.Boundsymbol.subsymbols` if it's the last symbol.
In thunder, an in-place is an out-of-place or functional op followed by :func:`~thunder.core.prims.copy_`.
This function replaces such in-place ops with out-of-place ops.
For example, :func:`thunder.torch.add_` is represented as a :class:`thunder.core.symbol.BoundSymbol`
whose `subsymbols` are :func:`thunder.torch.add` and :func:`thunder.core.prims.copy_`. This function
replaces it with a :class:`~thunder.core.symbol.BoundSymbol` of :func:`~thunder.torch.add`.
Note that functionalization is not applied, if any of an in-place op's arguments are
``computation_trace.args`` or ``computation_trace.kwargs``.
"""
import thunder.torch

Expand Down

0 comments on commit d9a1275

Please sign in to comment.