CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
support for checking op's inputs grad semantic #56925
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
support for checking op's inputs grad semantic #56925
Conversation
… of OP has grad semantics
…puts and bwd_op outputs
… check_inputs_grad_semantic
你的PR提交成功,感谢你对开源项目的贡献! |
… check_inputs_grad_semantic
…umt/Paddle into check_inputs_grad_semantic
@@ -704,6 +721,69 @@ def to_pascal_case(s): | |||
return "".join([word.capitalize() for word in words]) + "" | |||
|
|||
|
|||
def OpInputGradSemanticCheck(op_info, op_info_items): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python 函数命名用小写 + 下划线,跟上面保持一致,函数名是不是叫get_input_grad_semantic
更合适一点?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx
return input_grad_semantic_list | ||
|
||
|
||
def OpMutableAttributeGradSemanticCheck(op_info, op_info_items): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上 ,函数名用get_mutable_attribute_grad_semantic
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx
else: | ||
mutable_attribute_grad_semantic_list.append("false") | ||
|
||
return mutable_attribute_grad_semantic_list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个变量叫mutable_attribute_grad_semantics
更合适一点? 尽量不要在变量命名中加类型
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx
else: | ||
input_grad_semantic_list = ["false" for i in range(num_inputs)] | ||
|
||
return input_grad_semantic_list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
变量名是不是可以叫input_grad_semantics
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx
paddle.enable_static() | ||
|
||
|
||
def get_ir_program_0(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个函数是不是可以叫get_gather_program_new_ir
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx
return newir_program | ||
|
||
|
||
def get_ir_program_1(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_multiply_program_new_ir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx
|
||
|
||
class TestOpInputGradSemantic(unittest.TestCase): | ||
def test_gatherop_input_grad_semantic(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
函数名可以去掉op或者用下划线隔开
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx
class TestOpInputGradSemantic(unittest.TestCase): | ||
def test_gatherop_input_grad_semantic(self): | ||
newir_program = get_ir_program_0() | ||
op = newir_program.block().ops[-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
op->gather_op
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx
|
||
def test_multiplyop_input_grad_semantic(self): | ||
newir_program = get_ir_program_1() | ||
op = newir_program.block().ops[-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
op->multiply_op
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx
This reverts commit d8122a2.
* add <with_grad_semantic> in OpInputInfo to represent whether an input of OP has grad semantics * add support for check OP's input grad semantic by comparing fwd_op inputs and bwd_op outputs * add pybind interface to support checking OP's inputs grad semantic in python-level * add test * fix bugs * fix bugs in op_gen * fix bugs in op_gen * add test for multiply_op * fix bugs in codestype * fix bugs in codestype
PR types
New features
PR changes
Others
Description
Pcard-66975
Support for checking whether inputs of OP have grad semantic
Taking MultiplyOp as an example, the OpInputInfo generated before and after supporting input grad semantic is as follows: