-
Notifications
You must be signed in to change notification settings - Fork 229
Update the output of OFDFT, particularly for the ML part #7383
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -40,7 +40,8 @@ void ML_EXX::init_data( | |||||
| const std::vector<int> &of_ml_tanh_pnl, | ||||||
| const std::vector<int> &of_ml_tanh_qnl, | ||||||
| const std::vector<int> &of_ml_tanhp_nl, | ||||||
| const std::vector<int> &of_ml_tanhq_nl | ||||||
| const std::vector<int> &of_ml_tanhq_nl, | ||||||
| std::ostream& ofs_running | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Note that there are two commented-out
Suggested change
|
||||||
| ) | ||||||
| { | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -38,14 +38,15 @@ void KEDF_ML::set_para( | |||||
| const std::vector<int> &of_ml_tanhp_nl, | ||||||
| const std::vector<int> &of_ml_tanhq_nl, | ||||||
| const std::string device_inpt, | ||||||
| ModulePW::PW_Basis *pw_rho | ||||||
| ModulePW::PW_Basis *pw_rho, | ||||||
| std::ostream& ofs_running | ||||||
| ) | ||||||
| { | ||||||
| torch::set_default_dtype(caffe2::TypeMeta::fromScalarType(torch::kDouble)); | ||||||
| auto output = torch::get_default_dtype(); | ||||||
| std::cout << "Default type: " << output << std::endl; | ||||||
| ofs_running << " Default type: " << output << std::endl; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same inconsistent leading space as in
Suggested change
|
||||||
|
|
||||||
| this->set_device(device_inpt); | ||||||
| this->set_device(device_inpt, ofs_running); | ||||||
|
|
||||||
| this->nx = nx; | ||||||
| this->nx_tot = nx; | ||||||
|
|
@@ -68,17 +69,18 @@ void KEDF_ML::set_para( | |||||
| of_ml_tanh_pnl, | ||||||
| of_ml_tanh_qnl, | ||||||
| of_ml_tanhp_nl, | ||||||
| of_ml_tanhq_nl); | ||||||
| of_ml_tanhq_nl, | ||||||
| ofs_running); | ||||||
|
|
||||||
| std::cout << "ninput = " << ninput << std::endl; | ||||||
| ofs_running << "ninput = " << ninput << std::endl; | ||||||
|
|
||||||
| if (PARAM.inp.of_kinetic == "ml") | ||||||
| { | ||||||
| int nnode = 100; | ||||||
| int nlayer = 3; | ||||||
| this->nn = std::make_shared<NN_OFImpl>(this->nx, 0, this->ninput, nnode, nlayer, this->device); | ||||||
| this->nn = std::make_shared<NN_OFImpl>(this->nx, 0, this->ninput, nnode, nlayer, this->device, ofs_running); | ||||||
| torch::load(this->nn, "net.pt", this->device_type); | ||||||
| std::cout << "load net done" << std::endl; | ||||||
| ofs_running << "load net done" << std::endl; | ||||||
| if (PARAM.inp.of_ml_feg != 0) | ||||||
| { | ||||||
| torch::Tensor feg_inpt = torch::zeros(this->ninput, this->device_type); | ||||||
|
|
@@ -96,7 +98,7 @@ void KEDF_ML::set_para( | |||||
| this->feg_net_F = this->nn->forward(feg_inpt).to(this->device_CPU).contiguous().data_ptr<double>()[0]; | ||||||
| } | ||||||
|
|
||||||
| std::cout << "feg_net_F = " << this->feg_net_F << std::endl; | ||||||
| ofs_running << "feg_net_F = " << this->feg_net_F << std::endl; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -111,7 +113,7 @@ void KEDF_ML::set_para( | |||||
| this->chi_qnl = chi_qnl; | ||||||
|
|
||||||
| this->cal_tool->set_para(nx, nelec, tf_weight, vw_weight, chi_p, chi_q, | ||||||
| chi_xi, chi_pnl, chi_qnl, nkernel, kernel_type, kernel_scaling, yukawa_alpha, kernel_file, this->dV * pw_rho->nxyz, pw_rho); | ||||||
| chi_xi, chi_pnl, chi_qnl, nkernel, kernel_type, kernel_scaling, yukawa_alpha, kernel_file, this->dV * pw_rho->nxyz, pw_rho, ofs_running); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,24 +10,24 @@ ML_Base::~ML_Base() | |||||
| if (this->cal_tool) delete this->cal_tool; | ||||||
| } | ||||||
|
|
||||||
| void ML_Base::set_device(std::string device_inpt) | ||||||
| void ML_Base::set_device(const std::string& device_inpt, std::ostream& ofs_running) | ||||||
| { | ||||||
| if (device_inpt == "cpu") | ||||||
| { | ||||||
| std::cout << "------------------- Running NN on CPU -------------------" << std::endl; | ||||||
| ofs_running << "------------------- Running Neural Network on CPU -------------------" << std::endl; | ||||||
| this->device_type = torch::kCPU; | ||||||
| } | ||||||
| else if (device_inpt == "gpu") | ||||||
| { | ||||||
| if (torch::cuda::cudnn_is_available()) | ||||||
| { | ||||||
| std::cout << "------------------- Running NN on GPU -------------------" << std::endl; | ||||||
| ofs_running << "------------------- Running Neural Network on GPU -------------------" << std::endl; | ||||||
| this->device_type = torch::kCUDA; | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| std::cout << "--------------- Warning: GPU is unaviable ---------------" << std::endl; | ||||||
| std::cout << "------------------- Running NN on CPU -------------------" << std::endl; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: "unaviable" should be "unavailable". Since you're already touching this line, it would be a good opportunity to fix it.
Suggested change
|
||||||
| ofs_running << "--------------- Warning: GPU is unaviable ---------------" << std::endl; | ||||||
| ofs_running << "------------------- Running Neural Network on CPU -------------------" << std::endl; | ||||||
| this->device_type = torch::kCPU; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
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's an inconsistent leading space before
Default type:that was not present in the originalstd::coutversion. Other messages in this same file (e.g.,"ninput = ...","load net done","feg_net_F = ...") do not have this leading space.