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

fix exponential op #58029

Merged
merged 16 commits into from
Oct 26, 2023
Merged
1 change: 1 addition & 0 deletions paddle/fluid/pir/dialect/operator/utils/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const std::unordered_set<std::string> LegacyOpList = {
"pd_op.c_sync_calc_stream_",
"pd_op.c_sync_comm_stream_",
"pd_op.dpsgd",
"pd_op.exponential",
"pd_op.send_v2",
"pd_op.recv_v2",
"pd_op.c_allreduce_sum",
Expand Down
4 changes: 2 additions & 2 deletions paddle/phi/api/yaml/op_compat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -987,8 +987,8 @@
extra :
attrs : [bool use_mkldnn = false, bool use_cudnn = false]

- op : exponential_
backward : exponential__grad
- op : exponential_ (exponential)
backward : exponential__grad (exponential_grad)
inputs :
x : X
outputs :
Expand Down
4 changes: 4 additions & 0 deletions test/legacy_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,10 @@ foreach(IR_OP_TEST ${NEW_IR_OP_TESTS})
set_tests_properties(
${IR_OP_TEST} PROPERTIES ENVIRONMENT
"FLAGS_NEW_IR_OPTEST_WHITE_LIST=True")
if(${IR_OP_TEST} STREQUAL "test_exponential_op")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有扩展性,建议改为列表实现,类似 #55857

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

set_tests_properties(${IR_OP_TEST}
PROPERTIES ENVIRONMENT "FLAGS_NEW_IR_NO_CHECK=True")
endif()
else()
message(STATUS "NewIR OpTest: not found ${IR_OP_TEST} in legacy_test")
endif()
Expand Down
5 changes: 5 additions & 0 deletions test/legacy_test/op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,8 @@ def _check_ir_output(self, place, program, feed_map, fetch_list, outs):
check_method = lambda x, y, z: np.testing.assert_allclose(
x, y, err_msg=z, atol=1e-6, rtol=1e-6
)
if os.getenv("FLAGS_FLAGS_NEW_IR_NO_CHECK", None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个flag为什么和上面CMake里设置的不一样?而且他能生效?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改 这里感觉应该单测失败才对

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我怀疑这种写法是不是有问题,它会不会总是生效的?可以验证下这个flag对别的单测是不是也起效果了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确实有问题,if os.getenv("FLAGS_NEW_IR_NO_CHECK", None)只会检查这个环境变量是否存在,如果是0的话也会执行if后面的逻辑,现在改为if os.getenv("FLAGS_NEW_IR_NO_CHECK", None)==“True”只有得到环境变量为“True”才会执行

check_method = lambda x, y, err_msg: None

for i in range(len(outs)):
check_method(
Expand Down Expand Up @@ -3373,6 +3375,9 @@ def _check_ir_grad_output(
x, y, err_msg=z, atol=1e-6, rtol=1e-6
)

if os.getenv("FLAGS_FLAGS_NEW_IR_NO_CHECK", None):
check_method = lambda x, y, err_msg: None

for i in range(len(new_gradients)):
check_method(
gradients[i],
Expand Down
1 change: 1 addition & 0 deletions test/white_list/new_ir_op_test_white_list
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ test_elementwise_mul_op
test_elementwise_pow_op
test_erfinv_op
test_expand_v2_op
test_exponential_op
test_eye_op
test_fill_any_op
test_fill_constant_batch_size_like
Expand Down