-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Optimize the calling logic of the cast and cast_grad kernels to reduce compilation size #57083
Optimize the calling logic of the cast and cast_grad kernels to reduce compilation size #57083
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
CastCUDAKernelImpl<T, data_t>( | ||
dev_ctx, out_grad, x_grad->dtype(), x_grad); | ||
})); | ||
CastImpl<T, Context>(dev_ctx, out_grad, x_grad->dtype(), x_grad); |
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.
这样还是会编译2份吧?能直接调phi::CastKernel
吗?
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
paddle/phi/kernels/gpu/cast_impl.h
Outdated
} | ||
|
||
template <typename T, typename Context> | ||
void CastKernel(const Context& dev_ctx, |
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.
CastKernel实现不用挪到头文件中,在cast_kernel.cu里面实现就行,cast_grad_kernel.cu里面只需include cast_kernel.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.
done
3dc24d2
to
e55c537
Compare
CastCUDAKernelImpl<T, data_t>( | ||
dev_ctx, out_grad, x_grad->dtype(), x_grad); | ||
})); | ||
CastKernel<T, Context>(dev_ctx, out_grad, x_grad->dtype(), x_grad); |
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.
我觉得这里传x.dtype()
比较合适。x_grad是输出,其实它的数据类型在Alloc之前是没有确定的,后面也会重置(cast_impl.h
里面的第39行out->set_type(out_dtype);
)。
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
e55c537
to
6871280
Compare
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
…e compilation size (PaddlePaddle#57083)
PR types
Others
PR changes
Others
Description
Pcard-70459
![image](https://private-user-images.githubusercontent.com/51102941/268152610-cc870206-b4f2-40a2-afb6-e888504c22e3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE3MzA3MjUsIm5iZiI6MTcyMTczMDQyNSwicGF0aCI6Ii81MTEwMjk0MS8yNjgxNTI2MTAtY2M4NzAyMDYtYjRmMi00MGEyLWFmYjYtZTg4ODUwNGMyMmUzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzIzVDEwMjcwNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdjYjQxYmExZDcxMGM0NWFjMDRhYmVhMDY4NzYzNDFhYzczNjU3MDk4MDZkOWIyOWI2ZGE5ZDQxYWQxZDVmMWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.wq9fYHW9EmQ9Dn5rjAKQZ9hWSbjEsmder0kX4uR3YRo)
compile test 4.1
体积变化: