Skip to content

[BIT] Add enforce check #2

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

Open
wants to merge 2 commits into
base: fix_fused_bias_act_big_tensor
Choose a base branch
from
Open
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
49 changes: 49 additions & 0 deletions paddle/phi/kernels/fusion/gpu/fused_bias_act_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,55 @@ void DispatchWithDtype(const Context &dev_ctx,
float quant_min_bound,
DenseTensor *out,
NormalVersion) {
const auto &x_dims = x.dims();
if (bias != nullptr) {
const auto &bias_dims = bias->dims();
PADDLE_ENFORCE_EQ(bias_dims.size(),
1,
common::errors::InvalidArgument(
"The bias must be a 1D tensor, but got %dD tensor.",
bias_dims.size()));
PADDLE_ENFORCE_EQ(
bias_dims[0],
x_dims[x_dims.size() - 1],
common::errors::InvalidArgument(
"The bias length must be equal to the last dimension of input x. "
"Expected %d, but got %d.",
x_dims[x_dims.size() - 1],
bias_dims[0]));
}
if (dequant_scales != nullptr) {
const auto &scales_dims = dequant_scales->dims();
PADDLE_ENFORCE_EQ(
scales_dims.size(),
1,
common::errors::InvalidArgument(
"The dequant_scales must be a 1D tensor, but got %dD tensor.",
scales_dims.size()));
PADDLE_ENFORCE_EQ(scales_dims[0],
x_dims[x_dims.size() - 1],
common::errors::InvalidArgument(
"The dequant_scales length must be equal to the last "
"dimension of input x. "
"Expected %d, but got %d.",
x_dims[x_dims.size() - 1],
scales_dims[0]));
}
if (shift != nullptr) {
const auto &shift_dims = shift->dims();
PADDLE_ENFORCE_EQ(shift_dims,
x_dims,
common::errors::InvalidArgument(
"The shift must have the same shape as input x."));
}
if (smooth != nullptr) {
const auto &smooth_dims = smooth->dims();
PADDLE_ENFORCE_EQ(smooth_dims,
x_dims,
common::errors::InvalidArgument(
"The smooth must have the same shape as input x."));
}

auto *bias_p = bias.get_ptr();
auto *dequant_scales_p = dequant_scales.get_ptr();
auto *shift_p = shift.get_ptr();
Expand Down