Skip to content

Commit d1369a7

Browse files
fix code
1 parent 329f9bc commit d1369a7

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

source/api_cc/include/DeepPotPD.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,8 @@ class DeepPotPD : public DeepPotBackend {
392392
int do_message_passing; // 1:dpa2 model 0:others
393393
bool gpu_enabled;
394394
std::unique_ptr<paddle_infer::Tensor> firstneigh_tensor;
395-
395+
std::unique_ptr<paddle_infer::Tensor> mapping_tensor;
396+
// std::vector<paddle_infer::Tensor> comm_vec;
396397
/* comm_vec flatten all the communicatoin tensors below from comm dict:
397398
- [0] send_list
398399
- [1] send_proc
@@ -401,10 +402,6 @@ class DeepPotPD : public DeepPotBackend {
401402
- [4] recv_num
402403
- [5] communicator
403404
*/
404-
std::vector<paddle_infer::Tensor> comm_vec;
405-
406-
std::unique_ptr<paddle_infer::Tensor> mapping_tensor =
407-
predictor_fl->GetInputHandle("mapping");
408405
};
409406

410407
} // namespace deepmd

source/api_cc/src/DeepPotPD.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void DeepPotPD::compute(ENERGYVTYPE& ener,
223223
sendnum_tensor->CopyFromCpu(lmp_list.sendnum);
224224
auto communicator_tensor = predictor_fl->GetInputHandle("communicator");
225225
communicator_tensor->Reshape({1});
226-
if (lmp_list.world > 0) {
226+
if (lmp_list.world) {
227227
communicator_tensor->CopyFromCpu(static_cast<int*>(lmp_list.world));
228228
}
229229
int total_send =
@@ -244,14 +244,16 @@ void DeepPotPD::compute(ENERGYVTYPE& ener,
244244
for (size_t ii = 0; ii < nall_real; ii++) {
245245
mapping[ii] = lmp_list.mapping[fwd_map[ii]];
246246
}
247+
this->mapping_tensor = predictor_fl->GetInputHandle("mapping");
247248
this->mapping_tensor->Reshape({1, nall_real});
248249
this->mapping_tensor->CopyFromCpu(mapping.data());
249250
}
250251
}
251252
std::vector<int> firstneigh = createNlistTensorPD(nlist_data.jlist);
252-
firstneigh_tensor = predictor_fl->GetInputHandle("nlist");
253-
firstneigh_tensor->Reshape({1, nloc, (int)firstneigh.size() / (int)nloc});
254-
firstneigh_tensor->CopyFromCpu(firstneigh.data());
253+
this->firstneigh_tensor = predictor_fl->GetInputHandle("nlist");
254+
this->firstneigh_tensor->Reshape(
255+
{1, nloc, (int)firstneigh.size() / (int)nloc});
256+
this->firstneigh_tensor->CopyFromCpu(firstneigh.data());
255257
bool do_atom_virial_tensor = atomic;
256258
std::unique_ptr<paddle_infer::Tensor> fparam_tensor;
257259
if (!fparam.empty()) {

0 commit comments

Comments
 (0)