-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
elementwise_mul refactor #37471
elementwise_mul refactor #37471
Conversation
Thanks for your contribution! |
paddle/pten/kernels/cuda/math.cu
Outdated
// Create the definition of ElementwiseMul | ||
DEFINE_ELEMENTWISE_OP(Mul) | ||
// Create the definition of ElementwiseDiv | ||
DEFINE_ELEMENTWISE_OP(Div) |
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.
在CPU的math.cc里没定义Div,这里是多写了吗?
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.
没有多写,CUDA下的div函数删掉了,取而代之用这个div,cpu下的以前的div没删掉,所以没写
@@ -228,4 +228,29 @@ struct SameDimsElementwiseCompute { | |||
} | |||
}; | |||
|
|||
#define DEFINE_ELEMENTWISE_OP(name) \ |
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.
如果一定要用这种形式缩减代码,建议将宏定义放到kernels/cpu/**.h中,functions中的内容定位是由kernel来调用的,反向决定kernel的写法是不合适的
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
ASSERT_NEAR(expect_result[0][0], actual_result0, 1e-6f); | ||
ASSERT_NEAR(expect_result[0][1], actual_result1, 1e-6f); | ||
ASSERT_NEAR(expect_result[1][0], actual_result2, 1e-6f); | ||
} |
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.
后面建议命名空间都规范下,参照PR #37456
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
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.
LGTM
* elementwise_mul refactor * perfect code in test * delete redundant code * fix bugs when run test_multiply * adjust the location of macro * fix bugs when run ci
PR types
Others
PR changes
OPs
Describe
Refactor elementwise_mul kernel and slim elementwise code.