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
17 changes: 14 additions & 3 deletions source/api_cc/tests/test_deeppot_a_fparam_aparam_nframes_ptexpt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <vector>

#include "DeepPot.h"
#include "DeepPotPTExpt.h"
#include "test_utils.h"

template <class VALUETYPE>
Expand Down Expand Up @@ -113,13 +114,18 @@ class TestInferDeepPotAFparamAparamNFramesPtExpt : public ::testing::Test {
std::vector<double> expected_tot_e;
std::vector<VALUETYPE> expected_tot_v;

deepmd::DeepPot dp;
static deepmd::DeepPot dp;

static void SetUpTestSuite() {
#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT
dp.init("../../tests/infer/fparam_aparam.pt2");
#endif
}

void SetUp() override {
#ifndef BUILD_PYTORCH
#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT
GTEST_SKIP() << "Skip because PyTorch support is not enabled.";
#endif
dp.init("../../tests/infer/fparam_aparam.pt2");

natoms = expected_e.size() / nframes;
EXPECT_EQ(nframes * natoms * 3, expected_f.size());
Expand All @@ -142,8 +148,13 @@ class TestInferDeepPotAFparamAparamNFramesPtExpt : public ::testing::Test {
};

void TearDown() override {};

static void TearDownTestSuite() { dp = deepmd::DeepPot(); }
};

template <class VALUETYPE>
deepmd::DeepPot TestInferDeepPotAFparamAparamNFramesPtExpt<VALUETYPE>::dp;

TYPED_TEST_SUITE(TestInferDeepPotAFparamAparamNFramesPtExpt, ValueTypes);

TYPED_TEST(TestInferDeepPotAFparamAparamNFramesPtExpt, cpu_build_nlist) {
Expand Down
33 changes: 27 additions & 6 deletions source/api_cc/tests/test_deeppot_a_fparam_aparam_ptexpt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <vector>

#include "DeepPot.h"
#include "DeepPotPTExpt.h"
#include "neighbor_list.h"
#include "test_utils.h"

Expand Down Expand Up @@ -73,13 +74,18 @@ class TestInferDeepPotAFParamAParamPtExpt : public ::testing::Test {
double expected_tot_e;
std::vector<VALUETYPE> expected_tot_v;

deepmd::DeepPot dp;
static deepmd::DeepPot dp;

static void SetUpTestSuite() {
#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT
dp.init("../../tests/infer/fparam_aparam.pt2");
#endif
}

void SetUp() override {
#ifndef BUILD_PYTORCH
#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT
GTEST_SKIP() << "Skip because PyTorch support is not enabled.";
#endif
dp.init("../../tests/infer/fparam_aparam.pt2");

natoms = expected_e.size();
EXPECT_EQ(natoms * 3, expected_f.size());
Expand All @@ -98,8 +104,13 @@ class TestInferDeepPotAFParamAParamPtExpt : public ::testing::Test {
};

void TearDown() override {};

static void TearDownTestSuite() { dp = deepmd::DeepPot(); }
};

template <class VALUETYPE>
deepmd::DeepPot TestInferDeepPotAFParamAParamPtExpt<VALUETYPE>::dp;

TYPED_TEST_SUITE(TestInferDeepPotAFParamAParamPtExpt, ValueTypes);

TYPED_TEST(TestInferDeepPotAFParamAParamPtExpt, cpu_build_nlist) {
Expand Down Expand Up @@ -325,18 +336,28 @@ TYPED_TEST(TestInferDeepPotAFParamAParamPtExpt, cpu_lmp_nlist_atomic) {
template <class VALUETYPE>
class TestInferDeepPotNoDefaultFParamPtExpt : public ::testing::Test {
protected:
deepmd::DeepPot dp;
static deepmd::DeepPot dp;

static void SetUpTestSuite() {
#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT
dp.init("../../tests/infer/fparam_aparam.pt2");
#endif
}

void SetUp() override {
#ifndef BUILD_PYTORCH
#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT
GTEST_SKIP() << "Skip because PyTorch support is not enabled.";
#endif
dp.init("../../tests/infer/fparam_aparam.pt2");
};

void TearDown() override {};

static void TearDownTestSuite() { dp = deepmd::DeepPot(); }
};

template <class VALUETYPE>
deepmd::DeepPot TestInferDeepPotNoDefaultFParamPtExpt<VALUETYPE>::dp;

TYPED_TEST_SUITE(TestInferDeepPotNoDefaultFParamPtExpt, ValueTypes);

TYPED_TEST(TestInferDeepPotNoDefaultFParamPtExpt, no_default_fparam) {
Expand Down
17 changes: 14 additions & 3 deletions source/api_cc/tests/test_deeppot_default_fparam_ptexpt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <vector>

#include "DeepPot.h"
#include "DeepPotPTExpt.h"
#include "neighbor_list.h"
#include "test_utils.h"

Expand Down Expand Up @@ -78,13 +79,18 @@ class TestInferDeepPotDefaultFParamPtExpt : public ::testing::Test {
double expected_tot_e;
std::vector<VALUETYPE> expected_tot_v;

deepmd::DeepPot dp;
static deepmd::DeepPot dp;

static void SetUpTestSuite() {
#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT
dp.init("../../tests/infer/fparam_aparam_default.pt2");
#endif
}

void SetUp() override {
#ifndef BUILD_PYTORCH
#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT
GTEST_SKIP() << "Skip because PyTorch support is not enabled.";
#endif
dp.init("../../tests/infer/fparam_aparam_default.pt2");

natoms = expected_e.size();
EXPECT_EQ(natoms * 3, expected_f.size());
Expand All @@ -103,8 +109,13 @@ class TestInferDeepPotDefaultFParamPtExpt : public ::testing::Test {
};

void TearDown() override {};

static void TearDownTestSuite() { dp = deepmd::DeepPot(); }
};

template <class VALUETYPE>
deepmd::DeepPot TestInferDeepPotDefaultFParamPtExpt<VALUETYPE>::dp;

TYPED_TEST_SUITE(TestInferDeepPotDefaultFParamPtExpt, ValueTypes);

TYPED_TEST(TestInferDeepPotDefaultFParamPtExpt, attrs) {
Expand Down
33 changes: 27 additions & 6 deletions source/api_cc/tests/test_deeppot_dpa1_ptexpt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <vector>

#include "DeepPot.h"
#include "DeepPotPTExpt.h"
#include "neighbor_list.h"
#include "test_utils.h"

Expand Down Expand Up @@ -72,13 +73,18 @@ class TestInferDeepPotDpa1PtExpt : public ::testing::Test {
double expected_tot_e;
std::vector<VALUETYPE> expected_tot_v;

deepmd::DeepPot dp;
static deepmd::DeepPot dp;

static void SetUpTestSuite() {
#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT
dp.init("../../tests/infer/deeppot_dpa1.pt2");
#endif
}

void SetUp() override {
#ifndef BUILD_PYTORCH
#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT
GTEST_SKIP() << "Skip because PyTorch support is not enabled.";
#endif
dp.init("../../tests/infer/deeppot_dpa1.pt2");

natoms = expected_e.size();
EXPECT_EQ(natoms * 3, expected_f.size());
Expand All @@ -97,8 +103,13 @@ class TestInferDeepPotDpa1PtExpt : public ::testing::Test {
};

void TearDown() override {};

static void TearDownTestSuite() { dp = deepmd::DeepPot(); }
};

template <class VALUETYPE>
deepmd::DeepPot TestInferDeepPotDpa1PtExpt<VALUETYPE>::dp;

TYPED_TEST_SUITE(TestInferDeepPotDpa1PtExpt, ValueTypes);

TYPED_TEST(TestInferDeepPotDpa1PtExpt, cpu_build_nlist) {
Expand Down Expand Up @@ -218,13 +229,18 @@ class TestInferDeepPotDpa1PtExptNoPbc : public ::testing::Test {
double expected_tot_e;
std::vector<VALUETYPE> expected_tot_v;

deepmd::DeepPot dp;
static deepmd::DeepPot dp;

static void SetUpTestSuite() {
#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT
dp.init("../../tests/infer/deeppot_dpa1.pt2");
#endif
}

void SetUp() override {
#ifndef BUILD_PYTORCH
#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT
GTEST_SKIP() << "Skip because PyTorch support is not enabled.";
#endif
dp.init("../../tests/infer/deeppot_dpa1.pt2");

natoms = expected_e.size();
EXPECT_EQ(natoms * 3, expected_f.size());
Expand All @@ -243,8 +259,13 @@ class TestInferDeepPotDpa1PtExptNoPbc : public ::testing::Test {
};

void TearDown() override {};

static void TearDownTestSuite() { dp = deepmd::DeepPot(); }
};

template <class VALUETYPE>
deepmd::DeepPot TestInferDeepPotDpa1PtExptNoPbc<VALUETYPE>::dp;

TYPED_TEST_SUITE(TestInferDeepPotDpa1PtExptNoPbc, ValueTypes);

TYPED_TEST(TestInferDeepPotDpa1PtExptNoPbc, cpu_build_nlist) {
Expand Down
33 changes: 27 additions & 6 deletions source/api_cc/tests/test_deeppot_dpa2_ptexpt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <vector>

#include "DeepPot.h"
#include "DeepPotPTExpt.h"
#include "neighbor_list.h"
#include "test_utils.h"

Expand Down Expand Up @@ -71,13 +72,18 @@ class TestInferDeepPotDpa2PtExpt : public ::testing::Test {
double expected_tot_e;
std::vector<VALUETYPE> expected_tot_v;

deepmd::DeepPot dp;
static deepmd::DeepPot dp;

static void SetUpTestSuite() {
#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT
dp.init("../../tests/infer/deeppot_dpa2.pt2");
#endif
}

void SetUp() override {
#ifndef BUILD_PYTORCH
#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT
GTEST_SKIP() << "Skip because PyTorch support is not enabled.";
#endif
dp.init("../../tests/infer/deeppot_dpa2.pt2");

natoms = expected_e.size();
EXPECT_EQ(natoms * 3, expected_f.size());
Expand All @@ -96,8 +102,13 @@ class TestInferDeepPotDpa2PtExpt : public ::testing::Test {
};

void TearDown() override {};

static void TearDownTestSuite() { dp = deepmd::DeepPot(); }
};

template <class VALUETYPE>
deepmd::DeepPot TestInferDeepPotDpa2PtExpt<VALUETYPE>::dp;

TYPED_TEST_SUITE(TestInferDeepPotDpa2PtExpt, ValueTypes);

TYPED_TEST(TestInferDeepPotDpa2PtExpt, cpu_build_nlist) {
Expand Down Expand Up @@ -492,13 +503,18 @@ class TestInferDeepPotDpa2PtExptNoPbc : public ::testing::Test {
double expected_tot_e;
std::vector<VALUETYPE> expected_tot_v;

deepmd::DeepPot dp;
static deepmd::DeepPot dp;

static void SetUpTestSuite() {
#if defined(BUILD_PYTORCH) && BUILD_PT_EXPT
dp.init("../../tests/infer/deeppot_dpa2.pt2");
#endif
}

void SetUp() override {
#ifndef BUILD_PYTORCH
#if !defined(BUILD_PYTORCH) || !BUILD_PT_EXPT
GTEST_SKIP() << "Skip because PyTorch support is not enabled.";
#endif
dp.init("../../tests/infer/deeppot_dpa2.pt2");

natoms = expected_e.size();
EXPECT_EQ(natoms * 3, expected_f.size());
Expand All @@ -517,8 +533,13 @@ class TestInferDeepPotDpa2PtExptNoPbc : public ::testing::Test {
};

void TearDown() override {};

static void TearDownTestSuite() { dp = deepmd::DeepPot(); }
};

template <class VALUETYPE>
deepmd::DeepPot TestInferDeepPotDpa2PtExptNoPbc<VALUETYPE>::dp;

TYPED_TEST_SUITE(TestInferDeepPotDpa2PtExptNoPbc, ValueTypes);

TYPED_TEST(TestInferDeepPotDpa2PtExptNoPbc, cpu_build_nlist) {
Expand Down
Loading
Loading