From d9884e2077d024a2439b8864b21885402f228af7 Mon Sep 17 00:00:00 2001 From: zyfncg Date: Thu, 3 Mar 2022 10:06:11 +0800 Subject: [PATCH] adjust the args checking of backward in yaml (#40091) --- python/paddle/utils/code_gen/backward_api_gen.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/paddle/utils/code_gen/backward_api_gen.py b/python/paddle/utils/code_gen/backward_api_gen.py index 2d33cd5b18..125ebed82d 100644 --- a/python/paddle/utils/code_gen/backward_api_gen.py +++ b/python/paddle/utils/code_gen/backward_api_gen.py @@ -56,8 +56,9 @@ class BackwardAPI(BaseAPI): # check the attributes of backward for attr in self.attrs['names']: - assert attr in fw_attrs['names'] and self.attrs['attr_info'][attr][0] == fw_attrs['attr_info'][attr][0], \ - f"{self.api} : Attribute error: The attribute({attr}) of backward isn't consistent with forward api. \ + assert (attr in fw_attrs['names'] and self.attrs['attr_info'][attr][0] == fw_attrs['attr_info'][attr][0]) or \ + self.attrs['attr_info'][attr][1] is not None, \ + f"{self.api} : Attribute error: The attribute({attr}) of backward isn't consistent with forward api or doesn't have default value. \ Please check the args of {self.api} in yaml." # check the output of backward -- GitLab