diff --git a/source/api_cc/src/DeepPotPT.cc b/source/api_cc/src/DeepPotPT.cc index af8a0c0252..232c9efd31 100644 --- a/source/api_cc/src/DeepPotPT.cc +++ b/source/api_cc/src/DeepPotPT.cc @@ -2,9 +2,13 @@ #ifdef BUILD_PYTORCH #include "DeepPotPT.h" +#include + #include "common.h" #include "device.h" + using namespace deepmd; + torch::Tensor createNlistTensor(const std::vector>& data) { std::vector row_tensors; @@ -155,7 +159,7 @@ void DeepPotPT::compute(ENERGYVTYPE& ener, at::Tensor coord_wrapped_Tensor = torch::from_blob(coord_wrapped.data(), {1, nall_real, 3}, options) .to(device); - std::vector atype_64(datype.begin(), datype.end()); + std::vector atype_64(datype.begin(), datype.end()); at::Tensor atype_Tensor = torch::from_blob(atype_64.data(), {1, nall_real}, int_option).to(device); if (ago == 0) { @@ -199,17 +203,18 @@ void DeepPotPT::compute(ENERGYVTYPE& ener, if (!fparam.empty()) { fparam_tensor = torch::from_blob(const_cast(fparam.data()), - {1, static_cast(fparam.size())}, options) + {1, static_cast(fparam.size())}, options) .to(device); } c10::optional aparam_tensor; if (!aparam_.empty()) { - aparam_tensor = torch::from_blob( - const_cast(aparam_.data()), - {1, lmp_list.inum, - static_cast(aparam_.size()) / lmp_list.inum}, - options) - .to(device); + aparam_tensor = + torch::from_blob( + const_cast(aparam_.data()), + {1, lmp_list.inum, + static_cast(aparam_.size()) / lmp_list.inum}, + options) + .to(device); } c10::Dict outputs = (do_message_passing == 1) @@ -340,7 +345,7 @@ void DeepPotPT::compute(ENERGYVTYPE& ener, torch::from_blob(coord_wrapped.data(), {1, natoms, 3}, options) .to(device); inputs.push_back(coord_wrapped_Tensor); - std::vector atype_64(atype.begin(), atype.end()); + std::vector atype_64(atype.begin(), atype.end()); at::Tensor atype_Tensor = torch::from_blob(atype_64.data(), {1, natoms}, int_options).to(device); inputs.push_back(atype_Tensor); @@ -355,7 +360,7 @@ void DeepPotPT::compute(ENERGYVTYPE& ener, if (!fparam.empty()) { fparam_tensor = torch::from_blob(const_cast(fparam.data()), - {1, static_cast(fparam.size())}, options) + {1, static_cast(fparam.size())}, options) .to(device); } inputs.push_back(fparam_tensor); @@ -364,7 +369,8 @@ void DeepPotPT::compute(ENERGYVTYPE& ener, aparam_tensor = torch::from_blob( const_cast(aparam.data()), - {1, natoms, static_cast(aparam.size()) / natoms}, options) + {1, natoms, static_cast(aparam.size()) / natoms}, + options) .to(device); } inputs.push_back(aparam_tensor); diff --git a/source/api_cc/src/DeepPotTF.cc b/source/api_cc/src/DeepPotTF.cc index 7bf2bebce4..6b39e0ada9 100644 --- a/source/api_cc/src/DeepPotTF.cc +++ b/source/api_cc/src/DeepPotTF.cc @@ -2,6 +2,7 @@ #ifdef BUILD_TENSORFLOW #include "DeepPotTF.h" +#include #include #include "AtomMap.h" @@ -549,7 +550,7 @@ void DeepPotTF::tile_fparam_aparam(std::vector& out_param, out_param.resize(static_cast(nframes) * dparam); for (int ii = 0; ii < nframes; ++ii) { std::copy(param.begin(), param.end(), - out_param.begin() + static_cast(ii) * dparam); + out_param.begin() + static_cast(ii) * dparam); } } else if (param.size() == static_cast(nframes) * dparam) { out_param = param; diff --git a/source/op/pt/comm.cc b/source/op/pt/comm.cc index 11047ad1d6..ce497ac62d 100644 --- a/source/op/pt/comm.cc +++ b/source/op/pt/comm.cc @@ -1,13 +1,20 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -#if defined(GOOGLE_CUDA) || defined(TENSORFLOW_USE_ROCM) -#include "device.h" -#endif -#include + #ifdef USE_MPI #include #ifdef OMPI_MPI_H #include #endif +#endif +#include + +#include + +#if defined(GOOGLE_CUDA) || defined(TENSORFLOW_USE_ROCM) +#include "device.h" +#endif + +#ifdef USE_MPI template static MPI_Datatype get_mpi_type(); @@ -21,6 +28,7 @@ MPI_Datatype get_mpi_type() { return MPI_DOUBLE; } #endif + class Border : public torch::autograd::Function { public: static torch::autograd::variable_list forward( @@ -321,9 +329,9 @@ class Border : public torch::autograd::Function { static void unpack_communicator(const torch::Tensor& communicator_tensor, MPI_Comm& mpi_comm) { #ifdef OMPI_MPI_H - long int* communicator = communicator_tensor.data_ptr(); + std::int64_t* communicator = communicator_tensor.data_ptr(); #else - long int* ptr = communicator_tensor.data_ptr(); + std::int64_t* ptr = communicator_tensor.data_ptr(); int* communicator = reinterpret_cast(ptr); #endif mpi_comm = reinterpret_cast(*communicator);