Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
19f5dfe
add index sample fp16 support
wangxn12138 Nov 14, 2022
223bbee
remove fluid APIs in distributed_strategy.py and role_maker.py
wangxn12138 Nov 15, 2022
563ad21
Revert "remove fluid APIs in distributed_strategy.py and role_maker.py"
wangxn12138 Nov 15, 2022
6830679
remove fluid APIs in distributed_strategy.py and role_maker.py
wangxn12138 Nov 15, 2022
de7c2ec
Merge branch 'develop' of github.com:PaddlePaddle/Paddle into fluid_c…
wangxn12138 Nov 16, 2022
55f9fb3
remove index sample op changes
wangxn12138 Nov 17, 2022
a43288a
remove fluid APIs under fleet.base
wangxn12138 Nov 17, 2022
6a25753
remove fluid APIs under fleet.layers.mpu
wangxn12138 Nov 17, 2022
f4bfba1
remove fluid APIs under fleet.meta_optimizers
wangxn12138 Nov 17, 2022
5f6301c
fix fluid error
wangxn12138 Nov 17, 2022
d893d7e
fix util_factory.py
wangxn12138 Nov 18, 2022
f74ef15
reset fluid.io.load_inference_model API
wangxn12138 Nov 18, 2022
b54fdfd
Merge branch 'develop' of github.com:PaddlePaddle/Paddle into fluid_c…
wangxn12138 Nov 29, 2022
e4c1380
remove dygraph.parallel.prepare_context
wangxn12138 Dec 5, 2022
1c16307
remove fluid.dygraph.StaticModelRunner API
wangxn12138 Dec 6, 2022
6808bba
fix merge
wangxn12138 Dec 7, 2022
7f8bbbb
remove split_lod_tensor merge_lod_tensor
wangxn12138 Dec 8, 2022
3cf770e
fix merge
wangxn12138 Dec 8, 2022
25b98de
fix merge
wangxn12138 Dec 8, 2022
038717f
remove unittests
wangxn12138 Dec 8, 2022
9bd04e2
Merge branch 'develop' of github.com:PaddlePaddle/Paddle into fluid_c…
wangxn12138 Dec 8, 2022
8511663
fix merge
wangxn12138 Dec 19, 2022
1f36f62
Merge branch 'develop' of github.com:PaddlePaddle/Paddle into fluid_c…
wangxn12138 Dec 20, 2022
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
3 changes: 0 additions & 3 deletions python/paddle/fluid/dygraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
from . import learning_rate_scheduler
from .learning_rate_scheduler import *

from . import static_runner
from .static_runner import StaticModelRunner

from . import amp
from .amp import *

Expand Down
42 changes: 1 addition & 41 deletions python/paddle/fluid/dygraph/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,51 +37,11 @@
in_dygraph_mode,
)

__all__ = ["prepare_context", "ParallelEnv", "DataParallel"]
__all__ = ["ParallelEnv", "DataParallel"]

ParallelStrategy = core.ParallelStrategy


@deprecated(since="2.0.0", update_to="paddle.distributed.init_parallel_env")
def prepare_context(strategy=None):
'''
:api_attr: imperative
'''
if strategy is None:
strategy = ParallelStrategy()
strategy.nranks = Env().nranks
strategy.local_rank = Env().local_rank
strategy.trainer_endpoints = Env().trainer_endpoints
strategy.current_endpoint = Env().current_endpoint
if strategy.nranks < 2:
return
assert (
framework._non_static_mode() is True
), "dygraph.prepare_context should be used with dygraph mode."
place = framework._current_expected_place()
assert (
place is not None
), "dygraph.prepare_context should be used in fluid.dygraph.guard(place) guard."
if not parallel_helper._is_parallel_ctx_initialized():
if isinstance(place, core.CUDAPlace):
parallel_helper._set_parallel_ctx(
core.NCCLParallelContext(strategy, place)
)
elif isinstance(place, core.XPUPlace):
parallel_helper._set_parallel_ctx(
core.BKCLParallelContext(strategy, place)
)
elif isinstance(place, core.NPUPlace):
parallel_helper._set_parallel_ctx(
core.HCCLParallelContext(strategy, place)
)
else:
# TODO(Yancey1989): add Gloo Parallel Context to support CPU parallel computation
assert "Only support CUDAPlace or XPUPlace or NPUPlace for now."
parallel_helper._init_parallel_ctx()
return strategy


