This issue comes from a Codex global scan of deepmodeling/deepmd-kit at commit 73de44b1f94471b2e3bdb6b11f57b34d7bc791bb.
Problem
The examples/infer_water README tells users to run CMake and make:
|
Build the project using |
|
|
|
```sh |
|
cmake -DCMAKE_PREFIX_PATH=$deepmd_root . |
|
make |
|
``` |
The CMake project builds the four inference binaries:
|
# C++ example |
|
add_executable(infer_water_cc infer_water.cpp) |
|
# link DeePMD-kit C++ API |
|
target_link_libraries(infer_water_cc PRIVATE DeePMD::deepmd_cc) |
|
|
|
# C example |
|
add_executable(infer_water_c infer_water.c) |
|
# link DeePMD-kit C API |
|
target_link_libraries(infer_water_c PRIVATE DeePMD::deepmd_c) |
|
|
|
# header-only example |
|
add_executable(infer_water_hpp infer_water_hpp.cpp) |
|
# link DeePMD-kit C API |
|
target_link_libraries(infer_water_hpp PRIVATE DeePMD::deepmd_c) |
|
|
|
# nlist |
|
add_executable(infer_water_nlist infer_water_nlist.cpp) |
|
# link DeePMD-kit C API |
|
target_link_libraries(infer_water_nlist PRIVATE DeePMD::deepmd_c) |
Those binaries all open graph.pb from the current working directory:
|
int main() { |
|
const char* model = "graph.pb"; |
|
double coord[] = {1., 0., 0., 0., 0., 1.5, 1., 0., 3.}; |
|
double cell[] = {10., 0., 0., 0., 10., 0., 0., 0., 10.}; |
|
int atype[] = {1, 0, 1}; |
|
// init C pointers with given memory |
|
double* e = malloc(sizeof(*e)); |
|
double* f = malloc(sizeof(*f) * 9); // natoms * 3 |
|
double* v = malloc(sizeof(*v) * 9); |
|
double* ae = malloc(sizeof(*ae) * 9); // natoms |
|
double* av = malloc(sizeof(*av) * 27); // natoms * 9 |
|
// DP model |
|
DP_DeepPot* dp = DP_NewDeepPot(model); |
|
DP_DeepPotCompute(dp, 3, coord, atype, cell, e, f, v, ae, av); |
|
int main() { |
|
deepmd::DeepPot dp("graph.pb"); |
|
std::vector<double> coord = {1., 0., 0., 0., 0., 1.5, 1., 0., 3.}; |
|
std::vector<double> cell = {10., 0., 0., 0., 10., 0., 0., 0., 10.}; |
|
std::vector<int> atype = {1, 0, 1}; |
|
double e; |
|
std::vector<double> f, v; |
|
dp.compute(e, f, v, coord, atype, cell); |
|
int main() { |
|
deepmd::hpp::DeepPot dp("graph.pb"); |
|
std::vector<double> coord = {1., 0., 0., 0., 0., 1.5, 1., 0., 3.}; |
|
std::vector<double> cell = {10., 0., 0., 0., 10., 0., 0., 0., 10.}; |
|
std::vector<int> atype = {1, 0, 1}; |
|
double e; |
|
std::vector<double> f, v; |
|
dp.compute(e, f, v, coord, atype, cell); |
|
int main() { |
|
DeepPot dp("graph.pb"); |
|
std::vector<double> coord = {1., 0., 0., 0., 0., 1.5, 1., 0., 3.}; |
|
std::vector<double> cell = {10., 0., 0., 0., 10., 0., 0., 0., 10.}; |
|
std::vector<int> atype = {1, 0, 1}; |
|
// neighbor list |
|
std::vector<std::vector<int>> nlist_vec = {{1, 2}, {0, 2}, {0, 1}}; |
|
double e; |
|
std::vector<double> f, v; |
|
std::vector<int> ilist(3), numneigh(3); |
|
std::vector<int*> firstneigh(3); |
|
InputNlist nlist(3, &ilist[0], &numneigh[0], &firstneigh[0]); |
|
convert_nlist(nlist, nlist_vec); |
|
dp.compute(e, f, v, coord, atype, cell, 0, nlist, 0); |
graph.pb is ignored rather than checked in:
There is a convert_model.c helper that can create it, but the helper is not built by CMakeLists.txt and the README does not tell users to run it:
|
int main() { |
|
DP_ConvertPbtxtToPb("../../source/tests/infer/deeppot.pbtxt", "graph.pb"); |
|
return 0; |
Impact
Following the documented build commands produces binaries that fail at runtime unless the user already knows how to create graph.pb. The hidden conversion helper also depends on a test fixture path, which makes the example less self-contained.
Suggested fix
Either document the required model-generation step explicitly, or wire convert_model.c into the CMake project as a helper target and have the README run it before the inference examples.
This issue comes from a Codex global scan of
deepmodeling/deepmd-kitat commit73de44b1f94471b2e3bdb6b11f57b34d7bc791bb.Problem
The
examples/infer_waterREADME tells users to run CMake andmake:deepmd-kit/examples/infer_water/README.md
Lines 5 to 10 in 73de44b
The CMake project builds the four inference binaries:
deepmd-kit/examples/infer_water/CMakeLists.txt
Lines 7 to 25 in 73de44b
Those binaries all open
graph.pbfrom the current working directory:deepmd-kit/examples/infer_water/infer_water.c
Lines 7 to 20 in 73de44b
deepmd-kit/examples/infer_water/infer_water.cpp
Lines 4 to 11 in 73de44b
deepmd-kit/examples/infer_water/infer_water_hpp.cpp
Lines 6 to 13 in 73de44b
deepmd-kit/examples/infer_water/infer_water_nlist.cpp
Lines 18 to 31 in 73de44b
graph.pbis ignored rather than checked in:deepmd-kit/examples/infer_water/.gitignore
Line 10 in 73de44b
There is a
convert_model.chelper that can create it, but the helper is not built byCMakeLists.txtand the README does not tell users to run it:deepmd-kit/examples/infer_water/convert_model.c
Lines 4 to 6 in 73de44b
Impact
Following the documented build commands produces binaries that fail at runtime unless the user already knows how to create
graph.pb. The hidden conversion helper also depends on a test fixture path, which makes the example less self-contained.Suggested fix
Either document the required model-generation step explicitly, or wire
convert_model.cinto the CMake project as a helper target and have the README run it before the inference examples.