-
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
[KP] Add elementwise add xpu after phi, test=develop #39787
[KP] Add elementwise add xpu after phi, test=develop #39787
Conversation
Thanks for your contribution! |
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
@@ -127,9 +127,11 @@ macro(compile_kernel COMPILE_ARGS) | |||
kernel_build/${kernel_name}.bin.o | |||
COMMAND | |||
${CMAKE_COMMAND} -E make_directory kernel_build | |||
COMMAND | |||
cp ${kernel_path}/${kernel_name}.kps kernel_build/${kernel_name}.xpu |
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.
GPU环境下是否需要cp 成.cu文件呢
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.
是的,目前直接转成.cu文件还有一些工作量,后续提PR完成
REGISTER_OP_KERNEL(elementwise_add, KP, plat::XPUPlace, | ||
ops::ElementwiseAddXPUKPKernel<float>); | ||
|
||
REGISTER_OP_KERNEL(elementwise_add_grad, KP, plat::XPUPlace, |
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.
此处只有XPU 注册,那GPU注册添加到哪里呢
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.
后续会增加GPU注册,通过宏定义隔离
|
||
#define KPStream XPUStream | ||
#define KPDevice phi::XPUContext | ||
#define _ptr_ _global_ptr_ | ||
#define __forceinline__ __inline__ | ||
#define __restrict__ | ||
|
||
#include "paddle/phi/backends/xpu/xpu_context.h" |
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.
这个顺序还是有影响是吗
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.
有影响的
@@ -17,7 +17,7 @@ if(NOT WITH_XPU_KP) | |||
endif() | |||
|
|||
if(NOT XPU_TOOLCHAIN) | |||
set(XPU_TOOLCHAIN /workspace/paddle/xpu-demo/XTDK) | |||
set(XPU_TOOLCHAIN /workspace/output/XTDK-ubuntu_x86_64) |
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.
后续需要处理非x86情况
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.
好的
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 for unittest.skipIf and skip_check_grad_ci on XPU2
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 for op benchmark
PR types
New featuresPR changes
OPs
Describe
Added kernel for XPU2 KP system, elementwise_add
This PR involves 4 changes:
Improve the XPU2 source code compilation process, modify cmake/operators.cmake and cmake/xpu_kp.cmake to support .kps files.
Added the elementwise_add.kps file and added a test for it. This file provides the forward XPU2 source code compilation code of elementwise_add
Modified the relevant components of KP, compute_primitives_xpu2.h, etc., and solved some previous bugs
In order to support source code compilation of XPU2, some underlying codes such as elementwise and device have been modified, such as elementwise_base.h and cuda_kernel_config.h, etc.
The result is as follows:
The KP_flags turns on: