Skip to content

Commit 49e3784

Browse files
authored
[PIR] Warning once in ir backward (#64696)
1 parent f406545 commit 49e3784

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

python/paddle/autograd/backward_utils.py

+7
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
from __future__ import annotations
1515

1616
import collections
17+
import logging
1718
import warnings
1819
from collections.abc import Sequence
20+
from functools import lru_cache
1921
from typing import Any
2022

2123
from paddle import pir
@@ -660,3 +662,8 @@ def get_split_op(value):
660662
if op.name() == "builtin.split":
661663
return op
662664
return None
665+
666+
667+
@lru_cache
668+
def warning_once(message: str):
669+
logging.warning(message)

python/paddle/autograd/ir_backward.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
return_map_value_list,
4646
some_in_set,
4747
update_no_grad_set_by_stopgradient,
48+
warning_once,
4849
while_prune_check,
4950
)
5051
from paddle.base.libpaddle.pir import (
@@ -906,7 +907,7 @@ def prepare_backward_prune_set(inputs, outputs):
906907
for item in get_real_op_inputs(used_op):
907908
outputs_fwd_set.add(item)
908909
else:
909-
logging.warning("input provided by inputs has no use")
910+
warning_once("input provided by inputs has no use")
910911

911912
inputs_fwd_set = ValueSet()
912913
for output in outputs:

0 commit comments

Comments
 (0)