Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
34079a8
fix pir distribution
wanghuancoder Jun 7, 2024
63f567a
refine
wanghuancoder Jun 11, 2024
45a5ee0
refine
wanghuancoder Jun 11, 2024
dee63ac
remove runtime validator for distribution
cxxly Jun 12, 2024
0f66279
Merge commit 'refs/pull/65062/head' of https://github.com/PaddlePaddl…
wanghuancoder Jun 12, 2024
5ca9498
refine
wanghuancoder Jun 12, 2024
6858f5f
refine
wanghuancoder Jun 12, 2024
c17741c
remove runtime validator for distribution
cxxly Jun 12, 2024
9c390a9
merge
wanghuancoder Jun 12, 2024
105c714
merge
wanghuancoder Jun 14, 2024
d5d1589
refine
wanghuancoder Jun 14, 2024
6d17721
refine
wanghuancoder Jun 14, 2024
7a8485e
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
wanghuancoder Jun 17, 2024
2508e4a
refine
wanghuancoder Jun 17, 2024
39905c3
refine
wanghuancoder Jun 17, 2024
23c9663
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
wanghuancoder Jun 17, 2024
10d9e10
refine
wanghuancoder Jun 18, 2024
91b753c
refine
wanghuancoder Jun 18, 2024
ac03fd6
refine
wanghuancoder Jun 18, 2024
85b3c8c
Merge commit 'refs/pull/65034/head' of https://github.com/PaddlePaddl…
wanghuancoder Jun 18, 2024
585b924
refine
wanghuancoder Jun 18, 2024
77bea12
refine
wanghuancoder Jun 19, 2024
5391300
refine
wanghuancoder Jun 19, 2024
c372446
merge
wanghuancoder Jun 19, 2024
6c926ac
refine
wanghuancoder Jun 19, 2024
ba652fb
refine
wanghuancoder Jun 19, 2024
c9a061d
refine
wanghuancoder Jun 20, 2024
dad8eda
fix 3 rnn
wanghuancoder Jun 20, 2024
4bba47f
refine
wanghuancoder Jun 20, 2024
dd9e0da
refine
wanghuancoder Jun 20, 2024
7649a5c
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
wanghuancoder Jun 21, 2024
1da2672
refine
wanghuancoder Jun 21, 2024
adf0ca6
fix rnn test bug
chen2021673 Jun 21, 2024
25007f3
refine
wanghuancoder Jun 21, 2024
dc269b5
Merge commit 'refs/pull/65356/head' of https://github.com/PaddlePaddl…
wanghuancoder Jun 21, 2024
dc80271
refine
wanghuancoder Jun 24, 2024
0ceb007
refine
wanghuancoder Jun 24, 2024
956a0ff
refine
wanghuancoder Jun 24, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ void TuplePushInstruction::Run() {
for (size_t i = 0; i < tuple_push_op_.tuple_size(); i++) {
auto inlet_element_value = tuple_push_op_.inlet_element(i);
Variable* var = value_exe_info_->GetVarByValue(inlet_element_value);
int stack_size = tuple_push_op_.tuple_size();

auto var_name = value_2_var_name.at(inlet_element_value);
auto num_str = std::to_string(stack_element_var_array_->size());
Expand All @@ -110,7 +109,7 @@ void TuplePushInstruction::Run() {
DeepCopyVariable(var,
&copy_var,
value_exe_info_,
stack_size,
stack_element_var_array_->size(),
is_optional,
&src_to_dst);
VLOG(10) << "done DeepCopyVariable " << new_name;
Expand Down
10 changes: 9 additions & 1 deletion paddle/phi/infermeta/binary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,15 @@ void ArrayReadInferMeta(const MetaTensor& array,
MetaTensor* out,
MetaConfig config) {
if (!config.is_runtime) {
out->set_dims({-1});
auto dims = array.dims();
if (dims.size() > 1) {
for (int i = 0; i < dims.size(); ++i) {
dims[i] = -1;
}
out->set_dims(dims);
} else {
out->set_dims({-1});
}
} else {
double index = i.to<int64_t>();
out->set_dims(array.dims(index)); // NOLINT
Expand Down
1 change: 1 addition & 0 deletions paddle/phi/infermeta/unary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ void ArrayToTensorInferMeta(const MetaTensor& x,
dims[axis] = -1;
}
out->set_dims(dims);
out->set_dtype(x.dtype());
out_index->set_dtype(DataType::INT32);
out_index->set_dims(common::make_ddim({-1}));
}
Expand Down
12 changes: 9 additions & 3 deletions python/paddle/autograd/ir_backward.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,9 +870,15 @@ def append_yield(
else:
state.op_to_opgrad[op] = []
else:
if not is_builtin_op(
op
) and not paddle.core.is_forward_only(op):
all_results_stop_gradient = True
for value in op.results():
if not value.stop_gradient:
all_results_stop_gradient = False
if (
not is_builtin_op(op)
and not paddle.core.is_forward_only(op)
and not all_results_stop_gradient
):
raise ValueError(
f"op '{op.name()}' has no grad op, consider enable prim to decompose it."
)
Expand Down
74 changes: 51 additions & 23 deletions python/paddle/nn/layer/rnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
program_guard,
)
from paddle.common_ops_import import Variable
from paddle.framework import core
from paddle.framework import core, in_pir_mode
from paddle.nn import (
functional as F,
initializer as I,
Expand Down Expand Up @@ -106,7 +106,7 @@ def rnn(

"""

if in_dynamic_or_pir_mode():
if in_dynamic_mode():
return _rnn_dynamic_graph(
cell,
inputs,
Expand Down Expand Up @@ -230,7 +230,9 @@ def _rnn_static_graph(
is_reverse=False,
**kwargs,
):
check_type(inputs, 'inputs', (Variable, list, tuple), 'rnn')
check_type(
inputs, 'inputs', (Variable, list, tuple, paddle.pir.Value), 'rnn'
)
if isinstance(inputs, (list, tuple)):
for i, input_x in enumerate(inputs):
check_variable_and_dtype(
Expand All @@ -239,12 +241,15 @@ def _rnn_static_graph(
check_type(
initial_states,
'initial_states',
(Variable, list, tuple, type(None)),
(Variable, list, tuple, type(None), paddle.pir.Value),
'rnn',
)

check_type(
sequence_length, 'sequence_length', (Variable, type(None)), 'rnn'
sequence_length,
'sequence_length',
(Variable, type(None), paddle.pir.Value),
'rnn',
)

def _switch_grad(x, stop=False):
Expand All @@ -261,7 +266,7 @@ def _switch_grad(x, stop=False):
inputs = paddle.utils.map_structure(_transpose_batch_time, inputs)

max_seq_len = paddle.shape(paddle.utils.flatten(inputs)[0])[0]
if sequence_length:
if sequence_length is not None:
mask = paddle.static.nn.sequence_lod.sequence_mask(
sequence_length,
maxlen=max_seq_len,
Expand All @@ -272,7 +277,11 @@ def _switch_grad(x, stop=False):
inputs = paddle.utils.map_structure(
lambda x: paddle.reverse(x, axis=[0]), inputs
)
mask = paddle.reverse(mask, axis=[0]) if sequence_length else None
mask = (
paddle.reverse(mask, axis=[0])
if sequence_length is not None
else None
)

with paddle.base.framework.device_guard("cpu"):
start_i = paddle.zeros([], dtype="int64")
Expand Down Expand Up @@ -303,9 +312,11 @@ def _switch_grad(x, stop=False):
lambda x: paddle.tensor.array_read(x, start_i), init_array
)
outputs, new_states = cell(step_in, pre_state, **kwargs)
assert isinstance(outputs, paddle.base.framework.Variable)
assert isinstance(
outputs, (paddle.base.framework.Variable, paddle.pir.Value)
)
paddle.utils.assert_same_structure(new_states, pre_state)
if sequence_length:
if sequence_length is not None:
step_mask = paddle.unsqueeze(mask[start_i], 1)
# new_states = map_structure(
# partial(_maybe_copy, step_mask=step_mask),
Expand Down Expand Up @@ -1614,19 +1625,34 @@ def flatten_parameters(self):
default_startup_program(), default_startup_program()
):
with paddle.no_grad():
self._helper.append_op(
type="coalesce_tensor",
inputs={"Input": self._all_weights},
outputs={
"Output": self._all_weights,
"FusedOutput": self._flat_weight,
},
attrs={
"copy_data": True,
"use_align": False,
"dtype": params[0].dtype,
},
)
if in_pir_mode():
_C_ops.coalesce_tensor(
self._all_weights,
params[0].dtype,
True,
False,
False,
0.0,
False,
-1,
-1,
[],
[],
)
else:
self._helper.append_op(
type="coalesce_tensor",
inputs={"Input": self._all_weights},
outputs={
"Output": self._all_weights,
"FusedOutput": self._flat_weight,
},
attrs={
"copy_data": True,
"use_align": False,
"dtype": params[0].dtype,
},
)

def _cudnn_impl(self, inputs, initial_states, sequence_length):
if not self.time_major:
Expand Down Expand Up @@ -1712,7 +1738,9 @@ def forward(self, inputs, initial_states=None, sequence_length=None):
else:
initial_states = (
[initial_states]
if isinstance(initial_states, paddle.static.Variable)
if isinstance(
initial_states, (paddle.static.Variable, paddle.pir.Value)
)
else initial_states
)

Expand Down
1 change: 0 additions & 1 deletion test/deprecated/rnn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ endforeach()
if(NOT WIN32)
set_tests_properties(test_rnn_nets_static PROPERTIES TIMEOUT 120)
set_tests_properties(test_rnn_nets_static_deprecated PROPERTIES TIMEOUT 120)
set_tests_properties(test_rnn_nets PROPERTIES TIMEOUT 120)
set_tests_properties(test_rnn_nets_deprecated PROPERTIES TIMEOUT 120)
endif()
Loading