Skip to content

Commit

Permalink
修改COPY-FROM add_example_for_lazygurd (#55411)
Browse files Browse the repository at this point in the history
* add_example_for_lazygurd

* fix
  • Loading branch information
Ainavo authored Jul 18, 2023
1 parent 3624723 commit 96ff610
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions python/paddle/fluid/lazy_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,21 @@ class LazyGuard:
LazyGuard is a wrapper interface for nn.Layer, it forwards the construct
process of user defined Layer. Meanwhile, it provides necessary API to
trigger EagerParamBase Lazy Initialization and get startup Program.
Examples:
.. code-block:: python
from paddle import LazyGuard
from paddle.nn import Linear
with LazyGuard():
# w and b are initialized lazily and have no memory.
net = Linear(10, 10)
for param in net.parameters():
# Initialize param and allocate memory explicitly.
param.initialize()
"""

def __enter__(self):
Expand Down
1 change: 1 addition & 0 deletions python/paddle/tensor/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2851,6 +2851,7 @@ def scatter(x, index, updates, overwrite=True, name=None):
Output is obtained by updating the input on selected indices based on updates.
.. code-block:: python
:name: code-example1
import paddle
#input:
Expand Down

0 comments on commit 96ff610

Please sign in to comment.