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

Add cmake configuration for the location of the test data #513

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion tests/BlockUniTensor_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using namespace cytnx;
using namespace TestTools;
class BlockUniTensorTest : public ::testing::Test {
public:
std::string data_dir = "../../tests/test_data_base/common/BlockUniTensor/";
std::string data_dir = CYTNX_TEST_DATA_DIR "/common/BlockUniTensor/";

Bond B1 = Bond(BD_IN, {Qs(0) >> 1, Qs(1) >> 2});
Bond B2 = Bond(BD_IN, {Qs(0), Qs(1)}, {3, 4});
Expand Down
6 changes: 6 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
if(BACKEND_TORCH)
else()

# Define the path to the test data directory
set(CYTNX_TEST_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/test_data_base")

# Add the preprocessor definition for CYTNX_TEST_DATA_DIR
add_compile_definitions(CYTNX_TEST_DATA_DIR="${CYTNX_TEST_DATA_DIR}")

add_executable(
test_main
test_tools.cpp
Expand Down
2 changes: 1 addition & 1 deletion tests/DenseUniTensor_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace std;
using namespace TestTools;
class DenseUniTensorTest : public ::testing::Test {
public:
std::string data_dir = "../../tests/test_data_base/common/DenseUniTensor/";
std::string data_dir = CYTNX_TEST_DATA_DIR "/common/DenseUniTensor/";

UniTensor ut_uninit;
UniTensor utzero345;
Expand Down
2 changes: 1 addition & 1 deletion tests/Storage_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ TEST_F(StorageTest, from_vec_cf) {

// create suite for all real types (exclude bool)
using vector_typelist = testing::Types<cytnx_int64, cytnx_uint64, cytnx_int32, cytnx_uint32,
cytnx_double, cytnx_float, cytnx_uint16, cytnx_int64>;
cytnx_double, cytnx_float, cytnx_uint16, cytnx_int16>;
template <class>
struct vector_suite : testing::Test {};
TYPED_TEST_SUITE(vector_suite, vector_typelist);
Expand Down
2 changes: 1 addition & 1 deletion tests/Tensor_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace cytnx;
using namespace std;
class TensorTest : public ::testing::Test {
public:
std::string data_dir = "../../tests/test_data_base/common/Tensor/";
std::string data_dir = CYTNX_TEST_DATA_DIR "/common/Tensor/";

Tensor tzero345;
Tensor tone345;
Expand Down
2 changes: 1 addition & 1 deletion tests/common_data_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ using namespace TestTools;

namespace CommonDataGen {

std::string dataRoot = "../../tests/test_data_base/common/";
std::string dataRoot = CYTNX_TEST_DATA_DIR "/common/";
static std::vector<unsigned int> dtype_list1 = {
Type.ComplexDouble,
Type.Double,
Expand Down
2 changes: 1 addition & 1 deletion tests/gpu/BlockUniTensor_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace TestTools;

class BlockUniTensorTest : public ::testing::Test {
public:
std::string data_dir = "../../../tests/test_data_base/common/BlockUniTensor/";
std::string data_dir = CYTNX_TEST_DATA_DIR "/common/BlockUniTensor/";

Bond B1 = Bond(BD_IN, {Qs(0) >> 1, Qs(1) >> 2});
Bond B2 = Bond(BD_IN, {Qs(0), Qs(1)}, {3, 4});
Expand Down
2 changes: 1 addition & 1 deletion tests/gpu/DenseUniTensor_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace std;
using namespace TestTools;
class DenseUniTensorTest : public ::testing::Test {
public:
std::string data_dir = "../../../tests/test_data_base/common/DenseUniTensor/";
std::string data_dir = CYTNX_TEST_DATA_DIR "/common/DenseUniTensor/";

UniTensor utzero345;
UniTensor utone345;
Expand Down
2 changes: 1 addition & 1 deletion tests/gpu/Tensor_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace cytnx;
using namespace std;
class TensorTest : public ::testing::Test {
public:
std::string data_dir = "../../../tests/test_data_base/common/Tensor/";
std::string data_dir = CYTNX_TEST_DATA_DIR "/common/Tensor/";

Tensor tzero345;
Tensor tone345;
Expand Down
2 changes: 1 addition & 1 deletion tests/gpu/common_data_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ using namespace TestTools;

namespace CommonDataGen {

std::string dataRoot = "../../tests/test_data_base/common/";
std::string dataRoot = CYTNX_TEST_DATA_DIR "/common/";
static std::vector<unsigned int> dtype_list1 = {
Type.ComplexDouble,
Type.Double,
Expand Down
5 changes: 2 additions & 3 deletions tests/gpu/linalg_test/GeSvd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ namespace GesvdTest {
bool ReComposeCheck(const UniTensor& Tin, const std::vector<UniTensor>& Tout);
bool CheckLabels(const UniTensor& Tin, const std::vector<UniTensor>& Tout);
bool SingularValsCorrect(const UniTensor& res, const UniTensor& ans);
std::string data_root = "../../../tests/test_data_base/";
std::string src_data_root = data_root + "common/";
std::string ans_data_root = data_root + "linalg/Gesvd/";
std::string src_data_root = CYTNX_TEST_DATA_DIR "/common/";
std::string ans_data_root = CYTNX_TEST_DATA_DIR "/linalg/Gesvd/";
// normal test

/*=====test info=====
Expand Down
6 changes: 3 additions & 3 deletions tests/gpu/linalg_test/Lanczos_Gnd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class MyOp2 : public LinOp {
public:
UniTensor H;
MyOp2(int dim) : LinOp("mv", dim) {
Tensor A = Tensor::Load("../../../tests/test_data_base/linalg/Lanczos_Gnd/lan_block_A.cytn")
Tensor A = Tensor::Load(CYTNX_TEST_DATA_DIR "/linalg/Lanczos_Gnd/lan_block_A.cytn")
.to(cytnx::Device.cuda);
Tensor B = Tensor::Load("../../../tests/test_data_base/linalg/Lanczos_Gnd/lan_block_B.cytn")
Tensor B = Tensor::Load(CYTNX_TEST_DATA_DIR "/linalg/Lanczos_Gnd/lan_block_B.cytn")
.to(cytnx::Device.cuda);
Tensor C = Tensor::Load("../../../tests/test_data_base/linalg/Lanczos_Gnd/lan_block_C.cytn")
Tensor C = Tensor::Load(CYTNX_TEST_DATA_DIR "/linalg/Lanczos_Gnd/lan_block_C.cytn")
.to(cytnx::Device.cuda);
Bond lan_I = Bond(BD_IN, {Qs(-1), Qs(0), Qs(1)}, {9, 9, 9});
Bond lan_J = Bond(BD_OUT, {Qs(-1), Qs(0), Qs(1)}, {9, 9, 9});
Expand Down
5 changes: 2 additions & 3 deletions tests/gpu/linalg_test/Svd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ namespace SvdTest {
bool ReComposeCheck(const UniTensor& Tin, const std::vector<UniTensor>& Tout);
bool CheckLabels(const UniTensor& Tin, const std::vector<UniTensor>& Tout);
bool SingularValsCorrect(const UniTensor& res, const UniTensor& ans);
std::string data_root = "../../../tests/test_data_base/";
std::string src_data_root = data_root + "common/";
std::string ans_data_root = data_root + "linalg/Svd/";
std::string src_data_root = CYTNX_TEST_DATA_DIR "/common/";
std::string ans_data_root = CYTNX_TEST_DATA_DIR "/linalg/Svd/";
// normal test

/*=====test info=====
Expand Down
2 changes: 1 addition & 1 deletion tests/gpu/linalg_test/linalg_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class linalg_Test : public ::testing::Test {
Tensor eye3x3cd = eye(3, Type.ComplexDouble).to(cytnx::Device.cuda);
Tensor zeros3x3cd = zeros(9, Type.ComplexDouble).reshape(3, 3).to(cytnx::Device.cuda);

std::string data_dir = "../../../tests/test_data_base/linalg/";
std::string data_dir = CYTNX_TEST_DATA_DIR "/linalg/";
// ==================== svd_truncate ===================
Bond svd_I = Bond(BD_OUT, {Qs(1), Qs(-1)}, {1, 1});
Bond svd_J =
Expand Down
5 changes: 2 additions & 3 deletions tests/linalg_test/GeSvd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ namespace GesvdTest {
bool ReComposeCheck(const UniTensor& Tin, const std::vector<UniTensor>& Tout);
bool CheckLabels(const UniTensor& Tin, const std::vector<UniTensor>& Tout);
bool SingularValsCorrect(const UniTensor& res, const UniTensor& ans);
std::string data_root = "../../tests/test_data_base/";
std::string src_data_root = data_root + "common/";
std::string ans_data_root = data_root + "linalg/Gesvd/";
std::string src_data_root = CYTNX_TEST_DATA_DIR "/common/";
std::string ans_data_root = CYTNX_TEST_DATA_DIR "/linalg/Gesvd/";
// normal test

/*=====test info=====
Expand Down
6 changes: 3 additions & 3 deletions tests/linalg_test/Lanczos_Gnd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class MyOp2 : public LinOp {
public:
UniTensor H;
MyOp2(int dim) : LinOp("mv", dim) {
Tensor A = Tensor::Load("../../tests/test_data_base/linalg/Lanczos_Gnd/lan_block_A.cytn");
Tensor B = Tensor::Load("../../tests/test_data_base/linalg/Lanczos_Gnd/lan_block_B.cytn");
Tensor C = Tensor::Load("../../tests/test_data_base/linalg/Lanczos_Gnd/lan_block_C.cytn");
Tensor A = Tensor::Load(CYTNX_TEST_DATA_DIR "/linalg/Lanczos_Gnd/lan_block_A.cytn");
Tensor B = Tensor::Load(CYTNX_TEST_DATA_DIR "/linalg/Lanczos_Gnd/lan_block_B.cytn");
Tensor C = Tensor::Load(CYTNX_TEST_DATA_DIR "/linalg/Lanczos_Gnd/lan_block_C.cytn");
Bond lan_I = Bond(BD_IN, {Qs(-1), Qs(0), Qs(1)}, {9, 9, 9});
Bond lan_J = Bond(BD_OUT, {Qs(-1), Qs(0), Qs(1)}, {9, 9, 9});
H = UniTensor({lan_I, lan_J});
Expand Down
5 changes: 2 additions & 3 deletions tests/linalg_test/Svd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ namespace SvdTest {
bool ReComposeCheck(const UniTensor& Tin, const std::vector<UniTensor>& Tout);
bool CheckLabels(const UniTensor& Tin, const std::vector<UniTensor>& Tout);
bool SingularValsCorrect(const UniTensor& res, const UniTensor& ans);
std::string data_root = "../../tests/test_data_base/";
std::string src_data_root = data_root + "common/";
std::string ans_data_root = data_root + "linalg/Svd/";
std::string src_data_root = CYTNX_TEST_DATA_DIR "/common/";
std::string ans_data_root = CYTNX_TEST_DATA_DIR "/linalg/Svd/";
// normal test

/*=====test info=====
Expand Down
2 changes: 1 addition & 1 deletion tests/linalg_test/linalg_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class linalg_Test : public ::testing::Test {
UniTensor ones3x3cd_ut = UniTensor(ones3x3cd, false, -1);
UniTensor invertable3x3cd_ut = UniTensor(invertable3x3cd, false, -1);

std::string data_dir = "../../tests/test_data_base/linalg/";
std::string data_dir = CYTNX_TEST_DATA_DIR "/linalg/";
// ==================== svd_truncate ===================
Bond svd_I = Bond(BD_OUT, {Qs(1), Qs(-1)}, {1, 1});
Bond svd_J =
Expand Down
Loading