Skip to content

Commit

Permalink
try to export ut input
Browse files Browse the repository at this point in the history
  • Loading branch information
CaRoLZhangxy committed Feb 27, 2024
1 parent 75c8bb9 commit 0450873
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 6 additions & 0 deletions source/api_cc/src/DeepPotPT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ void DeepPotPT::compute(ENERGYVTYPE& ener,
torch::from_blob(atype_64.data(), {1, natoms}, int_options).to(device);
if (ago == 0) {
nlist_data.copy_from_nlist(lmp_list, max_num_neighbors);
std::cout << "Vector content:" << std::endl;
for (const auto& element : nlist_data.jlist) {
std::cout << element << " ";
}
std::cout << std::endl;
}
at::Tensor firstneigh =
torch::from_blob(nlist_data.jlist.data(),
Expand All @@ -127,6 +132,7 @@ void DeepPotPT::compute(ENERGYVTYPE& ener,
torch::Tensor flat_atom_energy_ =
atom_energy_.toTensor().view({-1}).to(floatType);
torch::Tensor cpu_atom_energy_ = flat_atom_energy_.to(torch::kCPU);
std::cout << cpu_atom_energy_ << std::endl;
atom_energy.assign(
cpu_atom_energy_.data_ptr<VALUETYPE>(),
cpu_atom_energy_.data_ptr<VALUETYPE>() + cpu_atom_energy_.numel());
Expand Down
2 changes: 0 additions & 2 deletions source/api_cc/tests/test_deeppot_pt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,12 @@ TYPED_TEST(TestInferDeepPotAPt, cpu_lmp_nlist_atomic) {
std::vector<int> ilist(nloc), numneigh(nloc);
std::vector<int*> firstneigh(nloc);
deepmd::InputNlist inlist(nloc, &ilist[0], &numneigh[0], &firstneigh[0]);
std::cout << nlist_data << std::endl;
convert_nlist(inlist, nlist_data);
double ener;
std::vector<VALUETYPE> force_, atom_ener_, atom_vir_, virial;
std::vector<VALUETYPE> force, atom_ener, atom_vir;
dp.compute(ener, force_, virial, atom_ener_, atom_vir_, coord_cpy, atype_cpy,
box, nall - nloc, inlist, 0);
std::cout << atom_ener_ << std::endl;
_fold_back<VALUETYPE>(force, force_, mapping, nloc, nall, 3);
_fold_back<VALUETYPE>(atom_ener, atom_ener_, mapping, nloc, nall, 1);
_fold_back<VALUETYPE>(atom_vir, atom_vir_, mapping, nloc, nall, 9);
Expand Down

0 comments on commit 0450873

Please sign in to comment.