Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改COPY-FROM add_example_for_lazygurd #55411

Merged
merged 2 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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