class ParallelEnv:
"""
.. note::
Expand Down
37 changes: 0 additions & 37 deletions python/paddle/fluid/dygraph/static_runner.py

This file was deleted.

124 changes: 0 additions & 124 deletions python/paddle/fluid/layers/control_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,130 +145,6 @@ def select_input(inputs, mask):
return out


def split_lod_tensor(input, mask, level=0):
"""
This function takes in an input that contains the complete lod information,
and takes in a mask which is used to mask certain parts of the input.
The output is the true branch and the false branch with the mask applied to
the input at a certain level in the tensor. Mainly used in IfElse to split
data into two parts.

Args:
input(Variable|tuple|list|None): The input tensor that contains complete
lod information needed to construct the output.
mask(Variable|list): A bool column vector which masks the input.
level(int): The specific lod level to split.

Returns:
tuple(Variable, Variable):
The true branch of tensor as per the mask applied to input.

The false branch of tensor as per the mask applied to input.

Examples:
.. code-block:: python

import paddle.fluid as fluid
x = fluid.layers.data(name='x', shape=[1])
x.persistable = True

y = fluid.layers.data(name='y', shape=[1])
y.persistable = True

out_true, out_false = fluid.layers.split_lod_tensor(
input=x, mask=y, level=level)

"""
check_type(
input,
'input',
(Variable, list, tuple, type(None)),
'fluid.layers.split_lod_tensor',
)
check_type(mask, 'mask', (Variable, list), 'fluid.layers.split_lod_tensor')
check_type(level, 'level', int, 'fluid.layers.split_lod_tensor')
helper = LayerHelper('split_lod_tensor', **locals())
out_true = helper.create_variable_for_type_inference(dtype=input.dtype)
out_false = helper.create_variable_for_type_inference(dtype=input.dtype)
helper.append_op(
type='split_lod_tensor',
inputs={
'X': input,
'Mask': mask,
},
outputs={'OutTrue': out_true, 'OutFalse': out_false},
attrs={'level': level},
)
return out_true, out_false


def merge_lod_tensor(in_true, in_false, x, mask, level=0):
"""
**merge_lod_tensor**

This function takes in an input :math:`x`, the True branch, the False
branch and a binary :math:`mask`. Using this information, this function
merges the True and False branches of the tensor into a single tensor as
output at a certain lod level indicated by :math:`level`. Used in IfElse
to merge the output if True block and False Block.

Args:
in_true(Variable|tuple|list|None): The True branch to be merged.
in_false(Variable|tuple|list|None): The False branch to be merged.
x(Variable|tuple|list|None): The input tensor that contains complete
lod information needed to construct the output.
mask(Variable|list): A bool column vector which masks the input.
level(int): The specific lod level to merge.

Returns:
Variable: The merged output tensor.

Examples:
.. code-block:: python

import paddle.fluid as fluid
x = layers.data(
name='x', shape=[1], dtype='float32', stop_gradient=False)
y = layers.data(
name='y', shape=[1], dtype='bool', stop_gradient=False)

level = 0

