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

fix(cc): remove C++ 17 usage #4570

Merged
merged 2 commits into from
Jan 24, 2025
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: 3 additions & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ set(DEEPMD_C_ROOT
""
CACHE PATH "Path to imported DeePMD-kit C library")

set(CMAKE_CXX_STANDARD 11)
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()
macro(set_if_higher VARIABLE VALUE)
# ${VARIABLE} is a variable name, not a string
if(${VARIABLE} LESS "${VALUE}")
Expand Down
4 changes: 2 additions & 2 deletions source/api_cc/src/DeepPotPT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void DeepPotPT::compute(ENERGYVTYPE& ener,
int natoms = atype.size();
auto options = torch::TensorOptions().dtype(torch::kFloat64);
torch::ScalarType floatType = torch::kFloat64;
if (std::is_same_v<VALUETYPE, float>) {
if (std::is_same<VALUETYPE, float>::value) {
options = torch::TensorOptions().dtype(torch::kFloat32);
floatType = torch::kFloat32;
}
Expand Down Expand Up @@ -341,7 +341,7 @@ void DeepPotPT::compute(ENERGYVTYPE& ener,
int natoms = atype.size();
auto options = torch::TensorOptions().dtype(torch::kFloat64);
torch::ScalarType floatType = torch::kFloat64;
if (std::is_same_v<VALUETYPE, float>) {
if (std::is_same<VALUETYPE, float>::value) {
options = torch::TensorOptions().dtype(torch::kFloat32);
floatType = torch::kFloat32;
}
Expand Down
4 changes: 2 additions & 2 deletions source/api_cc/src/DeepSpinPT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void DeepSpinPT::compute(ENERGYVTYPE& ener,
int natoms = atype.size();
auto options = torch::TensorOptions().dtype(torch::kFloat64);
torch::ScalarType floatType = torch::kFloat64;
if (std::is_same_v<VALUETYPE, float>) {
if (std::is_same<VALUETYPE, float>::value) {
options = torch::TensorOptions().dtype(torch::kFloat32);
floatType = torch::kFloat32;
}
Expand Down Expand Up @@ -365,7 +365,7 @@ void DeepSpinPT::compute(ENERGYVTYPE& ener,
int natoms = atype.size();
auto options = torch::TensorOptions().dtype(torch::kFloat64);
torch::ScalarType floatType = torch::kFloat64;
if (std::is_same_v<VALUETYPE, float>) {
if (std::is_same<VALUETYPE, float>::value) {
options = torch::TensorOptions().dtype(torch::kFloat32);
floatType = torch::kFloat32;
}
Expand Down
Loading