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

修复fast_ln算子动半开启后报错 #8891

Merged
merged 2 commits into from
Aug 8, 2024
Merged
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
11 changes: 10 additions & 1 deletion legacy/model_zoo/gpt-3/external_ops/fast_ln/ln_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,14 @@ std::vector<std::vector<int64_t>> RMSLnBwdInferShape(
return {x_shape, scale_shape};
}

std::vector<paddle::DataType> LnBwdInferDtype(paddle::DataType x_dtype,
paddle::DataType scale_dtype,
paddle::DataType mean_dtype,
paddle::DataType invvar_dtype,
paddle::DataType dy_dtype) {
return {x_dtype, scale_dtype, scale_dtype};
}

PD_BUILD_OP(fast_ln)
.Inputs({"x", "scale", "bias"})
.Outputs({"y", "mean", "invvar"})
Expand All @@ -542,7 +550,8 @@ PD_BUILD_GRAD_OP(fast_ln)
.Outputs({paddle::Grad("x"), paddle::Grad("scale"), paddle::Grad("bias")})
.Attrs({"epsilon: float"})
.SetKernelFn(PD_KERNEL(LnBwd))
.SetInferShapeFn(PD_INFER_SHAPE(LnBwdInferShape));
.SetInferShapeFn(PD_INFER_SHAPE(LnBwdInferShape))
.SetInferDtypeFn(PD_INFER_DTYPE(LnBwdInferDtype));

PD_BUILD_OP(fast_rms_norm)
.Inputs({"x", "scale"})
Expand Down
Loading