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
4 changes: 4 additions & 0 deletions .github/workflows/suppr.txt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
leak:libpaddle_inference
# TensorFlow 2.20
leak:xla::
leak:mlir::
leak:llvm::
34 changes: 30 additions & 4 deletions .github/workflows/test_cc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,23 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
check_memleak: [true, false]
include:
- check_memleak: true
enable_tensorflow: true
enable_pytorch: true
enable_paddle: false
- check_memleak: true
enable_tensorflow: false
enable_pytorch: false
enable_paddle: true
- check_memleak: false
enable_tensorflow: true
enable_pytorch: true
enable_paddle: false
- check_memleak: false
enable_tensorflow: false
enable_pytorch: false
enable_paddle: true
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
Expand Down Expand Up @@ -46,31 +62,41 @@ jobs:
CMAKE_GENERATOR: Ninja
CXXFLAGS: ${{ matrix.check_memleak && '-fsanitize=leak' || '' }}
LSAN_OPTIONS: suppressions=${{ github.workspace }}/.github/workflows/suppr.txt
ENABLE_TENSORFLOW: ${{ matrix.enable_tensorflow && 'TRUE' || 'FALSE' }}
ENABLE_PYTORCH: ${{ matrix.enable_pytorch && 'TRUE' || 'FALSE' }}
ENABLE_PADDLE: ${{ matrix.enable_paddle && 'TRUE' || 'FALSE' }}
# test lammps
- run: |
cp ${{ github.workspace }}/source/build_tests/paddle_inference_install_dir/paddle/lib/*.so ${{ github.workspace }}/dp_test/lib/
cp ${{ github.workspace }}/source/build_tests/paddle_inference_install_dir/third_party/install/onednn/lib/* ${{ github.workspace }}/dp_test/lib/
cp ${{ github.workspace }}/source/build_tests/paddle_inference_install_dir/third_party/install/mklml/lib/* ${{ github.workspace }}/dp_test/lib/
if: matrix.enable_paddle
- run: |
export LD_LIBRARY_PATH=${{ github.workspace }}/dp_test/lib:$LD_LIBRARY_PATH
pytest --cov=deepmd source/lmp/tests
env:
OMP_NUM_THREADS: 1
TF_INTRA_OP_PARALLELISM_THREADS: 1
TF_INTER_OP_PARALLELISM_THREADS: 1
LAMMPS_PLUGIN_PATH: ${{ github.workspace }}/dp_test/lib/deepmd_lmp
ENABLE_TENSORFLOW: ${{ matrix.enable_tensorflow && '1' || '0' }}
ENABLE_PYTORCH: ${{ matrix.enable_pytorch && '1' || '0' }}
ENABLE_JAX: ${{ matrix.enable_tensorflow && '1' || '0' }}
ENABLE_PADDLE: ${{ matrix.enable_paddle && '1' || '0' }}
if: ${{ !matrix.check_memleak }}
# test ipi
- run: |
export PATH=${{ github.workspace }}/dp_test/bin:$PATH
cp ${{ github.workspace }}/source/build_tests/paddle_inference_install_dir/paddle/lib/*.so ${{ github.workspace }}/dp_test/lib/
cp ${{ github.workspace }}/source/build_tests/paddle_inference_install_dir/third_party/install/onednn/lib/* ${{ github.workspace }}/dp_test/lib/
cp ${{ github.workspace }}/source/build_tests/paddle_inference_install_dir/third_party/install/mklml/lib/* ${{ github.workspace }}/dp_test/lib/
pytest --cov=deepmd source/ipi/tests
env:
OMP_NUM_THREADS: 1
TF_INTRA_OP_PARALLELISM_THREADS: 1
TF_INTER_OP_PARALLELISM_THREADS: 1
LD_LIBRARY_PATH: ${{ github.workspace }}/dp_test/lib
ENABLE_TENSORFLOW: ${{ matrix.enable_tensorflow && '1' || '0' }}
ENABLE_PYTORCH: ${{ matrix.enable_pytorch && '1' || '0' }}
ENABLE_JAX: ${{ matrix.enable_tensorflow && '1' || '0' }}
ENABLE_PADDLE: ${{ matrix.enable_paddle && '1' || '0' }}
if: ${{ !matrix.check_memleak }}
- uses: codecov/codecov-action@v5
env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
- run: pytest --cov=deepmd source/tests --splits 6 --group ${{ matrix.group }} --store-durations --clean-durations --durations-path=.test_durations --splitting-algorithm least_duration
env:
NUM_WORKERS: 0
DP_CI_IMPORT_PADDLE_BEFORE_TF: 1
FLAGS_use_stride_compute_kernel: 0
- name: Test TF2 eager mode
run: pytest --cov=deepmd --cov-append source/tests/consistent/io/test_io.py source/jax2tf_tests
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ dev = [
pin_tensorflow_cpu = [
# https://github.com/tensorflow/tensorflow/issues/75279
# macos x86 has been deprecated
"tensorflow-cpu~=2.18.0; platform_machine=='x86_64' and platform_system == 'Linux'",
"tensorflow-cpu>=2.18,<2.21; platform_machine=='x86_64' and platform_system == 'Linux'",
"tensorflow~=2.18.0; (platform_machine!='x86_64' or platform_system != 'Linux') and (platform_machine!='x86_64' or platform_system != 'Darwin')",
"tensorflow; platform_machine=='x86_64' and platform_system == 'Darwin'",
]
Expand Down
13 changes: 13 additions & 0 deletions source/api_c/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ target_link_libraries(runUnitTests_c PRIVATE GTest::gtest_main ${LIB_DEEPMD_C}
coverage_config)
target_link_libraries(runUnitTests_c PRIVATE ${LIB_DEEPMD} ${LIB_DEEPMD_CC})

if(ENABLE_TENSORFLOW)
target_compile_definitions(runUnitTests_c PRIVATE BUILD_TENSORFLOW)
endif()
if(ENABLE_PYTORCH)
target_compile_definitions(runUnitTests_c PRIVATE BUILD_PYTORCH)
endif()
if(ENABLE_JAX)
target_compile_definitions(runUnitTests_c PRIVATE BUILD_JAX)
endif()
if(ENABLE_PADDLE)
target_compile_definitions(runUnitTests_c PRIVATE BUILD_PADDLE)
endif()

if(UNIX AND NOT APPLE)
find_library(RT_LIBRARY rt)
if(RT_LIBRARY)
Expand Down
9 changes: 9 additions & 0 deletions source/api_c/tests/test_deepdipole_hpp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class TestInferDeepDipole : public ::testing::Test {
deepmd::hpp::DeepTensor dp;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
deepmd::hpp::convert_pbtxt_to_pb("../../tests/infer/deepdipole.pbtxt",
"deepdipole.pb");

Expand Down Expand Up @@ -221,6 +224,9 @@ class TestInferDeepDipoleNew : public ::testing::Test {
deepmd::hpp::DeepTensor dp;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
std::string file_name = "../../tests/infer/deepdipole_new.pbtxt";
deepmd::hpp::convert_pbtxt_to_pb("../../tests/infer/deepdipole_new.pbtxt",
"deepdipole_new.pb");
Expand Down Expand Up @@ -434,6 +440,9 @@ class TestInferDeepDipoleFake : public ::testing::Test {
deepmd::hpp::DeepTensor dp;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
deepmd::hpp::convert_pbtxt_to_pb("../../tests/infer/deepdipole_fake.pbtxt",
"deepdipole_fake.pb");

Expand Down
6 changes: 6 additions & 0 deletions source/api_c/tests/test_deeppolar_hpp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class TestInferDeepPolar : public ::testing::Test {
deepmd::hpp::DeepTensor dp;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
std::string file_name = "../../tests/infer/deeppolar.pbtxt";
deepmd::hpp::convert_pbtxt_to_pb("../../tests/infer/deeppolar.pbtxt",
"deeppolar.pb");
Expand Down Expand Up @@ -453,6 +456,9 @@ class TestInferDeepPolarNew : public ::testing::Test {
deepmd::hpp::DeepTensor dp;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
std::string file_name = "../../tests/infer/deeppolar_new.pbtxt";
deepmd::hpp::convert_pbtxt_to_pb("../../tests/infer/deeppolar_new.pbtxt",
"deeppolar_new.pb");
Expand Down
10 changes: 8 additions & 2 deletions source/api_c/tests/test_deeppot_a.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ class TestInferDeepPotA : public ::testing::Test {
double expected_tot_e;
std::vector<double> expected_tot_v;

DP_DeepPot* dp;
DP_DeepPot* dp = nullptr;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
const char* file_name = "../../tests/infer/deeppot.pbtxt";
const char* model_file = "deeppot.pb";
DP_ConvertPbtxtToPb(file_name, model_file);
Expand Down Expand Up @@ -242,9 +245,12 @@ class TestInferDeepPotANoPBC : public ::testing::Test {
double expected_tot_e;
std::vector<double> expected_tot_v;

DP_DeepPot* dp;
DP_DeepPot* dp = nullptr;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
const char* file_name = "../../tests/infer/deeppot.pbtxt";
const char* model_file = "deeppot.pb";
DP_ConvertPbtxtToPb(file_name, model_file);
Expand Down
6 changes: 6 additions & 0 deletions source/api_c/tests/test_deeppot_a_fparam_aparam.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class TestInferDeepPotAFParamAParam : public ::testing::Test {
deepmd::hpp::DeepPot dp;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
std::string file_name = "../../tests/infer/fparam_aparam.pbtxt";
deepmd::hpp::convert_pbtxt_to_pb(file_name, "fparam_aparam.pb");

Expand Down Expand Up @@ -394,6 +397,9 @@ class TestInferAParamNAll : public ::testing::Test {
deepmd::hpp::DeepPot dp;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
std::string file_name = "../../tests/infer/pairwise_dprc.pbtxt";
deepmd::hpp::convert_pbtxt_to_pb(file_name, "pairwise_dprc.pb");
dp.init("pairwise_dprc.pb");
Expand Down
6 changes: 6 additions & 0 deletions source/api_c/tests/test_deeppot_a_fparam_aparam_nframes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ class TestInferDeepPotAFparamAparamNFrames : public ::testing::Test {
deepmd::hpp::DeepPot dp;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
std::string file_name = "../../tests/infer/fparam_aparam.pbtxt";
deepmd::hpp::convert_pbtxt_to_pb("../../tests/infer/fparam_aparam.pbtxt",
"fparam_aparam.pb");
Expand Down Expand Up @@ -757,6 +760,9 @@ class TestInferDeepPotAFparamAparamNFramesSingleParam : public ::testing::Test {
deepmd::hpp::DeepPot dp;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
std::string file_name = "../../tests/infer/fparam_aparam.pbtxt";
deepmd::hpp::convert_pbtxt_to_pb("../../tests/infer/fparam_aparam.pbtxt",
"fparam_aparam.pb");
Expand Down
6 changes: 6 additions & 0 deletions source/api_c/tests/test_deeppot_a_hpp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class TestInferDeepPotAHPP : public ::testing::Test {
deepmd::hpp::DeepPot dp;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
std::string file_name = "../../tests/infer/deeppot.pbtxt";
deepmd::hpp::convert_pbtxt_to_pb("../../tests/infer/deeppot.pbtxt",
"deeppot.pb");
Expand Down Expand Up @@ -557,6 +560,9 @@ class TestInferDeepPotANoPbcHPP : public ::testing::Test {
deepmd::hpp::DeepPot dp;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
std::string file_name = "../../tests/infer/deeppot.pbtxt";
deepmd::hpp::convert_pbtxt_to_pb(file_name, "deeppot.pb");

Expand Down
6 changes: 6 additions & 0 deletions source/api_c/tests/test_deeppot_a_nframes_hpp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class TestInferDeepPotANFrames : public ::testing::Test {
deepmd::hpp::DeepPot dp;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
std::string file_name = "../../tests/infer/deeppot.pbtxt";
deepmd::hpp::convert_pbtxt_to_pb("../../tests/infer/deeppot.pbtxt",
"deeppot.pb");
Expand Down Expand Up @@ -719,6 +722,9 @@ class TestInferDeepPotANFramesNoPbc : public ::testing::Test {
deepmd::hpp::DeepPot dp;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
std::string file_name = "../../tests/infer/deeppot.pbtxt";
deepmd::hpp::convert_pbtxt_to_pb(file_name, "deeppot.pb");

Expand Down
3 changes: 3 additions & 0 deletions source/api_c/tests/test_deeppot_model_devi_fparam_aparam.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class TestInferDeepPotModeDeviFparamAparam : public ::testing::Test {
deepmd::hpp::DeepPotModelDevi dp_md;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
{
std::string file_name = "../../tests/infer/fparam_aparam.pbtxt";
deepmd::hpp::convert_pbtxt_to_pb("../../tests/infer/fparam_aparam.pbtxt",
Expand Down
6 changes: 6 additions & 0 deletions source/api_c/tests/test_deeppot_model_devi_hpp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class TestInferDeepPotModeDevi : public ::testing::Test {
deepmd::hpp::DeepPotModelDevi dp_md;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
{
std::string file_name = "../../tests/infer/deeppot.pbtxt";
deepmd::hpp::convert_pbtxt_to_pb("../../tests/infer/deeppot.pbtxt",
Expand Down Expand Up @@ -74,6 +77,9 @@ class TestInferDeepPotModeDeviPython : public ::testing::Test {
deepmd::hpp::DeepPotModelDevi dp_md;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
{
std::string file_name = "../../tests/infer/deeppot.pbtxt";
deepmd::hpp::convert_pbtxt_to_pb("../../tests/infer/deeppot.pbtxt",
Expand Down
10 changes: 8 additions & 2 deletions source/api_c/tests/test_deepspin_a.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ class TestInferDeepSpinA : public ::testing::Test {
double expected_tot_e;
// std::vector<double> expected_tot_v;

DP_DeepSpin* dp;
DP_DeepSpin* dp = nullptr;

void SetUp() override {
#ifndef BUILD_PYTORCH
GTEST_SKIP() << "Skip because PyTorch support is not enabled.";
#endif
dp = DP_NewDeepSpin("../../tests/infer/deeppot_dpa_spin.pth");

natoms = expected_e.size();
Expand Down Expand Up @@ -233,9 +236,12 @@ class TestInferDeepSpinANoPBC : public ::testing::Test {
double expected_tot_e;
// std::vector<double> expected_tot_v;

DP_DeepSpin* dp;
DP_DeepSpin* dp = nullptr;

void SetUp() override {
#ifndef BUILD_PYTORCH
GTEST_SKIP() << "Skip because PyTorch support is not enabled.";
#endif
dp = DP_NewDeepSpin("../../tests/infer/deeppot_dpa_spin.pth");

natoms = expected_e.size();
Expand Down
6 changes: 6 additions & 0 deletions source/api_c/tests/test_deepspin_a_hpp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class TestInferDeepSpinAHPP : public ::testing::Test {
deepmd::hpp::DeepSpin dp;

void SetUp() override {
#ifndef BUILD_PYTORCH
GTEST_SKIP() << "Skip because PyTorch support is not enabled.";
#endif
dp.init("../../tests/infer/deeppot_dpa_spin.pth");

natoms = expected_e.size();
Expand Down Expand Up @@ -208,6 +211,9 @@ class TestInferDeepSpinANoPbcHPP : public ::testing::Test {
deepmd::hpp::DeepSpin dp;

void SetUp() override {
#ifndef BUILD_PYTORCH
GTEST_SKIP() << "Skip because PyTorch support is not enabled.";
#endif
dp.init("../../tests/infer/deeppot_dpa_spin.pth");

natoms = expected_e.size();
Expand Down
3 changes: 3 additions & 0 deletions source/api_c/tests/test_deepspin_model_devi_hpp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class TestInferDeepSpinModeDevi : public ::testing::Test {
deepmd::hpp::DeepSpinModelDevi dp_md;

void SetUp() override {
#ifndef BUILD_PYTORCH
GTEST_SKIP() << "Skip because PyTorch support is not enabled.";
#endif
{
dp0.init("../../tests/infer/deeppot_dpa_spin.pth");
}
Expand Down
3 changes: 3 additions & 0 deletions source/api_c/tests/test_dipolecharge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class TestDipoleCharge : public ::testing::Test {
deepmd::hpp::DipoleChargeModifier dm;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
std::string file_name = "../../tests/infer/dipolecharge_e.pbtxt";
std::string model = "dipolecharge_e.pb";
deepmd::hpp::convert_pbtxt_to_pb(file_name, model);
Expand Down
3 changes: 3 additions & 0 deletions source/api_c/tests/test_mixed_type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class TestInferMixedType : public ::testing::Test {
deepmd::hpp::DeepPot dp;

void SetUp() override {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
std::string file_name = "../../tests/infer/virtual_type.pbtxt";
deepmd::hpp::convert_pbtxt_to_pb("../../tests/infer/virtual_type.pbtxt",
"virtual_type.pb");
Expand Down
6 changes: 6 additions & 0 deletions source/api_c/tests/test_read_file_to_string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

#include "deepmd.hpp"
TEST(TestReadFileToString, readfiletostring) {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
std::string file_content;
deepmd::hpp::read_file_to_string("../../tests/infer/deeppot.txt",
file_content);
Expand All @@ -26,6 +29,9 @@ TEST(TestReadFileToString, readfiletostring) {
}

TEST(TestReadFileToString, readfiletostringerr) {
#ifndef BUILD_TENSORFLOW
GTEST_SKIP() << "Skip because TensorFlow support is not enabled.";
#endif
std::string file_content;
EXPECT_THROW(
{
Expand Down
Loading