Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 10 additions & 10 deletions source/api_cc/src/DataModifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,18 @@ void DipoleChargeModifier::run_model(
Tensor output_f = output_tensors[cc++];
Tensor output_v = output_tensors[cc++];
Tensor output_av = output_tensors[cc++];
assert(output_f.dims() == 2), "dim of output tensor should be 2";
assert(output_v.dims() == 2), "dim of output tensor should be 2";
assert(output_av.dims() == 2), "dim of output tensor should be 2";
assert(output_f.dims() == 2 && "dim of output tensor should be 2");
assert(output_v.dims() == 2 && "dim of output tensor should be 2");
assert(output_av.dims() == 2 && "dim of output tensor should be 2");
int nframes = output_f.dim_size(0);
int natoms = output_f.dim_size(1) / 3;
assert(output_f.dim_size(0) == 1), "nframes should match";
assert(natoms == nall), "natoms should be nall";
assert(output_v.dim_size(0) == nframes), "nframes should match";
assert(output_v.dim_size(1) == 9), "dof of virial should be 9";
assert(output_av.dim_size(0) == nframes), "nframes should match";
assert(output_av.dim_size(1) == natoms * 9),
"dof of atom virial should be 9 * natoms";
assert(output_f.dim_size(0) == 1 && "nframes should match");
assert(natoms == nall && "natoms should be nall");
assert(output_v.dim_size(0) == nframes && "nframes should match");
assert(output_v.dim_size(1) == 9 && "dof of virial should be 9");
assert(output_av.dim_size(0) == nframes && "nframes should match");
assert(output_av.dim_size(1) == natoms * 9 &&
"dof of atom virial should be 9 * natoms");

auto of = output_f.flat<MODELTYPE>();
auto ov = output_v.flat<MODELTYPE>();
Expand Down
38 changes: 20 additions & 18 deletions source/api_cc/src/DeepTensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,25 +201,27 @@ void DeepTensor::run_model(
Tensor output_at = output_tensors[3];
Tensor output_av = output_tensors[4];
// this is the new model, output has to be rank 2 tensor
assert(output_gt.dims() == 2), "dim of output tensor should be 2";
assert(output_f.dims() == 2), "dim of output tensor should be 2";
assert(output_v.dims() == 2), "dim of output tensor should be 2";
assert(output_at.dims() == 2), "dim of output tensor should be 2";
assert(output_av.dims() == 2), "dim of output tensor should be 2";
assert(output_gt.dims() == 2 && "dim of output tensor should be 2");
assert(output_f.dims() == 2 && "dim of output tensor should be 2");
assert(output_v.dims() == 2 && "dim of output tensor should be 2");
assert(output_at.dims() == 2 && "dim of output tensor should be 2");
assert(output_av.dims() == 2 && "dim of output tensor should be 2");
// also check the tensor shapes
assert(output_gt.dim_size(0) == 1), "nframes should match";
assert(output_gt.dim_size(1) == odim), "dof of global tensor should be odim";
assert(output_f.dim_size(0) == 1), "nframes should match";
assert(output_f.dim_size(1) == odim * nall * 3),
"dof of force should be odim * nall * 3";
assert(output_v.dim_size(0) == 1), "nframes should match";
assert(output_v.dim_size(1) == odim * 9), "dof of virial should be odim * 9";
assert(output_at.dim_size(0) == 1), "nframes should match";
assert(output_at.dim_size(1) == nsel * odim),
"dof of atomic tensor should be nsel * odim";
assert(output_av.dim_size(0) == 1), "nframes should match";
assert(output_av.dim_size(1) == odim * nall * 9),
"dof of atomic virial should be odim * nall * 9";
assert(output_gt.dim_size(0) == 1 && "nframes should match");
assert(output_gt.dim_size(1) == odim &&
"dof of global tensor should be odim");
assert(output_f.dim_size(0) == 1 && "nframes should match");
assert(output_f.dim_size(1) == odim * nall * 3 &&
"dof of force should be odim * nall * 3");
assert(output_v.dim_size(0) == 1 && "nframes should match");
assert(output_v.dim_size(1) == odim * 9 &&
"dof of virial should be odim * 9");
assert(output_at.dim_size(0) == 1 && "nframes should match");
assert(output_at.dim_size(1) == nsel * odim &&
"dof of atomic tensor should be nsel * odim");
assert(output_av.dim_size(0) == 1 && "nframes should match");
assert(output_av.dim_size(1) == odim * nall * 9 &&
"dof of atomic virial should be odim * nall * 9");

auto ogt = output_gt.flat<ENERGYTYPE>();
auto of = output_f.flat<MODELTYPE>();
Expand Down
18 changes: 9 additions & 9 deletions source/api_cc/src/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -849,13 +849,13 @@ void deepmd::select_map(std::vector<VT>& out,
const int& nall2) {
for (int kk = 0; kk < nframes; ++kk) {
#ifdef DEBUG
assert(in.size() / stride * stride == in.size()),
"in size should be multiples of stride"
assert(in.size() / stride * stride == in.size() &&
"in size should be multiples of stride")
#endif
for (int ii = 0; ii < in.size() / stride / nframes; ++ii) {
#ifdef DEBUG
assert(ii < idx_map.size()), "idx goes over the idx map size";
assert(idx_map[ii] < out.size()), "mappped idx goes over the out size";
assert(ii < idx_map.size() && "idx goes over the idx map size");
assert(idx_map[ii] < out.size() && "mappped idx goes over the out size");
#endif
if (idx_map[ii] >= 0) {
int to_ii = idx_map[ii];
Expand Down Expand Up @@ -896,13 +896,13 @@ void deepmd::select_map_inv(std::vector<VT>& out,
const std::vector<int>& idx_map,
const int& stride) {
#ifdef DEBUG
assert(in.size() / stride * stride == in.size()),
"in size should be multiples of stride"
assert(in.size() / stride * stride == in.size() &&
"in size should be multiples of stride");
#endif
for (int ii = 0; ii < out.size() / stride; ++ii) {
for (int ii = 0; ii < out.size() / stride; ++ii) {
#ifdef DEBUG
assert(ii < idx_map.size()), "idx goes over the idx map size";
assert(idx_map[ii] < in.size()), "from idx goes over the in size";
assert(ii < idx_map.size() && "idx goes over the idx map size");
assert(idx_map[ii] < in.size() && "from idx goes over the in size");
#endif
if (idx_map[ii] >= 0) {
int from_ii = idx_map[ii];
Expand Down
12 changes: 6 additions & 6 deletions source/lib/include/ComputeDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,8 @@ void compute_descriptor_se_a_extf(std::vector<double> &descrpt_a,
ef[ii] = ef_[ii];
}
}
assert(fabs(deepmd::dot3(ef, ef) - 1.0) < 1e-12),
"ef should be a normalized std::vector";
assert(fabs(deepmd::dot3(ef, ef) - 1.0) < 1e-12 &&
"ef should be a normalized std::vector");

// compute the diff of the neighbors
std::vector<std::vector<double> > sel_a_diff(sec_a.back());
Expand Down Expand Up @@ -970,8 +970,8 @@ void compute_descriptor_se_a_ef_para(std::vector<double> &descrpt_a,
ef[ii] = ef_[ii];
}
}
assert(fabs(deepmd::dot3(ef, ef) - 1.0) < 1e-12),
"ef should be a normalized vector";
assert(fabs(deepmd::dot3(ef, ef) - 1.0) < 1e-12 &&
"ef should be a normalized vector");

// compute the diff of the neighbors
std::vector<std::vector<double> > sel_a_diff(sec_a.back());
Expand Down Expand Up @@ -1107,8 +1107,8 @@ void compute_descriptor_se_a_ef_vert(std::vector<double> &descrpt_a,
ef[ii] = ef_[ii];
}
}
assert(fabs(deepmd::dot3(ef, ef) - 1.0) < 1e-12),
"ef should be a normalized vector";
assert(fabs(deepmd::dot3(ef, ef) - 1.0) < 1e-12 &&
"ef should be a normalized vector");

// compute the diff of the neighbors
std::vector<std::vector<double> > sel_a_diff(sec_a.back());
Expand Down
4 changes: 2 additions & 2 deletions source/lmp/fix_dplr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ FixDPLR::FixDPLR(LAMMPS *lmp, int narg, char **arg)
break;
}
}
assert(map_vec.size() % 2 == 0),
"number of ints provided by type_associate should be even";
assert(map_vec.size() % 2 == 0 &&
"number of ints provided by type_associate should be even");

// dpt.init(model);
// dtm.init("frozen_model.pb");
Expand Down