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

fix InferMeta for some op when x_dims contains -1 #63961

Merged
merged 1 commit into from
May 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions paddle/phi/infermeta/unary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,9 @@ void DiagEmbedInferMeta(
dim1,
dim2));

int new_dim_len = static_cast<int>(offset_ + x_dims[x_dims.size() - 1]);
int x_last_dim = x_dims[x_dims.size() - 1];
int new_dim_len =
(x_last_dim == -1) ? -1 : static_cast<int>(offset_ + x_last_dim);
auto sizes = common::vectorize(x_dims);
sizes.pop_back();
sizes.insert(sizes.begin() + std::min(dim1_, dim2_), new_dim_len);
Expand Down Expand Up @@ -3653,7 +3655,7 @@ void RepeatInterleaveInferMeta(const MetaTensor& x,
phi::errors::InvalidArgument(
"repeat_interleave's output tensor can't be nullptr"));

output_dim[n_dim] = input_dim[n_dim] * repeats;
if (input_dim[n_dim] != -1) output_dim[n_dim] = input_dim[n_dim] * repeats;
out->set_dims(common::make_ddim(output_dim));
out->share_lod(x);
out->set_dtype(x.dtype());
Expand Down