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

pt: add real atoms select in c++ interface #3375

Merged
merged 137 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 135 commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
dac7a76
add torch backend support
CaRoLZhangxy Jan 22, 2024
d3befec
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 22, 2024
0512118
fix some bugs and add atomic output
CaRoLZhangxy Jan 25, 2024
e7a5cb7
Merge branch 'devel' into devel
CaRoLZhangxy Jan 25, 2024
018a035
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 25, 2024
5ebb9bf
fix atom compute bugs
CaRoLZhangxy Jan 25, 2024
6924e06
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 25, 2024
26217bf
fix bugs
CaRoLZhangxy Jan 25, 2024
5e52ede
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Jan 25, 2024
c9bbd83
include deeppotpt.h
CaRoLZhangxy Jan 25, 2024
54e8166
add float and vector energytype implement
CaRoLZhangxy Jan 25, 2024
8f0219b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 25, 2024
0a8e19e
modify pt nlistdata name
CaRoLZhangxy Jan 25, 2024
ecd6651
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Jan 25, 2024
02cf214
fix some bugs
CaRoLZhangxy Jan 25, 2024
1d5fb1c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 25, 2024
f8dab4d
fix bug
CaRoLZhangxy Jan 25, 2024
795058c
fix bug
CaRoLZhangxy Jan 25, 2024
a3cd2ef
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 25, 2024
f4c6901
fix compute api
CaRoLZhangxy Jan 25, 2024
a9c47ec
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Jan 25, 2024
08ea8df
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 25, 2024
ca70171
Deprecated valuetype
CaRoLZhangxy Jan 25, 2024
7c66cf7
Deprecated valuetype
CaRoLZhangxy Jan 25, 2024
b9c74db
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 25, 2024
295751c
fix compute definition
CaRoLZhangxy Jan 26, 2024
fc3040b
implement virtual function
CaRoLZhangxy Jan 26, 2024
3e70a28
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 26, 2024
1576fbb
fix bug
CaRoLZhangxy Jan 26, 2024
af415f4
try direct =
CaRoLZhangxy Jan 26, 2024
306f7d9
fix vtype and type bug
CaRoLZhangxy Jan 26, 2024
39a8de4
fix energy to vector
CaRoLZhangxy Jan 26, 2024
c86c14e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 26, 2024
a2e2144
using namespace deepmd
CaRoLZhangxy Jan 26, 2024
e9b1078
fix bug
CaRoLZhangxy Jan 26, 2024
18c8cd3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 26, 2024
6b27552
pass no backend test
CaRoLZhangxy Jan 26, 2024
0d494b4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 26, 2024
b1cc754
implement detect backend
CaRoLZhangxy Jan 26, 2024
cedcdc7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 26, 2024
d157a4f
fix compilation error
njzjz Jan 26, 2024
522b7c8
a backet is missing...
njzjz Jan 26, 2024
f75dab6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 26, 2024
46f17ef
Merge branch 'deepmodeling:devel' into devel
CaRoLZhangxy Feb 3, 2024
6750312
fix model inference interface and add cpu
CaRoLZhangxy Feb 3, 2024
0a3e208
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 3, 2024
3de36b0
fix bug: device init
CaRoLZhangxy Feb 3, 2024
7bb1b1c
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Feb 3, 2024
e5d1533
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 3, 2024
e61a509
fix bug: device constructor
CaRoLZhangxy Feb 3, 2024
6c4a641
fix bug:device constructor
CaRoLZhangxy Feb 3, 2024
f0c1742
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Feb 3, 2024
22d1a7e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 3, 2024
a68742d
add tests, although not passed
njzjz Feb 3, 2024
e7a8878
Merge branch 'devel' of https://github.com/deepmodeling/deepmd-kit in…
CaRoLZhangxy Feb 20, 2024
9bcd8b7
Merge branch 'devel' of https://github.com/deepmodeling/deepmd-kit in…
CaRoLZhangxy Feb 21, 2024
ba510e8
fix memory leak and nlist dim
CaRoLZhangxy Feb 23, 2024
f05570b
Merge branch 'devel' of https://github.com/deepmodeling/deepmd-kit in…
CaRoLZhangxy Feb 23, 2024
936b29a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 23, 2024
93c9ddb
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Feb 23, 2024
16a3e6b
get cublasCreate(handle) error local
CaRoLZhangxy Feb 23, 2024
7245470
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 23, 2024
7b92391
fix error in no nlist impl
CaRoLZhangxy Feb 23, 2024
077473c
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Feb 23, 2024
fc084db
fix loading info
CaRoLZhangxy Feb 23, 2024
93dacb6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 23, 2024
eda885a
Merge branch 'devel' of https://github.com/deepmodeling/deepmd-kit in…
CaRoLZhangxy Feb 26, 2024
8b49cf1
pass cpu test
CaRoLZhangxy Feb 26, 2024
12c2796
download libtorch in test_cuda action
njzjz Feb 26, 2024
b390e6a
install wget...
njzjz Feb 26, 2024
48c1759
install unzip
njzjz Feb 26, 2024
768dd93
update the frozen model
njzjz Feb 26, 2024
2af65a7
update test ret
njzjz Feb 26, 2024
e9f582f
try to fix float type error
CaRoLZhangxy Feb 26, 2024
90e28a2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 26, 2024
19099e2
Merge branch 'devel' of https://github.com/deepmodeling/deepmd-kit in…
CaRoLZhangxy Feb 27, 2024
fdeb914
fix memory bug
CaRoLZhangxy Feb 27, 2024
89e151b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
fc18da6
fix bug: precision diff in model and inference api
CaRoLZhangxy Feb 27, 2024
cb5fe58
Merge branch 'devel' of https://github.com/deepmodeling/deepmd-kit in…
CaRoLZhangxy Feb 27, 2024
55db59a
Merge branches 'devel' and 'devel' of https://github.com/CaRoLZhangxy…
CaRoLZhangxy Feb 27, 2024
e6dc86a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
f960626
try to fix overflow
CaRoLZhangxy Feb 27, 2024
9627078
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Feb 27, 2024
6ba4125
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
d169d81
fix compile error
CaRoLZhangxy Feb 27, 2024
eea944e
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Feb 27, 2024
e77f5f3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
7cb94ae
try to fix overflow
CaRoLZhangxy Feb 27, 2024
ed453fd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
3a06dbf
update model
CaRoLZhangxy Feb 27, 2024
db798a7
try to fix nopbc
CaRoLZhangxy Feb 27, 2024
0a440c5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
bb45b40
try to export ut output
CaRoLZhangxy Feb 27, 2024
75c8bb9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
0450873
try to export ut input
CaRoLZhangxy Feb 27, 2024
19e3cd5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
5da17cb
modify output
CaRoLZhangxy Feb 27, 2024
e4b3265
try
CaRoLZhangxy Feb 27, 2024
55db21f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
600e534
try
CaRoLZhangxy Feb 27, 2024
7ba3fcf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
3be3cbc
delete print
CaRoLZhangxy Feb 27, 2024
1785cbd
get extended coord and atype
CaRoLZhangxy Feb 27, 2024
962cf64
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 27, 2024
b005365
delete output
CaRoLZhangxy Feb 27, 2024
499ed17
remove memset
CaRoLZhangxy Feb 28, 2024
f872b1f
try to resize atom energy
CaRoLZhangxy Feb 28, 2024
aab6771
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 28, 2024
414fffe
fix atom ener size
CaRoLZhangxy Feb 28, 2024
f3f6402
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 28, 2024
c074687
precision transfer in common api and skip type sel tests
CaRoLZhangxy Feb 28, 2024
de0e3ab
Merge branch 'devel' of https://github.com/deepmodeling/deepmd-kit in…
CaRoLZhangxy Feb 28, 2024
b1ad4bc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 28, 2024
1fa1afc
del ener model precison
CaRoLZhangxy Feb 28, 2024
4464966
updata test model
CaRoLZhangxy Feb 28, 2024
011f157
fix LD_LIBRARY_PATH
njzjz Feb 28, 2024
8d6c11c
fix codeql warning
njzjz Feb 28, 2024
99dd474
add tests for ipi and lammps
njzjz Feb 28, 2024
f4a3271
fix model path
njzjz Feb 28, 2024
1e8bdff
consistent box
njzjz Feb 28, 2024
da18860
remove commented codes
njzjz Feb 28, 2024
8d35cd1
Merge branch 'devel' of https://github.com/CaRoLZhangxy/deepmd-kit in…
CaRoLZhangxy Mar 1, 2024
6e8b6ff
add type sel
CaRoLZhangxy Mar 1, 2024
504e657
fix merge error
CaRoLZhangxy Mar 1, 2024
b64ce34
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 1, 2024
c475e4c
update model file
CaRoLZhangxy Mar 1, 2024
5efa5a2
add type sel ut
CaRoLZhangxy Mar 1, 2024
11d0e53
update fparam file
CaRoLZhangxy Mar 1, 2024
f20755b
export ut input
CaRoLZhangxy Mar 1, 2024
0b2d0d2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 1, 2024
92f8524
fix error
CaRoLZhangxy Mar 1, 2024
3cbd46d
fix bug: use nall_real instead of nall
CaRoLZhangxy Mar 1, 2024
7f7e2e5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 1, 2024
8a602a0
remove commonPT file
CaRoLZhangxy Mar 1, 2024
1f0a5cb
add missing include
CaRoLZhangxy Mar 1, 2024
d2532e8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions deepmd/pt/model/atomic_model/base_atomic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def reinit_pair_exclude(
# export public methods that are not abstract
get_nsel = torch.jit.export(BaseAtomicModel_.get_nsel)
get_nnei = torch.jit.export(BaseAtomicModel_.get_nnei)
get_ntypes = torch.jit.export(BaseAtomicModel_.get_ntypes)

@torch.jit.export
def get_model_def_script(self) -> str:
Expand Down
1 change: 0 additions & 1 deletion deepmd/pt/model/model/make_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ def output_type_cast(
)
return model_ret

@torch.jit.export
def format_nlist(
self,
extended_coord: torch.Tensor,
Expand Down
5 changes: 2 additions & 3 deletions source/api_cc/include/DeepPotPT.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <torch/torch.h>

#include "DeepPot.h"
#include "commonPT.h"

namespace deepmd {
/**
Expand Down Expand Up @@ -106,7 +105,7 @@ class DeepPotPT : public DeepPotBase {
const std::vector<VALUETYPE>& coord,
const std::vector<int>& atype,
const std::vector<VALUETYPE>& box,
// const int nghost,
const int nghost,
const InputNlist& lmp_list,
const int& ago,
const std::vector<VALUETYPE>& fparam = std::vector<VALUETYPE>(),
Expand Down Expand Up @@ -322,7 +321,7 @@ class DeepPotPT : public DeepPotBase {
// copy neighbor list info from host
torch::jit::script::Module module;
double rcut;
NeighborListDataPT nlist_data;
NeighborListData nlist_data;
int max_num_neighbors;
int gpu_id;
bool gpu_enabled;
Expand Down
1 change: 1 addition & 0 deletions source/api_cc/include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct NeighborListData {
void shuffle(const deepmd::AtomMap& map);
void shuffle_exclude_empty(const std::vector<int>& fwd_map);
void make_inlist(InputNlist& inlist);
void padding();
};

/**
Expand Down
24 changes: 0 additions & 24 deletions source/api_cc/include/commonPT.h

This file was deleted.

82 changes: 59 additions & 23 deletions source/api_cc/src/DeepPotPT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@

#include "common.h"
using namespace deepmd;
torch::Tensor createNlistTensor(const std::vector<std::vector<int>>& data) {
std::vector<torch::Tensor> row_tensors;

for (const auto& row : data) {
torch::Tensor row_tensor = torch::tensor(row, torch::kInt32).unsqueeze(0);
row_tensors.push_back(row_tensor);
}

torch::Tensor tensor = torch::cat(row_tensors, 0).unsqueeze(0);
return tensor;
}
DeepPotPT::DeepPotPT() : inited(false) {}
DeepPotPT::DeepPotPT(const std::string& model,
const int& gpu_rank,
Expand Down Expand Up @@ -60,7 +71,7 @@ void DeepPotPT::init(const std::string& model,

auto rcut_ = module.run_method("get_rcut").toDouble();
rcut = static_cast<double>(rcut_);
ntypes = 0;
ntypes = module.run_method("get_ntypes").toInt();
ntypes_spin = 0;
dfparam = module.run_method("get_dim_fparam").toInt();
daparam = module.run_method("get_dim_aparam").toInt();
Expand All @@ -78,6 +89,7 @@ void DeepPotPT::compute(ENERGYVTYPE& ener,
const std::vector<VALUETYPE>& coord,
const std::vector<int>& atype,
const std::vector<VALUETYPE>& box,
const int nghost,
const InputNlist& lmp_list,
const int& ago,
const std::vector<VALUETYPE>& fparam,
Expand All @@ -86,7 +98,6 @@ void DeepPotPT::compute(ENERGYVTYPE& ener,
if (!gpu_enabled) {
device = torch::Device(torch::kCPU);
}
std::vector<VALUETYPE> coord_wrapped = coord;
int natoms = atype.size();
auto options = torch::TensorOptions().dtype(torch::kFloat64);
torch::ScalarType floatType = torch::kFloat64;
Expand All @@ -96,18 +107,29 @@ void DeepPotPT::compute(ENERGYVTYPE& ener,
}
auto int_options = torch::TensorOptions().dtype(torch::kInt64);
auto int32_options = torch::TensorOptions().dtype(torch::kInt32);

// select real atoms
std::vector<VALUETYPE> dcoord, dforce, aparam_, datom_energy, datom_virial;
std::vector<int> datype, fwd_map, bkw_map;
int nghost_real, nall_real, nloc_real;
int nall = natoms;
select_real_atoms_coord(dcoord, datype, aparam_, nghost_real, fwd_map,
bkw_map, nall_real, nloc_real, coord, atype, aparam,
nghost, ntypes, 1, daparam, nall, aparam_nall);
std::cout << datype.size() << std::endl;
std::vector<VALUETYPE> coord_wrapped = dcoord;
at::Tensor coord_wrapped_Tensor =
torch::from_blob(coord_wrapped.data(), {1, natoms, 3}, options)
torch::from_blob(coord_wrapped.data(), {1, nall_real, 3}, options)
.to(device);
std::vector<int64_t> atype_64(atype.begin(), atype.end());
std::vector<int64_t> atype_64(datype.begin(), datype.end());
at::Tensor atype_Tensor =
torch::from_blob(atype_64.data(), {1, natoms}, int_options).to(device);
torch::from_blob(atype_64.data(), {1, nall_real}, int_options).to(device);
if (ago == 0) {
nlist_data.copy_from_nlist(lmp_list, max_num_neighbors);
nlist_data.copy_from_nlist(lmp_list);
nlist_data.shuffle_exclude_empty(fwd_map);
nlist_data.padding();
}
at::Tensor firstneigh =
torch::from_blob(nlist_data.jlist.data(),
{1, lmp_list.inum, max_num_neighbors}, int32_options);
at::Tensor firstneigh = createNlistTensor(nlist_data.jlist);
firstneigh_tensor = firstneigh.to(torch::kInt64).to(device);
bool do_atom_virial_tensor = true;
c10::optional<torch::Tensor> optional_tensor;
Expand All @@ -119,13 +141,13 @@ void DeepPotPT::compute(ENERGYVTYPE& ener,
.to(device);
}
c10::optional<torch::Tensor> aparam_tensor;
if (!aparam.empty()) {
aparam_tensor =
torch::from_blob(const_cast<VALUETYPE*>(aparam.data()),
{1, lmp_list.inum,
static_cast<long int>(aparam.size()) / lmp_list.inum},
options)
.to(device);
if (!aparam_.empty()) {
aparam_tensor = torch::from_blob(
const_cast<VALUETYPE*>(aparam_.data()),
{1, lmp_list.inum,
static_cast<long int>(aparam_.size()) / lmp_list.inum},
options)
.to(device);
}
c10::Dict<c10::IValue, c10::IValue> outputs =
module
Expand All @@ -145,24 +167,36 @@ 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);
atom_energy.resize(natoms, 0.0); // resize to nall to be consistenet with TF.
atom_energy.assign(
datom_energy.resize(nall_real,
0.0); // resize to nall to be consistenet with TF.
datom_energy.assign(
cpu_atom_energy_.data_ptr<VALUETYPE>(),
cpu_atom_energy_.data_ptr<VALUETYPE>() + cpu_atom_energy_.numel());
torch::Tensor flat_force_ = force_.toTensor().view({-1}).to(floatType);
torch::Tensor cpu_force_ = flat_force_.to(torch::kCPU);
force.assign(cpu_force_.data_ptr<VALUETYPE>(),
cpu_force_.data_ptr<VALUETYPE>() + cpu_force_.numel());
dforce.assign(cpu_force_.data_ptr<VALUETYPE>(),
cpu_force_.data_ptr<VALUETYPE>() + cpu_force_.numel());
torch::Tensor flat_virial_ = virial_.toTensor().view({-1}).to(floatType);
torch::Tensor cpu_virial_ = flat_virial_.to(torch::kCPU);
virial.assign(cpu_virial_.data_ptr<VALUETYPE>(),
cpu_virial_.data_ptr<VALUETYPE>() + cpu_virial_.numel());
torch::Tensor flat_atom_virial_ =
atom_virial_.toTensor().view({-1}).to(floatType);
torch::Tensor cpu_atom_virial_ = flat_atom_virial_.to(torch::kCPU);
atom_virial.assign(
datom_virial.assign(
cpu_atom_virial_.data_ptr<VALUETYPE>(),
cpu_atom_virial_.data_ptr<VALUETYPE>() + cpu_atom_virial_.numel());
int nframes = 1;
// bkw map
force.resize(static_cast<size_t>(nframes) * fwd_map.size() * 3);
atom_energy.resize(static_cast<size_t>(nframes) * fwd_map.size());
atom_virial.resize(static_cast<size_t>(nframes) * fwd_map.size() * 9);
select_map<VALUETYPE>(force, dforce, bkw_map, 3, nframes, fwd_map.size(),
nall_real);
select_map<VALUETYPE>(atom_energy, datom_energy, bkw_map, 1, nframes,
fwd_map.size(), nall_real);
select_map<VALUETYPE>(atom_virial, datom_virial, bkw_map, 9, nframes,
fwd_map.size(), nall_real);
}
template void DeepPotPT::compute<double, std::vector<ENERGYTYPE>>(
std::vector<ENERGYTYPE>& ener,
Expand All @@ -173,6 +207,7 @@ template void DeepPotPT::compute<double, std::vector<ENERGYTYPE>>(
const std::vector<double>& coord,
const std::vector<int>& atype,
const std::vector<double>& box,
const int nghost,
const InputNlist& lmp_list,
const int& ago,
const std::vector<double>& fparam,
Expand All @@ -186,6 +221,7 @@ template void DeepPotPT::compute<float, std::vector<ENERGYTYPE>>(
const std::vector<float>& coord,
const std::vector<int>& atype,
const std::vector<float>& box,
const int nghost,
const InputNlist& lmp_list,
const int& ago,
const std::vector<float>& fparam,
Expand Down Expand Up @@ -353,7 +389,7 @@ void DeepPotPT::computew(std::vector<double>& ener,
const std::vector<double>& fparam,
const std::vector<double>& aparam) {
compute(ener, force, virial, atom_energy, atom_virial, coord, atype, box,
inlist, ago, fparam, aparam);
nghost, inlist, ago, fparam, aparam);
}
void DeepPotPT::computew(std::vector<double>& ener,
std::vector<float>& force,
Expand All @@ -369,7 +405,7 @@ void DeepPotPT::computew(std::vector<double>& ener,
const std::vector<float>& fparam,
const std::vector<float>& aparam) {
compute(ener, force, virial, atom_energy, atom_virial, coord, atype, box,
inlist, ago, fparam, aparam);
nghost, inlist, ago, fparam, aparam);
}
void DeepPotPT::computew_mixed_type(std::vector<double>& ener,
std::vector<double>& force,
Expand Down
10 changes: 10 additions & 0 deletions source/api_cc/src/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,16 @@ void deepmd::NeighborListData::shuffle_exclude_empty(
ilist = new_ilist;
jlist = new_jlist;
}
void deepmd::NeighborListData::padding() {
size_t max_length = 0;
for (const auto& row : jlist) {
max_length = std::max(max_length, row.size());
}

for (int i = 0; i < jlist.size(); i++) {
jlist[i].resize(max_length, -1);
}
}

void deepmd::NeighborListData::make_inlist(InputNlist& inlist) {
int nloc = ilist.size();
Expand Down
23 changes: 0 additions & 23 deletions source/api_cc/src/commonPT.cc

This file was deleted.

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 @@ -402,7 +402,6 @@ TYPED_TEST(TestInferDeepPotAPt, cpu_lmp_nlist_2rc) {
}

TYPED_TEST(TestInferDeepPotAPt, cpu_lmp_nlist_type_sel) {
GTEST_SKIP() << "Skipping this test for unsupported";
using VALUETYPE = TypeParam;
std::vector<VALUETYPE>& coord = this->coord;
std::vector<int>& atype = this->atype;
Expand Down Expand Up @@ -465,7 +464,6 @@ TYPED_TEST(TestInferDeepPotAPt, cpu_lmp_nlist_type_sel) {
}

TYPED_TEST(TestInferDeepPotAPt, cpu_lmp_nlist_type_sel_atomic) {
GTEST_SKIP() << "Skipping this test for unsupported";
using VALUETYPE = TypeParam;
std::vector<VALUETYPE>& coord = this->coord;
std::vector<int>& atype = this->atype;
Expand Down
Binary file modified source/tests/infer/deeppot_sea.pth
Binary file not shown.
Binary file modified source/tests/infer/fparam_aparam.pth
Binary file not shown.
Loading