out_true, out_false = layers.split_lod_tensor(
input=x, mask=y, level=level)
out = layers.merge_lod_tensor(
in_true=out_true, in_false=out_false, mask=y, x=x, level=level)
"""
helper = LayerHelper('merge_lod_tensor', **locals())
check_type(
x,
'x',
(Variable, list, tuple, type(None)),
'fluid.layers.merge_lod_tensor',
)
check_type(mask, 'mask', (Variable, list), 'fluid.layers.merge_lod_tensor')
check_type(
in_true,
'in_true',
(Variable, list, tuple, type(None)),
'fluid.layers.merge_lod_tensor',
)
check_type(
in_false,
'in_false',
(Variable, list, tuple, type(None)),
'fluid.layers.merge_lod_tensor',
)
out = helper.create_variable_for_type_inference(dtype=in_true.dtype)
helper.append_op(
type='merge_lod_tensor',
inputs={'X': x, 'Mask': mask, 'InTrue': in_true, 'InFalse': in_false},
outputs={'Out': out},
attrs={'level': level},
)
return out


@static_only
def Print(
input,
Expand Down
11 changes: 0 additions & 11 deletions python/paddle/fluid/tests/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,6 @@ list(REMOVE_ITEM TEST_OPS test_basic_lstm_unit_op)
list(REMOVE_ITEM TEST_OPS test_fuse_all_reduce_pass)
list(REMOVE_ITEM TEST_OPS test_fuse_bn_act_pass)
list(REMOVE_ITEM TEST_OPS test_fuse_bn_add_act_pass)
list(REMOVE_ITEM TEST_OPS test_imperative_static_runner_mnist)
list(REMOVE_ITEM TEST_OPS test_imperative_static_runner_while)

# disable this unittest temporarily
list(REMOVE_ITEM TEST_OPS test_imperative_data_loader_exception)
Expand Down Expand Up @@ -569,12 +567,6 @@ py_test_modules(
py_test_modules(test_install_check MODULES test_install_check ENVS
FLAGS_cudnn_deterministic=1)
set_tests_properties(test_install_check PROPERTIES LABELS "RUN_TYPE=DIST")
py_test_modules(
test_imperative_static_runner_mnist MODULES
test_imperative_static_runner_mnist ENVS FLAGS_cudnn_deterministic=1)
py_test_modules(
test_imperative_static_runner_while MODULES
test_imperative_static_runner_while ENVS FLAGS_cudnn_deterministic=1)

if((WITH_GPU) AND (CUDA_VERSION GREATER_EQUAL 11.6))
py_test_modules(test_fused_gemm_epilogue_op MODULES
Expand Down Expand Up @@ -1084,7 +1076,6 @@ set_tests_properties(test_svd_op PROPERTIES TIMEOUT 80)
set_tests_properties(test_einsum_op PROPERTIES TIMEOUT 120)
set_tests_properties(test_qr_op PROPERTIES TIMEOUT 60)
set_tests_properties(test_trilinear_interp_v2_op PROPERTIES TIMEOUT 120)
set_tests_properties(test_imperative_static_runner_mnist PROPERTIES TIMEOUT 120)
set_tests_properties(test_masked_select_op PROPERTIES TIMEOUT 120)
set_tests_properties(test_sigmoid_cross_entropy_with_logits_op
PROPERTIES TIMEOUT 120)
Expand Down Expand Up @@ -1167,8 +1158,6 @@ if(APPLE)
PROPERTIES TIMEOUT 300)
set_tests_properties(test_multiclass_nms_op PROPERTIES TIMEOUT 300)
set_tests_properties(test_weight_decay PROPERTIES TIMEOUT 300)
set_tests_properties(test_imperative_static_runner_mnist PROPERTIES TIMEOUT
300)
endif()

if((WITH_ROCM OR WITH_GPU) AND NOT WIN32)
Expand Down
1 change: 0 additions & 1 deletion python/paddle/fluid/tests/unittests/test_dist_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,6 @@ def run_trainer(self, args):
type(self).__name__,
"begin to prepare context in dygraph with nccl2",
)
dygraph.parallel.prepare_context(strategy)
if not args.find_unused_parameters:
model = dygraph.parallel.DataParallel(
model, strategy, find_unused_parameters=False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import paddle.fluid as fluid
import paddle.fluid.core as core
import paddle.fluid.dygraph as dygraph
from paddle.distributed import init_parallel_env
from paddle.nn import Linear


Expand All @@ -38,9 +39,9 @@ def forward(self, inputs):
class TestDataParallelStateDict(unittest.TestCase):
def test_data_parallel_state_dict(self):
with fluid.dygraph.guard():
strategy = dygraph.parallel.prepare_context()
init_parallel_env()
mlp = MLP()
parallel_mlp = dygraph.parallel.DataParallel(mlp, strategy)
parallel_mlp = dygraph.parallel.DataParallel(mlp)

single_state = mlp.state_dict()
parallel_state = parallel_mlp.state_dict()
Expand Down
Loading