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

feat fused_adamw #938

Merged
merged 9 commits into from
Oct 11, 2024
Merged

Conversation

zyf654321
Copy link
Contributor

No description provided.

Copy link
Collaborator

@lljbash lljbash left a comment

Choose a reason for hiding this comment

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

加上单元测试

Comment on lines 1330 to 1361
std::vector<diopiTensorHandle_t> diopiTensorHandles_self(self.size());
for(size_t i=0; i < self.size(); ++i){
diopiConstTensorHandle_t const_handle = dipu::diopi_helper::toDiopiTensorHandle(self.at(i));
diopiTensorHandle_t handle = const_cast<diopiTensorHandle_t>(const_handle);
diopiTensorHandles_self[i] = handle;
}
std::vector<diopiConstTensorHandle_t> diopiTensorHandles_grads(grads.size());
for(size_t i=0; i < grads.size(); ++i){
diopiTensorHandles_grads[i] = dipu::diopi_helper::toDiopiTensorHandle(grads.at(i));
}
std::vector<diopiTensorHandle_t> diopiTensorHandles_exp_avgs(exp_avgs.size());
for(size_t i=0; i < exp_avgs.size(); ++i){
diopiConstTensorHandle_t const_handle = dipu::diopi_helper::toDiopiTensorHandle(exp_avgs.at(i));
diopiTensorHandle_t handle = const_cast<diopiTensorHandle_t>(const_handle);
diopiTensorHandles_exp_avgs[i] = handle;
}
std::vector<diopiTensorHandle_t> diopiTensorHandles_exp_avg_sqs(exp_avg_sqs.size());
for(size_t i=0; i < exp_avg_sqs.size(); ++i){
diopiConstTensorHandle_t const_handle = dipu::diopi_helper::toDiopiTensorHandle(exp_avg_sqs.at(i));
diopiTensorHandle_t handle = const_cast<diopiTensorHandle_t>(const_handle);
diopiTensorHandles_exp_avg_sqs[i] = handle;
}
std::vector<diopiTensorHandle_t> diopiTensorHandles_max_exp_avg_sqs(max_exp_avg_sqs.size());
for(size_t i=0; i < max_exp_avg_sqs.size(); ++i){
diopiConstTensorHandle_t const_handle = dipu::diopi_helper::toDiopiTensorHandle(max_exp_avg_sqs.at(i));
diopiTensorHandle_t handle = const_cast<diopiTensorHandle_t>(const_handle);
diopiTensorHandles_max_exp_avg_sqs[i] = handle;
}
std::vector<diopiConstTensorHandle_t> diopiTensorHandles_state_steps(state_steps.size(), nullptr);
for(size_t i=0; i < state_steps.size(); ++i){
diopiTensorHandles_state_steps[i] = dipu::diopi_helper::toDiopiTensorHandle(state_steps.at(i));
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

削减重复代码,考虑:

  1. 提取函数
  2. 使用 std::transform

Copy link
Collaborator

Choose a reason for hiding this comment

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

toDiopiTensorHandleVector
已经有这个函数了

),
)

@onlyOn("CUDA")
Copy link
Collaborator

Choose a reason for hiding this comment

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

如果期望所有芯片都实现,应该用 skipon 比较好

@ustclight-sls ustclight-sls requested a review from lljbash October 10, 2024 07:00
@fandaoyi fandaoyi merged commit cfec228 into DeepLink-org:main Oct 11, 2024
33 checks passed
@lljbash lljbash deleted the zyf/fused_adamw_4 branch October 24, 2024 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants