Skip to content

Commit 106c973

Browse files
committed
Use insert_or_assign for send_list in comm_dict
Replaces comm_dict.insert with comm_dict.insert_or_assign for the 'send_list' key in both DeepPotPT.cc and DeepSpinPT.cc. This ensures that the value is updated if the key already exists, preventing potential issues with duplicate key insertion.
1 parent e9e39ad commit 106c973

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

source/api_cc/src/DeepPotPT.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void DeepPotPT::compute(ENERGYVTYPE& ener,
197197
std::accumulate(lmp_list.sendnum, lmp_list.sendnum + nswap, 0);
198198
torch::Tensor sendlist_tensor =
199199
torch::from_blob(lmp_list.sendlist, {total_send}, int32_option);
200-
comm_dict.insert("send_list", sendlist_tensor);
200+
comm_dict.insert_or_assign("send_list", sendlist_tensor);
201201
comm_dict.insert("send_proc", sendproc_tensor);
202202
comm_dict.insert("recv_proc", recvproc_tensor);
203203
comm_dict.insert("send_num", sendnum_tensor);

source/api_cc/src/DeepSpinPT.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void DeepSpinPT::compute(ENERGYVTYPE& ener,
205205
torch::Tensor sendlist_tensor =
206206
torch::from_blob(lmp_list.sendlist, {total_send}, int32_option);
207207
torch::Tensor has_spin = torch::tensor({1}, int32_option);
208-
comm_dict.insert("send_list", sendlist_tensor);
208+
comm_dict.insert_or_assign("send_list", sendlist_tensor);
209209
comm_dict.insert("send_proc", sendproc_tensor);
210210
comm_dict.insert("recv_proc", recvproc_tensor);
211211
comm_dict.insert("send_num", sendnum_tensor);

0 commit comments

Comments
 (0)