Skip to content

Commit

Permalink
cherry pick: reduce log for type promotion. (#62116)
Browse files Browse the repository at this point in the history
  • Loading branch information
zxcd authored Feb 27, 2024
1 parent dba9992 commit f4d9adf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ paddle::Tensor multiply_ad_func(const paddle::Tensor& x,
// Type promotion Logic
if (phi::NeedTypePromotion(x.dtype(), y.dtype())) {
VLOG(5) << "got different data type, run type protmotion automatically.";
LOG(WARNING) << "got different data type, run type protmotion "
"automatically, this may cause data type been changed.";
LOG_FIRST_N(WARNING, 1)
<< "got different data type, run type protmotion "
"automatically, this may cause data type been changed.";
auto op_name = phi::TransToFluidOpName("multiply");
auto promotion_type = phi::GetPromoteDtype(op_name, x.dtype(), y.dtype());

Expand Down Expand Up @@ -407,8 +408,9 @@ paddle::Tensor multiply_ad_func(const paddle::Tensor& x,
// Type promotion Logic
if (phi::NeedTypePromotion(x.dtype(), y.dtype())) {
VLOG(5) << "got different data type, run type protmotion automatically.";
LOG(WARNING) << "got different data type, run type protmotion "
"automatically, this may cause data type been changed.";
LOG_FIRST_N(WARNING, 1)
<< "got different data type, run type protmotion "
"automatically, this may cause data type been changed.";
auto op_name = phi::TransToFluidOpName("multiply");
auto promotion_type = phi::GetPromoteDtype(op_name, x.dtype(), y.dtype());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ class {} : public egr::GradNodeBase {{

TYPE_PROMOTION_LOGIC_TEMPLATE = """ if (phi::NeedTypePromotion({x}.dtype(), {y}.dtype())) {{
VLOG(5) << "got different data type, run type protmotion automatically.";
LOG(WARNING) << "got different data type, run type protmotion automatically, this may cause data type been changed.";
LOG_FIRST_N(WARNING, 1) << "got different data type, run type protmotion automatically, this may cause data type been changed.";
{op_name}
auto promotion_type = phi::GetPromoteDtype(op_name, {x}.dtype(), {y}.dtype());
Expand Down
6 changes: 4 additions & 2 deletions python/paddle/base/layers/math_op_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,10 @@ def __impl__(self, other_var):
op_type, lhs_dtype, rhs_dtype
)
warnings.warn(
f"The input dtypes of OP {op_type} are {lhs_dtype} and {rhs_dtype}, "
"the output will be auto-promoted to {common_dtype}"
f"The input dtypes of OP {op_type} are {lhs_dtype} and {rhs_dtype}, the output will be auto-promoted to {common_dtype}"
)
warnings.filterwarnings(
"ignore", message="The input dtypes of OP"
)
if rhs_dtype != common_dtype:
other_var = astype(other_var, common_dtype)
Expand Down

0 comments on commit f4d9adf

Please sign in to comment.