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

Support 0-size tensor in parameter creating, forward and backward #70504

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
02aa39d
support 0-size tensor forward and backward under simple operations pr…
HydrogenSulfate Dec 27, 2024
a18f2cc
Merge branch 'develop' into support_0-size_fwd_bwd
HydrogenSulfate Dec 27, 2024
288b863
fix error message format
HydrogenSulfate Dec 31, 2024
665698a
support initializing for 0-size tensor
HydrogenSulfate Dec 31, 2024
a157537
add TestZeroSizeParameter
HydrogenSulfate Dec 31, 2024
130251d
update forward, backward with 0-size tensor in eager/static mode
HydrogenSulfate Dec 31, 2024
7b396b4
Merge branch 'develop' into support_0-size_fwd_bwd
HydrogenSulfate Dec 31, 2024
2442cde
TestZeroSizeBackward skip XPU for place issue
HydrogenSulfate Jan 2, 2025
fc4aff3
Merge branch 'develop' into support_0-size_fwd_bwd
HydrogenSulfate Jan 2, 2025
c9267a9
[PIR] Insert backward ops into insertion point
SigureMo Jan 2, 2025
b0a87da
fix 2 ut
SigureMo Jan 2, 2025
68f0af9
Merge branch 'PaddlePaddle:develop' into support_0-size_fwd_bwd
HydrogenSulfate Jan 3, 2025
49f235d
Merge branch '70595' into support_0-size_fwd_bwd
HydrogenSulfate Jan 3, 2025
7614038
fix add_n infermeta when meeting 0-size and update UT
HydrogenSulfate Jan 3, 2025
16744ee
Merge branch 'develop' into support_0-size_fwd_bwd
HydrogenSulfate Jan 3, 2025
2d7cbf1
remove warnings
HydrogenSulfate Jan 3, 2025
5f71752
remove print
HydrogenSulfate Jan 3, 2025
89f3195
Merge branch 'PaddlePaddle:develop' into support_0-size_fwd_bwd
HydrogenSulfate Jan 3, 2025
e026da1
remove unnecessary code
HydrogenSulfate Jan 5, 2025
d416e30
Merge branch 'support_0-size_fwd_bwd' of https://github.com/HydrogenS…
HydrogenSulfate Jan 5, 2025
942f58b
remove condition of define() for paddle::Tensor
HydrogenSulfate Jan 6, 2025
da2ede8
Merge branch 'develop' into support_0-size_fwd_bwd
HydrogenSulfate Jan 6, 2025
aca7ba3
fix
HydrogenSulfate Jan 6, 2025
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
Prev Previous commit
Next Next commit
fix add_n infermeta when meeting 0-size and update UT
  • Loading branch information
HydrogenSulfate committed Jan 3, 2025
commit 7614038421b82cb160b49d56a6b5ba4c81f9c5a6
14 changes: 5 additions & 9 deletions paddle/phi/infermeta/multiary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,11 @@ void AddNInferMeta(const std::vector<const MetaTensor*>& x,
N,
0,
common::errors::InvalidArgument(
"The input tensor X's dimensions of SumOp "
"The input tensor X's dimensions of AddNOp "
"should be larger than 0. But received X's dimensions %d.",
N));
if (N == 1) {
VLOG(3) << "Warning: SumOp have only one input, may waste memory";
VLOG(3) << "Warning: AddNOp have only one input, may waste memory";
}
bool is_all_0d_tensor = true;
phi::DDim in_dim({0});
Expand All @@ -407,10 +407,6 @@ void AddNInferMeta(const std::vector<const MetaTensor*>& x,
if (x[i]->is_selected_rows() && x_dim.size() == 1) {
continue;
}
// for zero-sized tensor
if (common::product(x_dim) == 0) {
continue;
}
// for 0D tensor
if (x_dim.size() == 0) {
continue;
Expand All @@ -423,7 +419,7 @@ void AddNInferMeta(const std::vector<const MetaTensor*>& x,
PADDLE_ENFORCE_EQ(in_dim,
x_dim,
common::errors::InvalidArgument(
"The input tensor X of SumOp must"
"The input tensor X of AddNOp must"
" have same shape. But received X[0]'s shape = "
"[%s], X[%d]'s shape = [%s].",
in_dim,
Expand All @@ -434,7 +430,7 @@ void AddNInferMeta(const std::vector<const MetaTensor*>& x,
in_dim.size(),
x_dim.size(),
common::errors::InvalidArgument(
"The input tensor X of SumOp must have same "
"The input tensor X of AddNOp must have same "
"dimensions. But received X[0]'s dimensions = %d, X[0]'s "
"shape = "
"[%s], X[%d]'s dimensions = %d, X[%d]'s shape = [%s].",
Expand All @@ -453,7 +449,7 @@ void AddNInferMeta(const std::vector<const MetaTensor*>& x,
in_dim[j],
x_dim[j],
common::errors::InvalidArgument(
"The input tensor X of SumOp must have same shape "
"The input tensor X of AddNOp must have same shape "
"if not -1."
"But received X[0]'s shape = [%s], X[%d]'s shape = [%s].",
in_dim,
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/gpu/add_n_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void AddNKernel(const Context &dev_ctx,
const size_t in_num = x.size();
for (int i = 0; i < in_num; ++i) {
PADDLE_ENFORCE_EQ(
x[i]->initialized(),
x[i]->valid() && x[i]->has_allocation(),
true,
common::errors::InvalidArgument(
"This argument is invalid, %d-th tensor is uninitialized.", i));
Expand Down
Loading