diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 42181c8f959381746a926f037f2ad6487499cd6c..4b588cbeb91dcde21beeebeba19c7c218051f062 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,6 +33,10 @@ repos: entry: bash ./tools/codestyle/clang_format.hook -i language: system files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto|xpu|kps)$ + exclude: | + (?x)^( + paddle/fluid/distributed/ps/thirdparty/round_robin.h + )$ - repo: local hooks: - id: cpplint-cpp-source diff --git a/paddle/fluid/distributed/collective/HCCLTools.cc b/paddle/fluid/distributed/collective/HCCLTools.cc index 526a683e057c04466063a34b4d37777446d7ba18..676a71cb30d95e547116fc1e217e7508b5f9233c 100644 --- a/paddle/fluid/distributed/collective/HCCLTools.cc +++ b/paddle/fluid/distributed/collective/HCCLTools.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/collective/HCCLTools.h" + #include "paddle/fluid/distributed/collective/Types.h" namespace paddle { diff --git a/paddle/fluid/distributed/collective/HCCLTools.h b/paddle/fluid/distributed/collective/HCCLTools.h index a1dcf7cd9b62694cdf4ac68bf261c23e96b1a12b..4955e24eadbfbababed0c63d2aed9e64efa39fe7 100644 --- a/paddle/fluid/distributed/collective/HCCLTools.h +++ b/paddle/fluid/distributed/collective/HCCLTools.h @@ -15,6 +15,7 @@ #pragma once #include + #include #include "boost/variant.hpp" diff --git a/paddle/fluid/distributed/collective/NCCLTools.cc b/paddle/fluid/distributed/collective/NCCLTools.cc index 7e842ebf92166a4d0f2cf34584af6cab3ec80e3e..2cecaf0734df6cb043c486468da5daace582823e 100644 --- a/paddle/fluid/distributed/collective/NCCLTools.cc +++ b/paddle/fluid/distributed/collective/NCCLTools.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/collective/NCCLTools.h" + #include "paddle/fluid/distributed/collective/Types.h" namespace paddle { diff --git a/paddle/fluid/distributed/collective/NCCLTools.h b/paddle/fluid/distributed/collective/NCCLTools.h index 0454518b1836c8b232320ea4858874e67f587099..f38ce8faa7ffb53c8e80855bdd4d6c946767748e 100644 --- a/paddle/fluid/distributed/collective/NCCLTools.h +++ b/paddle/fluid/distributed/collective/NCCLTools.h @@ -16,9 +16,11 @@ #include #include + #include #include "boost/variant.hpp" +#include "paddle/fluid/distributed/collective/Types.h" #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/variable.h" #include "paddle/fluid/platform/cuda_device_guard.h" @@ -26,8 +28,6 @@ #include "paddle/fluid/platform/dynload/nccl.h" #include "paddle/fluid/platform/enforce.h" -#include "paddle/fluid/distributed/collective/Types.h" - namespace paddle { namespace distributed { diff --git a/paddle/fluid/distributed/collective/ProcessGroup.h b/paddle/fluid/distributed/collective/ProcessGroup.h index 52e09792d5d80a47ded9c1f692079774d3483dcc..7ed6b188fd217c70df147ecc581553074c2b3891 100644 --- a/paddle/fluid/distributed/collective/ProcessGroup.h +++ b/paddle/fluid/distributed/collective/ProcessGroup.h @@ -21,7 +21,6 @@ #include "paddle/fluid/distributed/collective/Types.h" #include "paddle/fluid/eager/api/utils/tensor_utils.h" - #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/framework/variable.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/distributed/collective/ProcessGroupGloo.cc b/paddle/fluid/distributed/collective/ProcessGroupGloo.cc index 824341c3cd97d5fbd21f809dcdd925aa2afee3e4..1a390e38755fd39a7deee0e9110f93bd3c430ebe 100644 --- a/paddle/fluid/distributed/collective/ProcessGroupGloo.cc +++ b/paddle/fluid/distributed/collective/ProcessGroupGloo.cc @@ -27,6 +27,7 @@ #include #include #include + #include "paddle/fluid/distributed/collective/Common.h" #include "paddle/fluid/distributed/collective/ProcessGroupGloo.h" #include "paddle/fluid/framework/fleet/gloo_wrapper.h" @@ -485,8 +486,9 @@ std::shared_ptr<::gloo::transport::Device> ProcessGroupGloo::createDefaultDevice() { std::array hostname{}; auto ret = ::gethostname(hostname.data(), HOST_NAME_MAX); - PADDLE_ENFORCE_EQ(ret, 0, platform::errors::Fatal( - "Get hostname error for createDefaultDevice.")); + PADDLE_ENFORCE_EQ( + ret, 0, + platform::errors::Fatal("Get hostname error for createDefaultDevice.")); ::addrinfo* result; result = tcputils::get_addr_info(hostname.data(), "", 0, AF_UNSPEC); ::addrinfo* cur; diff --git a/paddle/fluid/distributed/collective/ProcessGroupHCCL.cc b/paddle/fluid/distributed/collective/ProcessGroupHCCL.cc index 9ed6c2198df4c433ff7deceaf56d96217fac9647..50249b03967a9b7fc67e57ff8f0da9d6fc444f89 100644 --- a/paddle/fluid/distributed/collective/ProcessGroupHCCL.cc +++ b/paddle/fluid/distributed/collective/ProcessGroupHCCL.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/collective/ProcessGroupHCCL.h" + #include "paddle/fluid/distributed/collective/Common.h" #include "paddle/fluid/distributed/collective/HCCLTools.h" #include "paddle/fluid/memory/malloc.h" @@ -216,15 +217,16 @@ std::shared_ptr ProcessGroupHCCL::AllReduce( std::vector& in_tensors, // NOLINT std::vector& out_tensors, // NOLINT const AllreduceOptions& opts) { - return Collective(in_tensors, out_tensors, - [&](phi::DenseTensor& input, phi::DenseTensor& output, - HcclComm comm, const aclrtStream& stream) { - return platform::dynload::HcclAllReduce( - input.data(), output.data(), input.numel(), - platform::ToHCCLDataType(input.dtype()), - ToHCCLRedType(opts.reduce_op), comm, stream); - }, - CommType::ALLREDUCE); + return Collective( + in_tensors, out_tensors, + [&](phi::DenseTensor& input, phi::DenseTensor& output, HcclComm comm, + const aclrtStream& stream) { + return platform::dynload::HcclAllReduce( + input.data(), output.data(), input.numel(), + platform::ToHCCLDataType(input.dtype()), + ToHCCLRedType(opts.reduce_op), comm, stream); + }, + CommType::ALLREDUCE); } std::shared_ptr ProcessGroupHCCL::Broadcast( diff --git a/paddle/fluid/distributed/collective/ProcessGroupHCCL.h b/paddle/fluid/distributed/collective/ProcessGroupHCCL.h index 2f0ff6b9565ea7bf5201e3b0aee21c73118382fe..a32984798febdf681f1f9b6798a0aad60e2303b2 100644 --- a/paddle/fluid/distributed/collective/ProcessGroupHCCL.h +++ b/paddle/fluid/distributed/collective/ProcessGroupHCCL.h @@ -21,12 +21,11 @@ #include #include +#include "paddle/fluid/distributed/collective/HCCLTools.h" #include "paddle/fluid/distributed/collective/ProcessGroup.h" +#include "paddle/fluid/distributed/store/store.h" #include "paddle/fluid/platform/device/npu/npu_stream.h" #include "paddle/fluid/platform/device_context.h" - -#include "paddle/fluid/distributed/collective/HCCLTools.h" -#include "paddle/fluid/distributed/store/store.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/gen_comm_id_helper.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/distributed/collective/ProcessGroupHeter.cc b/paddle/fluid/distributed/collective/ProcessGroupHeter.cc index 0911a4a3e3e18021688b3374ad523fee2c60ac7a..0b388a6a848a95e61c4dc84de1eba3ee0428de89 100644 --- a/paddle/fluid/distributed/collective/ProcessGroupHeter.cc +++ b/paddle/fluid/distributed/collective/ProcessGroupHeter.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/distributed/collective/ProcessGroupHeter.h" + #include + #include "paddle/fluid/platform/device/gpu/nccl_helper.h" #include "paddle/fluid/platform/place.h" #include "paddle/phi/api/include/api.h" @@ -129,8 +131,9 @@ std::shared_ptr ProcessGroupHeter::AllReduce( gid_, {dense_cpu_tensor.name()}, send_size, dense_cpu_tensor.data(), dense_cpu_tensor.numel() * framework::DataTypeSize(dense_cpu_tensor.dtype())); - PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( - "Send to the switch module error.")); + PADDLE_ENFORCE_EQ(ret, 0, + platform::errors::PreconditionNotMet( + "Send to the switch module error.")); phi::DenseTensor cpu_tensor2; cpu_tensor2.AllocateFrom( std::make_unique( @@ -140,8 +143,9 @@ std::shared_ptr ProcessGroupHeter::AllReduce( ret = client_->Recv( gid_, {dense_cpu_tensor.name()}, cpu_tensor2.data(), cpu_tensor2.numel() * framework::DataTypeSize(cpu_tensor2.dtype())); - PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( - "Recv from the switch module error.")); + PADDLE_ENFORCE_EQ(ret, 0, + platform::errors::PreconditionNotMet( + "Recv from the switch module error.")); switch (dense_cpu_tensor.dtype()) { case DataType::FLOAT32: @@ -226,8 +230,9 @@ std::shared_ptr ProcessGroupHeter::Broadcast( dense_cpu_tensor.data(), dense_cpu_tensor.numel() * framework::DataTypeSize(dense_cpu_tensor.dtype())); - PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( - "Send to the switch module error.")); + PADDLE_ENFORCE_EQ(ret, 0, + platform::errors::PreconditionNotMet( + "Send to the switch module error.")); } else { int ret = client_->Recv( gid_, {dense_cpu_tensor.name()}, dense_cpu_tensor.data(), @@ -286,8 +291,9 @@ std::shared_ptr ProcessGroupHeter::Send( VLOG(2) << "tensor_name:" << tensor_name; int ret = client_->Send(gid_, {tensor_name}, send_size, cpu_tensor.data(), tensor_size); - PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( - "Send to the switch module error.")); + PADDLE_ENFORCE_EQ( + ret, 0, + platform::errors::PreconditionNotMet("Send to the switch module error.")); return CreateTask(rank_, CommType::SEND, in_tensors); } @@ -319,8 +325,9 @@ std::shared_ptr ProcessGroupHeter::Recv( int ret = client_->Recv( gid_, {tensor_name}, cpu_tensor.data(), cpu_tensor.numel() * framework::DataTypeSize(cpu_tensor.dtype())); - PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( - "receive to the switch module error.")); + PADDLE_ENFORCE_EQ(ret, 0, + platform::errors::PreconditionNotMet( + "receive to the switch module error.")); auto end = std::chrono::high_resolution_clock::now(); std::chrono::duration diff = end - start; double goodput = cpu_tensor.numel() * diff --git a/paddle/fluid/distributed/collective/ProcessGroupNCCL.cc b/paddle/fluid/distributed/collective/ProcessGroupNCCL.cc index f1b66864b29309818cce5167c0aa1e63afa5db86..dc67205c78f56d8d7012a42dd7383413d73d0692 100644 --- a/paddle/fluid/distributed/collective/ProcessGroupNCCL.cc +++ b/paddle/fluid/distributed/collective/ProcessGroupNCCL.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/collective/ProcessGroupNCCL.h" + #include "paddle/fluid/distributed/collective/Common.h" #include "paddle/fluid/platform/device/gpu/gpu_info.h" #include "paddle/fluid/platform/device/gpu/nccl_helper.h" @@ -320,15 +321,16 @@ std::shared_ptr ProcessGroupNCCL::AllReduce( PADDLE_ENFORCE_EQ( CheckTensorsInCudaPlace(in_tensors), true, platform::errors::InvalidArgument("All inputs should be in CudaPlace.")); - return Collective(in_tensors, out_tensors, - [&](const phi::DenseTensor& input, phi::DenseTensor& output, - ncclComm_t comm, const gpuStream_t& stream) { - return platform::dynload::ncclAllReduce( - input.data(), output.data(), input.numel(), - platform::ToNCCLDataType(input.type()), - ToNCCLRedType(opts.reduce_op), comm, stream); - }, - CommType::ALLREDUCE); + return Collective( + in_tensors, out_tensors, + [&](const phi::DenseTensor& input, phi::DenseTensor& output, + ncclComm_t comm, const gpuStream_t& stream) { + return platform::dynload::ncclAllReduce( + input.data(), output.data(), input.numel(), + platform::ToNCCLDataType(input.type()), + ToNCCLRedType(opts.reduce_op), comm, stream); + }, + CommType::ALLREDUCE); } std::shared_ptr ProcessGroupNCCL::Broadcast( @@ -338,17 +340,17 @@ std::shared_ptr ProcessGroupNCCL::Broadcast( CheckTensorsInCudaPlace(in_tensors), true, platform::errors::InvalidArgument("All inputs should be in CudaPlace.")); - return Collective(in_tensors, out_tensors, - [&](phi::DenseTensor& input, phi::DenseTensor& output, - ncclComm_t comm, const gpuStream_t& stream) { - const auto root = opts.source_rank * in_tensors.size() + - opts.source_root; - return platform::dynload::ncclBroadcast( - input.data(), output.data(), input.numel(), - platform::ToNCCLDataType(input.type()), root, comm, - stream); - }, - CommType::BROADCAST); + return Collective( + in_tensors, out_tensors, + [&](phi::DenseTensor& input, phi::DenseTensor& output, ncclComm_t comm, + const gpuStream_t& stream) { + const auto root = + opts.source_rank * in_tensors.size() + opts.source_root; + return platform::dynload::ncclBroadcast( + input.data(), output.data(), input.numel(), + platform::ToNCCLDataType(input.type()), root, comm, stream); + }, + CommType::BROADCAST); } std::shared_ptr ProcessGroupNCCL::Barrier( @@ -400,15 +402,15 @@ std::shared_ptr ProcessGroupNCCL::Send( std::vector& tensors, int dst_rank) { CheckTensorsInDifferentDevices(tensors, static_cast(GetSize())); - auto task = PointToPoint(tensors, - [&](phi::DenseTensor& input, ncclComm_t comm, - const gpuStream_t& stream, int dst_rank) { - return platform::dynload::ncclSend( - input.data(), input.numel(), - platform::ToNCCLDataType(input.dtype()), - dst_rank, comm, stream); - }, - dst_rank, CommType::SEND); + auto task = PointToPoint( + tensors, + [&](phi::DenseTensor& input, ncclComm_t comm, const gpuStream_t& stream, + int dst_rank) { + return platform::dynload::ncclSend( + input.data(), input.numel(), + platform::ToNCCLDataType(input.dtype()), dst_rank, comm, stream); + }, + dst_rank, CommType::SEND); return task; } @@ -416,15 +418,15 @@ std::shared_ptr ProcessGroupNCCL::Recv( std::vector& tensors, int src_rank) { CheckTensorsInDifferentDevices(tensors, static_cast(GetSize())); - auto task = PointToPoint(tensors, - [&](phi::DenseTensor& output, ncclComm_t comm, - const gpuStream_t& stream, int src_rank) { - return platform::dynload::ncclRecv( - output.data(), output.numel(), - platform::ToNCCLDataType(output.dtype()), - src_rank, comm, stream); - }, - src_rank, CommType::RECV); + auto task = PointToPoint( + tensors, + [&](phi::DenseTensor& output, ncclComm_t comm, const gpuStream_t& stream, + int src_rank) { + return platform::dynload::ncclRecv( + output.data(), output.numel(), + platform::ToNCCLDataType(output.dtype()), src_rank, comm, stream); + }, + src_rank, CommType::RECV); return task; } @@ -440,15 +442,15 @@ std::shared_ptr ProcessGroupNCCL::Send_Partial( std::vector shared_tensors; shared_tensors.push_back(shared_input); - auto task = PointToPoint(shared_tensors, - [&](phi::DenseTensor& input, ncclComm_t comm, - const gpuStream_t& stream, int dst_rank) { - return platform::dynload::ncclSend( - input.data(), input.numel(), - platform::ToNCCLDataType(input.dtype()), - dst_rank, comm, stream); - }, - dst_rank, CommType::SEND); + auto task = PointToPoint( + shared_tensors, + [&](phi::DenseTensor& input, ncclComm_t comm, const gpuStream_t& stream, + int dst_rank) { + return platform::dynload::ncclSend( + input.data(), input.numel(), + platform::ToNCCLDataType(input.dtype()), dst_rank, comm, stream); + }, + dst_rank, CommType::SEND); return task; } @@ -463,15 +465,15 @@ std::shared_ptr ProcessGroupNCCL::Recv_Partial( std::vector shared_tensors; shared_tensors.push_back(shared_input); - auto task = PointToPoint(shared_tensors, - [&](phi::DenseTensor& output, ncclComm_t comm, - const gpuStream_t& stream, int src_rank) { - return platform::dynload::ncclRecv( - output.data(), output.numel(), - platform::ToNCCLDataType(output.dtype()), - src_rank, comm, stream); - }, - src_rank, CommType::RECV); + auto task = PointToPoint( + shared_tensors, + [&](phi::DenseTensor& output, ncclComm_t comm, const gpuStream_t& stream, + int src_rank) { + return platform::dynload::ncclRecv( + output.data(), output.numel(), + platform::ToNCCLDataType(output.dtype()), src_rank, comm, stream); + }, + src_rank, CommType::RECV); return task; } @@ -484,15 +486,15 @@ std::shared_ptr ProcessGroupNCCL::AllGather( PADDLE_ENFORCE_EQ( CheckTensorsInCudaPlace(out_tensors), true, platform::errors::InvalidArgument("All outputs should be in CudaPlace.")); - return Collective(in_tensors, out_tensors, - [&](const phi::DenseTensor& input, phi::DenseTensor& output, - ncclComm_t comm, const gpuStream_t& stream) { - return platform::dynload::ncclAllGather( - input.data(), output.data(), input.numel(), - platform::ToNCCLDataType(input.dtype()), comm, - stream); - }, - CommType::ALLGATHER); + return Collective( + in_tensors, out_tensors, + [&](const phi::DenseTensor& input, phi::DenseTensor& output, + ncclComm_t comm, const gpuStream_t& stream) { + return platform::dynload::ncclAllGather( + input.data(), output.data(), input.numel(), + platform::ToNCCLDataType(input.dtype()), comm, stream); + }, + CommType::ALLGATHER); } void* GetPointerByOffset(void* raw_pointer, size_t offset, diff --git a/paddle/fluid/distributed/collective/ProcessGroupNCCL.h b/paddle/fluid/distributed/collective/ProcessGroupNCCL.h index 82ced6e135ac93745dbfdb241697c87b60a730cc..2325e645b4c46e184b68dfe1fd6341622cd3ac31 100644 --- a/paddle/fluid/distributed/collective/ProcessGroupNCCL.h +++ b/paddle/fluid/distributed/collective/ProcessGroupNCCL.h @@ -22,10 +22,9 @@ #include #include "paddle/fluid/distributed/collective/ProcessGroup.h" +#include "paddle/fluid/distributed/store/store.h" #include "paddle/fluid/platform/cuda_device_guard.h" #include "paddle/fluid/platform/device_context.h" - -#include "paddle/fluid/distributed/store/store.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/gen_comm_id_helper.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/distributed/collective/reducer.cc b/paddle/fluid/distributed/collective/reducer.cc index 96009ce722905cb50591a446b85c14a3ba7ecad0..9c04b95a732e8ca6e0574c4b8a44f95070e83830 100644 --- a/paddle/fluid/distributed/collective/reducer.cc +++ b/paddle/fluid/distributed/collective/reducer.cc @@ -403,8 +403,9 @@ void EagerReducer::InitializeDenseGroups( "Tensor %s is not initialized.", tensor_name)); const auto size = tensor.numel(); PADDLE_ENFORCE_GT( - size, 0, platform::errors::PreconditionNotMet( - "The number of tensor %s's elements is 0.", tensor_name)); + size, 0, + platform::errors::PreconditionNotMet( + "The number of tensor %s's elements is 0.", tensor_name)); all_length += size; p_group->length_.push_back(size); diff --git a/paddle/fluid/distributed/collective/reducer.h b/paddle/fluid/distributed/collective/reducer.h index 424bae0e5acd19fb39184e6b7cf8b2409e946add..0527ceb9b51211d2dbd8c235d2a3bbba8b57deea 100644 --- a/paddle/fluid/distributed/collective/reducer.h +++ b/paddle/fluid/distributed/collective/reducer.h @@ -16,6 +16,7 @@ #include #include + #include "paddle/fluid/distributed/collective/ProcessGroup.h" #include "paddle/fluid/eager/accumulation/accumulation_node.h" #include "paddle/fluid/eager/api/utils/hook_utils.h" diff --git a/paddle/fluid/distributed/common/afs_warpper.cc b/paddle/fluid/distributed/common/afs_warpper.cc index d539ec60804694b77707b481d2ce3b60ffea799e..3a37c6be7c2af7156bbc6772d9fef8416aad7ec5 100644 --- a/paddle/fluid/distributed/common/afs_warpper.cc +++ b/paddle/fluid/distributed/common/afs_warpper.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/common/afs_warpper.h" + #include "paddle/fluid/framework/io/fs.h" namespace paddle { @@ -27,9 +28,10 @@ int AfsClient::initialize(const FsClientParameter& fs_client_param) { int AfsClient::initialize(const std::string& hadoop_bin, const std::string& uri, const std::string& user, const std::string& passwd, int buffer_size_param) { - return initialize(hadoop_bin, uri, paddle::string::format_string( - "%s,%s", user.c_str(), passwd.c_str()), - buffer_size_param); + return initialize( + hadoop_bin, uri, + paddle::string::format_string("%s,%s", user.c_str(), passwd.c_str()), + buffer_size_param); } int AfsClient::initialize(const std::string& hadoop_bin, const std::string& uri, const std::string& ugi, int buffer_size_param) { diff --git a/paddle/fluid/distributed/common/afs_warpper.h b/paddle/fluid/distributed/common/afs_warpper.h index d10668046c0a7ee0ab249a6a2db1ec9977cf2f25..cef3e5ae35c281c97166f10746ff5d147084a3a1 100644 --- a/paddle/fluid/distributed/common/afs_warpper.h +++ b/paddle/fluid/distributed/common/afs_warpper.h @@ -19,6 +19,7 @@ #include #include #include + #include "paddle/fluid/distributed/ps.pb.h" #include "paddle/fluid/string/string_helper.h" diff --git a/paddle/fluid/distributed/common/cost_timer.h b/paddle/fluid/distributed/common/cost_timer.h index 5073dc9cf50845e5569965ca1251b99df6868608..1651121ee0cd957257bfa1e2edaec76650290054 100644 --- a/paddle/fluid/distributed/common/cost_timer.h +++ b/paddle/fluid/distributed/common/cost_timer.h @@ -15,6 +15,7 @@ #pragma once #include #include + #include "butil/time.h" #include "bvar/latency_recorder.h" #include "glog/logging.h" diff --git a/paddle/fluid/distributed/common/local_random.h b/paddle/fluid/distributed/common/local_random.h index 96b8d2d21a5605a9774071aad97b15d64fcd1252..5a9a3b595d023641f1c34ea9bc7d20689d233d59 100644 --- a/paddle/fluid/distributed/common/local_random.h +++ b/paddle/fluid/distributed/common/local_random.h @@ -15,6 +15,7 @@ #pragma once #include #include + #include #include diff --git a/paddle/fluid/distributed/common/registerer.h b/paddle/fluid/distributed/common/registerer.h index 630be930c14d9afc820bd58034ff5ae37751f2fb..f4938c0f93f8c394e9716820f4f96543ca16a956 100644 --- a/paddle/fluid/distributed/common/registerer.h +++ b/paddle/fluid/distributed/common/registerer.h @@ -15,6 +15,7 @@ #pragma once #include + #include #include #include diff --git a/paddle/fluid/distributed/fleet_executor/carrier.cc b/paddle/fluid/distributed/fleet_executor/carrier.cc index 53bae87c0020eae2bbeec2a0e1e0d7098e897421..754a3f5d2b22fee45cd30f8d95484b17d76b9748 100644 --- a/paddle/fluid/distributed/fleet_executor/carrier.cc +++ b/paddle/fluid/distributed/fleet_executor/carrier.cc @@ -12,9 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/distributed/fleet_executor/carrier.h" + #include -#include "paddle/fluid/distributed/fleet_executor/carrier.h" #include "paddle/fluid/distributed/fleet_executor/global.h" #include "paddle/fluid/distributed/fleet_executor/interceptor.h" #include "paddle/fluid/distributed/fleet_executor/message_bus.h" @@ -148,8 +149,9 @@ void Carrier::WakeUp() { } void Carrier::Start() { - PADDLE_ENFORCE_EQ(is_init_, true, platform::errors::PreconditionNotMet( - "Using carrier before initialized.")); + PADDLE_ENFORCE_EQ(is_init_, true, + platform::errors::PreconditionNotMet( + "Using carrier before initialized.")); for (int64_t id : source_interceptor_ids_) { VLOG(3) << "Carrier Start is sending start to source interceptor " << id << "."; diff --git a/paddle/fluid/distributed/fleet_executor/carrier.h b/paddle/fluid/distributed/fleet_executor/carrier.h index d35a3260915e2cfd40bea9dc03fe6af7d9d04c54..2846af97716da7bb8f82496cca215cc6f71c5bab 100644 --- a/paddle/fluid/distributed/fleet_executor/carrier.h +++ b/paddle/fluid/distributed/fleet_executor/carrier.h @@ -35,7 +35,7 @@ namespace paddle { namespace framework { class Scope; class ProgramDesc; -} +} // namespace framework namespace distributed { diff --git a/paddle/fluid/distributed/fleet_executor/compute_interceptor.cc b/paddle/fluid/distributed/fleet_executor/compute_interceptor.cc index fb907e3b5c29f4b8441aedcffe7cfd9cb8125ff2..4ba11fa7e327d380e9fa97a114f6c08bfff04028 100644 --- a/paddle/fluid/distributed/fleet_executor/compute_interceptor.cc +++ b/paddle/fluid/distributed/fleet_executor/compute_interceptor.cc @@ -13,8 +13,8 @@ // limitations under the License. #include "paddle/fluid/distributed/fleet_executor/compute_interceptor.h" -#include "paddle/fluid/distributed/fleet_executor/carrier.h" +#include "paddle/fluid/distributed/fleet_executor/carrier.h" #include "paddle/fluid/distributed/fleet_executor/task_node.h" #include "paddle/fluid/framework/executor_gc_helper.h" #include "paddle/fluid/framework/operator.h" diff --git a/paddle/fluid/distributed/fleet_executor/dist_model.cc b/paddle/fluid/distributed/fleet_executor/dist_model.cc index d8f937e218be440071971a5deef9ecc784541f83..8fe73d774946cc2da328388e9a444b8b76a6c162 100644 --- a/paddle/fluid/distributed/fleet_executor/dist_model.cc +++ b/paddle/fluid/distributed/fleet_executor/dist_model.cc @@ -12,10 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/distributed/fleet_executor/dist_model.h" + #include + #include // NOLINT -#include "paddle/fluid/distributed/fleet_executor/dist_model.h" #include "paddle/fluid/distributed/fleet_executor/fleet_executor.h" #include "paddle/fluid/distributed/fleet_executor/task_node.h" #include "paddle/fluid/framework/block_desc.h" @@ -294,8 +296,9 @@ bool DistModel::PrepareProgram() { bool DistModel::LoadProgram() { VLOG(3) << "Loading program from " << config_.model_dir; - PADDLE_ENFORCE_NE(config_.model_dir, "", platform::errors::InvalidArgument( - "Model dir must be provided.")); + PADDLE_ENFORCE_NE( + config_.model_dir, "", + platform::errors::InvalidArgument("Model dir must be provided.")); std::string model_path = config_.model_dir + ".pdmodel"; framework::proto::ProgramDesc program_proto; std::string pb_content; diff --git a/paddle/fluid/distributed/fleet_executor/dist_model.h b/paddle/fluid/distributed/fleet_executor/dist_model.h index d0203c131357c749b7df20a345982d2ddd025783..f5c1d47afb1a3d9a111e7a972dc26381d66431fd 100644 --- a/paddle/fluid/distributed/fleet_executor/dist_model.h +++ b/paddle/fluid/distributed/fleet_executor/dist_model.h @@ -31,7 +31,7 @@ namespace framework { class ProgramDesc; class Scope; class BlockDesc; -} +} // namespace framework namespace distributed { diff --git a/paddle/fluid/distributed/fleet_executor/dist_model_tensor_wrapper.cc b/paddle/fluid/distributed/fleet_executor/dist_model_tensor_wrapper.cc index b440d39c73a70f9c2eb8481d26af36d777ed68c7..b7f590e7a8c817e437da1ee92099281f2ecd31ce 100644 --- a/paddle/fluid/distributed/fleet_executor/dist_model_tensor_wrapper.cc +++ b/paddle/fluid/distributed/fleet_executor/dist_model_tensor_wrapper.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/fleet_executor/dist_model_tensor_wrapper.h" + #include "paddle/fluid/platform/enforce.h" namespace paddle { diff --git a/paddle/fluid/distributed/fleet_executor/dist_model_tensor_wrapper.h b/paddle/fluid/distributed/fleet_executor/dist_model_tensor_wrapper.h index dc8b2596803e074a7ca8cea069bf7d93ef1615e7..459e609762d844504146f2aa856d50d7e5c82e80 100644 --- a/paddle/fluid/distributed/fleet_executor/dist_model_tensor_wrapper.h +++ b/paddle/fluid/distributed/fleet_executor/dist_model_tensor_wrapper.h @@ -15,6 +15,7 @@ #pragma once #include #include + #include "paddle/fluid/platform/float16.h" #include "paddle/fluid/platform/macros.h" diff --git a/paddle/fluid/distributed/fleet_executor/fleet_executor.cc b/paddle/fluid/distributed/fleet_executor/fleet_executor.cc index e946d78550ff1bb0155843a680fbec33fdca9aa3..c4d7f3c7a69580915ef442cd26e34d24f7d32e26 100644 --- a/paddle/fluid/distributed/fleet_executor/fleet_executor.cc +++ b/paddle/fluid/distributed/fleet_executor/fleet_executor.cc @@ -11,9 +11,10 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/distributed/fleet_executor/fleet_executor.h" + #include -#include "paddle/fluid/distributed/fleet_executor/fleet_executor.h" #include "paddle/fluid/distributed/fleet_executor/global.h" #include "paddle/fluid/distributed/fleet_executor/message_bus.h" #include "paddle/fluid/distributed/fleet_executor/runtime_graph.h" diff --git a/paddle/fluid/distributed/fleet_executor/fleet_executor.h b/paddle/fluid/distributed/fleet_executor/fleet_executor.h index ccdb3dcc459489db9f342a2302fae3d777170313..176e5dab0da1778dc785d50aaad24c488b568179 100644 --- a/paddle/fluid/distributed/fleet_executor/fleet_executor.h +++ b/paddle/fluid/distributed/fleet_executor/fleet_executor.h @@ -25,7 +25,7 @@ namespace paddle { namespace framework { class ProgramDesc; class Scope; -} +} // namespace framework namespace distributed { class RuntimeGraph; diff --git a/paddle/fluid/distributed/fleet_executor/interceptor.cc b/paddle/fluid/distributed/fleet_executor/interceptor.cc index 710ebda41244ee3d731371ed1381e699c7cfced5..2ff2bc04ff85339c8fe8a465d26d20febdf16515 100644 --- a/paddle/fluid/distributed/fleet_executor/interceptor.cc +++ b/paddle/fluid/distributed/fleet_executor/interceptor.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/fleet_executor/interceptor.h" + #include "paddle/fluid/distributed/fleet_executor/carrier.h" #include "paddle/fluid/distributed/fleet_executor/task_loop.h" #include "paddle/fluid/distributed/fleet_executor/task_node.h" diff --git a/paddle/fluid/distributed/fleet_executor/interceptor.h b/paddle/fluid/distributed/fleet_executor/interceptor.h index 86ca7be7f44db8b8c98e09093ab0fc1520b2b9ac..00fe2154d28fa65b6fab678d798b7c5473098c77 100644 --- a/paddle/fluid/distributed/fleet_executor/interceptor.h +++ b/paddle/fluid/distributed/fleet_executor/interceptor.h @@ -33,7 +33,7 @@ namespace paddle { namespace framework { class Scope; class GarbageCollector; -} +} // namespace framework namespace distributed { class TaskNode; diff --git a/paddle/fluid/distributed/fleet_executor/message_bus.cc b/paddle/fluid/distributed/fleet_executor/message_bus.cc index 80a6b4667aa1a0dbfd957a390c9202ea1a4d2b68..76762af9e7e7a75edbadd7cca18d59287152a522 100644 --- a/paddle/fluid/distributed/fleet_executor/message_bus.cc +++ b/paddle/fluid/distributed/fleet_executor/message_bus.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/distributed/fleet_executor/message_bus.h" + #include #include #include @@ -19,7 +21,6 @@ #include "paddle/fluid/distributed/fleet_executor/carrier.h" #include "paddle/fluid/distributed/fleet_executor/global.h" -#include "paddle/fluid/distributed/fleet_executor/message_bus.h" #include "paddle/fluid/platform/gen_comm_id_helper.h" namespace paddle { @@ -28,8 +29,9 @@ namespace distributed { void MessageBus::Init( int64_t rank, const std::unordered_map& rank_to_addr, const std::string& addr) { - PADDLE_ENFORCE_EQ(is_init_, false, platform::errors::AlreadyExists( - "MessageBus is already init.")); + PADDLE_ENFORCE_EQ( + is_init_, false, + platform::errors::AlreadyExists("MessageBus is already init.")); rank_ = rank; is_init_ = true; rank_to_addr_ = rank_to_addr; diff --git a/paddle/fluid/distributed/fleet_executor/message_service.cc b/paddle/fluid/distributed/fleet_executor/message_service.cc index 1c66d83ea34d702733b3a5c0386abb62d4e1ec8a..9d42b0d73dbb428b76ad1d29ab275471683309f7 100644 --- a/paddle/fluid/distributed/fleet_executor/message_service.cc +++ b/paddle/fluid/distributed/fleet_executor/message_service.cc @@ -13,6 +13,7 @@ // limitations under the License. #if defined(PADDLE_WITH_DISTRIBUTE) && defined(PADDLE_WITH_PSCORE) #include "paddle/fluid/distributed/fleet_executor/message_service.h" + #include "brpc/server.h" #include "paddle/fluid/distributed/fleet_executor/global.h" #include "paddle/fluid/distributed/fleet_executor/message_bus.h" diff --git a/paddle/fluid/distributed/fleet_executor/runtime_graph.cc b/paddle/fluid/distributed/fleet_executor/runtime_graph.cc index 614b4c37e82545d7898fbc5db03f35991e8d3f1d..a5f90062dcfd9a4a262a89642436195874698ecf 100644 --- a/paddle/fluid/distributed/fleet_executor/runtime_graph.cc +++ b/paddle/fluid/distributed/fleet_executor/runtime_graph.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/fleet_executor/runtime_graph.h" + #include "paddle/fluid/distributed/fleet_executor/task_node.h" namespace paddle { diff --git a/paddle/fluid/distributed/fleet_executor/runtime_graph.h b/paddle/fluid/distributed/fleet_executor/runtime_graph.h index 1ca9f0174ed07f3c12a8fb937799cfc4dd444b37..a59a43cc200a5f1ed7581d652c8317f11408b1fb 100644 --- a/paddle/fluid/distributed/fleet_executor/runtime_graph.h +++ b/paddle/fluid/distributed/fleet_executor/runtime_graph.h @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/fluid/distributed/fleet_executor/fleet_executor_desc.pb.h" #include "paddle/fluid/framework/op_proto_maker.h" #include "paddle/fluid/platform/macros.h" diff --git a/paddle/fluid/distributed/fleet_executor/sink_interceptor.cc b/paddle/fluid/distributed/fleet_executor/sink_interceptor.cc index 77fbb23a6c71b1aae986217295baaab2707b3ec0..9d9e6c03565484fafcf9e4aa4acc4b3cc686dd2e 100644 --- a/paddle/fluid/distributed/fleet_executor/sink_interceptor.cc +++ b/paddle/fluid/distributed/fleet_executor/sink_interceptor.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/fleet_executor/sink_interceptor.h" + #include "paddle/fluid/distributed/fleet_executor/task_node.h" namespace paddle { diff --git a/paddle/fluid/distributed/fleet_executor/source_interceptor.cc b/paddle/fluid/distributed/fleet_executor/source_interceptor.cc index 78b2bed66dd99d60d1e39782e501d116bd6c1ec7..6b2fd5565ea135b78def86003af4d2bbcef70b8d 100644 --- a/paddle/fluid/distributed/fleet_executor/source_interceptor.cc +++ b/paddle/fluid/distributed/fleet_executor/source_interceptor.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/fleet_executor/source_interceptor.h" + #include "paddle/fluid/distributed/fleet_executor/task_node.h" namespace paddle { diff --git a/paddle/fluid/distributed/fleet_executor/task_loop_thread.cc b/paddle/fluid/distributed/fleet_executor/task_loop_thread.cc index bb313ad37890d9bd2d74fba9ca398f341a0e0ae8..90765dbdd2d094e92a61832e3cafbf929c7bb368 100644 --- a/paddle/fluid/distributed/fleet_executor/task_loop_thread.cc +++ b/paddle/fluid/distributed/fleet_executor/task_loop_thread.cc @@ -31,8 +31,9 @@ TaskLoopThread::~TaskLoopThread() { } TaskLoop* TaskLoopThread::StartLoop() { - PADDLE_ENFORCE_EQ(start_, false, platform::errors::PreconditionNotMet( - "thread is already running.")); + PADDLE_ENFORCE_EQ( + start_, false, + platform::errors::PreconditionNotMet("thread is already running.")); start_ = true; thread_ = std::thread([this]() { Loop(); }); diff --git a/paddle/fluid/distributed/fleet_executor/task_loop_thread_pool.cc b/paddle/fluid/distributed/fleet_executor/task_loop_thread_pool.cc index ed34bbb87fc6bd8d06a0d54a7184b908aae5de79..e962a29b4a1507c8e0ef7ff2f7aa4b8968a49de0 100644 --- a/paddle/fluid/distributed/fleet_executor/task_loop_thread_pool.cc +++ b/paddle/fluid/distributed/fleet_executor/task_loop_thread_pool.cc @@ -30,8 +30,9 @@ TaskLoopThreadPool::TaskLoopThreadPool(int thread_num) TaskLoopThreadPool::~TaskLoopThreadPool() = default; void TaskLoopThreadPool::Start() { - PADDLE_ENFORCE_EQ(start_, false, platform::errors::PreconditionNotMet( - "thread pool is already start.")); + PADDLE_ENFORCE_EQ( + start_, false, + platform::errors::PreconditionNotMet("thread pool is already start.")); PADDLE_ENFORCE_GT( thread_num_, 0, platform::errors::InvalidArgument( @@ -45,10 +46,12 @@ void TaskLoopThreadPool::Start() { } TaskLoop* TaskLoopThreadPool::GetLoop(int tid) { - PADDLE_ENFORCE_EQ(start_, true, platform::errors::PreconditionNotMet( - "thread pool must start first.")); - PADDLE_ENFORCE_GE(tid, 0, platform::errors::OutOfRange( - "tid must >= 0, but now is %d", tid)); + PADDLE_ENFORCE_EQ( + start_, true, + platform::errors::PreconditionNotMet("thread pool must start first.")); + PADDLE_ENFORCE_GE( + tid, 0, + platform::errors::OutOfRange("tid must >= 0, but now is %d", tid)); PADDLE_ENFORCE_LT(tid, thread_num_, platform::errors::OutOfRange( "tid must < thread_num, but now tid=%d thread_num=%d", @@ -57,8 +60,9 @@ TaskLoop* TaskLoopThreadPool::GetLoop(int tid) { } std::vector TaskLoopThreadPool::GetAllLoops() { - PADDLE_ENFORCE_EQ(start_, true, platform::errors::PreconditionNotMet( - "thread pool must start first.")); + PADDLE_ENFORCE_EQ( + start_, true, + platform::errors::PreconditionNotMet("thread pool must start first.")); return loops_; } diff --git a/paddle/fluid/distributed/fleet_executor/task_node.cc b/paddle/fluid/distributed/fleet_executor/task_node.cc index 232317333ea11f85da3f7da8606eeeb3c18619f9..00ae30d281ee8571ee309612ef97300d0ddfa240 100644 --- a/paddle/fluid/distributed/fleet_executor/task_node.cc +++ b/paddle/fluid/distributed/fleet_executor/task_node.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/fleet_executor/task_node.h" + #include "paddle/fluid/framework/op_desc.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" @@ -153,15 +154,17 @@ void TaskNode::SetRunAtOffset(int64_t value) { void TaskNode::SetReplyUpPerSteps(int64_t value) { PADDLE_ENFORCE_GE( - value, 1, platform::errors::InvalidArgument( - "reply_up_per_steps must >= 1, but received %ld", value)); + value, 1, + platform::errors::InvalidArgument( + "reply_up_per_steps must >= 1, but received %ld", value)); reply_up_per_steps_ = value; } void TaskNode::SetSendDownPerSteps(int64_t value) { PADDLE_ENFORCE_GE( - value, 1, platform::errors::InvalidArgument( - "send_down_per_steps must >= 1, but received %ld", value)); + value, 1, + platform::errors::InvalidArgument( + "send_down_per_steps must >= 1, but received %ld", value)); send_down_per_steps_ = value; } diff --git a/paddle/fluid/distributed/fleet_executor/task_node.h b/paddle/fluid/distributed/fleet_executor/task_node.h index 7dd4b5454567e58d33cf568f6c47f008dbca1fff..16e686a4401b8c85be3d3ea9528a4c85e11985f7 100644 --- a/paddle/fluid/distributed/fleet_executor/task_node.h +++ b/paddle/fluid/distributed/fleet_executor/task_node.h @@ -26,7 +26,7 @@ namespace paddle { namespace framework { class OperatorBase; class OpDesc; -} +} // namespace framework namespace distributed { class TaskNode final { diff --git a/paddle/fluid/distributed/fleet_executor/test/compute_interceptor_run_op_test.cc b/paddle/fluid/distributed/fleet_executor/test/compute_interceptor_run_op_test.cc index 35857fc86b5e0cc2c3c2dc84d017dcbfb8b948d2..bd81d3644f4d866b067e38d5853cd9cd435e6e85 100644 --- a/paddle/fluid/distributed/fleet_executor/test/compute_interceptor_run_op_test.cc +++ b/paddle/fluid/distributed/fleet_executor/test/compute_interceptor_run_op_test.cc @@ -16,7 +16,6 @@ limitations under the License. */ #include #include "gtest/gtest.h" - #include "paddle/fluid/distributed/fleet_executor/carrier.h" #include "paddle/fluid/distributed/fleet_executor/global.h" #include "paddle/fluid/distributed/fleet_executor/interceptor.h" diff --git a/paddle/fluid/distributed/fleet_executor/test/compute_interceptor_test.cc b/paddle/fluid/distributed/fleet_executor/test/compute_interceptor_test.cc index 954b52693f46c0d4b87e030f5629800eefc7c9e1..4992a8b34c9da163af6bb64cad0094da9142afb2 100644 --- a/paddle/fluid/distributed/fleet_executor/test/compute_interceptor_test.cc +++ b/paddle/fluid/distributed/fleet_executor/test/compute_interceptor_test.cc @@ -16,7 +16,6 @@ limitations under the License. */ #include #include "gtest/gtest.h" - #include "paddle/fluid/distributed/fleet_executor/carrier.h" #include "paddle/fluid/distributed/fleet_executor/global.h" #include "paddle/fluid/distributed/fleet_executor/interceptor.h" diff --git a/paddle/fluid/distributed/fleet_executor/test/interceptor_ping_pong_test.cc b/paddle/fluid/distributed/fleet_executor/test/interceptor_ping_pong_test.cc index 19c1d0a0d7a6a20a18e2ead960a69230e065cac5..54adf06fb67ddf6e5d9ac803b3aa097289c33c38 100644 --- a/paddle/fluid/distributed/fleet_executor/test/interceptor_ping_pong_test.cc +++ b/paddle/fluid/distributed/fleet_executor/test/interceptor_ping_pong_test.cc @@ -16,7 +16,6 @@ limitations under the License. */ #include #include "gtest/gtest.h" - #include "paddle/fluid/distributed/fleet_executor/carrier.h" #include "paddle/fluid/distributed/fleet_executor/global.h" #include "paddle/fluid/distributed/fleet_executor/interceptor.h" diff --git a/paddle/fluid/distributed/fleet_executor/test/interceptor_ping_pong_with_brpc_test.cc b/paddle/fluid/distributed/fleet_executor/test/interceptor_ping_pong_with_brpc_test.cc index 78cff2606f6b8fabc459838ee17b9ec29221ba32..3828c4478cbe6eecad18a88ce5501eae84eb0589 100644 --- a/paddle/fluid/distributed/fleet_executor/test/interceptor_ping_pong_with_brpc_test.cc +++ b/paddle/fluid/distributed/fleet_executor/test/interceptor_ping_pong_with_brpc_test.cc @@ -14,11 +14,11 @@ limitations under the License. */ #include #include + #include #include #include "gtest/gtest.h" - #include "paddle/fluid/distributed/fleet_executor/carrier.h" #include "paddle/fluid/distributed/fleet_executor/global.h" #include "paddle/fluid/distributed/fleet_executor/interceptor.h" diff --git a/paddle/fluid/distributed/fleet_executor/test/interceptor_pipeline_long_path_test.cc b/paddle/fluid/distributed/fleet_executor/test/interceptor_pipeline_long_path_test.cc index e909744a4b5d65456e96dcc7d7f8d25b54992151..a78cd6955f246acedeb8ef14dc7dcec5410ae36b 100644 --- a/paddle/fluid/distributed/fleet_executor/test/interceptor_pipeline_long_path_test.cc +++ b/paddle/fluid/distributed/fleet_executor/test/interceptor_pipeline_long_path_test.cc @@ -16,7 +16,6 @@ limitations under the License. */ #include #include "gtest/gtest.h" - #include "paddle/fluid/distributed/fleet_executor/carrier.h" #include "paddle/fluid/distributed/fleet_executor/global.h" #include "paddle/fluid/distributed/fleet_executor/interceptor.h" diff --git a/paddle/fluid/distributed/fleet_executor/test/interceptor_pipeline_short_path_test.cc b/paddle/fluid/distributed/fleet_executor/test/interceptor_pipeline_short_path_test.cc index 0e57596bacbe655ba8bbe8c02323a0affcb5ea11..53755bf1a40ebd8b25ac630ca9a6de572f636041 100644 --- a/paddle/fluid/distributed/fleet_executor/test/interceptor_pipeline_short_path_test.cc +++ b/paddle/fluid/distributed/fleet_executor/test/interceptor_pipeline_short_path_test.cc @@ -16,7 +16,6 @@ limitations under the License. */ #include #include "gtest/gtest.h" - #include "paddle/fluid/distributed/fleet_executor/carrier.h" #include "paddle/fluid/distributed/fleet_executor/global.h" #include "paddle/fluid/distributed/fleet_executor/interceptor.h" diff --git a/paddle/fluid/distributed/fleet_executor/test/sink_interceptor_test.cc b/paddle/fluid/distributed/fleet_executor/test/sink_interceptor_test.cc index 8ff908f90ec85e56d52042ceaec1a7af7920b223..879d7e9b02941811e8fa8e9d6bd3f0e6f5339851 100644 --- a/paddle/fluid/distributed/fleet_executor/test/sink_interceptor_test.cc +++ b/paddle/fluid/distributed/fleet_executor/test/sink_interceptor_test.cc @@ -16,7 +16,6 @@ #include #include "gtest/gtest.h" - #include "paddle/fluid/distributed/fleet_executor/carrier.h" #include "paddle/fluid/distributed/fleet_executor/global.h" #include "paddle/fluid/distributed/fleet_executor/interceptor.h" diff --git a/paddle/fluid/distributed/fleet_executor/test/source_interceptor_test.cc b/paddle/fluid/distributed/fleet_executor/test/source_interceptor_test.cc index e9c0437c829d4df574d27fb013cba8ea57711c2c..21a1b4accc9f1e64c6fbc4fab9a393fef6a430fe 100644 --- a/paddle/fluid/distributed/fleet_executor/test/source_interceptor_test.cc +++ b/paddle/fluid/distributed/fleet_executor/test/source_interceptor_test.cc @@ -16,7 +16,6 @@ #include #include "gtest/gtest.h" - #include "paddle/fluid/distributed/fleet_executor/carrier.h" #include "paddle/fluid/distributed/fleet_executor/global.h" #include "paddle/fluid/distributed/fleet_executor/interceptor.h" diff --git a/paddle/fluid/distributed/index_dataset/index_sampler.cc b/paddle/fluid/distributed/index_dataset/index_sampler.cc index 306d11d333dae680cb1623bff64093a1a8e35493..b82193220515ae1ee669614b06694a3290b0c0e6 100644 --- a/paddle/fluid/distributed/index_dataset/index_sampler.cc +++ b/paddle/fluid/distributed/index_dataset/index_sampler.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/index_dataset/index_sampler.h" + #include "paddle/fluid/framework/data_feed.h" namespace paddle { diff --git a/paddle/fluid/distributed/index_dataset/index_sampler.h b/paddle/fluid/distributed/index_dataset/index_sampler.h index 02806b814c20097306cf00cebbcd04e21718462e..a82348c9ec5867183187ff0043c864724c447c71 100644 --- a/paddle/fluid/distributed/index_dataset/index_sampler.h +++ b/paddle/fluid/distributed/index_dataset/index_sampler.h @@ -14,6 +14,7 @@ #pragma once #include + #include "paddle/fluid/distributed/index_dataset/index_wrapper.h" #include "paddle/fluid/framework/data_feed.h" #include "paddle/fluid/framework/program_desc.h" diff --git a/paddle/fluid/distributed/index_dataset/index_wrapper.cc b/paddle/fluid/distributed/index_dataset/index_wrapper.cc index 27aa890f7600fba20ef7a9b535d368fa28714972..61941ef513334bef888de0127b9d3870c083223a 100644 --- a/paddle/fluid/distributed/index_dataset/index_wrapper.cc +++ b/paddle/fluid/distributed/index_dataset/index_wrapper.cc @@ -9,15 +9,16 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/distributed/index_dataset/index_wrapper.h" + #include #include #include #include #include #include -#include "paddle/fluid/framework/io/fs.h" -#include "paddle/fluid/distributed/index_dataset/index_wrapper.h" +#include "paddle/fluid/framework/io/fs.h" namespace paddle { namespace distributed { diff --git a/paddle/fluid/distributed/index_dataset/index_wrapper.h b/paddle/fluid/distributed/index_dataset/index_wrapper.h index 8fb8faf6c84a2d9e1a5e80179a113b8d1ef312c8..1c652e60bbbc39274b7b6bfcc1e543799996e42d 100644 --- a/paddle/fluid/distributed/index_dataset/index_wrapper.h +++ b/paddle/fluid/distributed/index_dataset/index_wrapper.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/distributed/index_dataset/index_dataset.pb.h" #include "paddle/fluid/platform/enforce.h" @@ -90,10 +91,11 @@ class IndexWrapper { } TreePtr tree = std::make_shared(); int ret = tree->Load(tree_path); - PADDLE_ENFORCE_EQ(ret, 0, paddle::platform::errors::InvalidArgument( - "Load tree[%s] from path[%s] failed. Please " - "check whether the file exists.", - name, tree_path)); + PADDLE_ENFORCE_EQ(ret, 0, + paddle::platform::errors::InvalidArgument( + "Load tree[%s] from path[%s] failed. Please " + "check whether the file exists.", + name, tree_path)); tree_map.insert(std::pair{name, tree}); } diff --git a/paddle/fluid/distributed/ps/service/brpc_ps_client.cc b/paddle/fluid/distributed/ps/service/brpc_ps_client.cc old mode 100755 new mode 100644 index 0959b651bb5586faeef7c9124888cabd30babd4e..89466076b23d0658388165268094bf0d55dc5e7b --- a/paddle/fluid/distributed/ps/service/brpc_ps_client.cc +++ b/paddle/fluid/distributed/ps/service/brpc_ps_client.cc @@ -12,11 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/distributed/ps/service/brpc_ps_client.h" + #include #include #include -#include "paddle/fluid/distributed/ps/service/brpc_ps_client.h" #include "paddle/fluid/framework/archive.h" static const int max_port = 65535; @@ -245,8 +246,9 @@ int32_t BrpcPsClient::Initialize() { int DownpourBrpcClosure::check_response(size_t request_idx, int cmd_id) { if (_cntls[request_idx]->Failed()) { - LOG(ERROR) << "resquest cmd_id:" << cmd_id << " failed, " - "err:" + LOG(ERROR) << "resquest cmd_id:" << cmd_id + << " failed, " + "err:" << _cntls[request_idx]->ErrorText(); return -1; } @@ -263,8 +265,9 @@ int DownpourBrpcClosure::check_response(size_t request_idx, int cmd_id) { int DownpourBrpcClosure::check_save_response(size_t request_idx, int cmd_id) { int32_t feasign_size = 0; if (_cntls[request_idx]->Failed()) { - LOG(ERROR) << "resquest cmd_id:" << cmd_id << " failed, " - "err:" + LOG(ERROR) << "resquest cmd_id:" << cmd_id + << " failed, " + "err:" << _cntls[request_idx]->ErrorText(); return -1; } diff --git a/paddle/fluid/distributed/ps/service/brpc_ps_client.h b/paddle/fluid/distributed/ps/service/brpc_ps_client.h index e2c16d496c42c2675500c404cc300523d3c3924e..17b6bbe22cefe238a082e4c24b83cfd53518568c 100644 --- a/paddle/fluid/distributed/ps/service/brpc_ps_client.h +++ b/paddle/fluid/distributed/ps/service/brpc_ps_client.h @@ -15,6 +15,7 @@ #pragma once #include + #include #include #include diff --git a/paddle/fluid/distributed/ps/service/brpc_ps_server.cc b/paddle/fluid/distributed/ps/service/brpc_ps_server.cc old mode 100755 new mode 100644 index 8167c37b59987fa2f3f5d3d64c936086e850ab80..d859acbb42e44e912b41ce16964931447335759f --- a/paddle/fluid/distributed/ps/service/brpc_ps_server.cc +++ b/paddle/fluid/distributed/ps/service/brpc_ps_server.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/distributed/ps/service/brpc_ps_server.h" + #include // NOLINT + #include "butil/object_pool.h" #include "paddle/fluid/distributed/common/cost_timer.h" #include "paddle/fluid/distributed/ps/table/depends/sparse_utils.h" diff --git a/paddle/fluid/distributed/ps/service/brpc_utils.h b/paddle/fluid/distributed/ps/service/brpc_utils.h index e68e15058f7b00f60eeb5f528baff4e91b0b23c8..d4332744cebca3320ee4cdfa91223b600d740342 100644 --- a/paddle/fluid/distributed/ps/service/brpc_utils.h +++ b/paddle/fluid/distributed/ps/service/brpc_utils.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include #include #include diff --git a/paddle/fluid/distributed/ps/service/communicator/communicator.cc b/paddle/fluid/distributed/ps/service/communicator/communicator.cc index c4b833f294e177f13fcd7e99a086f14260502010..c50f1d909cd952bcf8334929df09fd754b5f3850 100644 --- a/paddle/fluid/distributed/ps/service/communicator/communicator.cc +++ b/paddle/fluid/distributed/ps/service/communicator/communicator.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/distributed/ps/service/communicator/communicator.h" + #include + #include "gflags/gflags.h" #include "paddle/fluid/distributed/ps/service/brpc_ps_client.h" #include "paddle/fluid/distributed/ps/wrapper/fleet.h" diff --git a/paddle/fluid/distributed/ps/service/communicator/communicator.h b/paddle/fluid/distributed/ps/service/communicator/communicator.h index 75676c392435cc2fc010d736556eabce85189790..5f2a0cbb9097625efe31cb819d357ca5795db272 100644 --- a/paddle/fluid/distributed/ps/service/communicator/communicator.h +++ b/paddle/fluid/distributed/ps/service/communicator/communicator.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include #include #include @@ -30,6 +31,7 @@ limitations under the License. */ #include "gflags/gflags.h" #include "paddle/fluid/distributed/ps/service/communicator/communicator_common.h" +#include "paddle/fluid/distributed/ps/service/ps_client.h" #include "paddle/fluid/framework/channel.h" #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/framework/variable.h" @@ -42,8 +44,6 @@ limitations under the License. */ #include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/math_function.h" -#include "paddle/fluid/distributed/ps/service/ps_client.h" - namespace paddle { namespace distributed { class PSClient; @@ -157,8 +157,9 @@ template inline void MergeVars(const std::string &var_name, const std::vector> &vars, Scope *scope, bool merge_add = true) { - PADDLE_ENFORCE_NE(vars.empty(), true, platform::errors::InvalidArgument( - "vector vars are empty.")); + PADDLE_ENFORCE_NE( + vars.empty(), true, + platform::errors::InvalidArgument("vector vars are empty.")); auto cpu_place = platform::CPUPlace(); auto &var0 = vars[0]; auto *out_var = scope->Var(var_name); diff --git a/paddle/fluid/distributed/ps/service/env.h b/paddle/fluid/distributed/ps/service/env.h index 162ee6f0984223baf10a95a2853c41e0c6821910..0fddb17da7c417e99cb6c8ef087ea88833dd13ba 100644 --- a/paddle/fluid/distributed/ps/service/env.h +++ b/paddle/fluid/distributed/ps/service/env.h @@ -18,11 +18,13 @@ #include #include #include + #include #include #include #include #include + #include "gflags/gflags.h" namespace paddle { diff --git a/paddle/fluid/distributed/ps/service/graph_brpc_client.cc b/paddle/fluid/distributed/ps/service/graph_brpc_client.cc index c1df490669dbe061374f4e00a2d3409b8e56e61e..ff9680044dd6b5f4b01a3855d21bcbc6bc12c8dd 100644 --- a/paddle/fluid/distributed/ps/service/graph_brpc_client.cc +++ b/paddle/fluid/distributed/ps/service/graph_brpc_client.cc @@ -13,12 +13,14 @@ // limitations under the License. #include "paddle/fluid/distributed/ps/service/graph_brpc_client.h" + #include #include #include #include #include #include + #include "Eigen/Dense" #include "paddle/fluid/distributed/ps/service/brpc_ps_client.h" #include "paddle/fluid/distributed/ps/table/table.h" @@ -149,7 +151,7 @@ std::future GraphBrpcClient::get_node_feat( std::future GraphBrpcClient::clear_nodes(uint32_t table_id, int type_id, int idx_) { DownpourBrpcClosure *closure = new DownpourBrpcClosure( - server_size, [&, server_size = this->server_size ](void *done) { + server_size, [&, server_size = this->server_size](void *done) { int ret = 0; auto *closure = (DownpourBrpcClosure *)done; size_t fail_num = 0; @@ -665,5 +667,5 @@ int32_t GraphBrpcClient::Initialize() { local_channel = NULL; return 0; } -} -} +} // namespace distributed +} // namespace paddle diff --git a/paddle/fluid/distributed/ps/service/graph_brpc_client.h b/paddle/fluid/distributed/ps/service/graph_brpc_client.h index 51f14bc57cde04a39be1052fd0fa489a5d29f4ea..c038c840df97fc436fddbab1129f1e51ac743cbb 100644 --- a/paddle/fluid/distributed/ps/service/graph_brpc_client.h +++ b/paddle/fluid/distributed/ps/service/graph_brpc_client.h @@ -15,11 +15,12 @@ #pragma once #include + #include #include +#include #include -#include #include "ThreadPool.h" #include "brpc/channel.h" #include "brpc/controller.h" diff --git a/paddle/fluid/distributed/ps/service/graph_brpc_server.cc b/paddle/fluid/distributed/ps/service/graph_brpc_server.cc index 8ff12265269b2848155e33b9b3b099611dfc918d..5ce26b452504115e92625757be4e62c4178bc352 100644 --- a/paddle/fluid/distributed/ps/service/graph_brpc_server.cc +++ b/paddle/fluid/distributed/ps/service/graph_brpc_server.cc @@ -13,13 +13,14 @@ // limitations under the License. #include "paddle/fluid/distributed/ps/service/graph_brpc_server.h" -#include "paddle/fluid/distributed/ps/service/brpc_ps_server.h" #include // NOLINT #include + #include "butil/endpoint.h" #include "iomanip" #include "paddle/fluid/distributed/ps/service/brpc_ps_client.h" +#include "paddle/fluid/distributed/ps/service/brpc_ps_server.h" #include "paddle/fluid/framework/archive.h" #include "paddle/fluid/platform/profiler.h" namespace paddle { diff --git a/paddle/fluid/distributed/ps/service/graph_brpc_server.h b/paddle/fluid/distributed/ps/service/graph_brpc_server.h index caf728701b289e9629a726aaee84d1f4744ff8c0..726876bef162156e1a902b1ecc1b07b6b7422550 100644 --- a/paddle/fluid/distributed/ps/service/graph_brpc_server.h +++ b/paddle/fluid/distributed/ps/service/graph_brpc_server.h @@ -14,12 +14,12 @@ #pragma once +#include +#include + #include "brpc/channel.h" #include "brpc/controller.h" #include "brpc/server.h" - -#include -#include #include "paddle/fluid/distributed/ps/service/brpc_ps_server.h" #include "paddle/fluid/distributed/ps/service/server.h" #include "paddle/fluid/distributed/ps/table/common_graph_table.h" diff --git a/paddle/fluid/distributed/ps/service/ps_client.cc b/paddle/fluid/distributed/ps/service/ps_client.cc index f7df99ec13cdf128e22e5ed9a702f9e1983186ad..a0216f2a7953aac29440d609c06c232ab0808ed3 100644 --- a/paddle/fluid/distributed/ps/service/ps_client.cc +++ b/paddle/fluid/distributed/ps/service/ps_client.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/ps/service/ps_client.h" + #include "glog/logging.h" #include "paddle/fluid/distributed/ps/service/brpc_ps_client.h" #include "paddle/fluid/distributed/ps/service/graph_brpc_client.h" diff --git a/paddle/fluid/distributed/ps/service/ps_client.h b/paddle/fluid/distributed/ps/service/ps_client.h index 926bb7e7c9fd31bccea82b343237d691f3698bdb..adf096c8469c54885cbced09f5da5e756a729fc3 100644 --- a/paddle/fluid/distributed/ps/service/ps_client.h +++ b/paddle/fluid/distributed/ps/service/ps_client.h @@ -20,6 +20,7 @@ #include #include #include + #include "paddle/fluid/distributed/common/cost_timer.h" #include "paddle/fluid/distributed/ps.pb.h" #include "paddle/fluid/distributed/ps/service/env.h" diff --git a/paddle/fluid/distributed/ps/service/ps_local_client.cc b/paddle/fluid/distributed/ps/service/ps_local_client.cc index bc024ed3175bc4e24d317d872ffd5b8c67f95e4a..b6407ccebe52b9d11cb4a546bd5b6c23a6458483 100644 --- a/paddle/fluid/distributed/ps/service/ps_local_client.cc +++ b/paddle/fluid/distributed/ps/service/ps_local_client.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/ps/service/ps_local_client.h" + #include "paddle/fluid/distributed/ps/table/table.h" //#define pslib_debug_dense_compress @@ -316,5 +317,5 @@ int32_t PsLocalClient::Initialize() { table_ptr->Push(table_context); return done(); } -} -} +} // namespace distributed +} // namespace paddle diff --git a/paddle/fluid/distributed/ps/service/ps_local_client.h b/paddle/fluid/distributed/ps/service/ps_local_client.h index 439ecf79f2f808c98edc9ca1c0ea8403f9266bc8..89c2f7446ac3be3e93a116daedb9926824bb3eec 100644 --- a/paddle/fluid/distributed/ps/service/ps_local_client.h +++ b/paddle/fluid/distributed/ps/service/ps_local_client.h @@ -223,5 +223,5 @@ class PsLocalClient : public PSClient { float _mse = 0; uint16_t _push_times = 0; }; -} -} +} // namespace distributed +} // namespace paddle diff --git a/paddle/fluid/distributed/ps/service/ps_local_server.h b/paddle/fluid/distributed/ps/service/ps_local_server.h index c09f8585b659d64951ee6c522e82a8d83f43c6e6..2075e9dd2be28608172c1f517ced201c382c5357 100644 --- a/paddle/fluid/distributed/ps/service/ps_local_server.h +++ b/paddle/fluid/distributed/ps/service/ps_local_server.h @@ -16,6 +16,7 @@ #include #include + #include "paddle/fluid/distributed/ps/service/server.h" namespace paddle { @@ -37,5 +38,5 @@ class PsLocalServer : public PSServer { private: virtual int32_t Initialize() { return 0; } }; -} -} +} // namespace distributed +} // namespace paddle diff --git a/paddle/fluid/distributed/ps/service/ps_service/graph_py_service.cc b/paddle/fluid/distributed/ps/service/ps_service/graph_py_service.cc index ced51b8cbe383b96ca1c9b8593e779b8cc2facc0..255c0d3d655aa295608e38b9b9820931304a9bd7 100644 --- a/paddle/fluid/distributed/ps/service/ps_service/graph_py_service.cc +++ b/paddle/fluid/distributed/ps/service/ps_service/graph_py_service.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/distributed/ps/service/ps_service/graph_py_service.h" + #include // NOLINT + #include "butil/endpoint.h" #include "iomanip" #include "paddle/fluid/distributed/ps/table/table.h" @@ -501,5 +503,5 @@ void GraphPyClient::StopServer() { if (status.get() == 0) stoped_ = true; } void GraphPyClient::FinalizeWorker() { this->worker_ptr->FinalizeWorker(); } -} -} +} // namespace distributed +} // namespace paddle diff --git a/paddle/fluid/distributed/ps/service/ps_service/graph_py_service.h b/paddle/fluid/distributed/ps/service/ps_service/graph_py_service.h index 55beb9b3932a62c411efffe19e9fafa646183438..7dd03401256932ef5381b138b13ff0e2e5007719 100644 --- a/paddle/fluid/distributed/ps/service/ps_service/graph_py_service.h +++ b/paddle/fluid/distributed/ps/service/ps_service/graph_py_service.h @@ -14,6 +14,7 @@ #pragma once #include + #include // NOLINT #include #include @@ -23,21 +24,20 @@ #include // NOLINT #include #include -#include "google/protobuf/text_format.h" +#include "google/protobuf/text_format.h" #include "gtest/gtest.h" -#include "paddle/fluid/framework/lod_tensor.h" -#include "paddle/fluid/framework/scope.h" -#include "paddle/fluid/framework/tensor_util.h" -#include "paddle/fluid/framework/variable.h" - #include "paddle/fluid/distributed/ps.pb.h" #include "paddle/fluid/distributed/ps/service/env.h" #include "paddle/fluid/distributed/ps/service/graph_brpc_client.h" #include "paddle/fluid/distributed/ps/service/graph_brpc_server.h" #include "paddle/fluid/distributed/ps/service/ps_service/service.h" #include "paddle/fluid/distributed/ps/service/sendrecv.pb.h" +#include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/program_desc.h" +#include "paddle/fluid/framework/scope.h" +#include "paddle/fluid/framework/tensor_util.h" +#include "paddle/fluid/framework/variable.h" #include "paddle/fluid/platform/place.h" #include "paddle/fluid/string/printf.h" #include "paddle/phi/kernels/funcs/math_function.h" @@ -198,5 +198,5 @@ class GraphPyClient : public GraphPyService { std::thread* client_thread; bool stoped_ = false; }; -} -} +} // namespace distributed +} // namespace paddle diff --git a/paddle/fluid/distributed/ps/service/ps_service/service.cc b/paddle/fluid/distributed/ps/service/ps_service/service.cc index 9c3a06c2212e6a797132a25ebec775abb05aeed8..9eb5d49a4051c3f68be75aa3534c91ee7a8dfa4b 100644 --- a/paddle/fluid/distributed/ps/service/ps_service/service.cc +++ b/paddle/fluid/distributed/ps/service/ps_service/service.cc @@ -17,7 +17,9 @@ #include #include #include + #include + #include "paddle/fluid/distributed/ps/service/communicator/communicator.h" #include "paddle/fluid/string/string_helper.h" diff --git a/paddle/fluid/distributed/ps/service/server.h b/paddle/fluid/distributed/ps/service/server.h index c044e82884604b3a7104dfaa94696fb61eb7b049..55bbbc06d878a2ed8e1d48322118792f34579f1f 100644 --- a/paddle/fluid/distributed/ps/service/server.h +++ b/paddle/fluid/distributed/ps/service/server.h @@ -20,6 +20,7 @@ #include #include #include + #include "butil/endpoint.h" #include "google/protobuf/service.h" #include "paddle/fluid/distributed/common/registerer.h" diff --git a/paddle/fluid/distributed/ps/table/accessor.h b/paddle/fluid/distributed/ps/table/accessor.h index 7713c2bda295fad1ab1c5289d3e2dd893b054591..4db8ad0a55a5e5dc63b5f871c00957e2f5be712f 100644 --- a/paddle/fluid/distributed/ps/table/accessor.h +++ b/paddle/fluid/distributed/ps/table/accessor.h @@ -15,8 +15,10 @@ #pragma once #include #include + #include #include + #include "paddle/fluid/distributed/common/afs_warpper.h" #include "paddle/fluid/distributed/common/registerer.h" #include "paddle/fluid/distributed/ps.pb.h" diff --git a/paddle/fluid/distributed/ps/table/common_graph_table.cc b/paddle/fluid/distributed/ps/table/common_graph_table.cc index 43dee275a3dc690dfc16cbc2149d47368ea66fb5..55a9c794e8ead2becd6f36ead1612522eef42c9f 100644 --- a/paddle/fluid/distributed/ps/table/common_graph_table.cc +++ b/paddle/fluid/distributed/ps/table/common_graph_table.cc @@ -13,11 +13,14 @@ // limitations under the License. #include "paddle/fluid/distributed/ps/table/common_graph_table.h" + #include + #include #include #include #include + #include "paddle/fluid/distributed/common/utils.h" #include "paddle/fluid/distributed/ps/table/graph/graph_node.h" #include "paddle/fluid/framework/generator.h" @@ -212,7 +215,6 @@ int64_t GraphTable::load_graph_to_memory_from_ssd(int idx, for (size_t i = 0; i < bags.size(); i++) { if (bags[i].size() > 0) { tasks.push_back(_shards_task_pool[i]->enqueue([&, i, idx, this]() -> int { - char ch[sizeof(int) * 2 + sizeof(int64_t)]; memset(ch, 0, sizeof(int)); memcpy(ch + sizeof(int), &idx, sizeof(int)); @@ -353,7 +355,6 @@ void GraphTable::export_partition_files(int idx, std::string file_path) { for (int i = 0; i < part_len; i++) { tasks.push_back(_shards_task_pool[i % task_pool_size_]->enqueue( [&, i, idx, this]() -> int { - std::string output_path = file_path + "partition_" + std::to_string(i); diff --git a/paddle/fluid/distributed/ps/table/common_graph_table.h b/paddle/fluid/distributed/ps/table/common_graph_table.h index 25bec5276e729371f4b40c6070904e2f34655784..6dd24df921dc187a512a964c99f722d5660b5117 100644 --- a/paddle/fluid/distributed/ps/table/common_graph_table.h +++ b/paddle/fluid/distributed/ps/table/common_graph_table.h @@ -17,6 +17,7 @@ #include #include #include + #include #include #include @@ -36,6 +37,7 @@ #include #include #include + #include "paddle/fluid/distributed/ps/table/accessor.h" #include "paddle/fluid/distributed/ps/table/common_table.h" #include "paddle/fluid/distributed/ps/table/graph/class_macro.h" @@ -670,4 +672,4 @@ struct hash { return s.idx ^ s.node_key ^ s.sample_size; } }; -} +} // namespace std diff --git a/paddle/fluid/distributed/ps/table/common_table.h b/paddle/fluid/distributed/ps/table/common_table.h index f69d9ccbf1453b6927d50e9effca3aff2b430ca0..280573f71947edfd03b4d0e7033d396bd33bb4e8 100644 --- a/paddle/fluid/distributed/ps/table/common_table.h +++ b/paddle/fluid/distributed/ps/table/common_table.h @@ -19,9 +19,8 @@ #include // NOLINT #include -#include "paddle/fluid/distributed/ps/table/table.h" - #include "paddle/fluid/distributed/common/utils.h" +#include "paddle/fluid/distributed/ps/table/table.h" namespace paddle { namespace distributed { diff --git a/paddle/fluid/distributed/ps/table/ctr_accessor.cc b/paddle/fluid/distributed/ps/table/ctr_accessor.cc index ef7311824faa6d6aad7247e6f6a71732cbf6445b..254bbb96cad6275e0818aa352fe983ebaa9be664 100644 --- a/paddle/fluid/distributed/ps/table/ctr_accessor.cc +++ b/paddle/fluid/distributed/ps/table/ctr_accessor.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/distributed/ps/table/ctr_accessor.h" + #include + #include "glog/logging.h" #include "paddle/fluid/string/string_helper.h" diff --git a/paddle/fluid/distributed/ps/table/ctr_accessor.h b/paddle/fluid/distributed/ps/table/ctr_accessor.h index 327c4cea760ebed7f5abd152fc0bbd7e887e0c97..96ec5b8398d13ba46c77bdd1604db021e0292d49 100644 --- a/paddle/fluid/distributed/ps/table/ctr_accessor.h +++ b/paddle/fluid/distributed/ps/table/ctr_accessor.h @@ -15,7 +15,9 @@ #pragma once #include #include + #include + #include "paddle/fluid/distributed/common/registerer.h" #include "paddle/fluid/distributed/ps.pb.h" #include "paddle/fluid/distributed/ps/table/accessor.h" diff --git a/paddle/fluid/distributed/ps/table/ctr_double_accessor.cc b/paddle/fluid/distributed/ps/table/ctr_double_accessor.cc index 4b84b7e8c36c309ec4fe3f2c65fcea09b85d90e0..2bde5271a0c43fc7a2df9f93af1b1866d6536f30 100644 --- a/paddle/fluid/distributed/ps/table/ctr_double_accessor.cc +++ b/paddle/fluid/distributed/ps/table/ctr_double_accessor.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/distributed/ps/table/ctr_double_accessor.h" + #include + #include "glog/logging.h" #include "paddle/fluid/string/string_helper.h" diff --git a/paddle/fluid/distributed/ps/table/ctr_double_accessor.h b/paddle/fluid/distributed/ps/table/ctr_double_accessor.h index 5b781b2621c5bc9c864c41abe0d028ccdbe25052..3134b46960409106f7e6d8e111cbcc6a9b9d3514 100644 --- a/paddle/fluid/distributed/ps/table/ctr_double_accessor.h +++ b/paddle/fluid/distributed/ps/table/ctr_double_accessor.h @@ -15,7 +15,9 @@ #pragma once #include #include + #include + #include "paddle/fluid/distributed/common/registerer.h" #include "paddle/fluid/distributed/ps.pb.h" #include "paddle/fluid/distributed/ps/table/accessor.h" diff --git a/paddle/fluid/distributed/ps/table/ctr_dymf_accessor.cc b/paddle/fluid/distributed/ps/table/ctr_dymf_accessor.cc index 68f28640fc69ece38ec0932a2fa9ba824d6424aa..6fb6675edde8d9bd56d75f0d9403bf37dfe0b84d 100644 --- a/paddle/fluid/distributed/ps/table/ctr_dymf_accessor.cc +++ b/paddle/fluid/distributed/ps/table/ctr_dymf_accessor.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/distributed/ps/table/ctr_dymf_accessor.h" + #include + #include "glog/logging.h" #include "paddle/fluid/string/string_helper.h" diff --git a/paddle/fluid/distributed/ps/table/ctr_dymf_accessor.h b/paddle/fluid/distributed/ps/table/ctr_dymf_accessor.h index 6a9f5d28f5e590268e09096311479f12413143b4..c4bcd2bb3c98abcbf0bd5060557a542b5050e6b6 100644 --- a/paddle/fluid/distributed/ps/table/ctr_dymf_accessor.h +++ b/paddle/fluid/distributed/ps/table/ctr_dymf_accessor.h @@ -15,7 +15,9 @@ #pragma once #include #include + #include + #include "paddle/fluid/distributed/common/registerer.h" #include "paddle/fluid/distributed/ps.pb.h" #include "paddle/fluid/distributed/ps/table/accessor.h" diff --git a/paddle/fluid/distributed/ps/table/depends/dense.h b/paddle/fluid/distributed/ps/table/depends/dense.h index aea757e8d59592dd9f52f201e7e36e24eaad4eb9..5e7c1cd438de8029372a5850cbfdf5263a39f84c 100644 --- a/paddle/fluid/distributed/ps/table/depends/dense.h +++ b/paddle/fluid/distributed/ps/table/depends/dense.h @@ -15,13 +15,14 @@ #pragma once #include // for sqrt in CPU and CUDA + #include #include #include #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/distributed/common/utils.h" namespace paddle { diff --git a/paddle/fluid/distributed/ps/table/depends/feature_value.h b/paddle/fluid/distributed/ps/table/depends/feature_value.h index 36dc34808bd274dbd6118d905710d8dcb0489bc5..e6ab278787d47fc13335a8e6580cbc4834089a16 100644 --- a/paddle/fluid/distributed/ps/table/depends/feature_value.h +++ b/paddle/fluid/distributed/ps/table/depends/feature_value.h @@ -14,10 +14,10 @@ #pragma once +#include #include -#include "gflags/gflags.h" -#include +#include "gflags/gflags.h" #include "paddle/fluid/distributed/common/chunk_allocator.h" namespace paddle { diff --git a/paddle/fluid/distributed/ps/table/depends/geo_recorder.h b/paddle/fluid/distributed/ps/table/depends/geo_recorder.h index adab0ee344bcab05dcc8be971030ad99fd7acdf0..99530f72b1f749e657739c6a2994d1504aa8c73b 100644 --- a/paddle/fluid/distributed/ps/table/depends/geo_recorder.h +++ b/paddle/fluid/distributed/ps/table/depends/geo_recorder.h @@ -15,6 +15,7 @@ #pragma once #include + #include // NOLINT #include #include diff --git a/paddle/fluid/distributed/ps/table/depends/initializers.h b/paddle/fluid/distributed/ps/table/depends/initializers.h index f46e659a88babb07918d02f1e05859829895f2bf..7c707feacecc5ed2fde65fc9a764c0e7280be332 100644 --- a/paddle/fluid/distributed/ps/table/depends/initializers.h +++ b/paddle/fluid/distributed/ps/table/depends/initializers.h @@ -20,10 +20,9 @@ #include #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/framework/generator.h" - #include "paddle/fluid/operators/truncated_gaussian_random_op.h" namespace paddle { diff --git a/paddle/fluid/distributed/ps/table/depends/rocksdb_warpper.h b/paddle/fluid/distributed/ps/table/depends/rocksdb_warpper.h index 223c8fafd26ab7f84bff8c088d00c71ce29bb342..4ae3aa7459a17a29a367640f4e133e8a21ad49cd 100644 --- a/paddle/fluid/distributed/ps/table/depends/rocksdb_warpper.h +++ b/paddle/fluid/distributed/ps/table/depends/rocksdb_warpper.h @@ -20,6 +20,7 @@ #include #include #include + #include #include @@ -153,5 +154,5 @@ class RocksDBHandler { std::vector _handles; rocksdb::DB* _db; }; -} // distributed -} // paddle +} // namespace distributed +} // namespace paddle diff --git a/paddle/fluid/distributed/ps/table/graph/graph_edge.cc b/paddle/fluid/distributed/ps/table/graph/graph_edge.cc index 004a536e8e56c28151986d56833a5708999e297c..f2f346232d3266571b99d51a833ccde17ebcdc75 100644 --- a/paddle/fluid/distributed/ps/table/graph/graph_edge.cc +++ b/paddle/fluid/distributed/ps/table/graph/graph_edge.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/ps/table/graph/graph_edge.h" + #include namespace paddle { namespace distributed { @@ -25,5 +26,5 @@ void WeightedGraphEdgeBlob::add_edge(int64_t id, float weight = 1) { id_arr.push_back(id); weight_arr.push_back(weight); } -} -} +} // namespace distributed +} // namespace paddle diff --git a/paddle/fluid/distributed/ps/table/graph/graph_edge.h b/paddle/fluid/distributed/ps/table/graph/graph_edge.h index 5fc785fe25682c8ff8de6606581cf7a13ae52999..6b929af679e50f2c54aafe6a434c060a86e16c57 100644 --- a/paddle/fluid/distributed/ps/table/graph/graph_edge.h +++ b/paddle/fluid/distributed/ps/table/graph/graph_edge.h @@ -43,5 +43,5 @@ class WeightedGraphEdgeBlob : public GraphEdgeBlob { protected: std::vector weight_arr; }; -} -} +} // namespace distributed +} // namespace paddle diff --git a/paddle/fluid/distributed/ps/table/graph/graph_node.cc b/paddle/fluid/distributed/ps/table/graph/graph_node.cc index 366e607261f0c350c5097fc76e7bcc87b04ee878..d966bd6965364c2e85bf507de2cb87c0783fdb40 100644 --- a/paddle/fluid/distributed/ps/table/graph/graph_node.cc +++ b/paddle/fluid/distributed/ps/table/graph/graph_node.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/ps/table/graph/graph_node.h" + #include namespace paddle { namespace distributed { diff --git a/paddle/fluid/distributed/ps/table/graph/graph_node.h b/paddle/fluid/distributed/ps/table/graph/graph_node.h index c6c594036d4fc94b296c0801b05c05801beb4fc0..13fdcf4c64e62fac662e6c9c2b3768b68eb61c64 100644 --- a/paddle/fluid/distributed/ps/table/graph/graph_node.h +++ b/paddle/fluid/distributed/ps/table/graph/graph_node.h @@ -18,6 +18,7 @@ #include #include #include + #include "paddle/fluid/distributed/ps/table/graph/graph_weighted_sampler.h" namespace paddle { namespace distributed { diff --git a/paddle/fluid/distributed/ps/table/graph/graph_weighted_sampler.cc b/paddle/fluid/distributed/ps/table/graph/graph_weighted_sampler.cc index 8186acec1be3da2abc18775e519ab38dac9f6dfd..4f5c86db3142b9443086753db1890c872c8115f7 100644 --- a/paddle/fluid/distributed/ps/table/graph/graph_weighted_sampler.cc +++ b/paddle/fluid/distributed/ps/table/graph/graph_weighted_sampler.cc @@ -13,9 +13,11 @@ // limitations under the License. #include "paddle/fluid/distributed/ps/table/graph/graph_weighted_sampler.h" + #include #include #include + #include "paddle/fluid/framework/generator.h" namespace paddle { namespace distributed { diff --git a/paddle/fluid/distributed/ps/table/graph/graph_weighted_sampler.h b/paddle/fluid/distributed/ps/table/graph/graph_weighted_sampler.h index c10617022decb2eaf3c8a9684fd3265e88722e76..cf83d27d7a2fddd1f68f3720345c84a2ab6f74c8 100644 --- a/paddle/fluid/distributed/ps/table/graph/graph_weighted_sampler.h +++ b/paddle/fluid/distributed/ps/table/graph/graph_weighted_sampler.h @@ -18,6 +18,7 @@ #include #include #include + #include "paddle/fluid/distributed/ps/table/graph/graph_edge.h" namespace paddle { namespace distributed { diff --git a/paddle/fluid/distributed/ps/table/memory_dense_table.h b/paddle/fluid/distributed/ps/table/memory_dense_table.h index 73653fbc2eb57baef8399c42e842b09403c0f7a2..87a3f8661ae93d9e23fe4a26ad202741db14e73e 100644 --- a/paddle/fluid/distributed/ps/table/memory_dense_table.h +++ b/paddle/fluid/distributed/ps/table/memory_dense_table.h @@ -17,7 +17,9 @@ #include #include #include + #include + #include "Eigen/Dense" #include "paddle/fluid/distributed/ps/table/accessor.h" #include "paddle/fluid/distributed/ps/table/common_table.h" diff --git a/paddle/fluid/distributed/ps/table/memory_sparse_geo_table.h b/paddle/fluid/distributed/ps/table/memory_sparse_geo_table.h index 60ba5d9602e449b29f9ce6ee840118fbe95c4a5e..bce9c774f1203d866eec08cbaaa131406c0375fb 100644 --- a/paddle/fluid/distributed/ps/table/memory_sparse_geo_table.h +++ b/paddle/fluid/distributed/ps/table/memory_sparse_geo_table.h @@ -17,6 +17,7 @@ #include // #include #include + #include #include // NOLINT #include diff --git a/paddle/fluid/distributed/ps/table/memory_sparse_table.cc b/paddle/fluid/distributed/ps/table/memory_sparse_table.cc index ee6a801fa91834b0eb8ae795caf3f1b7a579b7ef..464f788b454e871b9077a09d531b802bc87cb22e 100644 --- a/paddle/fluid/distributed/ps/table/memory_sparse_table.cc +++ b/paddle/fluid/distributed/ps/table/memory_sparse_table.cc @@ -12,15 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/distributed/ps/table/memory_sparse_table.h" + #include -#include -#include "paddle/fluid/distributed/common/cost_timer.h" -#include "paddle/fluid/distributed/ps/table/memory_sparse_table.h" -#include "paddle/fluid/framework/io/fs.h" +#include #include "boost/lexical_cast.hpp" #include "glog/logging.h" +#include "paddle/fluid/distributed/common/cost_timer.h" +#include "paddle/fluid/framework/io/fs.h" #include "paddle/fluid/platform/enforce.h" DEFINE_bool(pserver_print_missed_key_num_every_push, false, @@ -272,9 +273,8 @@ int32_t MemorySparseTable::Save(const std::string& dirname, if (_value_accesor->Save(it.value().data(), save_param)) { std::string format_value = _value_accesor->ParseToString( it.value().data(), it.value().size()); - if (0 != - write_channel->write_line(paddle::string::format_string( - "%lu %s", it.key(), format_value.c_str()))) { + if (0 != write_channel->write_line(paddle::string::format_string( + "%lu %s", it.key(), format_value.c_str()))) { ++retry_num; is_write_failed = true; LOG(ERROR) diff --git a/paddle/fluid/distributed/ps/table/memory_sparse_table.h b/paddle/fluid/distributed/ps/table/memory_sparse_table.h index 6516c75a5d69697878882761b2096f8cea59fe97..7b7a47ff998b11fdae360bcc1b7ff88947c2280d 100644 --- a/paddle/fluid/distributed/ps/table/memory_sparse_table.h +++ b/paddle/fluid/distributed/ps/table/memory_sparse_table.h @@ -17,12 +17,14 @@ #include #include #include + #include #include // NOLINT #include #include #include #include + #include "Eigen/Dense" #include "paddle/fluid/distributed/ps/table/accessor.h" #include "paddle/fluid/distributed/ps/table/common_table.h" diff --git a/paddle/fluid/distributed/ps/table/sparse_accessor.cc b/paddle/fluid/distributed/ps/table/sparse_accessor.cc index bc537880f1c211a83685421a1d8870934dd20c2a..772ff5d1fc5ccc42d9a4057efd7a2d23793ff112 100644 --- a/paddle/fluid/distributed/ps/table/sparse_accessor.cc +++ b/paddle/fluid/distributed/ps/table/sparse_accessor.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/distributed/ps/table/sparse_accessor.h" + #include + #include "glog/logging.h" #include "paddle/fluid/string/string_helper.h" diff --git a/paddle/fluid/distributed/ps/table/sparse_accessor.h b/paddle/fluid/distributed/ps/table/sparse_accessor.h index 875904847b2ea113570f2a3268dfd3fdc4bce64b..5e76365901c27302b9084abab958abf360c8aa6e 100644 --- a/paddle/fluid/distributed/ps/table/sparse_accessor.h +++ b/paddle/fluid/distributed/ps/table/sparse_accessor.h @@ -15,7 +15,9 @@ #pragma once #include #include + #include + #include "paddle/fluid/distributed/common/registerer.h" #include "paddle/fluid/distributed/ps.pb.h" #include "paddle/fluid/distributed/ps/table/accessor.h" diff --git a/paddle/fluid/distributed/ps/table/sparse_sgd_rule.cc b/paddle/fluid/distributed/ps/table/sparse_sgd_rule.cc index 8471b9361282852e00e04281d780d9116cb87394..a9a4c9beae22ccf886a6769f1d82caf0e8b8d637 100644 --- a/paddle/fluid/distributed/ps/table/sparse_sgd_rule.cc +++ b/paddle/fluid/distributed/ps/table/sparse_sgd_rule.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/distributed/ps/table/sparse_sgd_rule.h" + #include + #include "glog/logging.h" DEFINE_bool(enable_show_scale_gradient, true, "enable show scale gradient"); diff --git a/paddle/fluid/distributed/ps/table/sparse_sgd_rule.h b/paddle/fluid/distributed/ps/table/sparse_sgd_rule.h index 55a37b594192101cb36919d2c66324a4f2a17605..0f7766e20a326cb7de749cef9a93e9e05dd8e7cf 100644 --- a/paddle/fluid/distributed/ps/table/sparse_sgd_rule.h +++ b/paddle/fluid/distributed/ps/table/sparse_sgd_rule.h @@ -14,8 +14,10 @@ #pragma once #include + #include #include + #include "glog/logging.h" // for CHECK #include "paddle/fluid/distributed/common/local_random.h" // for local_uniform_real_distribution #include "paddle/fluid/distributed/common/registerer.h" diff --git a/paddle/fluid/distributed/ps/table/ssd_sparse_table.cc b/paddle/fluid/distributed/ps/table/ssd_sparse_table.cc index b1359d1323d8972d856953b2f9435556a7879195..7e1128baa0cd64b72905b2808181340d4ab27f3c 100644 --- a/paddle/fluid/distributed/ps/table/ssd_sparse_table.cc +++ b/paddle/fluid/distributed/ps/table/ssd_sparse_table.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/ps/table/ssd_sparse_table.h" + #include "paddle/fluid/distributed/common/cost_timer.h" #include "paddle/fluid/distributed/common/local_random.h" #include "paddle/fluid/distributed/common/topk_calculator.h" @@ -362,9 +363,8 @@ int32_t SSDSparseTable::Save(const std::string& path, if (_value_accesor->Save(it.value().data(), save_param)) { std::string format_value = _value_accesor->ParseToString( it.value().data(), it.value().size()); - if (0 != - write_channel->write_line(paddle::string::format_string( - "%lu %s", it.key(), format_value.c_str()))) { + if (0 != write_channel->write_line(paddle::string::format_string( + "%lu %s", it.key(), format_value.c_str()))) { ++retry_num; is_write_failed = true; LOG(ERROR) << "SSDSparseTable save failed, retry it! path:" @@ -597,9 +597,8 @@ int32_t SSDSparseTable::SaveCache( while (shuffled_channel->Read(data)) { for (auto& t : data) { ++feasign_size; - if (0 != - write_channel->write_line(paddle::string::format_string( - "%lu %s", t.first, t.second.c_str()))) { + if (0 != write_channel->write_line(paddle::string::format_string( + "%lu %s", t.first, t.second.c_str()))) { LOG(ERROR) << "Cache Table save failed, " "path:" << channel_config.path << ", retry it!"; diff --git a/paddle/fluid/distributed/ps/table/table.cc b/paddle/fluid/distributed/ps/table/table.cc index ef2eb3a746f66b04b0baeaba032ac0ca1f9cb620..cfa286f1c3f7f51a71a30e03faab05bf0328d686 100644 --- a/paddle/fluid/distributed/ps/table/table.cc +++ b/paddle/fluid/distributed/ps/table/table.cc @@ -16,13 +16,11 @@ #include "glog/logging.h" #include "paddle/fluid/distributed/common/registerer.h" - #include "paddle/fluid/distributed/ps/table/common_graph_table.h" -#include "paddle/fluid/distributed/ps/table/memory_dense_table.h" - #include "paddle/fluid/distributed/ps/table/ctr_accessor.h" #include "paddle/fluid/distributed/ps/table/ctr_double_accessor.h" #include "paddle/fluid/distributed/ps/table/ctr_dymf_accessor.h" +#include "paddle/fluid/distributed/ps/table/memory_dense_table.h" #include "paddle/fluid/distributed/ps/table/memory_sparse_geo_table.h" #include "paddle/fluid/distributed/ps/table/memory_sparse_table.h" #include "paddle/fluid/distributed/ps/table/sparse_accessor.h" diff --git a/paddle/fluid/distributed/ps/table/table.h b/paddle/fluid/distributed/ps/table/table.h index 48fda782d489fff33e18ebfc902dade58cabc752..0c56b48a246d2132ef685181fbf10b4562bbc975 100644 --- a/paddle/fluid/distributed/ps/table/table.h +++ b/paddle/fluid/distributed/ps/table/table.h @@ -15,11 +15,13 @@ #pragma once #include + #include #include // NOLINT #include #include #include + #include "paddle/fluid/distributed/common/afs_warpper.h" #include "paddle/fluid/distributed/ps/table/accessor.h" #include "paddle/fluid/distributed/ps/table/depends/sparse_utils.h" diff --git a/paddle/fluid/distributed/ps/table/tensor_accessor.cc b/paddle/fluid/distributed/ps/table/tensor_accessor.cc index 5d1f69b7463da201a1ad4984d7319062f8f79e5f..880583f36842de796db2de4f7a98993ba30aed2d 100644 --- a/paddle/fluid/distributed/ps/table/tensor_accessor.cc +++ b/paddle/fluid/distributed/ps/table/tensor_accessor.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/distributed/ps/table/tensor_accessor.h" + #include "Eigen/Dense" namespace paddle { diff --git a/paddle/fluid/distributed/ps/table/tensor_accessor.h b/paddle/fluid/distributed/ps/table/tensor_accessor.h index fad31d5df7f47f707d31e36c25642cf7795362d3..a5225127534a0fd65a7d26008b8e029d98f81a92 100644 --- a/paddle/fluid/distributed/ps/table/tensor_accessor.h +++ b/paddle/fluid/distributed/ps/table/tensor_accessor.h @@ -15,6 +15,7 @@ #pragma once #include #include + #include #include diff --git a/paddle/fluid/distributed/ps/wrapper/fleet.cc b/paddle/fluid/distributed/ps/wrapper/fleet.cc index 955ba75e672d17663f54d744f5e2516409a822b6..b9754d7b9debb34b7d6d65bf4abdc7404570e381 100644 --- a/paddle/fluid/distributed/ps/wrapper/fleet.cc +++ b/paddle/fluid/distributed/ps/wrapper/fleet.cc @@ -12,11 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/distributed/ps/wrapper/fleet.h" + #include #include "paddle/fluid/distributed/ps/service/communicator/communicator.h" #include "paddle/fluid/distributed/ps/table/table.h" -#include "paddle/fluid/distributed/ps/wrapper/fleet.h" namespace paddle { namespace distributed { diff --git a/paddle/fluid/distributed/ps/wrapper/fleet.h b/paddle/fluid/distributed/ps/wrapper/fleet.h index ce109b63cce9c73b1ccf4af39d632871345eca19..f88c478724b8b5f6fdacf693225153a52cfda4f2 100644 --- a/paddle/fluid/distributed/ps/wrapper/fleet.h +++ b/paddle/fluid/distributed/ps/wrapper/fleet.h @@ -49,8 +49,8 @@ class PSCore; using framework::LoDTensor; using framework::Scope; -using phi::SelectedRows; using framework::Variable; +using phi::SelectedRows; using RpcCtxMap = std::unordered_map; diff --git a/paddle/fluid/distributed/ps/wrapper/ps_wrapper.h b/paddle/fluid/distributed/ps/wrapper/ps_wrapper.h old mode 100755 new mode 100644 index ca02ad31195ef2cdee649f5348d3f735c38097b8..0156c0b42db05d5bb986cea8825b8d196aee6f4a --- a/paddle/fluid/distributed/ps/wrapper/ps_wrapper.h +++ b/paddle/fluid/distributed/ps/wrapper/ps_wrapper.h @@ -49,8 +49,8 @@ class PSCore; using framework::LoDTensor; using framework::Scope; -using phi::SelectedRows; using framework::Variable; +using phi::SelectedRows; using RpcCtxMap = std::unordered_map; diff --git a/paddle/fluid/distributed/store/tcp_store.cc b/paddle/fluid/distributed/store/tcp_store.cc index ec6f0e26a08fa303d6f7bd66f199f6a9362e5b5a..a46b4b32c9f1857b2cc70be3e7cd05befc35edbc 100644 --- a/paddle/fluid/distributed/store/tcp_store.cc +++ b/paddle/fluid/distributed/store/tcp_store.cc @@ -12,11 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/distributed/store/tcp_store.h" + #include #include #include -#include "paddle/fluid/distributed/store/tcp_store.h" #include "paddle/fluid/distributed/store/tcp_utils.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/flags.h" diff --git a/paddle/fluid/distributed/store/tcp_utils.cc b/paddle/fluid/distributed/store/tcp_utils.cc index a28cba288333d7f1c2a705049c29b59f43a70cc5..466cd11fa5d3d817eb3c0fbd0a8d9fc4a8da03d8 100644 --- a/paddle/fluid/distributed/store/tcp_utils.cc +++ b/paddle/fluid/distributed/store/tcp_utils.cc @@ -13,9 +13,11 @@ // limitations under the License. #include "paddle/fluid/distributed/store/tcp_utils.h" + #include #include #include + #include "paddle/fluid/platform/enforce.h" namespace paddle { @@ -51,12 +53,13 @@ void close_socket(SocketType socket) { int n; n = ::getaddrinfo(node, port_cstr, &hints, &res); const char* gai_err = ::gai_strerror(n); - const char* proto = - (family == AF_INET ? "IPv4" : family == AF_INET6 ? "IPv6" : ""); - PADDLE_ENFORCE_EQ( - n, 0, platform::errors::InvalidArgument( - "%s network %s:%s cannot be obtained. Details: %s.", proto, - host, port, gai_err)); + const char* proto = (family == AF_INET ? "IPv4" + : family == AF_INET6 ? "IPv6" + : ""); + PADDLE_ENFORCE_EQ(n, 0, + platform::errors::InvalidArgument( + "%s network %s:%s cannot be obtained. Details: %s.", + proto, host, port, gai_err)); return res; } @@ -79,10 +82,11 @@ SocketType tcp_connect(const std::string host, const std::string port, do { for (::addrinfo* cur = res; cur != nullptr; cur = cur->ai_next) { sockfd = ::socket(cur->ai_family, cur->ai_socktype, cur->ai_protocol); - PADDLE_ENFORCE_GT(sockfd, 0, platform::errors::InvalidArgument( - "Create socket to connect %s:%s failed. " - "Details: %s. ", - host, port, socket_error().message())); + PADDLE_ENFORCE_GT(sockfd, 0, + platform::errors::InvalidArgument( + "Create socket to connect %s:%s failed. " + "Details: %s. ", + host, port, socket_error().message())); if (::connect(sockfd, cur->ai_addr, cur->ai_addrlen) == 0) { retry = false; diff --git a/paddle/fluid/distributed/store/tcp_utils.h b/paddle/fluid/distributed/store/tcp_utils.h index 60cb3de124da3593f3d07ffadcf3b12c2deedf29..ec9f610a18c17bf122139ca2629dbf5319b60c27 100644 --- a/paddle/fluid/distributed/store/tcp_utils.h +++ b/paddle/fluid/distributed/store/tcp_utils.h @@ -29,6 +29,7 @@ #include #include #include + #include "paddle/fluid/platform/enforce.h" // Utility functions for TCP socket. @@ -73,9 +74,10 @@ void send_bytes(SocketType socket, const T* buffer, size_t len) { while (to_send > 0) { auto byte_sent = ::send(socket, ptr, to_send, 0); - PADDLE_ENFORCE_GT(byte_sent, 0, platform::errors::InvalidArgument( - "TCP send error. Details: %s.", - socket_error().message())); + PADDLE_ENFORCE_GT( + byte_sent, 0, + platform::errors::InvalidArgument("TCP send error. Details: %s.", + socket_error().message())); to_send -= byte_sent; ptr += byte_sent; } @@ -91,9 +93,10 @@ void receive_bytes(SocketType socket, T* buffer, size_t len) { while (to_recv > 0) { auto byte_received = ::recv(socket, ptr, to_recv, 0); - PADDLE_ENFORCE_GT(byte_received, 0, platform::errors::InvalidArgument( - "TCP receive error. Details: %s.", - socket_error().message())); + PADDLE_ENFORCE_GT( + byte_received, 0, + platform::errors::InvalidArgument("TCP receive error. Details: %s.", + socket_error().message())); to_recv -= byte_received; ptr += byte_received; diff --git a/paddle/fluid/distributed/test/barrier_table_test.cc b/paddle/fluid/distributed/test/barrier_table_test.cc index c4c5b229928049d14f494ce941aac4b2ed775415..f540939c6fd8f1b9bbe4d63a9103bcc8e2a37bc1 100644 --- a/paddle/fluid/distributed/test/barrier_table_test.cc +++ b/paddle/fluid/distributed/test/barrier_table_test.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include #include + #include "gtest/gtest.h" #include "paddle/fluid/distributed/ps.pb.h" #include "paddle/fluid/distributed/ps/table/common_table.h" diff --git a/paddle/fluid/distributed/test/brpc_service_dense_sgd_test.cc b/paddle/fluid/distributed/test/brpc_service_dense_sgd_test.cc index f9d57be95affe27f8c0f3ca4a440010a8208199d..c1467dae9a7e27783020e61c2fd0875e79b94cd2 100644 --- a/paddle/fluid/distributed/test/brpc_service_dense_sgd_test.cc +++ b/paddle/fluid/distributed/test/brpc_service_dense_sgd_test.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include #include // NOLINT diff --git a/paddle/fluid/distributed/test/brpc_service_sparse_sgd_test.cc b/paddle/fluid/distributed/test/brpc_service_sparse_sgd_test.cc index 29195d9985728590b87b61c22e6b8437708cfb4a..bade56f239f6500c86108060397993f130dc1cca 100644 --- a/paddle/fluid/distributed/test/brpc_service_sparse_sgd_test.cc +++ b/paddle/fluid/distributed/test/brpc_service_sparse_sgd_test.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include #include // NOLINT diff --git a/paddle/fluid/distributed/test/brpc_utils_test.cc b/paddle/fluid/distributed/test/brpc_utils_test.cc index 16ff9bd75840b87284c798cc3c75a3e0addcf178..33367bf16b72e139cb5054fb21f15728d61fbf60 100644 --- a/paddle/fluid/distributed/test/brpc_utils_test.cc +++ b/paddle/fluid/distributed/test/brpc_utils_test.cc @@ -12,11 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/distributed/ps/service/brpc_utils.h" + #include #include "gtest/gtest.h" - -#include "paddle/fluid/distributed/ps/service/brpc_utils.h" #include "paddle/phi/kernels/funcs/math_function.h" namespace paddle { diff --git a/paddle/fluid/distributed/test/ctr_accessor_test.cc b/paddle/fluid/distributed/test/ctr_accessor_test.cc index 27b6ddf722b701fd438ac45c1f190453f8fe9c02..51254391a42836dce849d770bd1ee85e4ebc3c61 100644 --- a/paddle/fluid/distributed/test/ctr_accessor_test.cc +++ b/paddle/fluid/distributed/test/ctr_accessor_test.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/distributed/ps/table/ctr_accessor.h" + #include #include + #include "gtest/gtest.h" #include "paddle/fluid/distributed/common/registerer.h" #include "paddle/fluid/distributed/ps.pb.h" diff --git a/paddle/fluid/distributed/test/ctr_dymf_accessor_test.cc b/paddle/fluid/distributed/test/ctr_dymf_accessor_test.cc index f6e773a414c7fddadfdb3952c0c8c3af53662d1c..fbf179dbeeef037ea88b24fe8f2a6418f353bcdb 100644 --- a/paddle/fluid/distributed/test/ctr_dymf_accessor_test.cc +++ b/paddle/fluid/distributed/test/ctr_dymf_accessor_test.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/distributed/ps/table/ctr_dymf_accessor.h" + #include #include + #include "gtest/gtest.h" #include "paddle/fluid/distributed/common/registerer.h" #include "paddle/fluid/distributed/ps.pb.h" diff --git a/paddle/fluid/distributed/test/dense_table_test.cc b/paddle/fluid/distributed/test/dense_table_test.cc index 9529c776c120e8d7529315cbb16da7d9b089fb4b..185d9d3aed1d4da50e26a45210b6874aedeed849 100644 --- a/paddle/fluid/distributed/test/dense_table_test.cc +++ b/paddle/fluid/distributed/test/dense_table_test.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include + #include "gtest/gtest.h" #include "paddle/fluid/distributed/ps.pb.h" #include "paddle/fluid/distributed/ps/table/memory_dense_table.h" diff --git a/paddle/fluid/distributed/test/feature_value_test.cc b/paddle/fluid/distributed/test/feature_value_test.cc index 32e3944d35a1c69ce375db207427a535018da481..6e848c3e2f4e44c353976b27bac53c45ed671e7a 100644 --- a/paddle/fluid/distributed/test/feature_value_test.cc +++ b/paddle/fluid/distributed/test/feature_value_test.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/distributed/ps/table/depends/feature_value.h" + #include + #include "gtest/gtest.h" namespace paddle { diff --git a/paddle/fluid/distributed/test/graph_node_split_test.cc b/paddle/fluid/distributed/test/graph_node_split_test.cc index 395d7c1eace82e949142827796a04d7417b4e7d3..fa9b89d75c83c701bb827a615bd9339fb591fcf5 100644 --- a/paddle/fluid/distributed/test/graph_node_split_test.cc +++ b/paddle/fluid/distributed/test/graph_node_split_test.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include // NOLINT #include #include @@ -17,8 +18,8 @@ limitations under the License. */ #include // NOLINT #include #include -#include "google/protobuf/text_format.h" +#include "google/protobuf/text_format.h" #include "gtest/gtest.h" #include "paddle/fluid/distributed/ps.pb.h" #include "paddle/fluid/distributed/ps/service/brpc_ps_client.h" diff --git a/paddle/fluid/distributed/test/graph_node_test.cc b/paddle/fluid/distributed/test/graph_node_test.cc index 3b43c2779ee4ebecfdbd2d519face3bb2933ed03..9cb244a9ec430d44a2292078969307d5b65e40f3 100644 --- a/paddle/fluid/distributed/test/graph_node_test.cc +++ b/paddle/fluid/distributed/test/graph_node_test.cc @@ -9,7 +9,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/distributed/ps/table/graph/graph_node.h" + #include + #include // NOLINT #include #include @@ -17,8 +20,8 @@ limitations under the License. */ #include // NOLINT #include #include -#include "google/protobuf/text_format.h" +#include "google/protobuf/text_format.h" #include "gtest/gtest.h" #include "paddle/fluid/distributed/ps.pb.h" #include "paddle/fluid/distributed/ps/service/brpc_ps_client.h" @@ -30,7 +33,6 @@ limitations under the License. */ #include "paddle/fluid/distributed/ps/service/ps_service/graph_py_service.h" #include "paddle/fluid/distributed/ps/service/ps_service/service.h" #include "paddle/fluid/distributed/ps/service/sendrecv.pb.h" -#include "paddle/fluid/distributed/ps/table/graph/graph_node.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/scope.h" diff --git a/paddle/fluid/distributed/test/graph_table_sample_test.cc b/paddle/fluid/distributed/test/graph_table_sample_test.cc index d7f6f2f34d77ac61b3e302fb057e5d548005d84d..a3463162d276cd6939765756213471db6d2a1cb8 100644 --- a/paddle/fluid/distributed/test/graph_table_sample_test.cc +++ b/paddle/fluid/distributed/test/graph_table_sample_test.cc @@ -13,6 +13,8 @@ // limitations under the License. #include + +#include #include // NOLINT #include #include @@ -20,9 +22,8 @@ #include // NOLINT #include #include -#include "google/protobuf/text_format.h" -#include +#include "google/protobuf/text_format.h" #include "gtest/gtest.h" #include "paddle/fluid/distributed/ps.pb.h" #include "paddle/fluid/distributed/ps/table/common_graph_table.h" diff --git a/paddle/fluid/distributed/test/memory_geo_table_test.cc b/paddle/fluid/distributed/test/memory_geo_table_test.cc index ca3b51fade177e690f9a1f75782916f5c2c3b884..507211e69fa0fd17481a1039784961fdfdd08699 100644 --- a/paddle/fluid/distributed/test/memory_geo_table_test.cc +++ b/paddle/fluid/distributed/test/memory_geo_table_test.cc @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. */ #include - #include + #include #include // NOLINT diff --git a/paddle/fluid/distributed/test/memory_sparse_table_test.cc b/paddle/fluid/distributed/test/memory_sparse_table_test.cc index 68bc50373ffadb9fa0166707ea8d189f0ff600d6..1689b7716bbc4c92818b8861b6c8b4787581d44a 100644 --- a/paddle/fluid/distributed/test/memory_sparse_table_test.cc +++ b/paddle/fluid/distributed/test/memory_sparse_table_test.cc @@ -12,16 +12,17 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include +#include "paddle/fluid/distributed/ps/table/memory_sparse_table.h" +#include #include + #include #include // NOLINT #include "google/protobuf/text_format.h" #include "gtest/gtest.h" #include "paddle/fluid/distributed/ps.pb.h" -#include "paddle/fluid/distributed/ps/table/memory_sparse_table.h" #include "paddle/fluid/distributed/ps/table/table.h" namespace paddle { diff --git a/paddle/fluid/distributed/test/sparse_sgd_rule_test.cc b/paddle/fluid/distributed/test/sparse_sgd_rule_test.cc index 1a4e16b9266197ebfd053885eced9f4f6d7c0ee6..3a9a8d0b39ccd712dd9eac48181b14ec3dfbd530 100644 --- a/paddle/fluid/distributed/test/sparse_sgd_rule_test.cc +++ b/paddle/fluid/distributed/test/sparse_sgd_rule_test.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/distributed/ps/table/sparse_sgd_rule.h" + #include #include + #include "gtest/gtest.h" #include "paddle/fluid/distributed/ps.pb.h" diff --git a/paddle/fluid/distributed/test/table_test.cc b/paddle/fluid/distributed/test/table_test.cc index 4f73519ef5e699076aaf65c9a1c06e5a1879e889..56809abad0c7c347c032f5211d94d2bac1612b7c 100644 --- a/paddle/fluid/distributed/test/table_test.cc +++ b/paddle/fluid/distributed/test/table_test.cc @@ -30,4 +30,4 @@ TEST(Table, Initialize) { ASSERT_EQ(ret, -1); } } // namespace distributed -} // // namespace paddle +} // namespace paddle diff --git a/paddle/fluid/eager/accumulation/accumulation_node.cc b/paddle/fluid/eager/accumulation/accumulation_node.cc index 544e7c8fe85d63e39a43f3fe3184e4f9d11426e4..09db68399f332ba6411bc72c472ab014ee763205 100644 --- a/paddle/fluid/eager/accumulation/accumulation_node.cc +++ b/paddle/fluid/eager/accumulation/accumulation_node.cc @@ -13,17 +13,15 @@ // limitations under the License. #include "paddle/fluid/eager/accumulation/accumulation_node.h" + +#include "glog/logging.h" #include "paddle/fluid/eager/eager_tensor.h" #include "paddle/fluid/imperative/gradient_accumulator.h" - -#include "paddle/phi/api/all.h" -#include "paddle/phi/core/dense_tensor.h" - #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/errors.h" - -#include "glog/logging.h" +#include "paddle/phi/api/all.h" +#include "paddle/phi/core/dense_tensor.h" namespace egr { @@ -72,8 +70,7 @@ paddle::small_vector, GradNodeAccumulation::operator()( paddle::small_vector, kSlotSmallVectorSize>& grads, // NOLINT - bool create_graph, - bool is_new_grad) { + bool create_graph, bool is_new_grad) { VLOG(3) << "Running Eager Backward Node: GradNodeAccumulation"; PADDLE_ENFORCE(grads.size() == 1, paddle::platform::errors::Fatal( diff --git a/paddle/fluid/eager/accumulation/accumulation_node.h b/paddle/fluid/eager/accumulation/accumulation_node.h index 6374534578cb862279663ada1768fb53f8c58682..7694e290bab95df73e3e76f01d685ac579be819a 100644 --- a/paddle/fluid/eager/accumulation/accumulation_node.h +++ b/paddle/fluid/eager/accumulation/accumulation_node.h @@ -41,8 +41,7 @@ class GradNodeAccumulation : public GradNodeBase { kSlotSmallVectorSize> operator()(paddle::small_vector, kSlotSmallVectorSize>& grads, // NOLINT - bool create_graph = false, - bool is_new_grad = false) override; + bool create_graph = false, bool is_new_grad = false) override; void ClearTensorWrappers() override { VLOG(6) << "Do nothing here now"; } diff --git a/paddle/fluid/eager/amp_utils.h b/paddle/fluid/eager/amp_utils.h index 2145f4a11965cafef9194b3440037fcf08985451..2834f7d5dc0b9b994d08089dc564e4e0c7c9f1ad 100644 --- a/paddle/fluid/eager/amp_utils.h +++ b/paddle/fluid/eager/amp_utils.h @@ -14,6 +14,7 @@ #pragma once #include + #include "paddle/fluid/eager/api/utils/global_utils.h" #include "paddle/fluid/imperative/amp_auto_cast.h" diff --git a/paddle/fluid/eager/api/generated/eager_generated/backwards/scale_node.cc b/paddle/fluid/eager/api/generated/eager_generated/backwards/scale_node.cc index 38f67cb5bdf2ace668b0a745e953a01a67a08ffb..5adceb7e79af1bbd333886f1d03a6df6393dd9a9 100644 --- a/paddle/fluid/eager/api/generated/eager_generated/backwards/scale_node.cc +++ b/paddle/fluid/eager/api/generated/eager_generated/backwards/scale_node.cc @@ -13,16 +13,14 @@ // limitations under the License. #include "paddle/fluid/eager/api/generated/eager_generated/backwards/scale_node.h" + +#include "glog/logging.h" #include "paddle/fluid/eager/api/utils/global_utils.h" #include "paddle/fluid/eager/eager_tensor.h" - -#include "paddle/phi/kernels/scale_kernel.h" - #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/errors.h" - -#include "glog/logging.h" +#include "paddle/phi/kernels/scale_kernel.h" namespace egr { @@ -147,8 +145,7 @@ paddle::small_vector, GradNodeScale::operator()( paddle::small_vector, kSlotSmallVectorSize>& grads, // NOLINT - bool create_graph, - bool is_new_grad) { + bool create_graph, bool is_new_grad) { // 1. Check Output Size VLOG(6) << "grad size is: " << grads.size(); PADDLE_ENFORCE( diff --git a/paddle/fluid/eager/api/generated/eager_generated/backwards/scale_node.h b/paddle/fluid/eager/api/generated/eager_generated/backwards/scale_node.h index 04ff510944dd2825405774d7590d4769b5da0dc7..45872c97002aa782df936d057680748afcf8139a 100644 --- a/paddle/fluid/eager/api/generated/eager_generated/backwards/scale_node.h +++ b/paddle/fluid/eager/api/generated/eager_generated/backwards/scale_node.h @@ -42,8 +42,7 @@ class GradNodeScale : public GradNodeBase { kSlotSmallVectorSize> operator()(paddle::small_vector, kSlotSmallVectorSize>& grads, // NOLINT - bool create_graph = false, - bool is_new_grad = false) override; + bool create_graph = false, bool is_new_grad = false) override; void ClearTensorWrappers() override { VLOG(6) << "Do nothing here now"; } diff --git a/paddle/fluid/eager/api/generated/eager_generated/forwards/scale.cc b/paddle/fluid/eager/api/generated/eager_generated/forwards/scale.cc index 7a374d567d5d05bb75c4088ebbb7d930711be894..836216d64b009586fec5994473679fb5e4e390bb 100644 --- a/paddle/fluid/eager/api/generated/eager_generated/forwards/scale.cc +++ b/paddle/fluid/eager/api/generated/eager_generated/forwards/scale.cc @@ -23,11 +23,11 @@ * **/ #include "paddle/fluid/eager/api/generated/eager_generated/forwards/scale.h" + #include "paddle/fluid/eager/api/generated/eager_generated/backwards/scale_node.h" #include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/eager/eager_tensor.h" #include "paddle/fluid/eager/utils.h" - #include "paddle/phi/api/all.h" namespace egr { diff --git a/paddle/fluid/eager/api/utils/global_utils.h b/paddle/fluid/eager/api/utils/global_utils.h index 3c18efea2034965fc66b4a69b16411108e9ba820..6a6a443f69333a8d4f4dc19d260f048a06749fe6 100644 --- a/paddle/fluid/eager/api/utils/global_utils.h +++ b/paddle/fluid/eager/api/utils/global_utils.h @@ -17,6 +17,7 @@ #include #include + #include "paddle/fluid/eager/type_defs.h" #include "paddle/fluid/imperative/tracer.h" #include "paddle/phi/api/ext/op_meta_info.h" @@ -73,8 +74,9 @@ class Controller { return op_meta_info_map_; } - void MergeOpMetaInfoMap(const std::unordered_map< - std::string, std::vector>& map) { + void MergeOpMetaInfoMap( + const std::unordered_map>& + map) { op_meta_info_map_.insert(map.begin(), map.end()); } diff --git a/paddle/fluid/eager/api/utils/hook_utils.cc b/paddle/fluid/eager/api/utils/hook_utils.cc index 8ee646b718c2f9d64f1d90c9fb28e5a70cedbb83..6493135141f6ac46ecab7b6791b7c8c35297acf5 100644 --- a/paddle/fluid/eager/api/utils/hook_utils.cc +++ b/paddle/fluid/eager/api/utils/hook_utils.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/eager/api/utils/hook_utils.h" + #include "paddle/fluid/eager/accumulation/accumulation_node.h" #include "paddle/fluid/eager/api/utils/tensor_utils.h" #include "paddle/fluid/eager/autograd_meta.h" diff --git a/paddle/fluid/eager/api/utils/tensor_utils.cc b/paddle/fluid/eager/api/utils/tensor_utils.cc index 81ea92d1c3c4848ceb6ff3b333030a90eccc0b79..84a9eb6dea6bbb3bab3add2abc4ab4c226575e10 100644 --- a/paddle/fluid/eager/api/utils/tensor_utils.cc +++ b/paddle/fluid/eager/api/utils/tensor_utils.cc @@ -13,17 +13,16 @@ // limitations under the License. #include "paddle/fluid/eager/api/utils/tensor_utils.h" + #include "paddle/fluid/eager/accumulation/accumulation_node.h" #include "paddle/fluid/eager/api/utils/global_utils.h" #include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/eager/grad_node_info.h" #include "paddle/fluid/eager/utils.h" - -#include "paddle/phi/api/all.h" - #include "paddle/fluid/framework/data_layout.h" #include "paddle/fluid/framework/phi_utils.h" #include "paddle/fluid/framework/variable.h" +#include "paddle/phi/api/all.h" namespace egr { namespace egr_utils_api { diff --git a/paddle/fluid/eager/backward.cc b/paddle/fluid/eager/backward.cc index 9de647a21ad743b06dfc20172b3c0b7017b38c62..36cfb4db1137ae32406a355c80ceee350f38fa17 100644 --- a/paddle/fluid/eager/backward.cc +++ b/paddle/fluid/eager/backward.cc @@ -13,28 +13,28 @@ // limitations under the License. #include "paddle/fluid/eager/backward.h" + #include +#include "glog/logging.h" +#include "paddle/fluid/eager/accumulation/accumulation_node.h" #include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/eager/grad_node_info.h" #include "paddle/fluid/eager/grad_tensor_holder.h" #include "paddle/fluid/eager/utils.h" -#include "paddle/fluid/platform/profiler.h" -#include "paddle/fluid/platform/profiler/event_tracing.h" - -#include "glog/logging.h" -#include "paddle/fluid/eager/accumulation/accumulation_node.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/errors.h" +#include "paddle/fluid/platform/profiler.h" +#include "paddle/fluid/platform/profiler/event_tracing.h" #include "paddle/phi/kernels/autotune/switch_autotune.h" namespace egr { /* -* GeneralGrad is Helpper class to implement custom grad operation between -* outputs and inputs. -* -* **/ + * GeneralGrad is Helpper class to implement custom grad operation between + * outputs and inputs. + * + * **/ class GeneralGrad { public: static GeneralGrad& Instance() { return *general_grad_; } diff --git a/paddle/fluid/eager/custom_operator/custom_operator_node.cc b/paddle/fluid/eager/custom_operator/custom_operator_node.cc index abdd8cadeed4cec82bf74b226655324d63883520..3efcf3b21a4e3e819bbfba348991dd46344ac644 100644 --- a/paddle/fluid/eager/custom_operator/custom_operator_node.cc +++ b/paddle/fluid/eager/custom_operator/custom_operator_node.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/eager/custom_operator/custom_operator_node.h" + #include "paddle/fluid/framework/custom_operator.h" #include "paddle/fluid/framework/op_meta_info_helper.h" #include "paddle/fluid/platform/profiler/event_tracing.h" diff --git a/paddle/fluid/eager/grad_node_info.cc b/paddle/fluid/eager/grad_node_info.cc index af387bb3238d175d06dec244940264d22e63c327..71ccb072ce917df764cc002dbd86ea6f669da38d 100644 --- a/paddle/fluid/eager/grad_node_info.cc +++ b/paddle/fluid/eager/grad_node_info.cc @@ -13,27 +13,24 @@ // limitations under the License. #include "paddle/fluid/eager/grad_node_info.h" + +#include "glog/logging.h" #include "paddle/fluid/eager/accumulation/accumulation_node.h" #include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/eager/utils.h" - -#include "paddle/phi/common/data_type.h" -#include "paddle/phi/core/dense_tensor.h" -#include "paddle/phi/core/sparse_coo_tensor.h" - #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/data_type_transform.h" #include "paddle/fluid/framework/var_type.h" - #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/errors.h" - -#include "glog/logging.h" +#include "paddle/phi/common/data_type.h" +#include "paddle/phi/core/dense_tensor.h" +#include "paddle/phi/core/sparse_coo_tensor.h" /** * Implementation of GradNodeBase, Edge and GradTensorHolder. -**/ + **/ namespace egr { static void CheckTensor(const paddle::experimental::Tensor& pre, diff --git a/paddle/fluid/eager/grad_node_info.h b/paddle/fluid/eager/grad_node_info.h index 747e98b846616848e25e43ef38443b97c25e7678..9070ac9e5b6524e78a6949409e3cfb29e93f69e2 100644 --- a/paddle/fluid/eager/grad_node_info.h +++ b/paddle/fluid/eager/grad_node_info.h @@ -179,14 +179,13 @@ class GradNodeBase { kSlotSmallVectorSize> operator()(paddle::small_vector, kSlotSmallVectorSize>& grads, // NOLINT - bool create_graph = false, - bool is_new_grad = false) = 0; + bool create_graph = false, bool is_new_grad = false) = 0; virtual void ClearTensorWrappers() = 0; /** - * Self-Copy interface designed for use in DoubleGrad - * **/ + * Self-Copy interface designed for use in DoubleGrad + * **/ virtual std::shared_ptr Copy() const = 0; // adj_edges were moved inside OutputMeta(), so no available direct access @@ -230,8 +229,8 @@ class GradNodeBase { std::shared_ptr&& hook); /** - * Remove GradientHook - * **/ + * Remove GradientHook + * **/ bool RemoveGradientHook(const int64_t& hook_id) { auto remove_cnt = gradient_hooks_.erase(hook_id); if (remove_cnt == 0) { @@ -252,8 +251,8 @@ class GradNodeBase { kSlotSmallVectorSize>& tensors); /** - * Handle Complex - Real Type Promotion - * **/ + * Handle Complex - Real Type Promotion + * **/ void HandleComplexGradToRealGrad( paddle::small_vector, kSlotSmallVectorSize>* out_grads); @@ -262,8 +261,8 @@ class GradNodeBase { virtual std::string name() { return "GradNodeBase"; } /** - * The following interfaces are designed for no_need_buffer - * **/ + * The following interfaces are designed for no_need_buffer + * **/ bool IsTensorWrappersCleared() { return is_tensor_wrappers_cleared_; } void SetIsTensorWrappersCleared(bool is_tensor_wrappers_cleared) { diff --git a/paddle/fluid/eager/grad_tensor_holder.cc b/paddle/fluid/eager/grad_tensor_holder.cc index 64fb8b53b473cd5ca91469fccc1cd0b75f30dfdf..6abf759cdba7aebfeb776f23611b4f2622be8e21 100644 --- a/paddle/fluid/eager/grad_tensor_holder.cc +++ b/paddle/fluid/eager/grad_tensor_holder.cc @@ -13,11 +13,11 @@ // limitations under the License. #include "paddle/fluid/eager/grad_tensor_holder.h" -#include "paddle/fluid/imperative/gradient_accumulator.h" #include "paddle/fluid/eager/api/generated/eager_generated/forwards/dygraph_functions.h" #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/var_type.h" +#include "paddle/fluid/imperative/gradient_accumulator.h" #include "paddle/phi/kernels/funcs/math_function.h" namespace egr { diff --git a/paddle/fluid/eager/hooks.h b/paddle/fluid/eager/hooks.h index 097150cf5ed59d0fdb9dda49e03eb75e6f1b4207..a98b3d9f8e4dfb341d0c587899823485b250be3c 100644 --- a/paddle/fluid/eager/hooks.h +++ b/paddle/fluid/eager/hooks.h @@ -18,6 +18,7 @@ #include #include #include + #include "paddle/phi/api/include/tensor.h" namespace egr { diff --git a/paddle/fluid/eager/pylayer/py_layer_node.cc b/paddle/fluid/eager/pylayer/py_layer_node.cc index a00b292fe09152b470181d22ce959e7dc5ad76f1..ec17a324b1ec976f3767d1e398d22adb73052bf0 100644 --- a/paddle/fluid/eager/pylayer/py_layer_node.cc +++ b/paddle/fluid/eager/pylayer/py_layer_node.cc @@ -13,18 +13,16 @@ // limitations under the License. #include "paddle/fluid/eager/pylayer/py_layer_node.h" -#include "paddle/fluid/eager/eager_tensor.h" - -#include "paddle/phi/api/all.h" -#include "paddle/phi/core/dense_tensor.h" +#include "glog/logging.h" +#include "paddle/fluid/eager/eager_tensor.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/errors.h" #include "paddle/fluid/pybind/eager.h" #include "paddle/fluid/pybind/eager_utils.h" - -#include "glog/logging.h" +#include "paddle/phi/api/all.h" +#include "paddle/phi/core/dense_tensor.h" #pragma GCC diagnostic ignored "-Wattributes" #include "pybind11/pytypes.h" @@ -34,8 +32,7 @@ paddle::small_vector, GradNodePyLayer::operator()( paddle::small_vector, kSlotSmallVectorSize>& grads, // NOLINT - bool create_graph, - bool is_new_grad) { + bool create_graph, bool is_new_grad) { VLOG(3) << "Running Eager Backward Node: " << name(); paddle::small_vector, diff --git a/paddle/fluid/eager/pylayer/py_layer_node.h b/paddle/fluid/eager/pylayer/py_layer_node.h index c1a8c6e626b4fdb527fca05e2e86aa5dffacdb50..998480bbfebfa3fa8dc1f89b0ca1a2602ddaf7fb 100644 --- a/paddle/fluid/eager/pylayer/py_layer_node.h +++ b/paddle/fluid/eager/pylayer/py_layer_node.h @@ -38,8 +38,7 @@ class GradNodePyLayer : public GradNodeBase { kSlotSmallVectorSize> operator()(paddle::small_vector, kSlotSmallVectorSize>& grads, // NOLINT - bool create_graph = false, - bool is_new_grad = false) override; + bool create_graph = false, bool is_new_grad = false) override; void ClearTensorWrappers() override { VLOG(6) << "Do nothing here now"; } diff --git a/paddle/fluid/eager/tests/data_structure_tests/accumulation_node_test.cc b/paddle/fluid/eager/tests/data_structure_tests/accumulation_node_test.cc index c159084d683e8fe9e37cd0654b7dcdb354e79a91..c53ffe823abbaeeedf8a1bc584de70c14da3c4c7 100644 --- a/paddle/fluid/eager/tests/data_structure_tests/accumulation_node_test.cc +++ b/paddle/fluid/eager/tests/data_structure_tests/accumulation_node_test.cc @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/eager/accumulation/accumulation_node.h" + #include #include "gtest/gtest.h" - -#include "paddle/fluid/eager/accumulation/accumulation_node.h" #include "paddle/fluid/eager/api/utils/hook_utils.h" #include "paddle/fluid/eager/eager_tensor.h" #include "paddle/fluid/eager/grad_node_info.h" diff --git a/paddle/fluid/eager/tests/data_structure_tests/autograd_meta_test.cc b/paddle/fluid/eager/tests/data_structure_tests/autograd_meta_test.cc index 48b4b9c57487af3b3b8c967c64e1b6fc4ca88ad1..f7415dd1f713d0f659f4b8ebffbd3dc127534e9f 100644 --- a/paddle/fluid/eager/tests/data_structure_tests/autograd_meta_test.cc +++ b/paddle/fluid/eager/tests/data_structure_tests/autograd_meta_test.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/eager/autograd_meta.h" + #include "glog/logging.h" #include "gtest/gtest.h" - -#include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/eager/eager_tensor.h" #include "paddle/fluid/eager/grad_node_info.h" #include "paddle/fluid/eager/tests/data_structure_tests/grad_node_test.h" diff --git a/paddle/fluid/eager/tests/data_structure_tests/eager_tensor_test.cc b/paddle/fluid/eager/tests/data_structure_tests/eager_tensor_test.cc index edbb441f27a08dc29010ef950dc5c2639617b1a9..a82965303af14f96a1ef6ce0168af2cce5615c32 100644 --- a/paddle/fluid/eager/tests/data_structure_tests/eager_tensor_test.cc +++ b/paddle/fluid/eager/tests/data_structure_tests/eager_tensor_test.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/eager/eager_tensor.h" + #include "glog/logging.h" #include "gtest/gtest.h" - -#include "paddle/fluid/eager/eager_tensor.h" #include "paddle/fluid/imperative/var_helper.h" #include "paddle/phi/api/lib/utils/allocator.h" #include "paddle/phi/common/layout.h" @@ -35,7 +35,7 @@ class AutogradMetaTest : public AbstractAutogradMeta { explicit AutogradMetaTest(int val) : val_(val) {} int val_ = 0; }; -} +} // namespace eager_test TEST(Tensor, Constructor) { paddle::experimental::Tensor et1 = paddle::experimental::Tensor(); paddle::experimental::Tensor et2 = paddle::experimental::Tensor("et2"); diff --git a/paddle/fluid/eager/tests/data_structure_tests/grad_node_info_test.cc b/paddle/fluid/eager/tests/data_structure_tests/grad_node_info_test.cc index 6687b6621ad54548f8692690aa569236ada545a4..63a4a72b631d65034acfc3cc5e311ac025de7fd9 100644 --- a/paddle/fluid/eager/tests/data_structure_tests/grad_node_info_test.cc +++ b/paddle/fluid/eager/tests/data_structure_tests/grad_node_info_test.cc @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/eager/grad_node_info.h" + #include "glog/logging.h" #include "gtest/gtest.h" - #include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/eager/eager_tensor.h" -#include "paddle/fluid/eager/grad_node_info.h" #include "paddle/fluid/eager/hooks.h" #include "paddle/fluid/eager/tests/data_structure_tests/grad_node_test.h" #include "paddle/phi/api/lib/utils/allocator.h" @@ -85,8 +85,8 @@ void TestGradNodeBase(bool is_remove_gradient_hook) { CHECK_EQ(grad_test_node2->OutputMeta()[0].size(), size_t(1)); VLOG(6) << "Test Gradient Hook"; - auto gradient_hook = []( - const paddle::experimental::Tensor& et) -> paddle::experimental::Tensor { + auto gradient_hook = [](const paddle::experimental::Tensor& et) + -> paddle::experimental::Tensor { paddle::experimental::Tensor res; phi::DenseTensorMeta meta = phi::DenseTensorMeta(phi::DataType::FLOAT32, phi::make_ddim({1, 1})); diff --git a/paddle/fluid/eager/tests/data_structure_tests/grad_node_test.h b/paddle/fluid/eager/tests/data_structure_tests/grad_node_test.h index a00e629d1029a7838e159aa13cdfab45268b02ce..eb9bd6007bf8a8e05974712a89c945d6c5850c4a 100644 --- a/paddle/fluid/eager/tests/data_structure_tests/grad_node_test.h +++ b/paddle/fluid/eager/tests/data_structure_tests/grad_node_test.h @@ -14,7 +14,6 @@ #pragma once #include "glog/logging.h" #include "gtest/gtest.h" - #include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/eager/eager_tensor.h" #include "paddle/fluid/eager/grad_node_info.h" @@ -35,8 +34,7 @@ class GradTestNode : public egr::GradNodeBase { egr::kSlotSmallVectorSize> operator()(paddle::small_vector, egr::kSlotSmallVectorSize>& grads, // NOLINT - bool create_graph = false, - bool is_new_grad = false) override { + bool create_graph = false, bool is_new_grad = false) override { val_ = std::dynamic_pointer_cast(grads[0][0].impl()) ->data()[0]; phi::DenseTensorMeta meta = diff --git a/paddle/fluid/eager/tests/data_structure_tests/grad_tensor_holder_test.cc b/paddle/fluid/eager/tests/data_structure_tests/grad_tensor_holder_test.cc index 0fe349294b438bf0344f44993e6d84128b476972..17f593e24905d4a4c1fc7d137f88b16c2e2bf82c 100644 --- a/paddle/fluid/eager/tests/data_structure_tests/grad_tensor_holder_test.cc +++ b/paddle/fluid/eager/tests/data_structure_tests/grad_tensor_holder_test.cc @@ -12,17 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/eager/grad_tensor_holder.h" + #include #include "gtest/gtest.h" - #include "paddle/fluid/eager/eager_tensor.h" #include "paddle/fluid/eager/grad_node_info.h" -#include "paddle/fluid/eager/grad_tensor_holder.h" #include "paddle/phi/api/lib/utils/allocator.h" -#include "paddle/phi/core/selected_rows.h" - #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/core/selected_rows.h" PD_DECLARE_KERNEL(full_like, CPU, ALL_LAYOUT); PD_DECLARE_KERNEL(add, CPU, ALL_LAYOUT); diff --git a/paddle/fluid/eager/tests/data_structure_tests/tensor_wrapper_test.cc b/paddle/fluid/eager/tests/data_structure_tests/tensor_wrapper_test.cc index 28c3472f90d033edd1b8298d6cd45cf94c95f9f5..8813f364840e052d79de43604399376794dffd26 100644 --- a/paddle/fluid/eager/tests/data_structure_tests/tensor_wrapper_test.cc +++ b/paddle/fluid/eager/tests/data_structure_tests/tensor_wrapper_test.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/eager/tensor_wrapper.h" + #include "glog/logging.h" #include "gtest/gtest.h" - -#include "paddle/fluid/eager/tensor_wrapper.h" #include "paddle/fluid/eager/tests/data_structure_tests/grad_node_test.h" #include "paddle/fluid/eager/utils.h" diff --git a/paddle/fluid/eager/tests/performance_tests/benchmark_eager_cpu.cc b/paddle/fluid/eager/tests/performance_tests/benchmark_eager_cpu.cc index 056c7102f663b93d215e494908d9c95be832068c..3b0e6a3fdb6e12edebf1ee46f5161dbb4695d655 100644 --- a/paddle/fluid/eager/tests/performance_tests/benchmark_eager_cpu.cc +++ b/paddle/fluid/eager/tests/performance_tests/benchmark_eager_cpu.cc @@ -15,19 +15,17 @@ // Eager Dygraph #include + #include #include "gtest/gtest.h" -#include "paddle/fluid/platform/flags.h" - #include "paddle/fluid/eager/api/all.h" #include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/eager/backward.h" - -#include "paddle/fluid/imperative/tracer.h" - #include "paddle/fluid/eager/tests/performance_tests/benchmark_utils.h" #include "paddle/fluid/eager/tests/test_utils.h" +#include "paddle/fluid/imperative/tracer.h" +#include "paddle/fluid/platform/flags.h" #ifdef WITH_GPERFTOOLS #include "gperftools/profiler.h" diff --git a/paddle/fluid/eager/tests/performance_tests/benchmark_eager_cuda.cc b/paddle/fluid/eager/tests/performance_tests/benchmark_eager_cuda.cc index 287d6e770dea2cce4387e8aebf53f2826f71725e..5dd5cde548fc0388fbb131739c49cb0cc229238a 100644 --- a/paddle/fluid/eager/tests/performance_tests/benchmark_eager_cuda.cc +++ b/paddle/fluid/eager/tests/performance_tests/benchmark_eager_cuda.cc @@ -14,19 +14,17 @@ // Eager Dygraph #include + #include #include "gtest/gtest.h" -#include "paddle/fluid/platform/flags.h" - #include "paddle/fluid/eager/api/all.h" #include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/eager/backward.h" - -#include "paddle/fluid/imperative/tracer.h" - #include "paddle/fluid/eager/tests/performance_tests/benchmark_utils.h" #include "paddle/fluid/eager/tests/test_utils.h" +#include "paddle/fluid/imperative/tracer.h" +#include "paddle/fluid/platform/flags.h" #ifdef WITH_GPERFTOOLS #include "gperftools/profiler.h" diff --git a/paddle/fluid/eager/tests/performance_tests/benchmark_fluid_cpu.cc b/paddle/fluid/eager/tests/performance_tests/benchmark_fluid_cpu.cc index b4b47a85f66662347d5e087cd4391979fb6c4250..bf1d955b9000f4acfe7bbde3eb24c19ca39b0724 100644 --- a/paddle/fluid/eager/tests/performance_tests/benchmark_fluid_cpu.cc +++ b/paddle/fluid/eager/tests/performance_tests/benchmark_fluid_cpu.cc @@ -23,7 +23,6 @@ #include "glog/logging.h" #include "gtest/gtest.h" - #include "paddle/fluid/eager/tests/performance_tests/benchmark_utils.h" #include "paddle/fluid/eager/tests/test_utils.h" #include "paddle/fluid/imperative/basic_engine.h" diff --git a/paddle/fluid/eager/tests/performance_tests/benchmark_fluid_cuda.cc b/paddle/fluid/eager/tests/performance_tests/benchmark_fluid_cuda.cc index d9afd7cc96523729833ecf3cd72456f07f761586..0cd33a72e1a9a1949079cea2453e9bd83abf8d23 100644 --- a/paddle/fluid/eager/tests/performance_tests/benchmark_fluid_cuda.cc +++ b/paddle/fluid/eager/tests/performance_tests/benchmark_fluid_cuda.cc @@ -23,7 +23,6 @@ #include "glog/logging.h" #include "gtest/gtest.h" - #include "paddle/fluid/eager/tests/performance_tests/benchmark_utils.h" #include "paddle/fluid/eager/tests/test_utils.h" #include "paddle/fluid/imperative/basic_engine.h" diff --git a/paddle/fluid/eager/tests/performance_tests/benchmark_utils.h b/paddle/fluid/eager/tests/performance_tests/benchmark_utils.h index 86bf13707ed40b0c37ccb54695cca3d165768cb6..5b37e973f1dc6cdce02d1cef4c07a438afeb9326 100644 --- a/paddle/fluid/eager/tests/performance_tests/benchmark_utils.h +++ b/paddle/fluid/eager/tests/performance_tests/benchmark_utils.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/eager/eager_tensor.h" #include "paddle/fluid/imperative/layer.h" #include "paddle/phi/api/all.h" diff --git a/paddle/fluid/eager/tests/task_tests/backward_test.cc b/paddle/fluid/eager/tests/task_tests/backward_test.cc index 7552ad83fa20fbbba4ce2fcf700f7f8d12578a59..c6d4514fa8e33b0ab772819ca4babc21676a38c4 100644 --- a/paddle/fluid/eager/tests/task_tests/backward_test.cc +++ b/paddle/fluid/eager/tests/task_tests/backward_test.cc @@ -12,25 +12,22 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/eager/backward.h" + #include #include "glog/logging.h" #include "gtest/gtest.h" - #include "paddle/fluid/eager/accumulation/accumulation_node.h" +#include "paddle/fluid/eager/api/all.h" #include "paddle/fluid/eager/api/generated/eager_generated/backwards/scale_node.h" #include "paddle/fluid/eager/api/utils/tensor_utils.h" #include "paddle/fluid/eager/autograd_meta.h" -#include "paddle/fluid/eager/backward.h" #include "paddle/fluid/eager/grad_node_info.h" #include "paddle/fluid/eager/tests/test_utils.h" - -#include "paddle/fluid/eager/api/all.h" - #include "paddle/phi/core/dense_tensor.h" -#include "paddle/phi/core/tensor_meta.h" - #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/core/tensor_meta.h" PD_DECLARE_KERNEL(full, CPU, ALL_LAYOUT); PD_DECLARE_KERNEL(copy, CPU, ALL_LAYOUT); diff --git a/paddle/fluid/eager/tests/task_tests/cross_batch_accumulation_test.cc b/paddle/fluid/eager/tests/task_tests/cross_batch_accumulation_test.cc index 4337c0d092ca0fdeb3ff074e29f88cb1eb3d6034..847c082a3017324e477f3d8314fbb2cedde9e6d8 100644 --- a/paddle/fluid/eager/tests/task_tests/cross_batch_accumulation_test.cc +++ b/paddle/fluid/eager/tests/task_tests/cross_batch_accumulation_test.cc @@ -16,22 +16,17 @@ #include "glog/logging.h" #include "gtest/gtest.h" - #include "paddle/fluid/eager/accumulation/accumulation_node.h" +#include "paddle/fluid/eager/api/all.h" #include "paddle/fluid/eager/api/generated/eager_generated/backwards/scale_node.h" #include "paddle/fluid/eager/api/utils/tensor_utils.h" #include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/eager/backward.h" #include "paddle/fluid/eager/grad_node_info.h" - -#include "paddle/fluid/eager/api/all.h" - -#include "paddle/phi/core/dense_tensor.h" -#include "paddle/phi/core/tensor_meta.h" - #include "paddle/fluid/eager/tests/test_utils.h" - +#include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/core/tensor_meta.h" PD_DECLARE_KERNEL(full, CPU, ALL_LAYOUT); diff --git a/paddle/fluid/eager/tests/task_tests/eager_utils_test.cc b/paddle/fluid/eager/tests/task_tests/eager_utils_test.cc index 551262d259e08f6eba54d5fd3620753ca8113b2e..e4ca8dd164b8f4234cbeb3a843a4c532587487e6 100644 --- a/paddle/fluid/eager/tests/task_tests/eager_utils_test.cc +++ b/paddle/fluid/eager/tests/task_tests/eager_utils_test.cc @@ -15,14 +15,12 @@ #include #include "gtest/gtest.h" - #include "paddle/fluid/eager/accumulation/accumulation_node.h" #include "paddle/fluid/eager/eager_tensor.h" #include "paddle/fluid/eager/grad_node_info.h" #include "paddle/fluid/eager/tests/data_structure_tests/grad_node_test.h" #include "paddle/fluid/eager/tests/test_utils.h" #include "paddle/fluid/eager/utils.h" - #include "paddle/phi/api/lib/utils/allocator.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/fluid/eager/tests/task_tests/forward_autograd_test.cc b/paddle/fluid/eager/tests/task_tests/forward_autograd_test.cc index 4cb316380aade956b5491830db48b774504c0728..ebf396bebfab0a81e60a5eceb4eecf58c6c8a628 100644 --- a/paddle/fluid/eager/tests/task_tests/forward_autograd_test.cc +++ b/paddle/fluid/eager/tests/task_tests/forward_autograd_test.cc @@ -16,18 +16,15 @@ #include "glog/logging.h" #include "gtest/gtest.h" - #include "paddle/fluid/eager/api/all.h" #include "paddle/fluid/eager/api/generated/eager_generated/backwards/scale_node.h" #include "paddle/fluid/eager/api/utils/tensor_utils.h" #include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/eager/grad_node_info.h" #include "paddle/fluid/eager/tests/test_utils.h" - #include "paddle/phi/core/dense_tensor.h" -#include "paddle/phi/core/tensor_meta.h" - #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/core/tensor_meta.h" PD_DECLARE_KERNEL(full, CPU, ALL_LAYOUT); diff --git a/paddle/fluid/eager/tests/task_tests/fwd_bwd_joint_test.cc b/paddle/fluid/eager/tests/task_tests/fwd_bwd_joint_test.cc index 1f8fdb7de0c1746818f60b6324af0052676f1214..a4da315f44a7a3d3aebcc9935dde80074323cf14 100644 --- a/paddle/fluid/eager/tests/task_tests/fwd_bwd_joint_test.cc +++ b/paddle/fluid/eager/tests/task_tests/fwd_bwd_joint_test.cc @@ -16,21 +16,17 @@ #include "glog/logging.h" #include "gtest/gtest.h" - #include "paddle/fluid/eager/accumulation/accumulation_node.h" #include "paddle/fluid/eager/api/all.h" #include "paddle/fluid/eager/api/generated/eager_generated/backwards/scale_node.h" #include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/eager/backward.h" #include "paddle/fluid/eager/grad_node_info.h" - -#include "paddle/phi/core/dense_tensor.h" -#include "paddle/phi/core/tensor_meta.h" - #include "paddle/fluid/eager/hooks.h" #include "paddle/fluid/eager/tests/test_utils.h" - +#include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/core/tensor_meta.h" PD_DECLARE_KERNEL(full, CPU, ALL_LAYOUT); PD_DECLARE_KERNEL(add, CPU, ALL_LAYOUT); diff --git a/paddle/fluid/eager/tests/task_tests/generated_test.cc b/paddle/fluid/eager/tests/task_tests/generated_test.cc index 3c237b76e64b0d15ba86a20a2308e968557d6800..b53cdf55d4306a5da421923541eee4e21b0403ce 100644 --- a/paddle/fluid/eager/tests/task_tests/generated_test.cc +++ b/paddle/fluid/eager/tests/task_tests/generated_test.cc @@ -17,17 +17,14 @@ #include #include "gtest/gtest.h" - #include "paddle/fluid/eager/api/all.h" +#include "paddle/fluid/eager/api/generated/fluid_generated/dygraph_forward_api.h" #include "paddle/fluid/eager/api/utils/tensor_utils.h" #include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/eager/backward.h" -#include "paddle/fluid/eager/utils.h" - #include "paddle/fluid/eager/tests/test_utils.h" +#include "paddle/fluid/eager/utils.h" #include "paddle/fluid/imperative/tracer.h" - -#include "paddle/fluid/eager/api/generated/fluid_generated/dygraph_forward_api.h" #include "paddle/phi/core/kernel_registry.h" PD_DECLARE_KERNEL(full, CPU, ALL_LAYOUT); diff --git a/paddle/fluid/eager/tests/task_tests/grad_test.cc b/paddle/fluid/eager/tests/task_tests/grad_test.cc index 72a94b40ed753ac5173be5af0a1b70cfd00b9cf8..8d6c4d7843fb2263dff7ce06133b01ed011b8163 100644 --- a/paddle/fluid/eager/tests/task_tests/grad_test.cc +++ b/paddle/fluid/eager/tests/task_tests/grad_test.cc @@ -16,17 +16,14 @@ #include "glog/logging.h" #include "gtest/gtest.h" - #include "paddle/fluid/eager/accumulation/accumulation_node.h" +#include "paddle/fluid/eager/api/all.h" #include "paddle/fluid/eager/api/generated/eager_generated/backwards/scale_node.h" #include "paddle/fluid/eager/api/utils/tensor_utils.h" #include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/eager/backward.h" #include "paddle/fluid/eager/grad_node_info.h" #include "paddle/fluid/eager/tests/test_utils.h" - -#include "paddle/fluid/eager/api/all.h" - #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/core/tensor_meta.h" diff --git a/paddle/fluid/eager/tests/task_tests/hook_test.cc b/paddle/fluid/eager/tests/task_tests/hook_test.cc index d7b887b28bde8008f896da6bc909c80b55076971..badbe8715978517f0bc57bf69d6ab3fb1b72b8a6 100644 --- a/paddle/fluid/eager/tests/task_tests/hook_test.cc +++ b/paddle/fluid/eager/tests/task_tests/hook_test.cc @@ -16,22 +16,17 @@ #include "glog/logging.h" #include "gtest/gtest.h" - #include "paddle/fluid/eager/accumulation/accumulation_node.h" +#include "paddle/fluid/eager/api/all.h" #include "paddle/fluid/eager/api/generated/eager_generated/backwards/scale_node.h" #include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/eager/backward.h" #include "paddle/fluid/eager/grad_node_info.h" - -#include "paddle/fluid/eager/api/all.h" - -#include "paddle/phi/core/dense_tensor.h" -#include "paddle/phi/core/tensor_meta.h" - #include "paddle/fluid/eager/hooks.h" #include "paddle/fluid/eager/tests/test_utils.h" - +#include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/core/tensor_meta.h" PD_DECLARE_KERNEL(full, CPU, ALL_LAYOUT); diff --git a/paddle/fluid/eager/tests/task_tests/hook_test_intermidiate.cc b/paddle/fluid/eager/tests/task_tests/hook_test_intermidiate.cc index c4d4ff91106820b3b6679cdb8a70d61839ee504a..dbe2c138945667fddd7b6760b6835ecacd92166b 100644 --- a/paddle/fluid/eager/tests/task_tests/hook_test_intermidiate.cc +++ b/paddle/fluid/eager/tests/task_tests/hook_test_intermidiate.cc @@ -15,16 +15,14 @@ #include #include "gtest/gtest.h" - #include "paddle/fluid/eager/api/all.h" +#include "paddle/fluid/eager/api/generated/fluid_generated/dygraph_forward_api.h" #include "paddle/fluid/eager/backward.h" #include "paddle/fluid/eager/grad_node_info.h" +#include "paddle/fluid/eager/hooks.h" #include "paddle/fluid/eager/tests/test_utils.h" #include "paddle/fluid/imperative/tracer.h" #include "paddle/phi/core/dense_tensor.h" - -#include "paddle/fluid/eager/api/generated/fluid_generated/dygraph_forward_api.h" -#include "paddle/fluid/eager/hooks.h" #include "paddle/phi/core/kernel_registry.h" PD_DECLARE_KERNEL(full, CPU, ALL_LAYOUT); diff --git a/paddle/fluid/eager/tests/task_tests/nan_inf_utils_test.cc b/paddle/fluid/eager/tests/task_tests/nan_inf_utils_test.cc index be0563fbeedb4ec120d58f680ab883b181d2062f..73d213f71148f7898b2b584deda1a48e59d1f543 100644 --- a/paddle/fluid/eager/tests/task_tests/nan_inf_utils_test.cc +++ b/paddle/fluid/eager/tests/task_tests/nan_inf_utils_test.cc @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/eager/nan_inf_utils.h" + #include #include #include #include "gtest/gtest.h" - -#include "paddle/fluid/eager/nan_inf_utils.h" #include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/phi/api/include/api.h" diff --git a/paddle/fluid/eager/tests/task_tests/tensor_utils_test.cc b/paddle/fluid/eager/tests/task_tests/tensor_utils_test.cc index 24e5da060111f083ef9b65574e75295fa07f8f43..aeddeb6fae7f27f93010fa2a7d4952c93262da26 100644 --- a/paddle/fluid/eager/tests/task_tests/tensor_utils_test.cc +++ b/paddle/fluid/eager/tests/task_tests/tensor_utils_test.cc @@ -12,17 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/eager/api/utils/tensor_utils.h" + #include #include "gtest/gtest.h" - -#include "paddle/fluid/eager/api/utils/tensor_utils.h" #include "paddle/fluid/eager/eager_tensor.h" #include "paddle/fluid/eager/grad_node_info.h" #include "paddle/fluid/eager/grad_tensor_holder.h" #include "paddle/fluid/eager/tests/test_utils.h" #include "paddle/phi/api/lib/utils/allocator.h" - #include "paddle/phi/core/kernel_registry.h" PD_DECLARE_KERNEL(full, CPU, ALL_LAYOUT); diff --git a/paddle/fluid/eager/tests/test_utils.h b/paddle/fluid/eager/tests/test_utils.h index 47bfe9a7cabd5fa1d25cdeaf174a77f8d9dd75e9..cb1e531d82d63729f716e6d81ae40233bb13e605 100644 --- a/paddle/fluid/eager/tests/test_utils.h +++ b/paddle/fluid/eager/tests/test_utils.h @@ -18,14 +18,12 @@ #include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/eager/eager_tensor.h" #include "paddle/fluid/eager/utils.h" - -#include "paddle/phi/api/all.h" -#include "paddle/phi/core/dense_tensor.h" -#include "paddle/phi/core/tensor_meta.h" - #include "paddle/fluid/memory/memcpy.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/init.h" +#include "paddle/phi/api/all.h" +#include "paddle/phi/core/dense_tensor.h" +#include "paddle/phi/core/tensor_meta.h" namespace eager_test { diff --git a/paddle/fluid/eager/to_static/run_program_op_node.h b/paddle/fluid/eager/to_static/run_program_op_node.h index 5a730e4dbf164d98f20936bcd5cd0f80d9ab4c56..3254b3bf89262ac106154d15e28450ead31bc861 100644 --- a/paddle/fluid/eager/to_static/run_program_op_node.h +++ b/paddle/fluid/eager/to_static/run_program_op_node.h @@ -17,7 +17,6 @@ #include "paddle/fluid/eager/api/utils/global_utils.h" #include "paddle/fluid/eager/grad_node_info.h" #include "paddle/fluid/eager/tensor_wrapper.h" - #include "paddle/fluid/operators/run_program_op.h" #include "paddle/fluid/platform/enforce.h" @@ -273,7 +272,7 @@ inline void RunProgramGradAPI( const paddle::framework::AttributeMap &attrs, std::vector &x_grad, // NOLINT std::vector ¶ms_grad // NOLINT - ) { +) { // if all output vars are set to stop_gradient, grad op no need to executed if (x_grad.empty() && params_grad.empty()) return; @@ -368,8 +367,7 @@ class GradNodeRunProgram : public egr::GradNodeBase { egr::kSlotSmallVectorSize> operator()(paddle::small_vector, egr::kSlotSmallVectorSize> &grads, // NOLINT - bool create_graph, - bool is_new_grad) override { + bool create_graph, bool is_new_grad) override { VLOG(3) << "Running Eager Backward Node: GradNodeRunProgram"; paddle::small_vector, egr::kSlotSmallVectorSize> diff --git a/paddle/fluid/eager/utils.h b/paddle/fluid/eager/utils.h index c6389e998315c8a58e07cf6785d72ce3000d9880..783afcc1e2c73745dee60ece6a75e139e9218287 100644 --- a/paddle/fluid/eager/utils.h +++ b/paddle/fluid/eager/utils.h @@ -18,7 +18,6 @@ #include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/eager/eager_tensor.h" #include "paddle/fluid/eager/grad_node_info.h" - #include "paddle/phi/api/all.h" namespace egr { @@ -161,10 +160,11 @@ class EagerUtils { if (require_any_grad && autograd_meta) { PADDLE_ENFORCE_EQ(!autograd_meta->StopGradient() && egr::egr_utils_api::IsLeafTensor(target), - false, paddle::platform::errors::InvalidArgument( - "Leaf Var (%s) that doesn't stop gradient " - "can't use inplace strategy.", - target.name())); + false, + paddle::platform::errors::InvalidArgument( + "Leaf Var (%s) that doesn't stop gradient " + "can't use inplace strategy.", + target.name())); } } @@ -234,8 +234,8 @@ class EagerUtils { const paddle::experimental::Tensor& tensor); /** - * Fill Zero - * **/ + * Fill Zero + * **/ static void FillZeroForEmptyOptionalGradInput( std::vector* in_grads, const std::vector& grad_in_metas); diff --git a/paddle/fluid/framework/archive.h b/paddle/fluid/framework/archive.h index d0589383863438d915c7c4ca8648bc7b54a656e9..6a8f4ff47f35d0dda33e06370340302613bb24cc 100644 --- a/paddle/fluid/framework/archive.h +++ b/paddle/fluid/framework/archive.h @@ -20,6 +20,7 @@ #endif #include + #include #include #include @@ -31,6 +32,7 @@ #include #include #include + #include "paddle/fluid/framework/expect.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/async_executor.cc b/paddle/fluid/framework/async_executor.cc index ae3d8379bdbf779e2cf82d27c18997f82cb92095..d6cc5dc639fe6eac4904497496fbe44aeef9e3c7 100644 --- a/paddle/fluid/framework/async_executor.cc +++ b/paddle/fluid/framework/async_executor.cc @@ -13,11 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/async_executor.h" + +#include "gflags/gflags.h" #include "google/protobuf/io/zero_copy_stream_impl.h" #include "google/protobuf/message.h" #include "google/protobuf/text_format.h" - -#include "gflags/gflags.h" #include "paddle/fluid/framework/data_feed_factory.h" #include "paddle/fluid/framework/executor_thread_worker.h" #include "paddle/fluid/framework/feed_fetch_method.h" diff --git a/paddle/fluid/framework/async_executor.h b/paddle/fluid/framework/async_executor.h index b0c6c8a01648ff7e995da60bc9b9f16d25aa3316..01daf3c11187b268db818eecb8f993b2c7afacd4 100644 --- a/paddle/fluid/framework/async_executor.h +++ b/paddle/fluid/framework/async_executor.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include #include #include // NOLINT @@ -24,6 +25,7 @@ limitations under the License. */ #include // NOLINT #include #include + #include "paddle/fluid/framework/data_feed.pb.h" #include "paddle/fluid/framework/data_set.h" #include "paddle/fluid/framework/executor.h" diff --git a/paddle/fluid/framework/attribute.h b/paddle/fluid/framework/attribute.h index 2164a21f3f892b2515dc77b94f7e4b91dba5dd1a..b2c5bfde3aa5608c458f6763dcecd43e045d4a74 100644 --- a/paddle/fluid/framework/attribute.h +++ b/paddle/fluid/framework/attribute.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include #include #include diff --git a/paddle/fluid/framework/attribute_test.cc b/paddle/fluid/framework/attribute_test.cc index 27a6afb49f5e817c6c09ab5adda260059f75b4a4..8a47e41d38359ca6b0de53db9629ec1b0b8e8ceb 100644 --- a/paddle/fluid/framework/attribute_test.cc +++ b/paddle/fluid/framework/attribute_test.cc @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/framework/attribute.h" + #include #include -#include "paddle/fluid/framework/attribute.h" -#include "paddle/fluid/framework/program_desc.h" - #include "gtest/gtest.h" +#include "paddle/fluid/framework/program_desc.h" #include "paddle/utils/any.h" TEST(Attribute, GetAttrValueToAny) { diff --git a/paddle/fluid/framework/channel.h b/paddle/fluid/framework/channel.h index 80fee94f1c85d961110bd0a9b9bd8946fa5c91b6..1eb3585fa33394deef2aefd985b097b9df34dce1 100644 --- a/paddle/fluid/framework/channel.h +++ b/paddle/fluid/framework/channel.h @@ -20,6 +20,7 @@ #endif #include + #include #include // NOLINT #include @@ -28,6 +29,7 @@ #include // NOLINT #include #include + #include "paddle/fluid/framework/expect.h" namespace paddle { diff --git a/paddle/fluid/framework/convert_utils_test.cc b/paddle/fluid/framework/convert_utils_test.cc index 140806dfd7c5e1ae2746f3d116f418fea16fa1f3..e3f5a4a8dcda11e333fcadb0834a4fee0e75901c 100644 --- a/paddle/fluid/framework/convert_utils_test.cc +++ b/paddle/fluid/framework/convert_utils_test.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/convert_utils.h" + #include "gtest/gtest.h" namespace phi { diff --git a/paddle/fluid/framework/copy_same_tensor_test.cc b/paddle/fluid/framework/copy_same_tensor_test.cc index d8c27ad280d18349af42ffd88baff2bbca1e23c8..d4f36be5e87e7f9fd9685d75cbcb6f20f5beda6c 100644 --- a/paddle/fluid/framework/copy_same_tensor_test.cc +++ b/paddle/fluid/framework/copy_same_tensor_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include #include "gflags/gflags.h" diff --git a/paddle/fluid/framework/custom_operator.cc b/paddle/fluid/framework/custom_operator.cc index 65c41e19ac423e754c23e45a489361ea95664bff..0130fd4b57ffa5ad71721d2d3d5645da3fe3b649 100644 --- a/paddle/fluid/framework/custom_operator.cc +++ b/paddle/fluid/framework/custom_operator.cc @@ -867,43 +867,43 @@ void RegisterOperatorWithMetaInfo(const std::vector& op_meta_infos, bool is_double_grad = (i == 2); // GradOpDescMaker - info.grad_op_maker_ = [grad_op_name, grad_op_inputs, grad_op_outputs, - is_double_grad]( - const OpDesc& fwd_op, - const std::unordered_set& no_grad_set, - std::unordered_map* grad_to_var, - const std::vector& grad_block) { - CustomGradOpMaker maker( - fwd_op, no_grad_set, grad_to_var, grad_block, grad_op_name, - grad_op_inputs, grad_op_outputs, is_double_grad); - return maker(); - }; + info.grad_op_maker_ = + [grad_op_name, grad_op_inputs, grad_op_outputs, is_double_grad]( + const OpDesc& fwd_op, + const std::unordered_set& no_grad_set, + std::unordered_map* grad_to_var, + const std::vector& grad_block) { + CustomGradOpMaker maker( + fwd_op, no_grad_set, grad_to_var, grad_block, grad_op_name, + grad_op_inputs, grad_op_outputs, is_double_grad); + return maker(); + }; // GradOpBaseMaker - info.dygraph_grad_op_maker_ = [grad_op_name, grad_op_inputs, - grad_op_outputs, is_double_grad]( - const std::string& type, - const imperative::NameVarBaseMap& var_base_map_in, - const imperative::NameVarBaseMap& var_base_map_out, - const framework::AttributeMap& attrs, - const framework::AttributeMap& default_attrs, - const std::map& inplace_map) { - CustomGradOpMaker maker( - type, var_base_map_in, var_base_map_out, attrs, inplace_map, - grad_op_name, grad_op_inputs, grad_op_outputs, is_double_grad); - maker.SetDygraphDefaultAttrsMap(default_attrs); - return maker(); - }; + info.dygraph_grad_op_maker_ = + [grad_op_name, grad_op_inputs, grad_op_outputs, is_double_grad]( + const std::string& type, + const imperative::NameVarBaseMap& var_base_map_in, + const imperative::NameVarBaseMap& var_base_map_out, + const framework::AttributeMap& attrs, + const framework::AttributeMap& default_attrs, + const std::map& inplace_map) { + CustomGradOpMaker maker( + type, var_base_map_in, var_base_map_out, attrs, inplace_map, + grad_op_name, grad_op_inputs, grad_op_outputs, is_double_grad); + maker.SetDygraphDefaultAttrsMap(default_attrs); + return maker(); + }; /* Grad op register */ OpInfo grad_info; // Grad Op - grad_info.creator_ = []( - const std::string& type, const VariableNameMap& inputs, - const VariableNameMap& outputs, const AttributeMap& attrs) { - return new CustomOperator(type, inputs, outputs, attrs); - }; + grad_info.creator_ = + [](const std::string& type, const VariableNameMap& inputs, + const VariableNameMap& outputs, const AttributeMap& attrs) { + return new CustomOperator(type, inputs, outputs, attrs); + }; // Grad InferShape if (grad_infer_shape_fn == nullptr) { diff --git a/paddle/fluid/framework/data_device_transform_test.cu b/paddle/fluid/framework/data_device_transform_test.cu index 4757eb60f4361cffd9354afd4a8bf4bf99e86eb3..d51707970ffe4518df72f9a2b52693dda3212754 100644 --- a/paddle/fluid/framework/data_device_transform_test.cu +++ b/paddle/fluid/framework/data_device_transform_test.cu @@ -13,18 +13,16 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "gtest/gtest.h" - #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/op_info.h" #include "paddle/fluid/framework/op_registry.h" +#include "paddle/fluid/framework/phi_utils.h" #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/operators/elementwise/elementwise_op_function.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/init.h" #include "paddle/phi/kernels/funcs/math_function.h" -#include "paddle/fluid/framework/phi_utils.h" - namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/data_feed.cc b/paddle/fluid/framework/data_feed.cc old mode 100755 new mode 100644 index 0801aa0e56a85648d5b7baeeb4bc9e537867447d..1808caddabccd64d59763a0304815befba137a3c --- a/paddle/fluid/framework/data_feed.cc +++ b/paddle/fluid/framework/data_feed.cc @@ -18,6 +18,7 @@ limitations under the License. */ #endif #include "paddle/fluid/framework/data_feed.h" + #include "paddle/fluid/framework/fleet/ps_gpu_wrapper.h" #ifdef _LINUX #include @@ -231,8 +232,9 @@ bool DataFeed::PickOneFile(std::string* filename) { } void DataFeed::CheckInit() { - PADDLE_ENFORCE_EQ(finish_init_, true, platform::errors::PreconditionNotMet( - "DataFeed initialization failed.")); + PADDLE_ENFORCE_EQ( + finish_init_, true, + platform::errors::PreconditionNotMet("DataFeed initialization failed.")); } void DataFeed::CheckSetFileList() { @@ -1619,9 +1621,10 @@ template class PrivateInstantDataFeed>; bool MultiSlotFileInstantDataFeed::Preprocess(const std::string& filename) { fd_ = open(filename.c_str(), O_RDONLY); PADDLE_ENFORCE_NE( - fd_, -1, platform::errors::Unavailable( - "Fail to open file: %s in MultiSlotFileInstantDataFeed.", - filename.c_str())); + fd_, -1, + platform::errors::Unavailable( + "Fail to open file: %s in MultiSlotFileInstantDataFeed.", + filename.c_str())); struct stat sb; fstat(fd_, &sb); @@ -2182,7 +2185,7 @@ void SlotRecordInMemoryDataFeed::LoadIntoMemoryByLine(void) { SlotRecordPool().get(&record_vec, OBJPOOL_BLOCK_SIZE); // get slotrecord object function auto record_func = [this, &offset, &record_vec, &old_offset]( - std::vector& vec, int num) { + std::vector& vec, int num) { vec.resize(num); if (offset + num > OBJPOOL_BLOCK_SIZE) { input_channel_->WriteMove(offset, &record_vec[0]); @@ -2675,8 +2678,8 @@ void SlotRecordInMemoryDataFeed::BuildSlotBatchGPU(const int ins_num) { size_t* off_start_ptr = &offsets[j * offset_cols_size]; int total_instance = static_cast(off_start_ptr[offset_cols_size - 1]); - CHECK(total_instance >= 0) << "slot idx:" << j - << ", total instance:" << total_instance; + CHECK(total_instance >= 0) + << "slot idx:" << j << ", total instance:" << total_instance; auto& info = used_slots_info_[j]; // fill slot value with default value 0 diff --git a/paddle/fluid/framework/data_feed_factory.cc b/paddle/fluid/framework/data_feed_factory.cc index e46e4aeb0124c2a5cefef0d7d330750c8af1d6e3..e058b1946900011ccff31f8c8d7888753e1e0e31 100644 --- a/paddle/fluid/framework/data_feed_factory.cc +++ b/paddle/fluid/framework/data_feed_factory.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/fluid/framework/data_feed_factory.h" #include + #include #include diff --git a/paddle/fluid/framework/data_feed_test.cc b/paddle/fluid/framework/data_feed_test.cc index 2cc441bbd34cb1e199000a9130d57f39be403699..8375ed80e831978819d7a73e418a296747c6aafd 100644 --- a/paddle/fluid/framework/data_feed_test.cc +++ b/paddle/fluid/framework/data_feed_test.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/framework/data_feed.h" + #include + #include // NOLINT #include #include @@ -23,6 +25,7 @@ #include // NOLINT #include #include + #include "google/protobuf/io/zero_copy_stream_impl.h" #include "google/protobuf/text_format.h" #include "gtest/gtest.h" diff --git a/paddle/fluid/framework/data_set.cc b/paddle/fluid/framework/data_set.cc index 0c762ab2e77e59def9af5cd45f5b789ca7a95b37..f89d0f969abb2cfa12e6d4e6b300ed7178d8731c 100644 --- a/paddle/fluid/framework/data_set.cc +++ b/paddle/fluid/framework/data_set.cc @@ -13,6 +13,7 @@ * limitations under the License. */ #include "paddle/fluid/framework/data_set.h" + #include "google/protobuf/text_format.h" #if (defined PADDLE_WITH_DISTRIBUTE) && (defined PADDLE_WITH_PSCORE) #include "paddle/fluid/distributed/index_dataset/index_sampler.h" diff --git a/paddle/fluid/framework/data_set.h b/paddle/fluid/framework/data_set.h index 3d096eaebe344a5cdc50ca8960d076012d5d5bd8..5d961841a250bf3e80e7282c479cfce22d839ab6 100644 --- a/paddle/fluid/framework/data_set.h +++ b/paddle/fluid/framework/data_set.h @@ -15,6 +15,7 @@ #pragma once #include + #include #include #include // NOLINT @@ -26,6 +27,7 @@ #include #ifdef PADDLE_WITH_GLOO #include + #include "paddle/fluid/framework/fleet/gloo_wrapper.h" #endif diff --git a/paddle/fluid/framework/data_type_test.cc b/paddle/fluid/framework/data_type_test.cc index 15cf30c1cf352324b57b8ca7bfcdf9d2d2640aea..01802c11d5219dc1c5cf12945901ca96d1acc026 100644 --- a/paddle/fluid/framework/data_type_test.cc +++ b/paddle/fluid/framework/data_type_test.cc @@ -44,8 +44,8 @@ TEST(DataType, float16) { TEST(DataType, bfloat16) { using paddle::framework::Tensor; - using paddle::platform::CPUPlace; using paddle::platform::bfloat16; + using paddle::platform::CPUPlace; namespace f = paddle::framework; f::proto::VarType::Type dtype = f::proto::VarType::BF16; diff --git a/paddle/fluid/framework/data_type_transform_test.cu b/paddle/fluid/framework/data_type_transform_test.cu index 4fab3a7845489a8e222b0bb7637ef49cc14eb9ec..3420298297b3febc932d6f0a3cbfb242e9c1f432 100644 --- a/paddle/fluid/framework/data_type_transform_test.cu +++ b/paddle/fluid/framework/data_type_transform_test.cu @@ -12,11 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "gtest/gtest.h" #include "paddle/fluid/framework/data_type_transform.h" #include "paddle/fluid/framework/tensor_util.h" -#include "gtest/gtest.h" - TEST(DataTypeTransform, GPUTransform) { auto cpu_place = paddle::platform::CPUPlace(); auto gpu_place = paddle::platform::CUDAPlace(0); diff --git a/paddle/fluid/framework/details/bind_threaded_ssa_graph_executor.cc b/paddle/fluid/framework/details/bind_threaded_ssa_graph_executor.cc index 75baf15dc5ec953c817c02227e4f34424bc65515..ebdf66cdde1313131bdd75077c9a4a24033348c4 100644 --- a/paddle/fluid/framework/details/bind_threaded_ssa_graph_executor.cc +++ b/paddle/fluid/framework/details/bind_threaded_ssa_graph_executor.cc @@ -12,12 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "paddle/fluid/framework/details/bind_threaded_ssa_graph_executor.h" + #include #include #include #include #include #include + #include "paddle/fluid/framework/details/computation_op_handle.h" #include "paddle/fluid/framework/details/fetch_op_handle.h" #include "paddle/fluid/framework/details/multi_devices_helper.h" diff --git a/paddle/fluid/framework/details/bind_threaded_ssa_graph_executor.h b/paddle/fluid/framework/details/bind_threaded_ssa_graph_executor.h index 5e973f13cc618a28c370b82576cc72c7fb499495..c907a4b4afc7cceb4abf6ff1a40039949f4f3ebd 100644 --- a/paddle/fluid/framework/details/bind_threaded_ssa_graph_executor.h +++ b/paddle/fluid/framework/details/bind_threaded_ssa_graph_executor.h @@ -14,12 +14,14 @@ #pragma once #include + #include // NOLINT #include #include // NOLINT #include #include #include + #include "paddle/fluid/framework/blocking_queue.h" #include "paddle/fluid/framework/details/exception_holder.h" #include "paddle/fluid/framework/details/execution_strategy.h" diff --git a/paddle/fluid/framework/details/bkcl_op_handle.h b/paddle/fluid/framework/details/bkcl_op_handle.h index 1a098f06f08f985600d8add287d5c130a36d7a3f..b0c2275b3a52bf1ea8a23c762fd5b29f1845386a 100644 --- a/paddle/fluid/framework/details/bkcl_op_handle.h +++ b/paddle/fluid/framework/details/bkcl_op_handle.h @@ -14,8 +14,6 @@ #pragma once -#include "xpu/bkcl.h" - #include #include #include @@ -24,6 +22,7 @@ #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/platform/device/xpu/bkcl_helper.h" +#include "xpu/bkcl.h" DECLARE_bool(sync_bkcl_allreduce); diff --git a/paddle/fluid/framework/details/build_strategy.cc b/paddle/fluid/framework/details/build_strategy.cc index fdf74d2f769fcdd49da19c0118a23d6b8fbb06e4..9ed76c87d846c6d1922860de02d0f2674a976194 100644 --- a/paddle/fluid/framework/details/build_strategy.cc +++ b/paddle/fluid/framework/details/build_strategy.cc @@ -16,6 +16,7 @@ limitations under the License. */ #include "paddle/fluid/framework/details/build_strategy.h" #include + #include "paddle/fluid/framework/details/reduce_op_handle.h" #include "paddle/fluid/framework/ir/graph_printer.h" #include "paddle/fluid/framework/ir/multi_devices_graph_pass/multi_devices_graph_pass.h" diff --git a/paddle/fluid/framework/details/build_strategy_test.cc b/paddle/fluid/framework/details/build_strategy_test.cc index 69af77d23fbf427e91bf152d6b258b1d3cfd3617..1914c1d33de015632fb7edbbd60f654ed6d10e0b 100644 --- a/paddle/fluid/framework/details/build_strategy_test.cc +++ b/paddle/fluid/framework/details/build_strategy_test.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/framework/details/build_strategy.h" + #include #include #include @@ -23,8 +25,6 @@ #include "gtest/gtest-test-part.h" #include "gtest/gtest.h" #include "gtest/gtest_pred_impl.h" - -#include "paddle/fluid/framework/details/build_strategy.h" #include "paddle/fluid/framework/op_proto_maker.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/var_type_inference.h" diff --git a/paddle/fluid/framework/details/cow_ptr_test.cc b/paddle/fluid/framework/details/cow_ptr_test.cc index 5b055d7cb4d127dc20f2cf70869134f24a93d429..b440da9f1dfb46fdbb8d40bbe45b00618b9b9110 100644 --- a/paddle/fluid/framework/details/cow_ptr_test.cc +++ b/paddle/fluid/framework/details/cow_ptr_test.cc @@ -13,6 +13,7 @@ limitations under the License. */ #include "paddle/fluid/framework/details/cow_ptr.h" + #include "gtest/gtest.h" namespace paddle { diff --git a/paddle/fluid/framework/details/execution_strategy.h b/paddle/fluid/framework/details/execution_strategy.h index 7f51de435ba6c4d32dc3aae371612e639dbbcceb..57440ed9aa2f49870d3e21c6ddfcddd274453f9e 100644 --- a/paddle/fluid/framework/details/execution_strategy.h +++ b/paddle/fluid/framework/details/execution_strategy.h @@ -14,6 +14,7 @@ #pragma once #include // for size_t + #include "paddle/fluid/platform/device_context.h" namespace paddle { diff --git a/paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.h b/paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.h index 4477702900a8da5e940b32fe2a1819498e464793..19b0061571596848568e90cec9f8fbb459ec6603 100644 --- a/paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.h +++ b/paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.h @@ -14,10 +14,12 @@ #pragma once #include + #include #include #include #include + #include "paddle/fluid/framework/blocking_queue.h" #include "paddle/fluid/framework/details/exception_holder.h" #include "paddle/fluid/framework/details/execution_strategy.h" diff --git a/paddle/fluid/framework/details/fused_all_reduce_op_handle.cc b/paddle/fluid/framework/details/fused_all_reduce_op_handle.cc index f4ca4907d48d08a4a357c3e6d12d8c856e12358b..7f44e68af6b0b8ae8f8f6928eefe8e42251968e9 100644 --- a/paddle/fluid/framework/details/fused_all_reduce_op_handle.cc +++ b/paddle/fluid/framework/details/fused_all_reduce_op_handle.cc @@ -325,9 +325,10 @@ void FusedAllReduceOpHandle::GetGradLoDTensor( PADDLE_ENFORCE_EQ( platform::is_same_place(lod_tensor.place(), places_.at(scope_idx)), - true, platform::errors::InvalidArgument( - "The variable '%s' at scope %d is not in the right place.", - var_name, scope_idx)); + true, + platform::errors::InvalidArgument( + "The variable '%s' at scope %d is not in the right place.", + var_name, scope_idx)); grad_tensor->emplace_back(std::make_pair(var_name, &lod_tensor)); } } @@ -356,10 +357,11 @@ void FusedAllReduceOpHandle::GetDTypeAndNumel( // Get element number int64_t len = grad_tensor.at(i).second->numel(); PADDLE_ENFORCE_GT( - len, 0, platform::errors::InvalidArgument( - "The size of grad tensors of fused_all_reduce_op_handle " - "must be > 0, but got %d.", - len)); + len, 0, + platform::errors::InvalidArgument( + "The size of grad tensors of fused_all_reduce_op_handle " + "must be > 0, but got %d.", + len)); *numel += platform::Alignment(len * size_of_dtype, places_[0]) / size_of_dtype; } diff --git a/paddle/fluid/framework/details/grad_merge_all_reduce_op_handle.cc b/paddle/fluid/framework/details/grad_merge_all_reduce_op_handle.cc index 44b9ca90fc540b39d5b3ae53f3ddcee2c8d74d6f..18de9f443a72fad55e79a62cb59852206e852a33 100644 --- a/paddle/fluid/framework/details/grad_merge_all_reduce_op_handle.cc +++ b/paddle/fluid/framework/details/grad_merge_all_reduce_op_handle.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "paddle/fluid/framework/details/grad_merge_all_reduce_op_handle.h" + #include "paddle/fluid/platform/profiler/event_tracing.h" #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) diff --git a/paddle/fluid/framework/details/graph_test_base.h b/paddle/fluid/framework/details/graph_test_base.h index d139f8488309eecf89c924a346ab0e574edc86dc..08d9c999a8a5dfc8fb12042edfccc1ad904d97e8 100644 --- a/paddle/fluid/framework/details/graph_test_base.h +++ b/paddle/fluid/framework/details/graph_test_base.h @@ -18,6 +18,7 @@ #include #include #include + #include "glog/logging.h" #include "gtest/gtest.h" #include "paddle/fluid/framework/ir/graph.h" diff --git a/paddle/fluid/framework/details/nan_inf_utils_detail.cc b/paddle/fluid/framework/details/nan_inf_utils_detail.cc index e6790de92d054343404c936707fddd0044d28084..7b93baddb4af68ee5e18b210d602e9d550e17bc7 100644 --- a/paddle/fluid/framework/details/nan_inf_utils_detail.cc +++ b/paddle/fluid/framework/details/nan_inf_utils_detail.cc @@ -12,8 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/details/nan_inf_utils.h" #include "paddle/fluid/framework/details/nan_inf_utils_detail.h" + +#include "paddle/fluid/framework/details/nan_inf_utils.h" #include "paddle/fluid/framework/op_proto_maker.h" #include "paddle/fluid/framework/scope.h" @@ -261,7 +262,7 @@ void CheckNanInf>( } template <> - void CheckNanInf>> + void CheckNanInf < paddle::platform::complex < double >>> (const paddle::platform::complex* value, const size_t numel, int print_num, const std::string& op_type, const std::string& var_name) { double real_sum = 0.0; @@ -563,8 +564,9 @@ static void NPUCheckOpHasNanOrInf(const framework::OperatorBase& op, if (sum >= 1.0) PrintNPUOpValueInfo(op, scope, place); - PADDLE_ENFORCE_LT(sum, 1.0, platform::errors::PreconditionNotMet( - "Operator %s contains Nan/Inf.", op.Type())); + PADDLE_ENFORCE_LT(sum, 1.0, + platform::errors::PreconditionNotMet( + "Operator %s contains Nan/Inf.", op.Type())); } #endif diff --git a/paddle/fluid/framework/details/nan_inf_utils_detail.cu b/paddle/fluid/framework/details/nan_inf_utils_detail.cu index 7cf11f7829da90f382e8d9da6bc22493452f6f75..b8b5537c93cca37bca717102f36731db5ef9e169 100644 --- a/paddle/fluid/framework/details/nan_inf_utils_detail.cu +++ b/paddle/fluid/framework/details/nan_inf_utils_detail.cu @@ -12,15 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/details/nan_inf_utils.h" -#include "paddle/fluid/framework/details/nan_inf_utils_detail.h" - #include #include #include #include #include "paddle/fluid/framework/convert_utils.h" +#include "paddle/fluid/framework/details/nan_inf_utils.h" +#include "paddle/fluid/framework/details/nan_inf_utils_detail.h" #include "paddle/fluid/framework/scope.h" namespace paddle { diff --git a/paddle/fluid/framework/details/op_registry.h b/paddle/fluid/framework/details/op_registry.h index 427b981e7cda27269f9da5f007464a5fd97d28c2..213d70337648a4b78abb48eee2960d70c7dffba9 100644 --- a/paddle/fluid/framework/details/op_registry.h +++ b/paddle/fluid/framework/details/op_registry.h @@ -213,14 +213,14 @@ struct OpInfoFiller { platform::errors::AlreadyExists( "GradOpDescMaker of %s has been registered", op_type)); - info->grad_op_maker_ = []( - const OpDesc& fwd_op, - const std::unordered_set& no_grad_set, - std::unordered_map* grad_to_var, - const std::vector& grad_block) { - T maker(fwd_op, no_grad_set, grad_to_var, grad_block); - return maker(); - }; + info->grad_op_maker_ = + [](const OpDesc& fwd_op, + const std::unordered_set& no_grad_set, + std::unordered_map* grad_to_var, + const std::vector& grad_block) { + T maker(fwd_op, no_grad_set, grad_to_var, grad_block); + return maker(); + }; info->use_default_grad_op_desc_maker_ = std::is_base_of, T>::value || @@ -244,17 +244,17 @@ struct OpInfoFiller { platform::errors::AlreadyExists( "GradOpBaseMaker of %s has been registered", op_type)); - info->dygraph_grad_op_maker_ = []( - const std::string& type, - const imperative::NameVarBaseMap& var_base_map_in, - const imperative::NameVarBaseMap& var_base_map_out, - const framework::AttributeMap& attrs, - const framework::AttributeMap& default_attrs, - const std::map& inplace_map) { - T maker(type, var_base_map_in, var_base_map_out, attrs, inplace_map); - maker.SetDygraphDefaultAttrsMap(default_attrs); - return maker(); - }; + info->dygraph_grad_op_maker_ = + [](const std::string& type, + const imperative::NameVarBaseMap& var_base_map_in, + const imperative::NameVarBaseMap& var_base_map_out, + const framework::AttributeMap& attrs, + const framework::AttributeMap& default_attrs, + const std::map& inplace_map) { + T maker(type, var_base_map_in, var_base_map_out, attrs, inplace_map); + maker.SetDygraphDefaultAttrsMap(default_attrs); + return maker(); + }; } }; diff --git a/paddle/fluid/framework/details/parallel_ssa_graph_executor.cc b/paddle/fluid/framework/details/parallel_ssa_graph_executor.cc index 936e84a6c82b9a84b5900292362bfce26cd33b37..22c27fe86f1ae9cd60401d47e3285a2a05700856 100644 --- a/paddle/fluid/framework/details/parallel_ssa_graph_executor.cc +++ b/paddle/fluid/framework/details/parallel_ssa_graph_executor.cc @@ -90,10 +90,9 @@ ParallelSSAGraphExecutor::ParallelSSAGraphExecutor( const std::vector &places, ir::Graph *graph) // TODO(Yancey1989): Copying graphs is not safely since it deleted the // attrs. - : ParallelSSAGraphExecutor(strategy, local_scopes, local_exec_scopes, - places, - SeparateMultiDevicesGraph(graph, - places.size())) {} + : ParallelSSAGraphExecutor( + strategy, local_scopes, local_exec_scopes, places, + SeparateMultiDevicesGraph(graph, places.size())) {} ParallelSSAGraphExecutor::ParallelSSAGraphExecutor( const ExecutionStrategy &strategy, const std::vector &local_scopes, diff --git a/paddle/fluid/framework/details/parallel_ssa_graph_executor.h b/paddle/fluid/framework/details/parallel_ssa_graph_executor.h index d9d83efcb8e9b6325ce60958c95070c33c0ee1e4..88c8b1cbfb294d0a7c7a20ce29eee88f31e4a354 100644 --- a/paddle/fluid/framework/details/parallel_ssa_graph_executor.h +++ b/paddle/fluid/framework/details/parallel_ssa_graph_executor.h @@ -17,6 +17,7 @@ #include #include #include + #include "ThreadPool.h" #include "paddle/fluid/framework/details/fast_threaded_ssa_graph_executor.h" #include "paddle/fluid/framework/details/multi_devices_helper.h" diff --git a/paddle/fluid/framework/details/reduce_op_handle.cc b/paddle/fluid/framework/details/reduce_op_handle.cc index 2ae3880ab3c2cbcf3d763b720422186c73f5e3ed..799005e4b09bbb12eed91a1d195db37d9f071c58 100644 --- a/paddle/fluid/framework/details/reduce_op_handle.cc +++ b/paddle/fluid/framework/details/reduce_op_handle.cc @@ -245,14 +245,15 @@ void ReduceOpHandle::RunImpl() { int type = platform::ToBKCLDataType( framework::TransToProtoVarType(lod_tensor.dtype())); size_t numel = static_cast(lod_tensor.numel()); - all_reduce_calls.emplace_back([buffer, recvbuffer, type, numel, root_id, - &bkcl_ctx] { - PADDLE_ENFORCE_EQ(bkcl_reduce(bkcl_ctx.comm(), buffer, recvbuffer, - numel, static_cast(type), - BKCL_ADD, root_id, nullptr), - BKCL_SUCCESS, platform::errors::Unavailable( - "bkcl_all_reduce failed")); - }); + all_reduce_calls.emplace_back( + [buffer, recvbuffer, type, numel, root_id, &bkcl_ctx] { + PADDLE_ENFORCE_EQ( + bkcl_reduce(bkcl_ctx.comm(), buffer, recvbuffer, numel, + static_cast(type), BKCL_ADD, + root_id, nullptr), + BKCL_SUCCESS, + platform::errors::Unavailable("bkcl_all_reduce failed")); + }); } WaitInputVarGenerated(); diff --git a/paddle/fluid/framework/details/rpc_op_handle.cc b/paddle/fluid/framework/details/rpc_op_handle.cc index 39bcf1d0f385f93cdd867e47c8dc8ba40dc263b9..35373e1a7090b4fc4813bcf6aa8d5a4aef820576 100644 --- a/paddle/fluid/framework/details/rpc_op_handle.cc +++ b/paddle/fluid/framework/details/rpc_op_handle.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/details/rpc_op_handle.h" + #include "paddle/fluid/framework/ir/graph.h" #include "paddle/fluid/platform/profiler/event_tracing.h" diff --git a/paddle/fluid/framework/details/scope_buffered_monitor.cc b/paddle/fluid/framework/details/scope_buffered_monitor.cc index 57faf0e75ba99ca023ac5bddfcd2f45835694fa5..bd1a4378f0729df6127c9bcda1ab78f884512256 100644 --- a/paddle/fluid/framework/details/scope_buffered_monitor.cc +++ b/paddle/fluid/framework/details/scope_buffered_monitor.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/details/scope_buffered_monitor.h" + #include "paddle/fluid/platform/profiler/event_tracing.h" namespace paddle { diff --git a/paddle/fluid/framework/details/scope_buffered_ssa_graph_executor.h b/paddle/fluid/framework/details/scope_buffered_ssa_graph_executor.h index ea5a3c07957bfde059ee7dbf7feaa60c56a03af4..091224f1e59bcf64bd3dc3a317a1f6f3a136274e 100644 --- a/paddle/fluid/framework/details/scope_buffered_ssa_graph_executor.h +++ b/paddle/fluid/framework/details/scope_buffered_ssa_graph_executor.h @@ -14,6 +14,7 @@ #pragma once #include + #include #include #include @@ -21,6 +22,7 @@ #include #include #include + #include "paddle/fluid/framework/details/execution_strategy.h" #include "paddle/fluid/framework/details/op_handle_base.h" #include "paddle/fluid/framework/details/scope_buffered_monitor.h" diff --git a/paddle/fluid/framework/details/sparse_all_reduce_op_handle.cc b/paddle/fluid/framework/details/sparse_all_reduce_op_handle.cc index 7e63c5ffb9a44d36fc3a7a84545db4cda25a4d19..28a5c31f6440fc6c55c3611f28f7ce5fde441293 100644 --- a/paddle/fluid/framework/details/sparse_all_reduce_op_handle.cc +++ b/paddle/fluid/framework/details/sparse_all_reduce_op_handle.cc @@ -41,8 +41,9 @@ SparseAllReduceOpHandle::SparseAllReduceOpHandle( is_encoded_(is_encoded), nranks_(nranks) { // TODO(gongwb) :polish them! - PADDLE_ENFORCE_EQ(is_encoded, true, platform::errors::InvalidArgument( - "The argument is_encoded is false.")); + PADDLE_ENFORCE_EQ( + is_encoded, true, + platform::errors::InvalidArgument("The argument is_encoded is false.")); VLOG(1) << "Use dgc allreduce mode" << ", nranks:" << nranks_; @@ -193,11 +194,12 @@ void SparseAllReduceOpHandle::RunImplEncoded() { sparse_reduce_calls.emplace_back([=] { platform::CUDADeviceGuard guard(dev_id); - PADDLE_ENFORCE_EQ(paddle::communication::dgc::sparseReduce( - gather_buff, k, out_tensor_buf, - static_cast(out_numel), nranks_, stream), - true, platform::errors::Unavailable( - "Calling sparseReduce() failed.")); + PADDLE_ENFORCE_EQ( + paddle::communication::dgc::sparseReduce( + gather_buff, k, out_tensor_buf, static_cast(out_numel), + nranks_, stream), + true, + platform::errors::Unavailable("Calling sparseReduce() failed.")); }); } diff --git a/paddle/fluid/framework/device_worker.cc b/paddle/fluid/framework/device_worker.cc index 880261436831d83ad42f393b740045d151243c46..56cd12f5001683f1e5b7631054569f1c2de4344d 100644 --- a/paddle/fluid/framework/device_worker.cc +++ b/paddle/fluid/framework/device_worker.cc @@ -190,9 +190,10 @@ void DeviceWorker::DumpField(const Scope& scope, int dump_mode, tensor = &cpu_tensor; } if (!CheckValidOutput(tensor, batch_size)) { - VLOG(0) << "Note: field[" << field << "] cannot pass check, so it was " - "skipped. Maybe the dimension is " - "wrong "; + VLOG(0) << "Note: field[" << field + << "] cannot pass check, so it was " + "skipped. Maybe the dimension is " + "wrong "; continue; } for (size_t i = 0; i < batch_size; ++i) { diff --git a/paddle/fluid/framework/device_worker_factory.cc b/paddle/fluid/framework/device_worker_factory.cc index e6635a2f941cd11381670156050567f47c56665c..c973afd156085df1353eeac42ec43febe3cc74fd 100644 --- a/paddle/fluid/framework/device_worker_factory.cc +++ b/paddle/fluid/framework/device_worker_factory.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/fluid/framework/device_worker_factory.h" #include + #include #include diff --git a/paddle/fluid/framework/dlpack_tensor.cc b/paddle/fluid/framework/dlpack_tensor.cc index 20d08ef18aeb3e4d8a9f5cfd0b38954daf27020d..7e1f740bcc2cf010b9c485ef18254e3632be36fa 100644 --- a/paddle/fluid/framework/dlpack_tensor.cc +++ b/paddle/fluid/framework/dlpack_tensor.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "paddle/fluid/framework/dlpack_tensor.h" + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/data_type.h" diff --git a/paddle/fluid/framework/dlpack_tensor_test.cc b/paddle/fluid/framework/dlpack_tensor_test.cc index 829908bd982287572abcde8475a4b7189f09dd22..6c19cf3450dbd8b98f2356f2a3faff50c545de75 100644 --- a/paddle/fluid/framework/dlpack_tensor_test.cc +++ b/paddle/fluid/framework/dlpack_tensor_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/dlpack_tensor.h" + #include #include @@ -39,7 +40,7 @@ constexpr uint8_t GetDLDataTypeCode() { : (std::is_integral::value ? static_cast(kDLInt) : static_cast(-1))); } -} // NOLINT +} // namespace template void TestMain(const platform::Place &place, uint16_t lanes) { diff --git a/paddle/fluid/framework/downpour_lite_worker.cc b/paddle/fluid/framework/downpour_lite_worker.cc index 7344c93ef06795aef79cf4b6124b5a1c5948d8cd..8ceffe58dcf42d67f7574638f22ca9e6e0f652eb 100644 --- a/paddle/fluid/framework/downpour_lite_worker.cc +++ b/paddle/fluid/framework/downpour_lite_worker.cc @@ -202,15 +202,15 @@ void DownpourLiteWorker::CopyDenseVars() { Variable* src_var = thread_scope_->FindVar(src_var_name); CHECK(src_var != nullptr) << src_var_name << " not found"; // NOLINT LoDTensor* src_tensor = src_var->GetMutable(); - CHECK(src_tensor != nullptr) << src_var_name - << " tensor is null"; // NOLINT + CHECK(src_tensor != nullptr) + << src_var_name << " tensor is null"; // NOLINT float* src_data = src_tensor->data(); Variable* dest_var = thread_scope_->FindVar(dest_var_name); CHECK(dest_var != nullptr) << dest_var_name << " not found"; // NOLINT LoDTensor* dest_tensor = dest_var->GetMutable(); - CHECK(dest_tensor != nullptr) << dest_var_name - << " tensor is null"; // NOLINT + CHECK(dest_tensor != nullptr) + << dest_var_name << " tensor is null"; // NOLINT float* dest_data = dest_tensor->data(); CHECK(src_tensor->numel() == dest_tensor->numel()) diff --git a/paddle/fluid/framework/downpour_worker.cc b/paddle/fluid/framework/downpour_worker.cc index 06c3d18af84ae84968c8da933a62899d132ad7a0..c14b48ef8a72fcf5e7aa3e0f77ebe97af35c3244 100644 --- a/paddle/fluid/framework/downpour_worker.cc +++ b/paddle/fluid/framework/downpour_worker.cc @@ -155,8 +155,8 @@ void DownpourWorker::CollectLabelInfo(size_t table_idx) { continue; } LoDTensor* tensor = fea_var->GetMutable(); - CHECK(tensor != nullptr) << "tensor of var " - << sparse_key_names_[table_id][i] << " is null"; + CHECK(tensor != nullptr) + << "tensor of var " << sparse_key_names_[table_id][i] << " is null"; // skip slots which do not have embedding Variable* emb_var = @@ -309,9 +309,9 @@ void DownpourWorker::AdjustInsWeight() { float* ins_weights = ins_weight_tensor->data(); size_t len = ins_weight_tensor->numel(); // len = batch size // here we assume nid_show slot only has one feasign in each instance - CHECK(len == nid_show_.size()) << "ins_weight size should be equal to " - << "nid_show size, " << len << " vs " - << nid_show_.size(); + CHECK(len == nid_show_.size()) + << "ins_weight size should be equal to " + << "nid_show size, " << len << " vs " << nid_show_.size(); float nid_adjw_threshold = adjust_ins_weight_config_.nid_adjw_threshold(); float nid_adjw_ratio = adjust_ins_weight_config_.nid_adjw_ratio(); int64_t nid_adjw_num = 0; @@ -326,9 +326,8 @@ void DownpourWorker::AdjustInsWeight() { } float ins_weight = 1.0; if (nid_show >= 0 && nid_show < nid_adjw_threshold) { - ins_weight = log(M_E + - (nid_adjw_threshold - nid_show) / nid_adjw_threshold * - nid_adjw_ratio); + ins_weight = log(M_E + (nid_adjw_threshold - nid_show) / + nid_adjw_threshold * nid_adjw_ratio); // count nid adjw insnum and weight ++nid_adjw_num; nid_adjw_weight += ins_weight; @@ -423,15 +422,15 @@ void DownpourWorker::CopyDenseVars() { Variable* src_var = thread_scope_->FindVar(src_var_name); CHECK(src_var != nullptr) << src_var_name << " not found"; // NOLINT LoDTensor* src_tensor = src_var->GetMutable(); - CHECK(src_tensor != nullptr) << src_var_name - << " tensor is null"; // NOLINT + CHECK(src_tensor != nullptr) + << src_var_name << " tensor is null"; // NOLINT float* src_data = src_tensor->data(); Variable* dest_var = thread_scope_->FindVar(dest_var_name); CHECK(dest_var != nullptr) << dest_var_name << " not found"; // NOLINT LoDTensor* dest_tensor = dest_var->GetMutable(); - CHECK(dest_tensor != nullptr) << dest_var_name - << " tensor is null"; // NOLINT + CHECK(dest_tensor != nullptr) + << dest_var_name << " tensor is null"; // NOLINT float* dest_data = dest_tensor->data(); CHECK(src_tensor->numel() == dest_tensor->numel()) diff --git a/paddle/fluid/framework/eigen_test.cc b/paddle/fluid/framework/eigen_test.cc index 43d5f9ea0e8dbfe70b588bdbb1ff05a88cb68fdb..4e214bd36f33ad5f7ed592959ccf508fd57e42eb 100644 --- a/paddle/fluid/framework/eigen_test.cc +++ b/paddle/fluid/framework/eigen_test.cc @@ -13,10 +13,11 @@ // limitations under the License. #include "paddle/fluid/framework/eigen.h" -#include "paddle/phi/core/ddim.h" #include +#include "paddle/phi/core/ddim.h" + namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/executor.cc b/paddle/fluid/framework/executor.cc index 06ce9712f5c52708eeba76c60291af5f91b83b09..830bbacb6398cc9a7753a051bbc2962cc75b3b05 100644 --- a/paddle/fluid/framework/executor.cc +++ b/paddle/fluid/framework/executor.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/executor.h" + #include + #include "paddle/fluid/framework/feed_fetch_method.h" #include "paddle/fluid/framework/trainer_desc.pb.h" #include "paddle/fluid/framework/trainer_factory.h" @@ -585,8 +587,9 @@ void Executor::RunPreparedContext( "Program in ExecutorPrepareContext should has feed_ops.")); PADDLE_ENFORCE_EQ( has_fetch_operators(global_block, *fetch_targets, fetch_holder_name), - true, platform::errors::PreconditionNotMet( - "Program in the prepared context should has fetch_ops.")); + true, + platform::errors::PreconditionNotMet( + "Program in the prepared context should has fetch_ops.")); // map the data of feed_targets to feed_holder for (auto* op : global_block.AllOps()) { diff --git a/paddle/fluid/framework/executor_cache.cc b/paddle/fluid/framework/executor_cache.cc index 50a41cb5611e10be4d7a445cbff6ca051d895913..468b3bc680af39b33fa6a6023fb5cc55b4b3171c 100644 --- a/paddle/fluid/framework/executor_cache.cc +++ b/paddle/fluid/framework/executor_cache.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/executor_cache.h" + #include "paddle/fluid/framework/op_info.h" namespace paddle { diff --git a/paddle/fluid/framework/executor_thread_worker.cc b/paddle/fluid/framework/executor_thread_worker.cc index 06019372a7323b3c61c067638da19b847eba9031..c6ccc2adc659fda60115f26f6a2e797a19fe3471 100644 --- a/paddle/fluid/framework/executor_thread_worker.cc +++ b/paddle/fluid/framework/executor_thread_worker.cc @@ -13,13 +13,14 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/executor_thread_worker.h" + #include #include + +#include "gflags/gflags.h" #include "google/protobuf/io/zero_copy_stream_impl.h" #include "google/protobuf/message.h" #include "google/protobuf/text_format.h" - -#include "gflags/gflags.h" #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/feed_fetch_method.h" #include "paddle/fluid/framework/feed_fetch_type.h" @@ -616,8 +617,8 @@ void AsyncExecutorThreadWorker::PushSparse(int table_id) { int len = tensor->numel(); CHECK(slot_dim * len == g_tensor->numel()) << "len:" << len << " g_numel:" << g_tensor->numel(); - CHECK(len == tensor->numel()) << "len:" << len - << "t_numel:" << tensor->numel(); + CHECK(len == tensor->numel()) + << "len:" << len << "t_numel:" << tensor->numel(); int64_t* ids = tensor->data(); for (auto id_idx = 0u; id_idx < len; ++id_idx) { if (ids[id_idx] == 0) { @@ -626,15 +627,15 @@ void AsyncExecutorThreadWorker::PushSparse(int table_id) { } memcpy(push_g[fea_idx].data() + offset, g, sizeof(float) * slot_dim); push_g[fea_idx][0] = 1.0f; - CHECK(fea_idx < fea_info.size()) << "fea_idx:" << fea_idx - << " size:" << fea_info.size(); + CHECK(fea_idx < fea_info.size()) + << "fea_idx:" << fea_idx << " size:" << fea_info.size(); push_g[fea_idx][1] = static_cast(fea_info[fea_idx].label); g += slot_dim; fea_idx++; } } - CHECK(fea_idx == features.size()) << "fea_idx:" << fea_idx - << " features size:" << features.size(); + CHECK(fea_idx == features.size()) + << "fea_idx:" << fea_idx << " features size:" << features.size(); CHECK_GT(features.size(), 0); std::vector push_g_vec; @@ -701,5 +702,5 @@ void AsyncExecutorThreadWorker::check_pull_push_memory( } #endif -} // einit_modelnd namespace framework +} // namespace framework } // end namespace paddle diff --git a/paddle/fluid/framework/executor_thread_worker.h b/paddle/fluid/framework/executor_thread_worker.h index 524922b0322e538d46f93011fbca3223b02d8849..f4fa54d2c3a7bf25f4e01db4b5d9e9ae34bcb29b 100644 --- a/paddle/fluid/framework/executor_thread_worker.h +++ b/paddle/fluid/framework/executor_thread_worker.h @@ -21,6 +21,7 @@ limitations under the License. */ #include #include // NOLINT #include + #include "paddle/fluid/framework/data_feed.h" #include "paddle/fluid/framework/executor.h" #include "paddle/fluid/framework/program_desc.h" diff --git a/paddle/fluid/framework/feed_fetch_method.cc b/paddle/fluid/framework/feed_fetch_method.cc index 096134e852833cf73fb1d004b334906e753e360a..ec3fdc49fdf1f91ee3839e56d0095830f0f6a971 100644 --- a/paddle/fluid/framework/feed_fetch_method.cc +++ b/paddle/fluid/framework/feed_fetch_method.cc @@ -14,9 +14,9 @@ limitations under the License. */ #include "paddle/fluid/framework/feed_fetch_method.h" +#include #include -#include #include "glog/logging.h" namespace phi { diff --git a/paddle/fluid/framework/fleet/ascend_wrapper.h b/paddle/fluid/framework/fleet/ascend_wrapper.h index d55862120116df4c711436641b2b9eb8c80405e6..a4bd208959e43db9b75986849c75f0b0ae01b1a9 100644 --- a/paddle/fluid/framework/fleet/ascend_wrapper.h +++ b/paddle/fluid/framework/fleet/ascend_wrapper.h @@ -22,6 +22,10 @@ limitations under the License. */ #include #include +#include "ge/ge_api.h" +#include "graph/attr_value.h" +#include "graph/tensor.h" +#include "graph/types.h" #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/lod_tensor.h" @@ -29,11 +33,6 @@ limitations under the License. */ #include "paddle/fluid/platform/place.h" #include "paddle/fluid/platform/timer.h" -#include "ge/ge_api.h" -#include "graph/attr_value.h" -#include "graph/tensor.h" -#include "graph/types.h" - namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/fleet/box_wrapper.cc b/paddle/fluid/framework/fleet/box_wrapper.cc index 8564a42165961b8d1bc15e8df21e68f229b29065..1bb432a791e2c2a81fe349513e1ef3e84f460f3c 100644 --- a/paddle/fluid/framework/fleet/box_wrapper.cc +++ b/paddle/fluid/framework/fleet/box_wrapper.cc @@ -14,10 +14,12 @@ #ifdef PADDLE_WITH_BOX_PS #include "paddle/fluid/framework/fleet/box_wrapper.h" + #include #include #include #include + #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/platform/device/gpu/gpu_info.h" @@ -186,26 +188,30 @@ void BasicAucCalculator::calculate_bucket_error() { void BoxWrapper::FeedPass(int date, const std::vector& feasgin_to_box) const { int ret = boxps_ptr_->FeedPass(date, feasgin_to_box); - PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( - "FeedPass failed in BoxPS.")); + PADDLE_ENFORCE_EQ( + ret, 0, + platform::errors::PreconditionNotMet("FeedPass failed in BoxPS.")); } void BoxWrapper::BeginFeedPass(int date, boxps::PSAgentBase** agent) const { int ret = boxps_ptr_->BeginFeedPass(date, *agent); - PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( - "BeginFeedPass failed in BoxPS.")); + PADDLE_ENFORCE_EQ( + ret, 0, + platform::errors::PreconditionNotMet("BeginFeedPass failed in BoxPS.")); } void BoxWrapper::EndFeedPass(boxps::PSAgentBase* agent) const { int ret = boxps_ptr_->EndFeedPass(agent); - PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( - "EndFeedPass failed in BoxPS.")); + PADDLE_ENFORCE_EQ( + ret, 0, + platform::errors::PreconditionNotMet("EndFeedPass failed in BoxPS.")); } void BoxWrapper::BeginPass() const { int ret = boxps_ptr_->BeginPass(); - PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( - "BeginPass failed in BoxPS.")); + PADDLE_ENFORCE_EQ( + ret, 0, + platform::errors::PreconditionNotMet("BeginPass failed in BoxPS.")); } void BoxWrapper::SetTestMode(bool is_test) const { diff --git a/paddle/fluid/framework/fleet/box_wrapper.cu b/paddle/fluid/framework/fleet/box_wrapper.cu index aea479ed0b214da7790c46bde84914b53c31c034..17e59ac9104f66688d58bea9f4b97c9ddf0b0679 100644 --- a/paddle/fluid/framework/fleet/box_wrapper.cu +++ b/paddle/fluid/framework/fleet/box_wrapper.cu @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/fluid/framework/fleet/box_wrapper.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/platform/device/gpu/gpu_info.h" @@ -175,13 +176,13 @@ void BoxWrapper::CopyForPull(const paddle::platform::Place& place, #define EXPAND_EMBED_PULL_CASE(i, ...) \ case i: { \ constexpr size_t ExpandDim = i; \ - PullCopy<<<(total_length + 512 - 1) / 512, 512, 0, stream>>>( \ - gpu_values, \ - reinterpret_cast*>( \ - total_values_gpu), \ - gpu_len, hidden_size, expand_embed_dim, slot_num, total_length, \ - gpu_keys); \ + PullCopy \ + <<<(total_length + 512 - 1) / 512, 512, 0, stream>>>( \ + gpu_values, \ + reinterpret_cast*>( \ + total_values_gpu), \ + gpu_len, hidden_size, expand_embed_dim, slot_num, total_length, \ + gpu_keys); \ } break #endif diff --git a/paddle/fluid/framework/fleet/box_wrapper.h b/paddle/fluid/framework/fleet/box_wrapper.h index b043edca138a8403da955660734ea37328d79b2f..dc01df221e9666f28edf6fcd9bd37e4a24c40fe1 100644 --- a/paddle/fluid/framework/fleet/box_wrapper.h +++ b/paddle/fluid/framework/fleet/box_wrapper.h @@ -24,6 +24,7 @@ limitations under the License. */ #include #endif #include + #include #include #include @@ -36,6 +37,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/data_feed.h" #include "paddle/fluid/framework/data_set.h" #include "paddle/fluid/framework/lod_tensor.h" @@ -65,10 +67,12 @@ class BasicAucCalculator { _local_pred = 0; } void add_data(double pred, int label) { - PADDLE_ENFORCE_GE(pred, 0.0, platform::errors::PreconditionNotMet( - "pred should be greater than 0")); - PADDLE_ENFORCE_LE(pred, 1.0, platform::errors::PreconditionNotMet( - "pred should be lower than 1")); + PADDLE_ENFORCE_GE( + pred, 0.0, + platform::errors::PreconditionNotMet("pred should be greater than 0")); + PADDLE_ENFORCE_LE( + pred, 1.0, + platform::errors::PreconditionNotMet("pred should be lower than 1")); PADDLE_ENFORCE_EQ( label * label, label, platform::errors::PreconditionNotMet( @@ -172,13 +176,15 @@ class AfsManager { pwd.c_str(), conf_path.c_str()); VLOG(0) << "AFSAPI Init: user: " << user << ", pwd: " << pwd; int ret = _afshandler->Init(true, (com_logstatus() == 0)); - PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( - "Called AFSAPI Init Interface Failed.")); + PADDLE_ENFORCE_EQ(ret, 0, + platform::errors::PreconditionNotMet( + "Called AFSAPI Init Interface Failed.")); // Too high level will hurt the performance comlog_set_log_level(4); ret = _afshandler->Connect(); - PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( - "Called AFSAPI Connect Interface Failed")); + PADDLE_ENFORCE_EQ(ret, 0, + platform::errors::PreconditionNotMet( + "Called AFSAPI Connect Interface Failed")); } virtual ~AfsManager() { if (_afshandler != NULL) { @@ -294,8 +300,9 @@ class AfsManager { int ret = PopenBidirectionalInternal(cmd.c_str(), rfp, wfp, pid, true, true); - PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( - "Called PopenBidirectionalInternal Failed")); + PADDLE_ENFORCE_EQ(ret, 0, + platform::errors::PreconditionNotMet( + "Called PopenBidirectionalInternal Failed")); std::string filename(path); if (strncmp(filename.c_str(), "afs:", 4) == 0) { filename = filename.substr(4); @@ -451,8 +458,9 @@ class BoxWrapper { std::string ret_str; int ret = boxps_ptr_->SaveBase(batch_model_path, xbox_model_path, ret_str, seconds_from_1970 / 86400); - PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( - "SaveBase failed in BoxPS.")); + PADDLE_ENFORCE_EQ( + ret, 0, + platform::errors::PreconditionNotMet("SaveBase failed in BoxPS.")); return ret_str; } @@ -460,8 +468,9 @@ class BoxWrapper { VLOG(3) << "Begin SaveDelta"; std::string ret_str; int ret = boxps_ptr_->SaveDelta(xbox_model_path, ret_str); - PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( - "SaveDelta failed in BoxPS.")); + PADDLE_ENFORCE_EQ( + ret, 0, + platform::errors::PreconditionNotMet("SaveDelta failed in BoxPS.")); return ret_str; } diff --git a/paddle/fluid/framework/fleet/box_wrapper_impl.h b/paddle/fluid/framework/fleet/box_wrapper_impl.h index 6f7009f4d5143f7f0d538421ae4dac7b7031014c..f6f1cbfc2a08d924f7cb5616374248a87240cefe 100644 --- a/paddle/fluid/framework/fleet/box_wrapper_impl.h +++ b/paddle/fluid/framework/fleet/box_wrapper_impl.h @@ -79,8 +79,9 @@ void BoxWrapper::PullSparseCase(const paddle::platform::Place& place, int ret = boxps_ptr_->PullSparseGPU( total_keys, reinterpret_cast(total_values_gpu), static_cast(total_length), device_id); - PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( - "PullSparseGPU failed in BoxPS.")); + PADDLE_ENFORCE_EQ( + ret, 0, + platform::errors::PreconditionNotMet("PullSparseGPU failed in BoxPS.")); pull_boxps_timer.Pause(); VLOG(3) << "Begin Copy result to tensor, total_length[" << total_length @@ -144,8 +145,9 @@ void BoxWrapper::PushSparseGradCase( int ret = boxps_ptr_->PushSparseGPU( total_keys, reinterpret_cast(total_grad_values_gpu), static_cast(total_length), place.GetDeviceId()); - PADDLE_ENFORCE_EQ(ret, 0, platform::errors::PreconditionNotMet( - "PushSparseGPU failed in BoxPS.")); + PADDLE_ENFORCE_EQ( + ret, 0, + platform::errors::PreconditionNotMet("PushSparseGPU failed in BoxPS.")); push_boxps_timer.Pause(); #else PADDLE_THROW(platform::errors::PreconditionNotMet( diff --git a/paddle/fluid/framework/fleet/fleet_wrapper.h b/paddle/fluid/framework/fleet/fleet_wrapper.h index deb2b90c9335329e3c9b5a93937689d79fc5c5a6..5c2be1e55f9efb1aedc50565d1e30194e028f7d1 100644 --- a/paddle/fluid/framework/fleet/fleet_wrapper.h +++ b/paddle/fluid/framework/fleet/fleet_wrapper.h @@ -20,6 +20,7 @@ limitations under the License. */ #include #endif #include + #include #include #include diff --git a/paddle/fluid/framework/fleet/gloo_wrapper.cc b/paddle/fluid/framework/fleet/gloo_wrapper.cc index d850d05d87f5cead49b4901b15bf5914e6be11a2..56d0e1ec47e7e578ce8b07b8621a479c2340e541 100644 --- a/paddle/fluid/framework/fleet/gloo_wrapper.cc +++ b/paddle/fluid/framework/fleet/gloo_wrapper.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/fleet/gloo_wrapper.h" + #include "paddle/fluid/framework/io/fs.h" #include "paddle/fluid/string/string_helper.h" diff --git a/paddle/fluid/framework/fleet/gloo_wrapper.h b/paddle/fluid/framework/fleet/gloo_wrapper.h index 42ae73f9b13f1ecba3020a689776aa04049d0688..1ecaf1318b01b1271193b288e60a4484cdd67a5a 100644 --- a/paddle/fluid/framework/fleet/gloo_wrapper.h +++ b/paddle/fluid/framework/fleet/gloo_wrapper.h @@ -214,8 +214,9 @@ class GlooWrapper { static_cast( &gloo::min)); } else { - PADDLE_ENFORCE_EQ(0, 1, paddle::platform::errors::InvalidArgument( - "AllReduce mode not known: " + mode)); + PADDLE_ENFORCE_EQ(0, 1, + paddle::platform::errors::InvalidArgument( + "AllReduce mode not known: " + mode)); } gloo::allreduce(opts); #else diff --git a/paddle/fluid/framework/fleet/heter_context.h b/paddle/fluid/framework/fleet/heter_context.h index 823b60c5ef1f24d9755e75b2c1b2c568acf005c9..560607bd160a1435e5488d01a0154e1fd8ac052c 100644 --- a/paddle/fluid/framework/fleet/heter_context.h +++ b/paddle/fluid/framework/fleet/heter_context.h @@ -17,6 +17,7 @@ limitations under the License. */ #ifdef PADDLE_WITH_HETERPS #include + #include #include #include diff --git a/paddle/fluid/framework/fleet/heter_ps/cudf/concurrent_unordered_map.cuh.h b/paddle/fluid/framework/fleet/heter_ps/cudf/concurrent_unordered_map.cuh.h index 4ad32d1714f7d55e8e36b7d5fe1b971734c0bc54..da65cccb435d1bef393ef5c1581e59b3bdef4168 100644 --- a/paddle/fluid/framework/fleet/heter_ps/cudf/concurrent_unordered_map.cuh.h +++ b/paddle/fluid/framework/fleet/heter_ps/cudf/concurrent_unordered_map.cuh.h @@ -22,6 +22,7 @@ #define CONCURRENT_UNORDERED_MAP_CUH #include + #include #include #include @@ -258,7 +259,7 @@ class cycle_iterator_adapter { return old; } - __host__ __device__ const cycle_iterator_adapter& operator++(int)const { + __host__ __device__ const cycle_iterator_adapter& operator++(int) const { cycle_iterator_adapter old(m_begin, m_end, m_current); if (m_end == (m_current + 1)) m_current = m_begin; diff --git a/paddle/fluid/framework/fleet/heter_ps/gpu_graph_node.h b/paddle/fluid/framework/fleet/heter_ps/gpu_graph_node.h index 19c355c671a386538ca060532b9b25ed0e5dabb3..2e7588d0ac48cca8cc5e915ba256d009aeee4942 100644 --- a/paddle/fluid/framework/fleet/heter_ps/gpu_graph_node.h +++ b/paddle/fluid/framework/fleet/heter_ps/gpu_graph_node.h @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/fluid/memory/allocation/allocator.h" #include "paddle/fluid/memory/memory.h" #include "paddle/fluid/platform/cuda_device_guard.h" @@ -284,6 +285,6 @@ struct NodeQueryResult { }; ~NodeQueryResult() {} }; -} -}; +} // namespace framework +}; // namespace paddle #endif diff --git a/paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table.h b/paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table.h index ae57c2ebe932f85d0559c18800a0f2e869f3d210..5831863f7f5c3e27d623c9af258828bb8c7a6f15 100644 --- a/paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table.h +++ b/paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table.h @@ -14,7 +14,9 @@ #pragma once #include + #include + #include "heter_comm.h" #include "paddle/fluid/distributed/ps/table/common_graph_table.h" #include "paddle/fluid/framework/fleet/heter_ps/gpu_graph_node.h" @@ -123,7 +125,7 @@ class GpuPsGraphTable : public HeterComm { std::condition_variable cv_; int cpu_table_status; }; -} -}; +} // namespace framework +}; // namespace paddle //#include "paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table_inl.h" #endif diff --git a/paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table_inl.cu b/paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table_inl.cu index 72b9cae41c0fdfb2807ffc3d90bc3bca1377b059..ab33d2a9c05bf88f446532425cd1dc86fa41c641 100644 --- a/paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table_inl.cu +++ b/paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table_inl.cu @@ -15,6 +15,7 @@ #include #include #include + #include #pragma once #ifdef PADDLE_WITH_HETERPS @@ -859,11 +860,10 @@ NeighborSampleResult GpuPsGraphTable::graph_neighbor_sample_v2( constexpr int TILE_SIZE = BLOCK_WARPS * 16; const dim3 block(WARP_SIZE, BLOCK_WARPS); const dim3 grid((shard_len + TILE_SIZE - 1) / TILE_SIZE); - neighbor_sample_example_v2< - WARP_SIZE, BLOCK_WARPS, - TILE_SIZE><<remote_stream(i, gpu_id)>>>( - graph, id_array, actual_size_array, sample_array, sample_size, - shard_len, default_value); + neighbor_sample_example_v2 + <<remote_stream(i, gpu_id)>>>( + graph, id_array, actual_size_array, sample_array, sample_size, + shard_len, default_value); } for (int i = 0; i < total_gpu; ++i) { @@ -946,12 +946,12 @@ NeighborSampleResult GpuPsGraphTable::graph_neighbor_sample_v2( constexpr int TILE_SIZE_ = BLOCK_WARPS_ * 16; const dim3 block2(WARP_SIZE_, BLOCK_WARPS_); const dim3 grid2((number_on_cpu + TILE_SIZE_ - 1) / TILE_SIZE_); - copy_buffer_ac_to_final_place<<>>( - gpu_buffers_ptr, gpu_ac_ptr, val, actual_sample_size, - thrust::raw_pointer_cast(t_index.data()) + 1, - thrust::raw_pointer_cast(cumsum_gpu_ac.data()), number_on_cpu, - sample_size); + copy_buffer_ac_to_final_place + <<>>( + gpu_buffers_ptr, gpu_ac_ptr, val, actual_sample_size, + thrust::raw_pointer_cast(t_index.data()) + 1, + thrust::raw_pointer_cast(cumsum_gpu_ac.data()), number_on_cpu, + sample_size); delete[] merge_buffers; delete[] cpu_keys; @@ -1027,13 +1027,13 @@ NodeQueryResult GpuPsGraphTable::query_node_list(int gpu_id, int start, local_begin_pos = [0,3] sample_size = [2,3] */ - std::function range_check = []( - int x, int y, int x1, int y1, int& x2, int& y2) { - if (y <= x1 || x >= y1) return 0; - y2 = min(y, y1); - x2 = max(x1, x); - return y2 - x2; - }; + std::function range_check = + [](int x, int y, int x1, int y1, int& x2, int& y2) { + if (y <= x1 || x >= y1) return 0; + y2 = min(y, y1); + x2 = max(x1, x); + return y2 - x2; + }; auto graph = gpu_graph_list[gpu_id]; if (graph.node_size == 0) { return result; @@ -1106,6 +1106,6 @@ NodeQueryResult GpuPsGraphTable::query_node_list(int gpu_id, int start, return result; */ } -} -}; +} // namespace framework +}; // namespace paddle #endif diff --git a/paddle/fluid/framework/fleet/heter_ps/graph_gpu_wrapper.cu b/paddle/fluid/framework/fleet/heter_ps/graph_gpu_wrapper.cu index c976bb67cb21e102f7e5fd4c18de20b3170d3c70..43f0101009d0830412b3f4f863664eb5c2f4551b 100644 --- a/paddle/fluid/framework/fleet/heter_ps/graph_gpu_wrapper.cu +++ b/paddle/fluid/framework/fleet/heter_ps/graph_gpu_wrapper.cu @@ -271,5 +271,5 @@ void GraphGpuWrapper::export_partition_files(int idx, std::string file_path) { ->cpu_graph_table->export_partition_files(idx, file_path); } #endif -} -}; +} // namespace framework +}; // namespace paddle diff --git a/paddle/fluid/framework/fleet/heter_ps/graph_gpu_wrapper.h b/paddle/fluid/framework/fleet/heter_ps/graph_gpu_wrapper.h index a34e752fc7ea7d4ff988f24a0eb9be4684f2ba1a..d3c4dea5890304c0033e2ac32fe31097d4d226a6 100644 --- a/paddle/fluid/framework/fleet/heter_ps/graph_gpu_wrapper.h +++ b/paddle/fluid/framework/fleet/heter_ps/graph_gpu_wrapper.h @@ -16,6 +16,7 @@ #include #include #include + #include "paddle/fluid/distributed/ps/table/common_graph_table.h" #include "paddle/fluid/framework/fleet/heter_ps/gpu_graph_node.h" namespace paddle { @@ -73,5 +74,5 @@ class GraphGpuWrapper { void* graph_table; }; #endif -} -}; +} // namespace framework +}; // namespace paddle diff --git a/paddle/fluid/framework/fleet/heter_ps/graph_sampler.h b/paddle/fluid/framework/fleet/heter_ps/graph_sampler.h index a7c043f1edf375eea9edcbe54569ab17c962306e..7cec4fcfb8311894823db2de54773b2f1eba8b0a 100644 --- a/paddle/fluid/framework/fleet/heter_ps/graph_sampler.h +++ b/paddle/fluid/framework/fleet/heter_ps/graph_sampler.h @@ -14,6 +14,7 @@ #pragma once #include + #include #include #include @@ -23,6 +24,7 @@ #include #include #include + #include "paddle/fluid/distributed/ps/table/common_graph_table.h" #include "paddle/fluid/framework/fleet/heter_ps/gpu_graph_node.h" #include "paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table.h" @@ -106,7 +108,7 @@ class AllInGpuGraphSampler : public GraphSampler { // std::shared_ptr random; int gpu_num; }; -} -}; +} // namespace framework +}; // namespace paddle #include "paddle/fluid/framework/fleet/heter_ps/graph_sampler_inl.h" #endif diff --git a/paddle/fluid/framework/fleet/heter_ps/graph_sampler_inl.h b/paddle/fluid/framework/fleet/heter_ps/graph_sampler_inl.h index ad4b00b11aa39fc23308206ca390e6442c666b7a..e68612d57e25902d64595a00ad40134f92c817ac 100644 --- a/paddle/fluid/framework/fleet/heter_ps/graph_sampler_inl.h +++ b/paddle/fluid/framework/fleet/heter_ps/graph_sampler_inl.h @@ -156,6 +156,6 @@ void AllInGpuGraphSampler::init(GpuPsGraphTable *g, this->gpu_num = g->gpu_num; graph_table = g->cpu_graph_table.get(); } -} -}; +} // namespace framework +}; // namespace paddle #endif diff --git a/paddle/fluid/framework/fleet/heter_ps/hashtable.h b/paddle/fluid/framework/fleet/heter_ps/hashtable.h index 234aa15ebf74d1da276cf1e2664017ca7893f66f..112a59c8fec87641ecd10480dcc709fd3690f74c 100644 --- a/paddle/fluid/framework/fleet/heter_ps/hashtable.h +++ b/paddle/fluid/framework/fleet/heter_ps/hashtable.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #ifdef PADDLE_WITH_HETERPS #include + #include #include #include @@ -36,6 +37,7 @@ limitations under the License. */ #include "thrust/pair.h" #elif defined(__xpu__) #include + #include "xpu/kernel/cluster_header.h" #include "xpu/kernel/math.h" #include "xpu/kernel/simd.h" diff --git a/paddle/fluid/framework/fleet/heter_ps/hashtable_kernel.cu b/paddle/fluid/framework/fleet/heter_ps/hashtable_kernel.cu index 57741c2c19b1cad5af8fee97dc360c7eb90b5255..c2e6cdc5c69937325b77151bcc65fe8e40ba10d5 100644 --- a/paddle/fluid/framework/fleet/heter_ps/hashtable_kernel.cu +++ b/paddle/fluid/framework/fleet/heter_ps/hashtable_kernel.cu @@ -14,6 +14,7 @@ limitations under the License. */ #ifdef PADDLE_WITH_HETERPS #include + #include "paddle/fluid/framework/fleet/heter_ps/hashtable.h" #include "paddle/fluid/framework/fleet/heter_ps/optimizer.cuh.h" @@ -366,10 +367,10 @@ template class HashTable; template class HashTable; template class HashTable; -template void HashTable::get< - cudaStream_t>(const unsigned long* d_keys, - paddle::framework::FeatureValue* d_vals, size_t len, - cudaStream_t stream); +template void +HashTable::get( + const unsigned long* d_keys, paddle::framework::FeatureValue* d_vals, + size_t len, cudaStream_t stream); template void HashTable::get( @@ -395,10 +396,10 @@ template void HashTable::get( // const unsigned long* d_keys, char* d_vals, size_t len, cudaStream_t // stream); -template void HashTable::insert< - cudaStream_t>(const unsigned long* d_keys, - const paddle::framework::FeatureValue* d_vals, size_t len, - cudaStream_t stream); +template void +HashTable::insert( + const unsigned long* d_keys, const paddle::framework::FeatureValue* d_vals, + size_t len, cudaStream_t stream); template void HashTable:: insert(const unsigned long* d_keys, size_t len, char* pool, @@ -438,21 +439,22 @@ template void HashTable::update< paddle::framework::FeaturePushValue>, cudaStream_t>(const unsigned long* d_keys, const paddle::framework::FeaturePushValue* d_grads, - size_t len, Optimizer - sgd, - cudaStream_t stream); - -template void -HashTable::update< - Optimizer, - cudaStream_t>(const unsigned long* d_keys, const char* d_grads, size_t len, + size_t len, Optimizer sgd, cudaStream_t stream); +template void HashTable:: + update, + cudaStream_t>(const unsigned long* d_keys, const char* d_grads, + size_t len, + Optimizer + sgd, + cudaStream_t stream); + // template void HashTable::update< // Optimizer #include + #include "cub/cub.cuh" #include "cub/util_allocator.cuh" #if defined(PADDLE_WITH_CUDA) @@ -26,6 +27,7 @@ limitations under the License. */ #elif defined(PADDLE_WITH_XPU_KP) // #include "paddle/fluid/framework/fleet/heter_ps/optimizer_conf.h" #include + #include "paddle/fluid/platform/device/xpu/enforce_xpu.h" #endif diff --git a/paddle/fluid/framework/fleet/heter_ps/heter_comm_inl.h b/paddle/fluid/framework/fleet/heter_ps/heter_comm_inl.h index 64b177abb863872959fdf8332c325924cfc85164..38a4e7b7bb1a9a97777c55ed797f16fdb12032f7 100644 --- a/paddle/fluid/framework/fleet/heter_ps/heter_comm_inl.h +++ b/paddle/fluid/framework/fleet/heter_ps/heter_comm_inl.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #ifdef PADDLE_WITH_HETERPS #include + #include "paddle/fluid/framework/fleet/heter_ps/feature_value.h" #include "paddle/fluid/framework/fleet/heter_ps/heter_comm_kernel.h" #include "paddle/fluid/platform/device_context.h" diff --git a/paddle/fluid/framework/fleet/heter_ps/heter_comm_kernel.cu b/paddle/fluid/framework/fleet/heter_ps/heter_comm_kernel.cu index 94d7929b2947d21d06a0c43d2e364a6e99496163..a5ee8e2ff83958969b45a5e549a7d6d48033d2ab 100644 --- a/paddle/fluid/framework/fleet/heter_ps/heter_comm_kernel.cu +++ b/paddle/fluid/framework/fleet/heter_ps/heter_comm_kernel.cu @@ -294,10 +294,10 @@ template void HeterCommKernel::fill_idx( template void HeterCommKernel::calc_shard_offset( int* idx, int* left, int* right, long long len, int total_devs, const cudaStream_t& stream); -template void HeterCommKernel::calc_shard_index< - unsigned long, int, cudaStream_t>(unsigned long* d_keys, long long len, - int* shard_index, int total_devs, - const cudaStream_t& stream); +template void +HeterCommKernel::calc_shard_index( + unsigned long* d_keys, long long len, int* shard_index, int total_devs, + const cudaStream_t& stream); template void HeterCommKernel::calc_shard_index( long* d_keys, long long len, int* shard_index, int total_devs, diff --git a/paddle/fluid/framework/fleet/heter_ps/heter_ps.cc b/paddle/fluid/framework/fleet/heter_ps/heter_ps.cc index 700b43f18fb96764773e5eeeb12ca000c1b80333..fe8e8c86505ce9263afdeffc57830443c3ed73da 100644 --- a/paddle/fluid/framework/fleet/heter_ps/heter_ps.cc +++ b/paddle/fluid/framework/fleet/heter_ps/heter_ps.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/fleet/heter_ps/heter_ps.h" + #include #ifdef PADDLE_WITH_HETERPS diff --git a/paddle/fluid/framework/fleet/heter_ps/heter_ps.cu b/paddle/fluid/framework/fleet/heter_ps/heter_ps.cu index 43b84ee5d26fbe98487dca95b328f7cc395a46ff..cfe4662629415223dee91602086022eaf5546eba 100644 --- a/paddle/fluid/framework/fleet/heter_ps/heter_ps.cu +++ b/paddle/fluid/framework/fleet/heter_ps/heter_ps.cu @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/fleet/heter_ps/heter_ps.h" #ifdef PADDLE_WITH_HETERPS diff --git a/paddle/fluid/framework/fleet/heter_ps/heter_ps.h b/paddle/fluid/framework/fleet/heter_ps/heter_ps.h index 8449a4048b72f9493feffdc29969eaf87f572938..83dc232bc6a3bdca743ac1182e71b63b86a63dbe 100644 --- a/paddle/fluid/framework/fleet/heter_ps/heter_ps.h +++ b/paddle/fluid/framework/fleet/heter_ps/heter_ps.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/fleet/heter_ps/heter_comm.h" #include "paddle/fluid/framework/fleet/heter_ps/heter_ps_base.h" #if defined(PADDLE_WITH_CUDA) diff --git a/paddle/fluid/framework/fleet/heter_ps/heter_ps_base.h b/paddle/fluid/framework/fleet/heter_ps/heter_ps_base.h index 2c312e9d4d60aa7494573138c89848dd0b765474..fe44c81fe445f5ce1562ccde37943a320b9c289b 100644 --- a/paddle/fluid/framework/fleet/heter_ps/heter_ps_base.h +++ b/paddle/fluid/framework/fleet/heter_ps/heter_ps_base.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/fleet/heter_ps/feature_value.h" #include "paddle/fluid/framework/fleet/heter_ps/heter_resource.h" #include "paddle/fluid/framework/fleet/heter_ps/optimizer_conf.h" diff --git a/paddle/fluid/framework/fleet/heter_ps/heter_resource.h b/paddle/fluid/framework/fleet/heter_ps/heter_resource.h index 5717f44d400a55ae21cf2ef5293c522c986b657d..087877818f5fb3b309f15ba7d489caab43653d3b 100644 --- a/paddle/fluid/framework/fleet/heter_ps/heter_resource.h +++ b/paddle/fluid/framework/fleet/heter_ps/heter_resource.h @@ -24,6 +24,7 @@ limitations under the License. */ #ifdef PADDLE_WITH_XPU_KP #include // NOLINT + #include "paddle/fluid/platform/device/xpu/xpu_info.h" #endif diff --git a/paddle/fluid/framework/fleet/heter_ps/optimizer.cuh.h b/paddle/fluid/framework/fleet/heter_ps/optimizer.cuh.h index 4684b4a0bc155c76286f9731dab63cf7c6606b3d..82090ef4817c957d32d3d2c15e2c6c76241655a8 100644 --- a/paddle/fluid/framework/fleet/heter_ps/optimizer.cuh.h +++ b/paddle/fluid/framework/fleet/heter_ps/optimizer.cuh.h @@ -19,6 +19,7 @@ limitations under the License. */ #include #endif #include + #include "paddle/fluid/framework/fleet/heter_ps/feature_value.h" #include "paddle/fluid/framework/fleet/heter_ps/optimizer_conf.h" diff --git a/paddle/fluid/framework/fleet/heter_ps/test_comm.cu b/paddle/fluid/framework/fleet/heter_ps/test_comm.cu index 3a6ed50ad8e70229ee7dfa97c1a222b1abe296df..72fa0282066d2a70935347e752fb4a0fc67f56f1 100644 --- a/paddle/fluid/framework/fleet/heter_ps/test_comm.cu +++ b/paddle/fluid/framework/fleet/heter_ps/test_comm.cu @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include + #include "paddle/fluid/framework/fleet/heter_ps/feature_value.h" #include "paddle/fluid/framework/fleet/heter_ps/heter_comm.h" #include "paddle/fluid/framework/fleet/heter_ps/heter_resource.h" diff --git a/paddle/fluid/framework/fleet/heter_ps/test_cpu_graph_sample.cu b/paddle/fluid/framework/fleet/heter_ps/test_cpu_graph_sample.cu index 62a0df943000295bb9b3516dfe2e6990c9fef11d..621c7f5bab4121fb46eb7b554a4dc6a941104c22 100644 --- a/paddle/fluid/framework/fleet/heter_ps/test_cpu_graph_sample.cu +++ b/paddle/fluid/framework/fleet/heter_ps/test_cpu_graph_sample.cu @@ -13,8 +13,10 @@ // limitations under the License. #include + #include #include + #include "paddle/fluid/framework/fleet/heter_ps/feature_value.h" #include "paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table.h" #include "paddle/fluid/framework/fleet/heter_ps/heter_comm.h" diff --git a/paddle/fluid/framework/fleet/heter_ps/test_cpu_query.cu b/paddle/fluid/framework/fleet/heter_ps/test_cpu_query.cu index ff3cd9d2d046d11e5ffa45274bb4b1c51a6a1fc7..49e9a051ec0c0c03a9989f7523e7d241b1a186b7 100644 --- a/paddle/fluid/framework/fleet/heter_ps/test_cpu_query.cu +++ b/paddle/fluid/framework/fleet/heter_ps/test_cpu_query.cu @@ -13,8 +13,10 @@ // limitations under the License. #include + #include #include + #include "paddle/fluid/framework/fleet/heter_ps/feature_value.h" #include "paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table.h" #include "paddle/fluid/framework/fleet/heter_ps/graph_gpu_wrapper.h" diff --git a/paddle/fluid/framework/fleet/heter_ps/test_graph.cu b/paddle/fluid/framework/fleet/heter_ps/test_graph.cu index 06c7026eb51ca8ed808d528391ab6723fd83831c..28098181b6c2a85cec2b438640716a6d3e800ad1 100644 --- a/paddle/fluid/framework/fleet/heter_ps/test_graph.cu +++ b/paddle/fluid/framework/fleet/heter_ps/test_graph.cu @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include + #include "paddle/fluid/framework/fleet/heter_ps/feature_value.h" #include "paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table.h" #include "paddle/fluid/framework/fleet/heter_ps/heter_comm.h" diff --git a/paddle/fluid/framework/fleet/heter_ps/test_sample_rate.cu b/paddle/fluid/framework/fleet/heter_ps/test_sample_rate.cu index affa60d022ece746d97cde6dab3e6340e59bebac..a1e8f06368b07c747437b0ae720a7a078b989a11 100644 --- a/paddle/fluid/framework/fleet/heter_ps/test_sample_rate.cu +++ b/paddle/fluid/framework/fleet/heter_ps/test_sample_rate.cu @@ -13,6 +13,8 @@ // limitations under the License. #include + +#include #include // NOLINT #include #include @@ -20,32 +22,30 @@ #include // NOLINT #include #include -#include "google/protobuf/text_format.h" -#include +#include "google/protobuf/text_format.h" #include "gtest/gtest.h" #include "paddle/fluid/distributed/ps.pb.h" #include "paddle/fluid/distributed/ps/service/env.h" #include "paddle/fluid/distributed/ps/service/sendrecv.pb.h" #include "paddle/fluid/distributed/ps/table/common_graph_table.h" #include "paddle/fluid/distributed/ps/table/graph/graph_node.h" +#include "paddle/fluid/framework/fleet/heter_ps/feature_value.h" +#include "paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table.h" +#include "paddle/fluid/framework/fleet/heter_ps/graph_sampler.h" +#include "paddle/fluid/framework/fleet/heter_ps/heter_comm.h" +#include "paddle/fluid/framework/fleet/heter_ps/heter_resource.h" +#include "paddle/fluid/framework/fleet/heter_ps/optimizer.cuh.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/framework/variable.h" +#include "paddle/fluid/platform/cuda_device_guard.h" #include "paddle/fluid/platform/place.h" #include "paddle/fluid/string/printf.h" #include "paddle/phi/kernels/funcs/math_function.h" -#include "paddle/fluid/framework/fleet/heter_ps/feature_value.h" -#include "paddle/fluid/framework/fleet/heter_ps/graph_gpu_ps_table.h" -#include "paddle/fluid/framework/fleet/heter_ps/graph_sampler.h" -#include "paddle/fluid/framework/fleet/heter_ps/heter_comm.h" -#include "paddle/fluid/framework/fleet/heter_ps/heter_resource.h" -#include "paddle/fluid/framework/fleet/heter_ps/optimizer.cuh.h" -#include "paddle/fluid/platform/cuda_device_guard.h" - using namespace paddle::framework; namespace platform = paddle::platform; namespace operators = paddle::operators; diff --git a/paddle/fluid/framework/fleet/metrics.cc b/paddle/fluid/framework/fleet/metrics.cc index 56bc568460bbc6380fd70ae8b5e868c7775000d4..4225281640588e2b02e809d34f0828002afa23e1 100644 --- a/paddle/fluid/framework/fleet/metrics.cc +++ b/paddle/fluid/framework/fleet/metrics.cc @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/fluid/framework/lod_tensor.h" #if defined(PADDLE_WITH_PSLIB) || defined(PADDLE_WITH_PSCORE) @@ -63,10 +64,12 @@ void BasicAucCalculator::add_data(const float* d_pred, const int64_t* d_label, } void BasicAucCalculator::add_unlock_data(double pred, int label) { - PADDLE_ENFORCE_GE(pred, 0.0, platform::errors::PreconditionNotMet( - "pred should be greater than 0")); - PADDLE_ENFORCE_LE(pred, 1.0, platform::errors::PreconditionNotMet( - "pred should be lower than 1")); + PADDLE_ENFORCE_GE( + pred, 0.0, + platform::errors::PreconditionNotMet("pred should be greater than 0")); + PADDLE_ENFORCE_LE( + pred, 1.0, + platform::errors::PreconditionNotMet("pred should be lower than 1")); PADDLE_ENFORCE_EQ( label * label, label, platform::errors::PreconditionNotMet( @@ -272,10 +275,12 @@ void BasicAucCalculator::add_uid_data(const float* d_pred, void BasicAucCalculator::add_uid_unlock_data(double pred, int label, uint64_t uid) { - PADDLE_ENFORCE_GE(pred, 0.0, platform::errors::PreconditionNotMet( - "pred should be greater than 0")); - PADDLE_ENFORCE_LE(pred, 1.0, platform::errors::PreconditionNotMet( - "pred should be lower than 1")); + PADDLE_ENFORCE_GE( + pred, 0.0, + platform::errors::PreconditionNotMet("pred should be greater than 0")); + PADDLE_ENFORCE_LE( + pred, 1.0, + platform::errors::PreconditionNotMet("pred should be lower than 1")); PADDLE_ENFORCE_EQ( label * label, label, platform::errors::PreconditionNotMet( diff --git a/paddle/fluid/framework/fleet/metrics.h b/paddle/fluid/framework/fleet/metrics.h index 69b242664bb469a510257fe6d3349454f0e0dfe8..7c3ea1b5512f6f21aee33b9d4412e84aa0dbe06b 100644 --- a/paddle/fluid/framework/fleet/metrics.h +++ b/paddle/fluid/framework/fleet/metrics.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include #include #include @@ -35,6 +36,7 @@ limitations under the License. */ #if defined(PADDLE_WITH_GLOO) #include + #include "paddle/fluid/framework/fleet/gloo_wrapper.h" #endif diff --git a/paddle/fluid/framework/fleet/ps_gpu_wrapper.cu b/paddle/fluid/framework/fleet/ps_gpu_wrapper.cu index 488a9ef8ce78ffe969b94dd3c283b927b2ec9a45..fbe76696114d59f4aefcdc400e17cea2813e6061 100644 --- a/paddle/fluid/framework/fleet/ps_gpu_wrapper.cu +++ b/paddle/fluid/framework/fleet/ps_gpu_wrapper.cu @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/fleet/heter_ps/optimizer_conf.h" #include "paddle/fluid/framework/fleet/ps_gpu_wrapper.h" #include "paddle/fluid/framework/lod_tensor.h" diff --git a/paddle/fluid/framework/fleet/ps_gpu_wrapper.h b/paddle/fluid/framework/fleet/ps_gpu_wrapper.h index 0efec57e59db6c0319eaebe182987cb898d62b28..7ddc5a1f6dd66d9a96b89cfead5cfdf6955d771d 100644 --- a/paddle/fluid/framework/fleet/ps_gpu_wrapper.h +++ b/paddle/fluid/framework/fleet/ps_gpu_wrapper.h @@ -27,6 +27,7 @@ limitations under the License. */ #include #ifdef PADDLE_WITH_GLOO #include + #include "paddle/fluid/framework/data_set.h" #include "paddle/fluid/framework/fleet/gloo_wrapper.h" #endif diff --git a/paddle/fluid/framework/fleet/test_fleet.cc b/paddle/fluid/framework/fleet/test_fleet.cc index 24f3e6bed6494c7ee9c8ff6ab6c2507654ce163d..34aea9de3b1c5a395b3bc41629fb5f4d630b4d48 100644 --- a/paddle/fluid/framework/fleet/test_fleet.cc +++ b/paddle/fluid/framework/fleet/test_fleet.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/framework/fleet/fleet_wrapper.h" #include "paddle/fluid/framework/fleet/gloo_wrapper.h" #include "paddle/fluid/string/string_helper.h" diff --git a/paddle/fluid/framework/generator.cc b/paddle/fluid/framework/generator.cc index b621eca35b893e95b825b3a5ae228ac125c07a72..e3b9fe3626ddf6109e42dc664cf04c4de5231d39 100644 --- a/paddle/fluid/framework/generator.cc +++ b/paddle/fluid/framework/generator.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/fluid/framework/generator.h" #include + #include #include diff --git a/paddle/fluid/framework/generator.h b/paddle/fluid/framework/generator.h index 35efc1bee33d59b1b96d4d1fb895069326c9f124..f62e8f74d26d52a3ca7d3932382c12b1ea865679 100644 --- a/paddle/fluid/framework/generator.h +++ b/paddle/fluid/framework/generator.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include #include #include // temp for debug diff --git a/paddle/fluid/framework/gpu_utils.h b/paddle/fluid/framework/gpu_utils.h index 37c9852a1ab1f23fe1b377854db0dc91f3a96476..9c59333000e91816394f83887d82fb11d62e6552 100644 --- a/paddle/fluid/framework/gpu_utils.h +++ b/paddle/fluid/framework/gpu_utils.h @@ -17,6 +17,7 @@ #define EIGEN_USE_GPU #include + #include "paddle/fluid/platform/enforce.h" #include "unsupported/Eigen/CXX11/Tensor" @@ -104,15 +105,17 @@ ConvertTensorIndex(int index, const Dim3& dims) { template IntType CeilOrFloor(IntType x, IntType deviser) { - PADDLE_ENFORCE_GT(deviser, 0, platform::errors::InvalidArgument( - "deviser should be greater than 0, " - "but received is:%d", - deviser)); + PADDLE_ENFORCE_GT( + deviser, 0, + platform::errors::InvalidArgument("deviser should be greater than 0, " + "but received is:%d", + deviser)); PADDLE_ENFORCE_GT( - x, 0, platform::errors::InvalidArgument("input should be greater than 0, " - "but received is:%d", - x)); + x, 0, + platform::errors::InvalidArgument("input should be greater than 0, " + "but received is:%d", + x)); const IntType round_to_zero = x / deviser; const IntType inte_result = round_to_zero * deviser; diff --git a/paddle/fluid/framework/grad_op_desc_maker.h b/paddle/fluid/framework/grad_op_desc_maker.h index ebbfd446a03de203d6af1a6d3f77ff392ba3ca90..81f17be867f76461943a20c44159264c6b057117 100644 --- a/paddle/fluid/framework/grad_op_desc_maker.h +++ b/paddle/fluid/framework/grad_op_desc_maker.h @@ -20,6 +20,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_call_stack.h" #include "paddle/fluid/framework/op_desc.h" #include "paddle/fluid/framework/operator.h" @@ -157,8 +158,9 @@ class GradOpDescMakerBase { const Attribute& GetAttr(const std::string& name) const { auto& map = fwd_op_.GetAttrMap(); auto it = map.find(name); - PADDLE_ENFORCE_NE(it, map.end(), platform::errors::NotFound( - "Cannot find attribute (%s).", name)); + PADDLE_ENFORCE_NE( + it, map.end(), + platform::errors::NotFound("Cannot find attribute (%s).", name)); return it->second; } diff --git a/paddle/fluid/framework/heter_service.h b/paddle/fluid/framework/heter_service.h index 9d0e3c50953bd87ddcf197befd8ed4e0443577f2..6b115d33d2faa5ae2db10f0bdcae18d9af5bdf6e 100644 --- a/paddle/fluid/framework/heter_service.h +++ b/paddle/fluid/framework/heter_service.h @@ -22,6 +22,7 @@ limitations under the License. */ #include // NOLINT #include // NOLINT #include + #include "paddle/fluid/framework/heter_service.pb.h" #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/scope.h" diff --git a/paddle/fluid/framework/hetercpu_worker.cc b/paddle/fluid/framework/hetercpu_worker.cc index 75cc18887da9a14c30fb29db41d8ffc61fa98bcf..85e44ec44c6e37727143f2f70e58f91a777dc43d 100644 --- a/paddle/fluid/framework/hetercpu_worker.cc +++ b/paddle/fluid/framework/hetercpu_worker.cc @@ -311,8 +311,8 @@ void HeterCpuWorker::CollectLabelInfo(std::shared_ptr task, continue; } LoDTensor* tensor = fea_var->GetMutable(); - CHECK(tensor != nullptr) << "tensor of var " - << sparse_key_names_[table_id][i] << " is null"; + CHECK(tensor != nullptr) + << "tensor of var " << sparse_key_names_[table_id][i] << " is null"; // skip slots which do not have embedding Variable* emb_var = scope->FindVar(sparse_value_names_[table_id][i]); @@ -465,9 +465,9 @@ void HeterCpuWorker::AdjustInsWeight(std::shared_ptr task) { float* ins_weights = ins_weight_tensor->data(); size_t len = ins_weight_tensor->numel(); // len = batch size // here we assume nid_show slot only has one feasign in each instance - CHECK(len == nid_show_.size()) << "ins_weight size should be equal to " - << "nid_show size, " << len << " vs " - << nid_show_.size(); + CHECK(len == nid_show_.size()) + << "ins_weight size should be equal to " + << "nid_show size, " << len << " vs " << nid_show_.size(); float nid_adjw_threshold = adjust_ins_weight_config_.nid_adjw_threshold(); float nid_adjw_ratio = adjust_ins_weight_config_.nid_adjw_ratio(); int64_t nid_adjw_num = 0; @@ -482,9 +482,8 @@ void HeterCpuWorker::AdjustInsWeight(std::shared_ptr task) { } float ins_weight = 1.0; if (nid_show >= 0 && nid_show < nid_adjw_threshold) { - ins_weight = log(M_E + - (nid_adjw_threshold - nid_show) / nid_adjw_threshold * - nid_adjw_ratio); + ins_weight = log(M_E + (nid_adjw_threshold - nid_show) / + nid_adjw_threshold * nid_adjw_ratio); // count nid adjw insnum and weight ++nid_adjw_num; nid_adjw_weight += ins_weight; @@ -579,15 +578,15 @@ void HeterCpuWorker::CopyDenseVars() { Variable* src_var = thread_scope_->FindVar(src_var_name); CHECK(src_var != nullptr) << src_var_name << " not found"; // NOLINT LoDTensor* src_tensor = src_var->GetMutable(); - CHECK(src_tensor != nullptr) << src_var_name - << " tensor is null"; // NOLINT + CHECK(src_tensor != nullptr) + << src_var_name << " tensor is null"; // NOLINT float* src_data = src_tensor->data(); Variable* dest_var = thread_scope_->FindVar(dest_var_name); CHECK(dest_var != nullptr) << dest_var_name << " not found"; // NOLINT LoDTensor* dest_tensor = dest_var->GetMutable(); - CHECK(dest_tensor != nullptr) << dest_var_name - << " tensor is null"; // NOLINT + CHECK(dest_tensor != nullptr) + << dest_var_name << " tensor is null"; // NOLINT float* dest_data = dest_tensor->data(); CHECK(src_tensor->numel() == dest_tensor->numel()) diff --git a/paddle/fluid/framework/heterxpu_trainer.cc b/paddle/fluid/framework/heterxpu_trainer.cc index a4af56419a766df0be51328ca80f37ee8e14dece..81c1a684959fa10fa60b0d4beded9eaecf02e955 100644 --- a/paddle/fluid/framework/heterxpu_trainer.cc +++ b/paddle/fluid/framework/heterxpu_trainer.cc @@ -16,6 +16,7 @@ limitations under the License. */ #include #include #include + #include "io/fs.h" #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/data_feed_factory.h" diff --git a/paddle/fluid/framework/infershape_utils_test.cc b/paddle/fluid/framework/infershape_utils_test.cc index 2eeefb19a1aa8c5c9e4f92ff06618c719bb30785..805f992cf3e8b9cf64bd69ccc579355367651c89 100644 --- a/paddle/fluid/framework/infershape_utils_test.cc +++ b/paddle/fluid/framework/infershape_utils_test.cc @@ -12,13 +12,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/framework/infershape_utils.h" + #include #include #include "gtest/gtest.h" - #include "paddle/fluid/framework/attribute.h" -#include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_info.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" diff --git a/paddle/fluid/framework/inplace_op_inference.h b/paddle/fluid/framework/inplace_op_inference.h index c46a77f0b3590be621248e6a89ad2bc17710df1e..93bbec251fee445ab7bf738f7a17a1b3681c18e1 100644 --- a/paddle/fluid/framework/inplace_op_inference.h +++ b/paddle/fluid/framework/inplace_op_inference.h @@ -15,6 +15,7 @@ #pragma once #include #include + #include "paddle/fluid/framework/op_desc.h" #include "paddle/fluid/framework/type_defs.h" diff --git a/paddle/fluid/framework/io/crypto/aes_cipher_test.cc b/paddle/fluid/framework/io/crypto/aes_cipher_test.cc index 7f923f597b6decb6c379c9787ec6f8e8238e3382..67c758b012ad5211565367e8a5fe026992acb61f 100644 --- a/paddle/fluid/framework/io/crypto/aes_cipher_test.cc +++ b/paddle/fluid/framework/io/crypto/aes_cipher_test.cc @@ -13,11 +13,14 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/io/crypto/aes_cipher.h" + #include #include #include + #include #include + #include "paddle/fluid/framework/io/crypto/cipher_utils.h" namespace paddle { diff --git a/paddle/fluid/framework/io/crypto/cipher.cc b/paddle/fluid/framework/io/crypto/cipher.cc index eca175c020cb6f85eac2970aa9734c0a6850ebef..2001e8a416a1a1441a18826951ce150e6c53944b 100644 --- a/paddle/fluid/framework/io/crypto/cipher.cc +++ b/paddle/fluid/framework/io/crypto/cipher.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/io/crypto/cipher.h" + #include "paddle/fluid/framework/io/crypto/aes_cipher.h" #include "paddle/fluid/framework/io/crypto/cipher_utils.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/io/crypto/cipher_utils.cc b/paddle/fluid/framework/io/crypto/cipher_utils.cc index ee9f06b2f3eb10d22a2f50c80827f0f80259bb35..b622138f7814a84d525428d510808a33d0ee6788 100644 --- a/paddle/fluid/framework/io/crypto/cipher_utils.cc +++ b/paddle/fluid/framework/io/crypto/cipher_utils.cc @@ -15,6 +15,7 @@ #include "paddle/fluid/framework/io/crypto/cipher_utils.h" #include + #include #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/io/crypto/cipher_utils_test.cc b/paddle/fluid/framework/io/crypto/cipher_utils_test.cc index 928e2ced9b195b7846b8e0c17c8f157db85a49e0..356c919cbcbe8caee7f169972d36cd24d78d5a7e 100644 --- a/paddle/fluid/framework/io/crypto/cipher_utils_test.cc +++ b/paddle/fluid/framework/io/crypto/cipher_utils_test.cc @@ -12,12 +12,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/framework/io/crypto/cipher_utils.h" + #include + #include #include -#include "paddle/fluid/framework/io/crypto/cipher_utils.h" - namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/io/fs.cc b/paddle/fluid/framework/io/fs.cc index b8aca886e7d60d9ca2e9595ba5063858a4a3ee29..fd602895aaed5fc3562d50e383db249be9589aef 100644 --- a/paddle/fluid/framework/io/fs.cc +++ b/paddle/fluid/framework/io/fs.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/fluid/framework/io/fs.h" #include + #include #include "glog/logging.h" diff --git a/paddle/fluid/framework/io/fs.h b/paddle/fluid/framework/io/fs.h index 1ebe80e943aaeabfef1306729a9b8c60d3b20573..088d4d97424a14b13ef2011bc651483dbf19c126 100644 --- a/paddle/fluid/framework/io/fs.h +++ b/paddle/fluid/framework/io/fs.h @@ -16,6 +16,7 @@ #include #include + #include #include #include diff --git a/paddle/fluid/framework/io/test_fs.cc b/paddle/fluid/framework/io/test_fs.cc index 49dee603200c9533b0d9f8fa443106a852431b08..adb6141fd56a1cdea7df00a0fe7206119d3e9a19 100644 --- a/paddle/fluid/framework/io/test_fs.cc +++ b/paddle/fluid/framework/io/test_fs.cc @@ -13,7 +13,9 @@ // limitations under the License. #include + #include + #include "paddle/fluid/framework/io/fs.h" #if defined _WIN32 || defined __APPLE__ diff --git a/paddle/fluid/framework/ir/adaptive_pool2d_convert_global_pass_tester.cc b/paddle/fluid/framework/ir/adaptive_pool2d_convert_global_pass_tester.cc index 8870b68fbc5c596e8b32f248f86b64349bde66b6..e0ce58121a15ee7ddc9c3c6dffc4a6087f687282 100644 --- a/paddle/fluid/framework/ir/adaptive_pool2d_convert_global_pass_tester.cc +++ b/paddle/fluid/framework/ir/adaptive_pool2d_convert_global_pass_tester.cc @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/framework/ir/adaptive_pool2d_convert_global_pass.h" - #include + +#include "paddle/fluid/framework/ir/adaptive_pool2d_convert_global_pass.h" #include "paddle/fluid/framework/ir/pass_tester_helper.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/ir/add_support_int8_pass.cc b/paddle/fluid/framework/ir/add_support_int8_pass.cc index 3a3f5c3741f4dd5b7b94050680a9a4fc1d5169be..d38853bb9648901e538e58400100d0f93a64bd2b 100644 --- a/paddle/fluid/framework/ir/add_support_int8_pass.cc +++ b/paddle/fluid/framework/ir/add_support_int8_pass.cc @@ -68,9 +68,8 @@ void AddSupportInt8Pass::ApplyImpl(ir::Graph* graph) const { i++) { if (quanted_op_desc->Output(quanted_op_desc->OutputNames()[i]) .size() > 0 && - input_name == - quanted_op_desc->Output( - quanted_op_desc->OutputNames()[i])[0]) { + input_name == quanted_op_desc->Output( + quanted_op_desc->OutputNames()[i])[0]) { outscale_flag = true; quanted_op_desc->SetAttr( quanted_op_desc->OutputNames()[i], diff --git a/paddle/fluid/framework/ir/coalesce_grad_tensor_pass.cc b/paddle/fluid/framework/ir/coalesce_grad_tensor_pass.cc index 08e7c6f5b8689c48ac8fe420c42a88179039d967..910cb5801db459f65c45fd02b60f1aae1a85c2fd 100644 --- a/paddle/fluid/framework/ir/coalesce_grad_tensor_pass.cc +++ b/paddle/fluid/framework/ir/coalesce_grad_tensor_pass.cc @@ -13,8 +13,10 @@ // limitations under the License. #include "paddle/fluid/framework/ir/coalesce_grad_tensor_pass.h" + #include #include + #include "paddle/fluid/framework/details/multi_devices_helper.h" #include "paddle/fluid/framework/ir/graph_helper.h" diff --git a/paddle/fluid/framework/ir/conv_bn_fuse_pass_tester.cc b/paddle/fluid/framework/ir/conv_bn_fuse_pass_tester.cc index ae843aad7d3139ee5bfe6a474ed7ecd381b3642b..710f8ef1b375937b38d48eae5f146eea30c5ee79 100644 --- a/paddle/fluid/framework/ir/conv_bn_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/conv_bn_fuse_pass_tester.cc @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/conv_bn_fuse_pass.h" - #include + +#include "paddle/fluid/framework/ir/conv_bn_fuse_pass.h" #include "paddle/fluid/framework/ir/pass_tester_helper.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/cost_model.cc b/paddle/fluid/framework/ir/cost_model.cc index 6086409ffd971fff2a3cc5432e00e59165464634..05c7834c9ca9baf9067f906df6cd1e3369ca468a 100644 --- a/paddle/fluid/framework/ir/cost_model.cc +++ b/paddle/fluid/framework/ir/cost_model.cc @@ -15,6 +15,7 @@ #include "paddle/fluid/framework/ir/cost_model.h" #include + #include "paddle/fluid/framework/executor.h" #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/platform/errors.h" diff --git a/paddle/fluid/framework/ir/cost_model_test.cc b/paddle/fluid/framework/ir/cost_model_test.cc index 57f3904d845c8db17c3e91162d261f45ebfbd09f..f5eaa2f0338cb2d3b4e400f0e3da14055accd7f2 100644 --- a/paddle/fluid/framework/ir/cost_model_test.cc +++ b/paddle/fluid/framework/ir/cost_model_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/cost_model.h" + #include "gtest/gtest.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" diff --git a/paddle/fluid/framework/ir/cudnn_placement_pass_tester.cc b/paddle/fluid/framework/ir/cudnn_placement_pass_tester.cc index 2d270f444adbcee0be5c47217cb4cb419ff0b20b..2711ddf92d792327e0a2420acf61691d2e18702d 100644 --- a/paddle/fluid/framework/ir/cudnn_placement_pass_tester.cc +++ b/paddle/fluid/framework/ir/cudnn_placement_pass_tester.cc @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/cudnn_placement_pass.h" - #include + +#include "paddle/fluid/framework/ir/cudnn_placement_pass.h" #include "paddle/fluid/framework/ir/pass_tester_helper.h" #include "paddle/fluid/framework/operator.h" diff --git a/paddle/fluid/framework/ir/delete_dropout_op_pass.cc b/paddle/fluid/framework/ir/delete_dropout_op_pass.cc index 9473cc069285c40c44e4c2898de466201031ef22..5043beef82401ad77e8dbf644631c412a4855b2b 100644 --- a/paddle/fluid/framework/ir/delete_dropout_op_pass.cc +++ b/paddle/fluid/framework/ir/delete_dropout_op_pass.cc @@ -11,10 +11,10 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "paddle/fluid/framework/ir/delete_dropout_op_pass.h" +#include + namespace phi { class DenseTensor; } // namespace phi diff --git a/paddle/fluid/framework/ir/delete_fill_constant_op_pass.cc b/paddle/fluid/framework/ir/delete_fill_constant_op_pass.cc index 79a06572d14274f7b650651b4c447c2e45981435..e4b6e43e5c3dce9233e3082b42340f873d0269ea 100644 --- a/paddle/fluid/framework/ir/delete_fill_constant_op_pass.cc +++ b/paddle/fluid/framework/ir/delete_fill_constant_op_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/delete_fill_constant_op_pass.h" + #include "paddle/fluid/framework/ir/graph_pattern_detector.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/delete_quant_dequant_filter_op_pass.cc b/paddle/fluid/framework/ir/delete_quant_dequant_filter_op_pass.cc index 2fc133edb7a960e666ef90ed5f4f37d669b0928d..a02efc0a7cef2f4af00880132feda3b9e04f382d 100644 --- a/paddle/fluid/framework/ir/delete_quant_dequant_filter_op_pass.cc +++ b/paddle/fluid/framework/ir/delete_quant_dequant_filter_op_pass.cc @@ -102,9 +102,10 @@ void DeleteQuantDequantFilterOpPass::ApplyImpl(ir::Graph* graph) const { break; } } - PADDLE_ENFORCE_GT(arg_name.size(), 0, platform::errors::InvalidArgument( - "can not find the input %s.", - quant_dequant_op_out_name)); + PADDLE_ENFORCE_GT( + arg_name.size(), 0, + platform::errors::InvalidArgument("can not find the input %s.", + quant_dequant_op_out_name)); // any_op2_desc->SetAttr("enable_int8", true); any_op2_desc->SetAttr("bit_length", bit_length); diff --git a/paddle/fluid/framework/ir/embedding_eltwise_layernorm_fuse_pass_tester.cc b/paddle/fluid/framework/ir/embedding_eltwise_layernorm_fuse_pass_tester.cc index 727e42629f9fab9183668ae0cc84ae54eb01982c..8deaf10d200a562fef527005eb6e437db67199ad 100644 --- a/paddle/fluid/framework/ir/embedding_eltwise_layernorm_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/embedding_eltwise_layernorm_fuse_pass_tester.cc @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/framework/ir/embedding_eltwise_layernorm_fuse_pass.h" - #include + +#include "paddle/fluid/framework/ir/embedding_eltwise_layernorm_fuse_pass.h" #include "paddle/fluid/framework/ir/pass_tester_helper.h" #include "paddle/fluid/framework/op_version_registry.h" diff --git a/paddle/fluid/framework/ir/embedding_fc_lstm_fuse_pass.cc b/paddle/fluid/framework/ir/embedding_fc_lstm_fuse_pass.cc index 482e38355c59cb75aa7d73328b3afc63144da707..a34e0a5d1deae32bf67746c8e0a1c8ddb7577001 100644 --- a/paddle/fluid/framework/ir/embedding_fc_lstm_fuse_pass.cc +++ b/paddle/fluid/framework/ir/embedding_fc_lstm_fuse_pass.cc @@ -15,6 +15,7 @@ #include "paddle/fluid/framework/ir/embedding_fc_lstm_fuse_pass.h" #include + #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/phi/kernels/funcs/blas/blas.h" diff --git a/paddle/fluid/framework/ir/fc_elementwise_layernorm_fuse_pass_tester.cc b/paddle/fluid/framework/ir/fc_elementwise_layernorm_fuse_pass_tester.cc index 46a9b2eae35dba393f22d917c13e0b30743eb059..be22ee9b2fe36ba21134b9f78553219c5bc96ec8 100644 --- a/paddle/fluid/framework/ir/fc_elementwise_layernorm_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/fc_elementwise_layernorm_fuse_pass_tester.cc @@ -12,10 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/framework/ir/fc_elementwise_layernorm_fuse_pass.h" - #include +#include "paddle/fluid/framework/ir/fc_elementwise_layernorm_fuse_pass.h" #include "paddle/fluid/framework/ir/pass_tester_helper.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/fc_fuse_pass.cc b/paddle/fluid/framework/ir/fc_fuse_pass.cc index 1e25b21483b829d3e8eaf610f13307c410cd6e29..1802616c0df5b3e0d03dc29d7c66090ec324283d 100644 --- a/paddle/fluid/framework/ir/fc_fuse_pass.cc +++ b/paddle/fluid/framework/ir/fc_fuse_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/fc_fuse_pass.h" + #include #include "paddle/fluid/framework/op_version_registry.h" diff --git a/paddle/fluid/framework/ir/fc_fuse_pass_tester.cc b/paddle/fluid/framework/ir/fc_fuse_pass_tester.cc index 39b544e7160796c18694582e31146b5e4924dcb9..e40759cd3fbe2fdedf2a4a742f5d49ffb9ff7f2f 100644 --- a/paddle/fluid/framework/ir/fc_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/fc_fuse_pass_tester.cc @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/fc_fuse_pass.h" - #include + +#include "paddle/fluid/framework/ir/fc_fuse_pass.h" #include "paddle/fluid/framework/ir/pass_tester_helper.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/fc_gru_fuse_pass_tester.h b/paddle/fluid/framework/ir/fc_gru_fuse_pass_tester.h index df3fbc293b78e0406ef45fb3159fae428845403e..9ad3c28f09a2ed49083bedb4ff7ba0dabbfc8faa 100644 --- a/paddle/fluid/framework/ir/fc_gru_fuse_pass_tester.h +++ b/paddle/fluid/framework/ir/fc_gru_fuse_pass_tester.h @@ -13,9 +13,9 @@ // limitations under the License. #pragma once -#include "paddle/fluid/framework/ir/fc_gru_fuse_pass.h" - #include + +#include "paddle/fluid/framework/ir/fc_gru_fuse_pass.h" #include "paddle/fluid/framework/ir/pass_tester_helper.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/fc_lstm_fuse_pass.cc b/paddle/fluid/framework/ir/fc_lstm_fuse_pass.cc index b99e607f92b5daa3c37bc9bc68c740fce2ea3654..5b4bb98ff537c60df273b5f3147a8e9639916e5f 100644 --- a/paddle/fluid/framework/ir/fc_lstm_fuse_pass.cc +++ b/paddle/fluid/framework/ir/fc_lstm_fuse_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/fc_lstm_fuse_pass.h" + #include #include "paddle/fluid/framework/op_version_registry.h" diff --git a/paddle/fluid/framework/ir/fc_lstm_fuse_pass_tester.h b/paddle/fluid/framework/ir/fc_lstm_fuse_pass_tester.h index a313e49f0b2b692c55c4cdc924876777c5adef6e..3e47f0795738eb3a2974b27c722a4b0420698aee 100644 --- a/paddle/fluid/framework/ir/fc_lstm_fuse_pass_tester.h +++ b/paddle/fluid/framework/ir/fc_lstm_fuse_pass_tester.h @@ -14,9 +14,9 @@ #pragma once -#include "paddle/fluid/framework/ir/fc_lstm_fuse_pass.h" - #include + +#include "paddle/fluid/framework/ir/fc_lstm_fuse_pass.h" #include "paddle/fluid/framework/ir/pass_tester_helper.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/fillconstant_elementwisemul_fuse.h b/paddle/fluid/framework/ir/fillconstant_elementwisemul_fuse.h index ab66fb4a46a8a5b60b3bf95e27ae24c7217a5a3a..632bb237fa21972d63a348e1e9b11ce688bce89d 100644 --- a/paddle/fluid/framework/ir/fillconstant_elementwisemul_fuse.h +++ b/paddle/fluid/framework/ir/fillconstant_elementwisemul_fuse.h @@ -14,6 +14,7 @@ #pragma once #include + #include "paddle/fluid/framework/ir/fuse_pass_base.h" #include "paddle/fluid/framework/ir/graph_pattern_detector.h" diff --git a/paddle/fluid/framework/ir/fuse_bn_act_pass.cc b/paddle/fluid/framework/ir/fuse_bn_act_pass.cc index f12273e94dddd51d923b90412677b16ca7a5186d..6a2a0867048299be1ac9827bca61b61256bca37f 100644 --- a/paddle/fluid/framework/ir/fuse_bn_act_pass.cc +++ b/paddle/fluid/framework/ir/fuse_bn_act_pass.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/framework/ir/fuse_bn_act_pass.h" + #include + #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/ir/fuse_bn_add_act_pass.cc b/paddle/fluid/framework/ir/fuse_bn_add_act_pass.cc index 005f006ab047886081cde819122e16d186116fd4..ff4850838c51fd8439435bd0ed5a396546377afb 100644 --- a/paddle/fluid/framework/ir/fuse_bn_add_act_pass.cc +++ b/paddle/fluid/framework/ir/fuse_bn_add_act_pass.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/framework/ir/fuse_bn_add_act_pass.h" + #include + #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/platform/device/gpu/gpu_dnn.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/ir/fuse_elewise_add_act_pass.cc b/paddle/fluid/framework/ir/fuse_elewise_add_act_pass.cc index 62f65baf336187b98210a132c41ef7712a749ccd..3feea822bc1ef9fec780132ac400b5b4d14c5723 100644 --- a/paddle/fluid/framework/ir/fuse_elewise_add_act_pass.cc +++ b/paddle/fluid/framework/ir/fuse_elewise_add_act_pass.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/framework/ir/fuse_elewise_add_act_pass.h" + #include + #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/ir/fuse_gemm_epilogue_pass.cc b/paddle/fluid/framework/ir/fuse_gemm_epilogue_pass.cc index b72a63d37853c04ead4547ae4c384c5282c8abcd..1c6b856d987ce61e90e3e639ae088a40ca731eb2 100644 --- a/paddle/fluid/framework/ir/fuse_gemm_epilogue_pass.cc +++ b/paddle/fluid/framework/ir/fuse_gemm_epilogue_pass.cc @@ -14,7 +14,9 @@ // limitations under the License. #include "paddle/fluid/framework/ir/fuse_gemm_epilogue_pass.h" + #include + #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/ir/fuse_optimizer_ops_pass/fuse_adam_op_pass.cc b/paddle/fluid/framework/ir/fuse_optimizer_ops_pass/fuse_adam_op_pass.cc index 0094b674c2a176605f1fb13c2a759d75833f20a3..9629b9209c4d88601ee4715ca71ea49f739d60e9 100644 --- a/paddle/fluid/framework/ir/fuse_optimizer_ops_pass/fuse_adam_op_pass.cc +++ b/paddle/fluid/framework/ir/fuse_optimizer_ops_pass/fuse_adam_op_pass.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. #include + #include #include "glog/logging.h" diff --git a/paddle/fluid/framework/ir/fuse_optimizer_ops_pass/fuse_momentum_op_pass.cc b/paddle/fluid/framework/ir/fuse_optimizer_ops_pass/fuse_momentum_op_pass.cc index f87d31cbc409c7c4db634e994738d106d2a8146e..e290bdf99ce65c97d0282329ef93afbc5b55f153 100644 --- a/paddle/fluid/framework/ir/fuse_optimizer_ops_pass/fuse_momentum_op_pass.cc +++ b/paddle/fluid/framework/ir/fuse_optimizer_ops_pass/fuse_momentum_op_pass.cc @@ -67,8 +67,9 @@ class FuseMomentumOpPass : public FuseOptimizerOpPass { platform::errors::InvalidArgument( "All momentum Op's attr(use_nesterov) must be same, but there " "are two different value: %d, %d.", - use_nesterov, BOOST_GET_CONST(bool, momentum_op->Op()->GetAttr( - "use_nesterov")))); + use_nesterov, + BOOST_GET_CONST(bool, + momentum_op->Op()->GetAttr("use_nesterov")))); PADDLE_ENFORCE_EQ( op_role, BOOST_GET_CONST(int, momentum_op->Op()->GetAttr( diff --git a/paddle/fluid/framework/ir/fuse_optimizer_ops_pass/fuse_optimizer_op_pass.cc b/paddle/fluid/framework/ir/fuse_optimizer_ops_pass/fuse_optimizer_op_pass.cc index 40e1de8a523aa3883b740bcedbae2512296071ef..e3e5221531ee02f5cf58541ce319157734e92401 100644 --- a/paddle/fluid/framework/ir/fuse_optimizer_ops_pass/fuse_optimizer_op_pass.cc +++ b/paddle/fluid/framework/ir/fuse_optimizer_ops_pass/fuse_optimizer_op_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/fuse_optimizer_ops_pass/fuse_optimizer_op_pass.h" + #include "paddle/fluid/framework/ir/graph_helper.h" #include "paddle/fluid/framework/operator.h" #include "paddle/phi/core/kernel_factory.h" diff --git a/paddle/fluid/framework/ir/fuse_relu_depthwise_conv_pass.cc b/paddle/fluid/framework/ir/fuse_relu_depthwise_conv_pass.cc index 56ca98b566070ce5ed49a96ec9aedc3276ae0499..bcfa69ac2e7effce5dabedfec001be6184f2ab57 100644 --- a/paddle/fluid/framework/ir/fuse_relu_depthwise_conv_pass.cc +++ b/paddle/fluid/framework/ir/fuse_relu_depthwise_conv_pass.cc @@ -13,10 +13,12 @@ // limitations under the License. #include "paddle/fluid/framework/ir/fuse_relu_depthwise_conv_pass.h" + #include #include #include #include + #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/ir/fusion_group/code_generator.cc b/paddle/fluid/framework/ir/fusion_group/code_generator.cc index 5b125030a7a7799648307e8345c89ebeab920327..a8a09d690239c4124438f9ba8d6e613517cf0f74 100644 --- a/paddle/fluid/framework/ir/fusion_group/code_generator.cc +++ b/paddle/fluid/framework/ir/fusion_group/code_generator.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/ir/fusion_group/code_generator.h" + #include "paddle/fluid/framework/ir/fusion_group/code_generator_helper.h" #include "paddle/fluid/framework/ir/fusion_group/cuda_resources.h" diff --git a/paddle/fluid/framework/ir/fusion_group/code_generator_helper.cc b/paddle/fluid/framework/ir/fusion_group/code_generator_helper.cc index 18bd6d623b7ea9c864510b86e69862a85573d6c1..650ed965067adaae441a58e20f222e0aa7a9df60 100644 --- a/paddle/fluid/framework/ir/fusion_group/code_generator_helper.cc +++ b/paddle/fluid/framework/ir/fusion_group/code_generator_helper.cc @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/ir/fusion_group/operation.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/fusion_group/code_generator_tester.cc b/paddle/fluid/framework/ir/fusion_group/code_generator_tester.cc index 7b6bbf0251001ab3bff96ea6d9b49dd8859fdf1f..a24a9af158ec033877b10cfdcc19c3f8cca31878 100644 --- a/paddle/fluid/framework/ir/fusion_group/code_generator_tester.cc +++ b/paddle/fluid/framework/ir/fusion_group/code_generator_tester.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include #include diff --git a/paddle/fluid/framework/ir/fusion_group/elementwise_group_detector.cc b/paddle/fluid/framework/ir/fusion_group/elementwise_group_detector.cc index 6fa3044affc21a69d54767dae3ebd0fc359ea6ce..5be4091ca8b3c6c198d81a18bc33f015632f7a7c 100644 --- a/paddle/fluid/framework/ir/fusion_group/elementwise_group_detector.cc +++ b/paddle/fluid/framework/ir/fusion_group/elementwise_group_detector.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/ir/fusion_group/elementwise_group_detector.h" + #include #include "paddle/fluid/framework/ir/fusion_group/operation.h" diff --git a/paddle/fluid/framework/ir/fusion_group/fusion_group_pass.cc b/paddle/fluid/framework/ir/fusion_group/fusion_group_pass.cc index 85d34405c5e5784bb3d671d6027fd44dcf63ff8b..44df3a837f6d367f146343f0d1800eccdc45d7dc 100644 --- a/paddle/fluid/framework/ir/fusion_group/fusion_group_pass.cc +++ b/paddle/fluid/framework/ir/fusion_group/fusion_group_pass.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/ir/fusion_group/fusion_group_pass.h" + #include "paddle/fluid/framework/ir/fusion_group/code_generator.h" #include "paddle/fluid/framework/ir/fusion_group/elementwise_group_detector.h" #include "paddle/fluid/framework/ir/graph_pattern_detector.h" diff --git a/paddle/fluid/framework/ir/fusion_group/fusion_group_pass_tester.cc b/paddle/fluid/framework/ir/fusion_group/fusion_group_pass_tester.cc index db22c03a7d9c00fb4a067a9a62ba0442d7f43e54..402fad0e84cfa98e9de7c8acc57315c38bba4dda 100644 --- a/paddle/fluid/framework/ir/fusion_group/fusion_group_pass_tester.cc +++ b/paddle/fluid/framework/ir/fusion_group/fusion_group_pass_tester.cc @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/framework/ir/fusion_group/fusion_group_pass.h" - #include + +#include "paddle/fluid/framework/ir/fusion_group/fusion_group_pass.h" #include "paddle/fluid/framework/ir/pass_tester_helper.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/fusion_group/operation.cc b/paddle/fluid/framework/ir/fusion_group/operation.cc index 2b7a3e1899c76b6a2ec02dbe66781a2130947519..7d1b7bafa1365c9841d9e6e91a5dd1232a3c609c 100644 --- a/paddle/fluid/framework/ir/fusion_group/operation.cc +++ b/paddle/fluid/framework/ir/fusion_group/operation.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/ir/fusion_group/operation.h" + #include "paddle/fluid/framework/operator.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/fusion_group/subgraph.h b/paddle/fluid/framework/ir/fusion_group/subgraph.h index 5a29e875aea615c36711aa7dc044e4e1f563c297..1c334e70f1c30e5dba00a584de7e16617ee77e22 100644 --- a/paddle/fluid/framework/ir/fusion_group/subgraph.h +++ b/paddle/fluid/framework/ir/fusion_group/subgraph.h @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/ir/fusion_group/operation.h" #include "paddle/fluid/framework/ir/graph.h" #include "paddle/fluid/framework/ir/graph_traits.h" diff --git a/paddle/fluid/framework/ir/generate_pass.cc b/paddle/fluid/framework/ir/generate_pass.cc index 02c9d8e1c0c24aa5632f4ffd7aaeec42962e50dd..00d69c9d5d2b12f034b42e6afa98f84ebc47ccb2 100644 --- a/paddle/fluid/framework/ir/generate_pass.cc +++ b/paddle/fluid/framework/ir/generate_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/generate_pass.h" + #include "paddle/fluid/framework/ir/graph_pattern_detector.h" namespace paddle { @@ -234,178 +235,183 @@ bool IsDuplicatePattern(const GraphPatternDetector::subgraph_t& subgraph, GraphPatternDetector::handle_t GetGenerateDelete( const PDPattern& pattern, const proto::PassDesc& pass_desc) { - GraphPatternDetector::handle_t handler = [&]( - const GraphPatternDetector::subgraph_t& subgraph, Graph* graph) { - if (IsDuplicatePattern(subgraph, graph)) { - return; - } - // `var_node_maps` record the mapping of variable to the pattern subgraph. - std::map var_node_maps; - for (const proto::PassDesc::VarMap& var_map : pass_desc.var_maps()) { - Node* node = subgraph.at(pattern.RetrieveNode(var_map.pattern_var())); - const auto& iter = var_node_maps.find(var_map.replace_var()); - if (var_node_maps.end() == iter) { - // first node is input - var_node_maps.insert({var_map.replace_var(), node}); - } else { - // output node - for (Node* s_node : node->outputs) { - iter->second->outputs.push_back(s_node); - std::replace(s_node->inputs.begin(), s_node->inputs.end(), node, - iter->second); - s_node->Op()->RenameInput(node->Name(), iter->second->Name()); + GraphPatternDetector::handle_t handler = + [&](const GraphPatternDetector::subgraph_t& subgraph, Graph* graph) { + if (IsDuplicatePattern(subgraph, graph)) { + return; } - } - } - // Remove nodes that are intermediate. - std::unordered_set remove_nodes; - for (const std::unique_ptr& pdnode : pattern.nodes()) { - remove_nodes.emplace(subgraph.at(pdnode.get())); - } - for (auto iter : var_node_maps) { - remove_nodes.erase(iter.second); - } - GraphSafeRemoveNodes(graph, remove_nodes); - }; + // `var_node_maps` record the mapping of variable to the pattern + // subgraph. + std::map var_node_maps; + for (const proto::PassDesc::VarMap& var_map : pass_desc.var_maps()) { + Node* node = subgraph.at(pattern.RetrieveNode(var_map.pattern_var())); + const auto& iter = var_node_maps.find(var_map.replace_var()); + if (var_node_maps.end() == iter) { + // first node is input + var_node_maps.insert({var_map.replace_var(), node}); + } else { + // output node + for (Node* s_node : node->outputs) { + iter->second->outputs.push_back(s_node); + std::replace(s_node->inputs.begin(), s_node->inputs.end(), node, + iter->second); + s_node->Op()->RenameInput(node->Name(), iter->second->Name()); + } + } + } + // Remove nodes that are intermediate. + std::unordered_set remove_nodes; + for (const std::unique_ptr& pdnode : pattern.nodes()) { + remove_nodes.emplace(subgraph.at(pdnode.get())); + } + for (auto iter : var_node_maps) { + remove_nodes.erase(iter.second); + } + GraphSafeRemoveNodes(graph, remove_nodes); + }; return handler; } GraphPatternDetector::handle_t GetGenerateRewrite( const PDPattern& pattern, const proto::PassDesc& pass_desc) { - GraphPatternDetector::handle_t handler = [&]( - const GraphPatternDetector::subgraph_t& subgraph, Graph* graph) { - if (IsDuplicatePattern(subgraph, graph)) { - return; - } - for (const auto& condition : pass_desc.var_attr_conditions()) { - if (condition.has_condition_attr()) { - Node* node = - subgraph.at(pattern.RetrieveNode(condition.attr().var_name())); - Attribute node_attr = GetVarAttrValue(node->Var(), condition.attr()); - Attribute condition_attr; - if (condition.condition_attr().role() == - proto::PassDesc_RoleType_kVariable) { - Node* condition_node = - subgraph.at(pattern.RetrieveNode(condition.attr().var_name())); - condition_attr = GetVarAttrValue(condition_node->Var(), - condition.condition_attr()); - } else { - PADDLE_THROW( - platform::errors::Unimplemented("Unimplemented for operation.")); - } - bool check_failed = false; - if (condition.type() == proto::PassDesc_ConditionType_kEQ) { - check_failed = !(node_attr == condition_attr); - } - if (check_failed) { - VLOG(3) << "Check var [" << node->Name() << "] with attr [" - << condition.attr().name() << "] failed, skip this pattern."; + GraphPatternDetector::handle_t handler = + [&](const GraphPatternDetector::subgraph_t& subgraph, Graph* graph) { + if (IsDuplicatePattern(subgraph, graph)) { return; } - } - } - // `var_node_maps` record the mapping of variable to the pattern subgraph. - std::map var_node_maps; - for (const proto::PassDesc::VarMap& var_map : pass_desc.var_maps()) { - Node* node = subgraph.at(pattern.RetrieveNode(var_map.pattern_var())); - var_node_maps.insert({var_map.replace_var(), node}); - } - // Traverse all operators to create subgraph. - for (int index = 0; index < pass_desc.replace_size(); ++index) { - const proto::OpDesc& op = pass_desc.replace(index); - OpDesc op_desc; - std::vector in_nodes, out_nodes; - op_desc.SetType(op.type()); - // Create Nodes for inputs of current operator. - for (const proto::OpDesc::Var& var : op.inputs()) { - std::vector arguments; - for (const std::string& argument : var.arguments()) { - // The input may be mapped on the operator of pattern subgraph. - Node* node = nullptr; - auto iter = var_node_maps.find(argument); - if (var_node_maps.end() == iter) { - VarDesc var_desc(patterns::UniqueKey(argument)); - node = graph->CreateVarNode(&var_desc); - var_node_maps.insert({argument, node}); - } else { - node = iter->second; - } - in_nodes.push_back(node); - arguments.push_back(node->Name()); - } - op_desc.SetInput(var.parameter(), arguments); - } - // Create Nodes for outputs of current operator. - for (const proto::OpDesc::Var& var : op.outputs()) { - std::vector arguments; - for (const std::string& argument : var.arguments()) { - // The output may be mapped on the operator of pattern subgraph. - Node* node = nullptr; - auto iter = var_node_maps.find(argument); - if (var_node_maps.end() == iter) { - VarDesc var_desc(patterns::UniqueKey(argument)); - node = graph->CreateVarNode(&var_desc); - var_node_maps.insert({argument, node}); - } else { - if (in_nodes.end() == - std::find(in_nodes.begin(), in_nodes.end(), iter->second)) { - node = iter->second; + for (const auto& condition : pass_desc.var_attr_conditions()) { + if (condition.has_condition_attr()) { + Node* node = + subgraph.at(pattern.RetrieveNode(condition.attr().var_name())); + Attribute node_attr = + GetVarAttrValue(node->Var(), condition.attr()); + Attribute condition_attr; + if (condition.condition_attr().role() == + proto::PassDesc_RoleType_kVariable) { + Node* condition_node = subgraph.at( + pattern.RetrieveNode(condition.attr().var_name())); + condition_attr = GetVarAttrValue(condition_node->Var(), + condition.condition_attr()); } else { - node = graph->CreateVarNode(iter->second->Var()); + PADDLE_THROW(platform::errors::Unimplemented( + "Unimplemented for operation.")); + } + bool check_failed = false; + if (condition.type() == proto::PassDesc_ConditionType_kEQ) { + check_failed = !(node_attr == condition_attr); + } + if (check_failed) { + VLOG(3) << "Check var [" << node->Name() << "] with attr [" + << condition.attr().name() + << "] failed, skip this pattern."; + return; } } - out_nodes.push_back(node); - arguments.push_back(node->Name()); } - op_desc.SetOutput(var.parameter(), arguments); - } - // Set attribute for current operator. - for (const proto::OpDesc::Attr& attr : op.attrs()) { - op_desc.SetAttr(attr.name(), GetAttrValue(attr)); - } - for (const auto& attr_map : pass_desc.op_attr_maps()) { - if (attr_map.replace_attr().op_index() == index) { - Attribute attr; - if (attr_map.pattern_attr().role() == - proto::PassDesc_RoleType_kVariable) { - Node* condition_node = subgraph.at( - pattern.RetrieveNode(attr_map.pattern_attr().var_name())); - attr = - GetVarAttrValue(condition_node->Var(), attr_map.pattern_attr()); - } else { - Node* condition_node = subgraph.at(pattern.RetrieveNode( - std::to_string(attr_map.pattern_attr().op_index()))); - attr = - GetOpAttrValue(condition_node->Op(), attr_map.pattern_attr()); + // `var_node_maps` record the mapping of variable to the pattern + // subgraph. + std::map var_node_maps; + for (const proto::PassDesc::VarMap& var_map : pass_desc.var_maps()) { + Node* node = subgraph.at(pattern.RetrieveNode(var_map.pattern_var())); + var_node_maps.insert({var_map.replace_var(), node}); + } + // Traverse all operators to create subgraph. + for (int index = 0; index < pass_desc.replace_size(); ++index) { + const proto::OpDesc& op = pass_desc.replace(index); + OpDesc op_desc; + std::vector in_nodes, out_nodes; + op_desc.SetType(op.type()); + // Create Nodes for inputs of current operator. + for (const proto::OpDesc::Var& var : op.inputs()) { + std::vector arguments; + for (const std::string& argument : var.arguments()) { + // The input may be mapped on the operator of pattern subgraph. + Node* node = nullptr; + auto iter = var_node_maps.find(argument); + if (var_node_maps.end() == iter) { + VarDesc var_desc(patterns::UniqueKey(argument)); + node = graph->CreateVarNode(&var_desc); + var_node_maps.insert({argument, node}); + } else { + node = iter->second; + } + in_nodes.push_back(node); + arguments.push_back(node->Name()); + } + op_desc.SetInput(var.parameter(), arguments); + } + // Create Nodes for outputs of current operator. + for (const proto::OpDesc::Var& var : op.outputs()) { + std::vector arguments; + for (const std::string& argument : var.arguments()) { + // The output may be mapped on the operator of pattern subgraph. + Node* node = nullptr; + auto iter = var_node_maps.find(argument); + if (var_node_maps.end() == iter) { + VarDesc var_desc(patterns::UniqueKey(argument)); + node = graph->CreateVarNode(&var_desc); + var_node_maps.insert({argument, node}); + } else { + if (in_nodes.end() == + std::find(in_nodes.begin(), in_nodes.end(), iter->second)) { + node = iter->second; + } else { + node = graph->CreateVarNode(iter->second->Var()); + } + } + out_nodes.push_back(node); + arguments.push_back(node->Name()); + } + op_desc.SetOutput(var.parameter(), arguments); + } + // Set attribute for current operator. + for (const proto::OpDesc::Attr& attr : op.attrs()) { + op_desc.SetAttr(attr.name(), GetAttrValue(attr)); } - if (attr_map.has_operation()) { - Attribute operation = GetAttrValue(attr_map.operation().value()); - attr = boost::apply_visitor( - operation_visitor(attr_map.operation().type()), attr, - operation); + for (const auto& attr_map : pass_desc.op_attr_maps()) { + if (attr_map.replace_attr().op_index() == index) { + Attribute attr; + if (attr_map.pattern_attr().role() == + proto::PassDesc_RoleType_kVariable) { + Node* condition_node = subgraph.at( + pattern.RetrieveNode(attr_map.pattern_attr().var_name())); + attr = GetVarAttrValue(condition_node->Var(), + attr_map.pattern_attr()); + } else { + Node* condition_node = subgraph.at(pattern.RetrieveNode( + std::to_string(attr_map.pattern_attr().op_index()))); + attr = GetOpAttrValue(condition_node->Op(), + attr_map.pattern_attr()); + } + if (attr_map.has_operation()) { + Attribute operation = + GetAttrValue(attr_map.operation().value()); + attr = boost::apply_visitor( + operation_visitor(attr_map.operation().type()), attr, + operation); + } + op_desc.SetAttr(attr_map.replace_attr().name(), attr); + } + } + // Create a Node for current operator. + Node* op_node = graph->CreateOpNode(&op_desc); + for (Node* node : in_nodes) { + IR_NODE_LINK_TO(node, op_node); + } + for (Node* node : out_nodes) { + IR_NODE_LINK_TO(op_node, node); } - op_desc.SetAttr(attr_map.replace_attr().name(), attr); } - } - // Create a Node for current operator. - Node* op_node = graph->CreateOpNode(&op_desc); - for (Node* node : in_nodes) { - IR_NODE_LINK_TO(node, op_node); - } - for (Node* node : out_nodes) { - IR_NODE_LINK_TO(op_node, node); - } - } - // Remove nodes that are intermediate. - std::unordered_set remove_nodes; - for (const std::unique_ptr& pdnode : pattern.nodes()) { - remove_nodes.emplace(subgraph.at(pdnode.get())); - } - for (auto iter : var_node_maps) { - remove_nodes.erase(iter.second); - } - GraphSafeRemoveNodes(graph, remove_nodes); - }; + // Remove nodes that are intermediate. + std::unordered_set remove_nodes; + for (const std::unique_ptr& pdnode : pattern.nodes()) { + remove_nodes.emplace(subgraph.at(pdnode.get())); + } + for (auto iter : var_node_maps) { + remove_nodes.erase(iter.second); + } + GraphSafeRemoveNodes(graph, remove_nodes); + }; return handler; } diff --git a/paddle/fluid/framework/ir/generate_pass_tester.cc b/paddle/fluid/framework/ir/generate_pass_tester.cc index 6876dde50c157c3e14d2aa5b1212e9ffd48f90bf..7e98b11215a75e0113d7b3aea462bdeacac0a554 100644 --- a/paddle/fluid/framework/ir/generate_pass_tester.cc +++ b/paddle/fluid/framework/ir/generate_pass_tester.cc @@ -12,16 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/generate_pass.h" #include "gtest/gtest.h" +#include "paddle/fluid/framework/ir/generate_pass.h" #include "paddle/fluid/framework/ir/pass_tester_helper.h" REGISTER_GENERATE_PASS(generate_fc_fuse) { paddle::framework::ir::PassPairs pass_pairs; for (bool with_relu : {true, false}) { // pattern - SUBGRAPH_(pattern) = - [ subgraph = &pattern, with_relu ](VAR_(x), VAR_(y), VAR_(z)) { + SUBGRAPH_(pattern) = [subgraph = &pattern, with_relu](VAR_(x), VAR_(y), + VAR_(z)) { VLOG(3) << "exec lambda func."; auto mul = OP_(mul)({{"X", x}, {"Y", y}}).Out("Out"); auto ewadd = OP_(elementwise_add)({{"X", mul}, {"Y", z}}).Out("Out"); @@ -32,8 +32,8 @@ REGISTER_GENERATE_PASS(generate_fc_fuse) { } }; // replace - SUBGRAPH_(replace) = - [ subgraph = &replace, with_relu ](VAR_(x), VAR_(y), VAR_(z)) { + SUBGRAPH_(replace) = [subgraph = &replace, with_relu](VAR_(x), VAR_(y), + VAR_(z)) { auto& fc = OP_(fc)({{"Input", x}, {"W", y}, {"Bias", z}}); return fc.Out("Out"); }; diff --git a/paddle/fluid/framework/ir/gpu_cpu_map_matmul_to_mul_pass.cc b/paddle/fluid/framework/ir/gpu_cpu_map_matmul_to_mul_pass.cc index ac580b99b5c95e3de89d240acfe1496f662e4a48..8e58231e986811af45149b3c3ebf60c6deffd64b 100644 --- a/paddle/fluid/framework/ir/gpu_cpu_map_matmul_to_mul_pass.cc +++ b/paddle/fluid/framework/ir/gpu_cpu_map_matmul_to_mul_pass.cc @@ -16,9 +16,9 @@ #include #include + #include "paddle/fluid/framework/ir/graph_pattern_detector.h" #include "paddle/fluid/framework/op_proto_maker.h" - #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/ir/graph.cc b/paddle/fluid/framework/ir/graph.cc index f5f6f3ecb855cfa9acb6c2169f1fc43458578a2a..acf8f6ec6435b955cc0e56d04678aa3ca8a95076 100644 --- a/paddle/fluid/framework/ir/graph.cc +++ b/paddle/fluid/framework/ir/graph.cc @@ -12,9 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/framework/ir/graph.h" + #include -#include "paddle/fluid/framework/ir/graph.h" #include "paddle/fluid/framework/operator.h" PADDLE_DEFINE_EXPORTED_bool(convert_all_blocks, true, diff --git a/paddle/fluid/framework/ir/graph.h b/paddle/fluid/framework/ir/graph.h index 10645f08dc3ba833c3a4ca75a1ac623ee2c1e8e9..40a6fbbade80e02636506c1d624d4d8cc941d22a 100644 --- a/paddle/fluid/framework/ir/graph.h +++ b/paddle/fluid/framework/ir/graph.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include #include #include diff --git a/paddle/fluid/framework/ir/graph_helper.cc b/paddle/fluid/framework/ir/graph_helper.cc index ed7aa451d134c329025921311eacbd69fb11a1bc..d4c7a607db371aecad29d57f96628347ba79fab5 100644 --- a/paddle/fluid/framework/ir/graph_helper.cc +++ b/paddle/fluid/framework/ir/graph_helper.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/ir/graph_helper.h" + #include #include + #include "paddle/fluid/framework/details/multi_devices_helper.h" #include "paddle/fluid/framework/op_proto_maker.h" @@ -421,8 +423,9 @@ std::vector TopologySortGraphByDescOrder(const Graph &graph) { DescOrderComparator> adj_list = BuildOperationAdjList(graph); PADDLE_ENFORCE_EQ(HasCircleInternal(adj_list, nullptr), - false, platform::errors::InvalidArgument( - "Generated graph shouldn't contain cycle.")); + false, + platform::errors::InvalidArgument( + "Generated graph shouldn't contain cycle.")); std::unordered_set visited; std::vector ret; for (auto adj : adj_list) { diff --git a/paddle/fluid/framework/ir/graph_helper_test.cc b/paddle/fluid/framework/ir/graph_helper_test.cc index 0a2dcfed000c9f4bbddc280912dc8966044c265d..5972cd40817ac1a225730ead8cc967d62854906f 100644 --- a/paddle/fluid/framework/ir/graph_helper_test.cc +++ b/paddle/fluid/framework/ir/graph_helper_test.cc @@ -12,9 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/framework/ir/graph.h" -#include "gtest/gtest.h" #include "paddle/fluid/framework/ir/graph_helper.h" + +#include "gtest/gtest.h" +#include "paddle/fluid/framework/ir/graph.h" #include "paddle/fluid/framework/program_desc.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/graph_pattern_detector.cc b/paddle/fluid/framework/ir/graph_pattern_detector.cc index ea101125b18d2d1ac01df69c4d54c28fd7243c7b..ca5a82708c554bfd7a991b9d204b9ce80e9a570f 100644 --- a/paddle/fluid/framework/ir/graph_pattern_detector.cc +++ b/paddle/fluid/framework/ir/graph_pattern_detector.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/graph_pattern_detector.h" + #include "paddle/fluid/framework/ir/graph_traits.h" #include "paddle/fluid/framework/ir/graph_viz_pass.h" #include "paddle/fluid/framework/operator.h" @@ -70,8 +71,9 @@ void PDPattern::AddEdge(PDNode *a, PDNode *b) { a, platform::errors::NotFound("PDNode %s is not found.", a->name())); PADDLE_ENFORCE_NOT_NULL( b, platform::errors::NotFound("PDNode %s is not found.", b->name())); - PADDLE_ENFORCE_NE(a, b, platform::errors::PermissionDenied( - "Cannot connect the same node in the graph.")); + PADDLE_ENFORCE_NE(a, b, + platform::errors::PermissionDenied( + "Cannot connect the same node in the graph.")); edges_.emplace_back(a, b); } @@ -3062,11 +3064,10 @@ PDNode *patterns::ReshapeTransposeMatmulPattern::operator()( transpose_out->assert_is_only_output_of_op("transpose2"); auto transpose_xshape = - with_transpose_xshape - ? pattern->NewNode(transpose_xshape_repr()) - ->AsIntermediate() - ->assert_is_op_output("transpose2", "XShape") - : nullptr; + with_transpose_xshape ? pattern->NewNode(transpose_xshape_repr()) + ->AsIntermediate() + ->assert_is_op_output("transpose2", "XShape") + : nullptr; auto matmul_out = pattern->NewNode(matmul_out_repr()) ->AsOutput() diff --git a/paddle/fluid/framework/ir/graph_pattern_detector_tester.cc b/paddle/fluid/framework/ir/graph_pattern_detector_tester.cc index 5ac5a5d983992746c8bbbb318c41d04a0cf76fae..b02b2e13edc978f3543a635d76c7db70dfdceca1 100644 --- a/paddle/fluid/framework/ir/graph_pattern_detector_tester.cc +++ b/paddle/fluid/framework/ir/graph_pattern_detector_tester.cc @@ -152,12 +152,12 @@ TEST(GraphPatternDetecter, MultiSubgraph) { x.mutable_pattern()->AddEdge(any_var, any_op1); int count = 0; - GraphPatternDetector::handle_t handle = [&]( - const GraphPatternDetector::subgraph_t& s, Graph* g) { - LOG(INFO) << "Detect " << s.at(any_op)->Name() << " -> " - << s.at(any_var)->Name() << " -> " << s.at(any_op1)->Name(); - count++; - }; + GraphPatternDetector::handle_t handle = + [&](const GraphPatternDetector::subgraph_t& s, Graph* g) { + LOG(INFO) << "Detect " << s.at(any_op)->Name() << " -> " + << s.at(any_var)->Name() << " -> " << s.at(any_op1)->Name(); + count++; + }; x(&graph, handle); diff --git a/paddle/fluid/framework/ir/graph_printer.h b/paddle/fluid/framework/ir/graph_printer.h index 76b07f0d6530907e7b20253d6a2a744fd2e11362..1b0e059f122b51db3977a1616e529d6809471d13 100644 --- a/paddle/fluid/framework/ir/graph_printer.h +++ b/paddle/fluid/framework/ir/graph_printer.h @@ -15,11 +15,13 @@ #pragma once #include + #include #include #include #include #include + #include "paddle/fluid/framework/details/multi_devices_helper.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/graph_test.cc b/paddle/fluid/framework/ir/graph_test.cc index 1ff67ae0fe0d910f920459cc0800b2aab8e18c2a..db18a735ce2dd6d930632900e6fa875296278a14 100644 --- a/paddle/fluid/framework/ir/graph_test.cc +++ b/paddle/fluid/framework/ir/graph_test.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/ir/graph.h" + #include "gtest/gtest.h" #include "paddle/fluid/framework/details/multi_devices_helper.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/framework/ir/graph_to_program_pass.cc b/paddle/fluid/framework/ir/graph_to_program_pass.cc index 3ad591c6dff04ce6334d1675616f0cf2d5c39182..f57cdd9d9746ca867ad2b506738650ae8e48791e 100644 --- a/paddle/fluid/framework/ir/graph_to_program_pass.cc +++ b/paddle/fluid/framework/ir/graph_to_program_pass.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/fluid/framework/ir/graph_to_program_pass.h" #include + #include #include "paddle/fluid/framework/op_proto_maker.h" diff --git a/paddle/fluid/framework/ir/graph_traits.cc b/paddle/fluid/framework/ir/graph_traits.cc index b06314563025aab0043966ad038269185069e525..36bc3e6dd781bd7d3c9bdcf2dc1b896abc4ae6c8 100644 --- a/paddle/fluid/framework/ir/graph_traits.cc +++ b/paddle/fluid/framework/ir/graph_traits.cc @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/framework/ir/graph_traits.h" + #include #include -#include "paddle/fluid/framework/ir/graph_traits.h" - namespace paddle { namespace framework { namespace ir { @@ -76,21 +76,22 @@ NodesDFSIterator::NodesDFSIterator(const std::vector &source) { } NodesDFSIterator::NodesDFSIterator(NodesDFSIterator &&other) noexcept - : stack_(std::move(other.stack_)), - visited_(std::move(other.visited_)) {} + : stack_(std::move(other.stack_)), visited_(std::move(other.visited_)) {} NodesDFSIterator::NodesDFSIterator(const NodesDFSIterator &other) : stack_(other.stack_), visited_(other.visited_) {} Node &NodesDFSIterator::operator*() { - PADDLE_ENFORCE_EQ(stack_.empty(), false, platform::errors::OutOfRange( - "The iterator exceeds range.")); + PADDLE_ENFORCE_EQ( + stack_.empty(), false, + platform::errors::OutOfRange("The iterator exceeds range.")); return *stack_.top(); } NodesDFSIterator &NodesDFSIterator::operator++() { - PADDLE_ENFORCE_EQ(stack_.empty(), false, platform::errors::OutOfRange( - "The iterator exceeds range.")); + PADDLE_ENFORCE_EQ( + stack_.empty(), false, + platform::errors::OutOfRange("The iterator exceeds range.")); visited_.insert(stack_.top()); auto *cur = stack_.top(); stack_.pop(); diff --git a/paddle/fluid/framework/ir/graph_viz_pass.cc b/paddle/fluid/framework/ir/graph_viz_pass.cc index 7311eb4b91df8a36942b563e89e575befcaec3ae..da48d1d19b60a8e8a6edb2fa7f00c732b50ba38a 100644 --- a/paddle/fluid/framework/ir/graph_viz_pass.cc +++ b/paddle/fluid/framework/ir/graph_viz_pass.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/ir/graph_viz_pass.h" + #include + #include "paddle/fluid/framework/ir/graph_helper.h" #include "paddle/fluid/framework/ir/graph_printer.h" #include "paddle/fluid/framework/op_proto_maker.h" diff --git a/paddle/fluid/framework/ir/identity_scale_op_clean_pass.cc b/paddle/fluid/framework/ir/identity_scale_op_clean_pass.cc index 6b91ea4e360df3e34be68d29ad05e1f496459dc7..3d60148c170f94fe2019f719554fa1b2c27ea783 100644 --- a/paddle/fluid/framework/ir/identity_scale_op_clean_pass.cc +++ b/paddle/fluid/framework/ir/identity_scale_op_clean_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/identity_scale_op_clean_pass.h" + #include "paddle/fluid/framework/ir/graph_pattern_detector.h" #include "paddle/fluid/framework/op_version_registry.h" @@ -46,42 +47,42 @@ void IdentityScaleOpCleanPass::ApplyImpl(ir::Graph* graph) const { scale_op->LinksFrom({scale_in}).LinksTo({scale_out}); int found_subgraph_count = 0; - GraphPatternDetector::handle_t handler = [&]( - const GraphPatternDetector::subgraph_t& subgraph, Graph* graph) { - Node* scale_op_var = subgraph.at(scale_op); - Node* scale_in_var = subgraph.at(scale_in); - Node* scale_out_var = subgraph.at(scale_out); - const std::string scale_in_name = scale_in_var->Name(); - const std::string scale_out_name = scale_out_var->Name(); - // Remove links in graph - GraphSafeRemoveNodes(graph, {scale_in_var, scale_op_var}); - // Modify pre_op_desc - // Link pre_op directly to scale_out - for (auto& node : graph->Nodes()) { - if (node->IsOp()) { - auto* op_desc = node->Op(); - auto out_vars_map = op_desc->Outputs(); - for (auto out_var_map : out_vars_map) { - auto names = out_var_map.second; - bool reset = false; - for (size_t i = 0; i < names.size(); i++) { - if (names[i] == scale_in_name) { - reset = true; - names[i] = scale_out_name; - break; + GraphPatternDetector::handle_t handler = + [&](const GraphPatternDetector::subgraph_t& subgraph, Graph* graph) { + Node* scale_op_var = subgraph.at(scale_op); + Node* scale_in_var = subgraph.at(scale_in); + Node* scale_out_var = subgraph.at(scale_out); + const std::string scale_in_name = scale_in_var->Name(); + const std::string scale_out_name = scale_out_var->Name(); + // Remove links in graph + GraphSafeRemoveNodes(graph, {scale_in_var, scale_op_var}); + // Modify pre_op_desc + // Link pre_op directly to scale_out + for (auto& node : graph->Nodes()) { + if (node->IsOp()) { + auto* op_desc = node->Op(); + auto out_vars_map = op_desc->Outputs(); + for (auto out_var_map : out_vars_map) { + auto names = out_var_map.second; + bool reset = false; + for (size_t i = 0; i < names.size(); i++) { + if (names[i] == scale_in_name) { + reset = true; + names[i] = scale_out_name; + break; + } + } + if (reset) { + op_desc->SetOutput(out_var_map.first, names); + op_desc->Flush(); + IR_NODE_LINK_TO(node, scale_out_var); + break; + } } } - if (reset) { - op_desc->SetOutput(out_var_map.first, names); - op_desc->Flush(); - IR_NODE_LINK_TO(node, scale_out_var); - break; - } } - } - } - found_subgraph_count++; - }; + found_subgraph_count++; + }; detector(graph, handler); AddStatis(found_subgraph_count); diff --git a/paddle/fluid/framework/ir/ipu/avg_shard_pass.cc b/paddle/fluid/framework/ir/ipu/avg_shard_pass.cc index f1ee3c26b8f4840d7ed7bbb1991bd1e73eee4175..5c7373e1a77d852e55f91fc3a9c491e1747be0d6 100644 --- a/paddle/fluid/framework/ir/ipu/avg_shard_pass.cc +++ b/paddle/fluid/framework/ir/ipu/avg_shard_pass.cc @@ -14,10 +14,9 @@ #include "paddle/fluid/framework/ir/ipu/avg_shard_pass.h" -#include "paddle/fluid/platform/device/ipu/ipu_backend.h" - #include "paddle/fluid/framework/ir/graph_helper.h" #include "paddle/fluid/framework/ir/pass_tester_helper.h" +#include "paddle/fluid/platform/device/ipu/ipu_backend.h" namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/ir/ipu/infer_shape_pass.cc b/paddle/fluid/framework/ir/ipu/infer_shape_pass.cc index ebe40c3ee204ef7edae32dee591c096be11140cf..cbe57eae4c496e808c035be7239db4b9ca9251f2 100644 --- a/paddle/fluid/framework/ir/ipu/infer_shape_pass.cc +++ b/paddle/fluid/framework/ir/ipu/infer_shape_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/ipu/infer_shape_pass.h" + #include "paddle/fluid/framework/ir/graph_helper.h" #include "paddle/fluid/framework/ir/pass_tester_helper.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/framework/ir/ipu/inference_process_pass.cc b/paddle/fluid/framework/ir/ipu/inference_process_pass.cc index a6b82089dc4dfe8f8d55b1100602f8645efac4c0..df4ea7fac4b35afed0c8e01cd356430727f95c23 100644 --- a/paddle/fluid/framework/ir/ipu/inference_process_pass.cc +++ b/paddle/fluid/framework/ir/ipu/inference_process_pass.cc @@ -14,11 +14,10 @@ #include "paddle/fluid/framework/ir/ipu/inference_process_pass.h" -#include "paddle/fluid/platform/device/ipu/ipu_backend.h" -#include "paddle/fluid/platform/device/ipu/ipu_strategy.h" - #include "paddle/fluid/framework/ir/fuse_pass_base.h" #include "paddle/fluid/framework/ir/pass_tester_helper.h" +#include "paddle/fluid/platform/device/ipu/ipu_backend.h" +#include "paddle/fluid/platform/device/ipu/ipu_strategy.h" #include "paddle/fluid/platform/enforce.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/ipu/optimizer_state_align_pass.cc b/paddle/fluid/framework/ir/ipu/optimizer_state_align_pass.cc index 4da913e7176ca3bf36b05514b5a6854e6fde806a..12d646e153b4f922767692694813783dfebd8f86 100644 --- a/paddle/fluid/framework/ir/ipu/optimizer_state_align_pass.cc +++ b/paddle/fluid/framework/ir/ipu/optimizer_state_align_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/ipu/optimizer_state_align_pass.h" + #include "paddle/fluid/framework/ir/pass_tester_helper.h" #include "paddle/fluid/platform/device/ipu/ipu_backend.h" #include "paddle/fluid/platform/device/ipu/ipu_names.h" diff --git a/paddle/fluid/framework/ir/is_test_pass_tester.cc b/paddle/fluid/framework/ir/is_test_pass_tester.cc index bf0667aeafe605e30725ee9438fdadad03a4f501..d2444295544b9e970ddce9122e7c3fbf6ad0c130 100644 --- a/paddle/fluid/framework/ir/is_test_pass_tester.cc +++ b/paddle/fluid/framework/ir/is_test_pass_tester.cc @@ -11,9 +11,9 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/is_test_pass.h" - #include + +#include "paddle/fluid/framework/ir/is_test_pass.h" #ifdef _WIN32 #undef FALSE #undef TRUE diff --git a/paddle/fluid/framework/ir/layer_norm_fuse_pass.cc b/paddle/fluid/framework/ir/layer_norm_fuse_pass.cc index 4b0dc4809f550d71fe2838754ddb2bcc6a86cdf7..1b7b06213fe3c9fa1cc5477c6ca1026fafd1aac3 100644 --- a/paddle/fluid/framework/ir/layer_norm_fuse_pass.cc +++ b/paddle/fluid/framework/ir/layer_norm_fuse_pass.cc @@ -12,11 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/framework/ir/layer_norm_fuse_pass.h" + #include #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/ir/graph_pattern_detector.h" -#include "paddle/fluid/framework/ir/layer_norm_fuse_pass.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/framework/var_desc.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/ir/lock_free_optimize_pass.h b/paddle/fluid/framework/ir/lock_free_optimize_pass.h index 93b6396bf7f3101f7def6c4876355d7e80e4db7e..a72a59374f902308ab2b38eab0a82d3f661576f6 100644 --- a/paddle/fluid/framework/ir/lock_free_optimize_pass.h +++ b/paddle/fluid/framework/ir/lock_free_optimize_pass.h @@ -29,31 +29,31 @@ class Node; class Graph; /* -* Remove the sum op of all gradients of the backward op. -* And remove the dependecies of the optimizer related to the -* same backward op. -* -* Before this pass: -* -* forward_op1 forward_op2 -* | | -* grad_op1 grad_op2 -* \ / -* \ / -* sum_op -* | -* sgd_op -* -* After this pass: -* forward_op1 forward_op2 -* | | -* grad_op1 grad_op2 -* | | -* sgd_op1 sgd_op2 -* -* sgd_op1 and sgd_op2 will update the same weight which holds the same -* memory, so we could benefits from the acceleration -*/ + * Remove the sum op of all gradients of the backward op. + * And remove the dependecies of the optimizer related to the + * same backward op. + * + * Before this pass: + * + * forward_op1 forward_op2 + * | | + * grad_op1 grad_op2 + * \ / + * \ / + * sum_op + * | + * sgd_op + * + * After this pass: + * forward_op1 forward_op2 + * | | + * grad_op1 grad_op2 + * | | + * sgd_op1 sgd_op2 + * + * sgd_op1 and sgd_op2 will update the same weight which holds the same + * memory, so we could benefits from the acceleration + */ class LockFreeOptimizePass : public Pass { public: virtual ~LockFreeOptimizePass() {} diff --git a/paddle/fluid/framework/ir/matmul_scale_fuse_pass.cc b/paddle/fluid/framework/ir/matmul_scale_fuse_pass.cc index 2335e5eee01dbe234dd2673895245bdb5e9f5898..a4bab58506e82dcef62549213f8b0e32359b99e6 100644 --- a/paddle/fluid/framework/ir/matmul_scale_fuse_pass.cc +++ b/paddle/fluid/framework/ir/matmul_scale_fuse_pass.cc @@ -16,9 +16,9 @@ #include #include + #include "paddle/fluid/framework/ir/graph_pattern_detector.h" #include "paddle/fluid/framework/op_proto_maker.h" - #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/ir/memory_optimize_pass/buffer_shared_cross_op_memory_reuse_pass.cc b/paddle/fluid/framework/ir/memory_optimize_pass/buffer_shared_cross_op_memory_reuse_pass.cc index b12b84d4a491b3747a59b99b52903ddff2509fdf..090673b87ed8fd6f0a2ef7550e8ce0d11b59fe8e 100644 --- a/paddle/fluid/framework/ir/memory_optimize_pass/buffer_shared_cross_op_memory_reuse_pass.cc +++ b/paddle/fluid/framework/ir/memory_optimize_pass/buffer_shared_cross_op_memory_reuse_pass.cc @@ -321,13 +321,15 @@ size_t BufferSharedCrossOpMemoryReusePass::ResolveDependencyBetween( } void BufferSharedCrossOpMemoryReusePass::BuildOpDependencyMap() const { - PADDLE_ENFORCE_EQ(ops_.empty(), true, platform::errors::InvalidArgument( - "Ops must be initialized here.")); + PADDLE_ENFORCE_EQ( + ops_.empty(), true, + platform::errors::InvalidArgument("Ops must be initialized here.")); PADDLE_ENFORCE_EQ( op_to_idx_.empty(), true, platform::errors::InvalidArgument("Op to idx must be initialized here.")); - PADDLE_ENFORCE_EQ(deps_.empty(), true, platform::errors::InvalidArgument( - "Deps must be initialized here.")); + PADDLE_ENFORCE_EQ( + deps_.empty(), true, + platform::errors::InvalidArgument("Deps must be initialized here.")); // Toposort ops OpGraphView graph_view(ir::FilterByNodeWrapper(*graph_)); diff --git a/paddle/fluid/framework/ir/memory_optimize_pass/buffer_shared_inplace_op_pass.cc b/paddle/fluid/framework/ir/memory_optimize_pass/buffer_shared_inplace_op_pass.cc index 1ca6e989f275c6ce5130b28b03552a7a6a8bf37f..682a72c5729aca99505d6cd29db81c7cbd1c1bc9 100644 --- a/paddle/fluid/framework/ir/memory_optimize_pass/buffer_shared_inplace_op_pass.cc +++ b/paddle/fluid/framework/ir/memory_optimize_pass/buffer_shared_inplace_op_pass.cc @@ -166,8 +166,9 @@ static std::string GetFirstVarName(const OpDesc &op, const std::string &slot, static std::vector>> GetInplaceVars(const BlockDesc &block, bool use_cuda, const std::vector &skip_vars) { - PADDLE_ENFORCE_EQ(block.ID(), 0, platform::errors::Unimplemented( - "Inplace can only perform in block 0.")); + PADDLE_ENFORCE_EQ( + block.ID(), 0, + platform::errors::Unimplemented("Inplace can only perform in block 0.")); // only take block 0 gc_vars const auto op_gc_vars = GetEagerDeletionCleanVars(*block.Program(), skip_vars)[0]; diff --git a/paddle/fluid/framework/ir/memory_optimize_pass/memory_optimization_var_info.h b/paddle/fluid/framework/ir/memory_optimize_pass/memory_optimization_var_info.h index e89734bacec36e9178d6b315e4df716ffe92f72f..8d593254f90faafb3c6717f34a85a17daa4bdaa6 100644 --- a/paddle/fluid/framework/ir/memory_optimize_pass/memory_optimization_var_info.h +++ b/paddle/fluid/framework/ir/memory_optimize_pass/memory_optimization_var_info.h @@ -19,6 +19,7 @@ #include #include #include + #include "paddle/fluid/platform/enforce.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/memory_optimize_pass/op_graph_view.h b/paddle/fluid/framework/ir/memory_optimize_pass/op_graph_view.h index d6f286afc559064fc97ddc7b936651878fa3a0d0..b5506dd1dcbdde7bfaf77b6a181e1a1365e2f6e7 100644 --- a/paddle/fluid/framework/ir/memory_optimize_pass/op_graph_view.h +++ b/paddle/fluid/framework/ir/memory_optimize_pass/op_graph_view.h @@ -136,13 +136,15 @@ void OpGraphView::BreadthFirstVisit(Callback &&callback) const { } } - PADDLE_ENFORCE_EQ(num_calls, op_num, platform::errors::InvalidArgument( - "There are unvisited ops.")); + PADDLE_ENFORCE_EQ( + num_calls, op_num, + platform::errors::InvalidArgument("There are unvisited ops.")); PADDLE_ENFORCE_EQ( visited_ops.size(), op_num, platform::errors::InvalidArgument("There are unvisited ops.")); - PADDLE_ENFORCE_EQ(op_deps.empty(), true, platform::errors::InvalidArgument( - "There are unvisited ops.")); + PADDLE_ENFORCE_EQ( + op_deps.empty(), true, + platform::errors::InvalidArgument("There are unvisited ops.")); } } // namespace ir diff --git a/paddle/fluid/framework/ir/memory_optimize_pass/recurrent_op_eager_deletion_pass.cc b/paddle/fluid/framework/ir/memory_optimize_pass/recurrent_op_eager_deletion_pass.cc index 6077069ea747a60b5989c5da373536e6654b2b74..b1fdb5e2160e00ebfdca537a62fd76358bab8b09 100644 --- a/paddle/fluid/framework/ir/memory_optimize_pass/recurrent_op_eager_deletion_pass.cc +++ b/paddle/fluid/framework/ir/memory_optimize_pass/recurrent_op_eager_deletion_pass.cc @@ -26,9 +26,9 @@ namespace paddle { namespace framework { namespace ir { +using paddle::operators::OpAndGradOpPair; using paddle::operators::OpVariant; using paddle::operators::OpVariantSet; -using paddle::operators::OpAndGradOpPair; void RecurrentOpEagerDeletionPass::ApplyImpl(Graph *graph) const { // Find all recurrent_op and recurrent_grad_op in graph diff --git a/paddle/fluid/framework/ir/memory_optimize_pass/share_varinfo_into_cinn_pass.cc b/paddle/fluid/framework/ir/memory_optimize_pass/share_varinfo_into_cinn_pass.cc index 313b2cc33459e0c48527113760f3147a607f3f45..3f88aaad57e268034412b1505484e4d7938e71d3 100644 --- a/paddle/fluid/framework/ir/memory_optimize_pass/share_varinfo_into_cinn_pass.cc +++ b/paddle/fluid/framework/ir/memory_optimize_pass/share_varinfo_into_cinn_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/framework/details/computation_op_handle.h" #include "paddle/fluid/framework/details/eager_deletion_op_handle.h" #include "paddle/fluid/framework/ir/graph_helper.h" diff --git a/paddle/fluid/framework/ir/memory_optimize_pass/share_varinfo_into_cinn_pass_test.cc b/paddle/fluid/framework/ir/memory_optimize_pass/share_varinfo_into_cinn_pass_test.cc index 88bf9e387639987525f56943da7a1e44871ba6bd..848b6e494ad6781a425793074ee27bee69375e64 100644 --- a/paddle/fluid/framework/ir/memory_optimize_pass/share_varinfo_into_cinn_pass_test.cc +++ b/paddle/fluid/framework/ir/memory_optimize_pass/share_varinfo_into_cinn_pass_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "gtest/gtest.h" #include "paddle/fluid/framework/details/computation_op_handle.h" #include "paddle/fluid/framework/details/eager_deletion_op_handle.h" diff --git a/paddle/fluid/framework/ir/mixed_precision_configure_pass.cc b/paddle/fluid/framework/ir/mixed_precision_configure_pass.cc index 4aa59d9196b1b4d73fffa8f1b2a9bba08d6091be..80f201d2d5afce4aa54450f6733c23558e83d3f1 100644 --- a/paddle/fluid/framework/ir/mixed_precision_configure_pass.cc +++ b/paddle/fluid/framework/ir/mixed_precision_configure_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/mixed_precision_configure_pass.h" + #include "paddle/fluid/framework/ir/graph_helper.h" #include "paddle/fluid/framework/op_version_registry.h" @@ -25,9 +26,10 @@ void MixedPrecisionConfigurePass::InsertCastOps( VLOG(3) << "Insert the cast op before and after the kernel that does not " "supports fp16 precision"; - auto update_cast_desc = [&]( - framework::OpDesc& desc, const std::string& x_name, - const std::string& out_name, const int in_dtype, const int out_dtype) { + auto update_cast_desc = [&](framework::OpDesc& desc, + const std::string& x_name, + const std::string& out_name, const int in_dtype, + const int out_dtype) { desc.SetType("cast"); desc.SetInput("X", {x_name}); desc.SetOutput("Out", {out_name}); diff --git a/paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass.cc index 9f6cd8992dcb9b5100ff88112117567cbd7c478c..62145cb6a0fb1c98e7ec928c3866bc86bba929a0 100644 --- a/paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass.h" + #include "paddle/fluid/framework/ir/graph_pattern_detector.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass_tester.cc index e13d44ac23222187a82753a027dd3585f423800b..b1b546f085cf80e1da7bbc7f598685385e69b597 100644 --- a/paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass_tester.cc @@ -34,7 +34,7 @@ void SetBatchNormAttrs(OpDesc* bn_op, bool is_test = true, bn_op->SetAttr("fuse_with_relu", false); bn_op->SetAttr("epsilon", 0.001f); } -} +} // namespace // ------------------------------ Test cases ----------------------------------- @@ -48,11 +48,12 @@ TEST(FuseBatchNormActOneDNNPass, ThrowIsTestTrainableStats) { auto prog = test::BuildProgramDesc( {"x", "m", "v", "bn_y", "act_y", "m_out", "var_out", "sm", "sv"}, {"scale", "bias"}); - auto* bn_op = test::CreateOp(&prog, "batch_norm", {{"X", "x"}, - {"Scale", "scale"}, - {"Bias", "bias"}, - {"Mean", "m"}, - {"Variance", "v"}}, + auto* bn_op = test::CreateOp(&prog, "batch_norm", + {{"X", "x"}, + {"Scale", "scale"}, + {"Bias", "bias"}, + {"Mean", "m"}, + {"Variance", "v"}}, {{"Y", "bn_y"}, {"MeanOut", "m_out"}, {"VarianceOut", "var_out"}, @@ -73,11 +74,12 @@ TEST(FuseBatchNormActOneDNNPass, ThrowIsTestTrainableStats) { TEST(FuseBatchNormActOneDNNPass, FuseIsTest) { auto prog = test::BuildProgramDesc({"x", "m", "v", "bn_y", "act_y"}, {"scale", "bias"}); - auto* bn_op = test::CreateOp(&prog, "batch_norm", {{"X", "x"}, - {"Scale", "scale"}, - {"Bias", "bias"}, - {"Mean", "m"}, - {"Variance", "v"}}, + auto* bn_op = test::CreateOp(&prog, "batch_norm", + {{"X", "x"}, + {"Scale", "scale"}, + {"Bias", "bias"}, + {"Mean", "m"}, + {"Variance", "v"}}, {{"Y", "bn_y"}}); SetBatchNormAttrs(bn_op, true, false); test::CreateOp(&prog, "relu", {{"X", "bn_y"}}, {{"Out", "act_y"}}, false); @@ -106,11 +108,12 @@ TEST(FuseBatchNormActOneDNNPass, ThrowTrainableStats) { auto prog = test::BuildProgramDesc( {"x", "m", "v", "bn_y", "act_y", "m_out", "var_out", "sm", "sv"}, {"scale", "bias"}); - auto* bn_op = test::CreateOp(&prog, "batch_norm", {{"X", "x"}, - {"Scale", "scale"}, - {"Bias", "bias"}, - {"Mean", "m"}, - {"Variance", "v"}}, + auto* bn_op = test::CreateOp(&prog, "batch_norm", + {{"X", "x"}, + {"Scale", "scale"}, + {"Bias", "bias"}, + {"Mean", "m"}, + {"Variance", "v"}}, {{"Y", "bn_y"}, {"MeanOut", "m_out"}, {"VarianceOut", "var_out"}, @@ -132,11 +135,12 @@ TEST(FuseBatchNormActOneDNNPass, AllAttrsFalse) { auto prog = test::BuildProgramDesc( {"x", "m", "v", "bn_y", "act_y", "m_out", "var_out", "sm", "sv"}, {"scale", "bias"}); - auto* bn_op = test::CreateOp(&prog, "batch_norm", {{"X", "x"}, - {"Scale", "scale"}, - {"Bias", "bias"}, - {"Mean", "m"}, - {"Variance", "v"}}, + auto* bn_op = test::CreateOp(&prog, "batch_norm", + {{"X", "x"}, + {"Scale", "scale"}, + {"Bias", "bias"}, + {"Mean", "m"}, + {"Variance", "v"}}, {{"Y", "bn_y"}, {"MeanOut", "m_out"}, {"VarianceOut", "var_out"}, @@ -158,11 +162,12 @@ TEST(FuseBatchNormActOneDNNPass, ThrowUseMkldnn) { auto prog = test::BuildProgramDesc( {"x", "m", "v", "bn_y", "act_y", "m_out", "var_out", "sm", "sv"}, {"scale", "bias"}); - auto* bn_op = test::CreateOp(&prog, "batch_norm", {{"X", "x"}, - {"Scale", "scale"}, - {"Bias", "bias"}, - {"Mean", "m"}, - {"Variance", "v"}}, + auto* bn_op = test::CreateOp(&prog, "batch_norm", + {{"X", "x"}, + {"Scale", "scale"}, + {"Bias", "bias"}, + {"Mean", "m"}, + {"Variance", "v"}}, {{"Y", "bn_y"}, {"MeanOut", "m_out"}, {"VarianceOut", "var_out"}, diff --git a/paddle/fluid/framework/ir/mkldnn/compute_propagate_scales_mkldnn_pass.cc b/paddle/fluid/framework/ir/mkldnn/compute_propagate_scales_mkldnn_pass.cc index d7d0b988b551eb2fb4d06795b5111e9a6e9daa91..e19426d01d195c33eb6a58af4578d16c0b679a86 100644 --- a/paddle/fluid/framework/ir/mkldnn/compute_propagate_scales_mkldnn_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/compute_propagate_scales_mkldnn_pass.cc @@ -12,11 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/framework/ir/mkldnn/compute_propagate_scales_mkldnn_pass.h" + #include + #include #include "paddle/fluid/framework/ir/graph_helper.h" -#include "paddle/fluid/framework/ir/mkldnn/compute_propagate_scales_mkldnn_pass.h" #include "paddle/fluid/framework/ir/mkldnn/mkldnn_pass_util.h" #include "paddle/fluid/framework/op_version_registry.h" diff --git a/paddle/fluid/framework/ir/mkldnn/compute_propagate_scales_mkldnn_pass.h b/paddle/fluid/framework/ir/mkldnn/compute_propagate_scales_mkldnn_pass.h index b0076c1b38cd46ad9aed28f3418c1da1dd5a33cd..26fb6e4978ff5755387c586241c0ad25e0327125 100644 --- a/paddle/fluid/framework/ir/mkldnn/compute_propagate_scales_mkldnn_pass.h +++ b/paddle/fluid/framework/ir/mkldnn/compute_propagate_scales_mkldnn_pass.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/framework/ir/fuse_pass_base.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/mkldnn/conv_activation_mkldnn_fuse_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/conv_activation_mkldnn_fuse_pass_tester.cc index 1fefab805b1d3620e3f8b966ac77d2f9c10b70fa..e3db85471766f11547e68246c33463ea53001959 100644 --- a/paddle/fluid/framework/ir/mkldnn/conv_activation_mkldnn_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/conv_activation_mkldnn_fuse_pass_tester.cc @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/mkldnn/conv_activation_mkldnn_fuse_pass.h" - #include + #include + +#include "paddle/fluid/framework/ir/mkldnn/conv_activation_mkldnn_fuse_pass.h" #include "paddle/fluid/framework/op_proto_maker.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/mkldnn/conv_bias_mkldnn_fuse_pass.h b/paddle/fluid/framework/ir/mkldnn/conv_bias_mkldnn_fuse_pass.h index a74d7443ee1fe13212c6514d415a16d6f0cb2f5b..18e09173491da877e4e92a105aad58320271de68 100644 --- a/paddle/fluid/framework/ir/mkldnn/conv_bias_mkldnn_fuse_pass.h +++ b/paddle/fluid/framework/ir/mkldnn/conv_bias_mkldnn_fuse_pass.h @@ -23,8 +23,8 @@ namespace paddle { namespace framework { namespace ir { /* -* Fuse the Conv and Elementwise_add to a ConvBiasOp. -*/ + * Fuse the Conv and Elementwise_add to a ConvBiasOp. + */ class Graph; class ConvBiasFusePass : public FusePassBase { @@ -38,8 +38,8 @@ class ConvBiasFusePass : public FusePassBase { const std::string name_scope_{"conv_bias_mkldnn_fuse"}; }; /* -* Fuse the Conv3D and Elementwise_add to a Conv3DBiasOp. -*/ + * Fuse the Conv3D and Elementwise_add to a Conv3DBiasOp. + */ class Conv2DTransposeBiasFusePass : public ConvBiasFusePass { public: Conv2DTransposeBiasFusePass(); diff --git a/paddle/fluid/framework/ir/mkldnn/conv_bias_mkldnn_fuse_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/conv_bias_mkldnn_fuse_pass_tester.cc index e9850483ebe913e298dc7501ed4155fb0dfc2879..0e052debaeeb2a3951f5d3263b1ef41edfcbba26 100644 --- a/paddle/fluid/framework/ir/mkldnn/conv_bias_mkldnn_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/conv_bias_mkldnn_fuse_pass_tester.cc @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/mkldnn/conv_bias_mkldnn_fuse_pass.h" #include -#include "paddle/fluid/framework/naive_executor.h" -#include "paddle/fluid/platform/place.h" +#include "paddle/fluid/framework/ir/mkldnn/conv_bias_mkldnn_fuse_pass.h" +#include "paddle/fluid/framework/naive_executor.h" #include "paddle/fluid/framework/op_proto_maker.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/imperative/type_defs.h" +#include "paddle/fluid/platform/place.h" namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/ir/mkldnn/conv_concat_relu_mkldnn_fuse_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/conv_concat_relu_mkldnn_fuse_pass_tester.cc index 6b648608ca1d2a24eeba79dc76a9e6d3b77fb3f2..7d165b1a38a463c10b31f61fe18e8d8a81bedaac 100644 --- a/paddle/fluid/framework/ir/mkldnn/conv_concat_relu_mkldnn_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/conv_concat_relu_mkldnn_fuse_pass_tester.cc @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/mkldnn/conv_concat_relu_mkldnn_fuse_pass.h" - #include + +#include "paddle/fluid/framework/ir/mkldnn/conv_concat_relu_mkldnn_fuse_pass.h" #include "paddle/fluid/framework/op_proto_maker.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/mkldnn/cpu_bfloat16_pass.cc b/paddle/fluid/framework/ir/mkldnn/cpu_bfloat16_pass.cc index 879c669bbbee6a0e090e8759dc8d0d9215ba7b92..58eec79344dd5e87c79bfd601b7caa8e24f0cdcb 100644 --- a/paddle/fluid/framework/ir/mkldnn/cpu_bfloat16_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/cpu_bfloat16_pass.cc @@ -226,7 +226,7 @@ class DeQuantizer final : public Quanter { return Quanter::create_quant_op(output_name, input_name); } }; -} +} // namespace using string::PrettyLogDetail; void CPUBFloat16Pass::ApplyImpl(ir::Graph* graph) const { diff --git a/paddle/fluid/framework/ir/mkldnn/cpu_quantize_pass.cc b/paddle/fluid/framework/ir/mkldnn/cpu_quantize_pass.cc index a61c043b580653b751fd1d0b0e106683bed275de..452212664ec93999e0168d81df2c83e6783ec6fc 100644 --- a/paddle/fluid/framework/ir/mkldnn/cpu_quantize_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/cpu_quantize_pass.cc @@ -12,11 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/framework/ir/mkldnn/cpu_quantize_pass.h" + #include #include #include -#include "paddle/fluid/framework/ir/mkldnn/cpu_quantize_pass.h" #include "paddle/fluid/framework/ir/mkldnn/mkldnn_pass_util.h" #include "paddle/fluid/platform/mkldnn_helper.h" #include "paddle/fluid/string/pretty_log.h" diff --git a/paddle/fluid/framework/ir/mkldnn/cpu_quantize_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/cpu_quantize_pass_tester.cc index 912c16288c2b9edec544412682106f8852ab75a7..fb36365ac54ef4d49b663ae495ffc078e1430746 100644 --- a/paddle/fluid/framework/ir/mkldnn/cpu_quantize_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/cpu_quantize_pass_tester.cc @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/mkldnn/cpu_quantize_pass.h" // NOLINT #include + #include +#include "paddle/fluid/framework/ir/mkldnn/cpu_quantize_pass.h" // NOLINT #include "paddle/fluid/framework/naive_executor.h" #include "paddle/fluid/imperative/type_defs.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/framework/ir/mkldnn/cpu_quantize_placement_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/cpu_quantize_placement_pass_tester.cc index 350fad2c672d4c9f238ca76c63f908e57d42bc4d..f6e5279ed23af01dfb4c97c6556921d999a109c5 100644 --- a/paddle/fluid/framework/ir/mkldnn/cpu_quantize_placement_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/cpu_quantize_placement_pass_tester.cc @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/mkldnn/cpu_quantize_placement_pass.h" - #include + +#include "paddle/fluid/framework/ir/mkldnn/cpu_quantize_placement_pass.h" #include "paddle/fluid/platform/mkldnn_helper.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/mkldnn/depthwise_conv_mkldnn_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/depthwise_conv_mkldnn_pass_tester.cc index 06940b38ea8e005c59c3c2604f6a6bb822b84511..979c601ac04c99e85abc24f3f46bca991eef6bb9 100644 --- a/paddle/fluid/framework/ir/mkldnn/depthwise_conv_mkldnn_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/depthwise_conv_mkldnn_pass_tester.cc @@ -12,10 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/mkldnn/depthwise_conv_mkldnn_pass.h" - #include +#include "paddle/fluid/framework/ir/mkldnn/depthwise_conv_mkldnn_pass.h" #include "paddle/fluid/framework/op_version_registry.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/mkldnn/elt_act_mkldnn_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/elt_act_mkldnn_fuse_pass.cc index b7f7a8071d21413f45d86e98b8649a3aaba5d2f5..2a8a248a99faf3037c27212bc6bd13e0955b6c71 100644 --- a/paddle/fluid/framework/ir/mkldnn/elt_act_mkldnn_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/elt_act_mkldnn_fuse_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/mkldnn/elt_act_mkldnn_fuse_pass.h" + #include "paddle/fluid/framework/ir/graph_pattern_detector.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/ir/mkldnn/fc_act_mkldnn_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/fc_act_mkldnn_fuse_pass.cc index 7fc8806452b883040fca1e71ba785583429f6cf3..afcd493f92f565dee429c6864c629b7c451628f6 100644 --- a/paddle/fluid/framework/ir/mkldnn/fc_act_mkldnn_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/fc_act_mkldnn_fuse_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/mkldnn/fc_act_mkldnn_fuse_pass.h" + #include "paddle/fluid/framework/ir/graph_pattern_detector.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/ir/mkldnn/fc_act_mkldnn_fuse_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/fc_act_mkldnn_fuse_pass_tester.cc index 59d81cb86474d5e17ba29dd6c72581ff8c13b41d..4b158ccc5a8b0baabb9dbb35f349d79c705cd707 100644 --- a/paddle/fluid/framework/ir/mkldnn/fc_act_mkldnn_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/fc_act_mkldnn_fuse_pass_tester.cc @@ -32,7 +32,9 @@ TEST(FuseFCActOneDNNPass, ThrowUseMkldnn) { test::BuildProgramDesc({"x", "fc_y", "act_y"}, {"weights", "bias"}); test::CreateOp(&prog, "fc", { - {"Input", "x"}, {"Weights", "weights"}, {"Bias", "bias"}, + {"Input", "x"}, + {"Weights", "weights"}, + {"Bias", "bias"}, }, {{"Out", "fc_y"}}, false); test::CreateOp(&prog, "gelu", {{"Input", "fc_y"}}, {{"Out", "act_y"}}, false); @@ -51,7 +53,9 @@ TEST(FuseFCActOneDNNPass, FuseWithGeluTanh) { test::BuildProgramDesc({"x", "fc_y", "act_y"}, {"weights", "bias"}); test::CreateOp(&prog, "fc", { - {"Input", "x"}, {"Weights", "weights"}, {"Bias", "bias"}, + {"Input", "x"}, + {"Weights", "weights"}, + {"Bias", "bias"}, }, {{"Out", "fc_y"}}); auto* act_op = test::CreateOp(&prog, "gelu", {{"Input", "fc_y"}}, @@ -83,7 +87,9 @@ TEST(FuseFCActOneDNNPass, FuseWithGeluErf) { test::BuildProgramDesc({"x", "fc_y", "act_y"}, {"weights", "bias"}); test::CreateOp(&prog, "fc", { - {"Input", "x"}, {"Weights", "weights"}, {"Bias", "bias"}, + {"Input", "x"}, + {"Weights", "weights"}, + {"Bias", "bias"}, }, {{"Out", "fc_y"}}); auto* act_op = test::CreateOp(&prog, "gelu", {{"Input", "fc_y"}}, @@ -115,7 +121,9 @@ TEST(FuseFCActOneDNNPass, FuseWithGeluAuto) { test::BuildProgramDesc({"x", "fc_y", "act_y"}, {"weights", "bias"}); test::CreateOp(&prog, "fc", { - {"Input", "x"}, {"Weights", "weights"}, {"Bias", "bias"}, + {"Input", "x"}, + {"Weights", "weights"}, + {"Bias", "bias"}, }, {{"Out", "fc_y"}}); test::CreateOp(&prog, "gelu", {{"Input", "fc_y"}}, {{"Out", "act_y"}}, false); @@ -145,7 +153,9 @@ TEST(FuseFCActOneDNNPass, FuseWithTanh) { test::BuildProgramDesc({"x", "fc_y", "act_y"}, {"weights", "bias"}); test::CreateOp(&prog, "fc", { - {"Input", "x"}, {"Weights", "weights"}, {"Bias", "bias"}, + {"Input", "x"}, + {"Weights", "weights"}, + {"Bias", "bias"}, }, {{"Out", "fc_y"}}); test::CreateOp(&prog, "tanh", {{"Input", "fc_y"}}, {{"Out", "act_y"}}, false); @@ -175,7 +185,9 @@ TEST(FuseFCActOneDNNPass, FuseWithSigmoid) { test::BuildProgramDesc({"x", "fc_y", "act_y"}, {"weights", "bias"}); test::CreateOp(&prog, "fc", { - {"Input", "x"}, {"Weights", "weights"}, {"Bias", "bias"}, + {"Input", "x"}, + {"Weights", "weights"}, + {"Bias", "bias"}, }, {{"Out", "fc_y"}}); test::CreateOp(&prog, "sigmoid", {{"Input", "fc_y"}}, {{"Out", "act_y"}}, @@ -206,7 +218,9 @@ TEST(FuseFCActOneDNNPass, FuseWithMish) { test::BuildProgramDesc({"x", "fc_y", "act_y"}, {"weights", "bias"}); test::CreateOp(&prog, "fc", { - {"Input", "x"}, {"Weights", "weights"}, {"Bias", "bias"}, + {"Input", "x"}, + {"Weights", "weights"}, + {"Bias", "bias"}, }, {{"Out", "fc_y"}}); test::CreateOp(&prog, "mish", {{"Input", "fc_y"}}, {{"Out", "act_y"}}, false); @@ -236,7 +250,9 @@ TEST(FuseFCActOneDNNPass, FuseWithHardSwish) { test::BuildProgramDesc({"x", "fc_y", "act_y"}, {"weights", "bias"}); test::CreateOp(&prog, "fc", { - {"Input", "x"}, {"Weights", "weights"}, {"Bias", "bias"}, + {"Input", "x"}, + {"Weights", "weights"}, + {"Bias", "bias"}, }, {{"Out", "fc_y"}}); test::CreateOp(&prog, "hard_swish", {{"Input", "fc_y"}}, {{"Out", "act_y"}}, diff --git a/paddle/fluid/framework/ir/mkldnn/fc_elementwise_add_mkldnn_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/fc_elementwise_add_mkldnn_fuse_pass.cc index 2e62597f2ee29a906e6fb17abd25a21e76f0a71d..60856512779ff8808288d6722b0e0c638c70472e 100644 --- a/paddle/fluid/framework/ir/mkldnn/fc_elementwise_add_mkldnn_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/fc_elementwise_add_mkldnn_fuse_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/mkldnn/fc_elementwise_add_mkldnn_fuse_pass.h" + #include "paddle/fluid/framework/ir/graph_traits.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/string/pretty_log.h" diff --git a/paddle/fluid/framework/ir/mkldnn/int8_scale_calculation_mkldnn_pass.cc b/paddle/fluid/framework/ir/mkldnn/int8_scale_calculation_mkldnn_pass.cc index 678a8fb4a6955626f153b104a926ea7e5e66ff51..a5481f5c6f30e0027a768515a5f20a525525352d 100644 --- a/paddle/fluid/framework/ir/mkldnn/int8_scale_calculation_mkldnn_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/int8_scale_calculation_mkldnn_pass.cc @@ -129,17 +129,13 @@ void Int8ScaleCalculationMkldnnPass::ApplyImpl(ir::Graph* graph) const { bool has_activation = !conv_op->Op()->GetAttrIfExists("fuse_activation").empty(); float activation_scale = - force_fp32_output - ? 1.0f - : has_activation - ? conv_op->Op()->GetAttrIfExists("Scale_out") - : 1.0f; + force_fp32_output ? 1.0f + : has_activation ? conv_op->Op()->GetAttrIfExists("Scale_out") + : 1.0f; auto scale_out_data = - force_fp32_output - ? 1.0f - : has_activation - ? 1.0f - : conv_op->Op()->GetAttrIfExists("Scale_out"); + force_fp32_output ? 1.0f + : has_activation ? 1.0f + : conv_op->Op()->GetAttrIfExists("Scale_out"); float sum_scale = fuse_residual_conn ? scale_out_data / scale_in_eltwise_data : 1.0f; diff --git a/paddle/fluid/framework/ir/mkldnn/int8_scale_calculation_mkldnn_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/int8_scale_calculation_mkldnn_pass_tester.cc index 804d04e35f6909d070db3e9310aa5a006ee2f7c2..9d3940c96644b6747f9c4fc5dd963dc4f02e8eb5 100644 --- a/paddle/fluid/framework/ir/mkldnn/int8_scale_calculation_mkldnn_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/int8_scale_calculation_mkldnn_pass_tester.cc @@ -12,9 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/mkldnn/int8_scale_calculation_mkldnn_pass.h" #include +#include "paddle/fluid/framework/ir/mkldnn/int8_scale_calculation_mkldnn_pass.h" + namespace paddle { namespace framework { namespace ir { diff --git a/paddle/fluid/framework/ir/mkldnn/interpolate_mkldnn_pass.cc b/paddle/fluid/framework/ir/mkldnn/interpolate_mkldnn_pass.cc index 4eb532b47cb4b59cb3df0fe775400caa01354269..1ed36e06fb19faa8786f973d1b18f8863d8043d2 100644 --- a/paddle/fluid/framework/ir/mkldnn/interpolate_mkldnn_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/interpolate_mkldnn_pass.cc @@ -13,8 +13,10 @@ // limitations under the License. #include "paddle/fluid/framework/ir/mkldnn/interpolate_mkldnn_pass.h" + #include #include + #include "paddle/fluid/platform/enforce.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/mkldnn/matmul_transpose_reshape_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/matmul_transpose_reshape_fuse_pass.cc index 34a35877a7f2565f8a8903fab21ce1486073b837..f6c99a477bcd8f7cd5e3ef7cb7db7747870a27d3 100644 --- a/paddle/fluid/framework/ir/mkldnn/matmul_transpose_reshape_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/matmul_transpose_reshape_fuse_pass.cc @@ -13,8 +13,11 @@ // limitations under the License. #include "paddle/fluid/framework/ir/mkldnn/matmul_transpose_reshape_fuse_pass.h" + #include + #include + #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/ir/mkldnn/matmul_transpose_reshape_fuse_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/matmul_transpose_reshape_fuse_pass_tester.cc index ed99989cf382f1d03762e13460f7f6b2cf91f1b1..ddb9e717392e1701de2e8dd26e7fa1ae601fa6dc 100644 --- a/paddle/fluid/framework/ir/mkldnn/matmul_transpose_reshape_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/matmul_transpose_reshape_fuse_pass_tester.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/framework/ir/mkldnn/matmul_v2_transpose_reshape_fuse_pass.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/mkldnn/matmul_v2_transpose_reshape_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/matmul_v2_transpose_reshape_fuse_pass.cc index dcf4664d963da77b7d480c7de14d692ad34238e4..6e106fa9dae5fc1847da8b3d1542555ee644da59 100644 --- a/paddle/fluid/framework/ir/mkldnn/matmul_v2_transpose_reshape_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/matmul_v2_transpose_reshape_fuse_pass.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/framework/ir/mkldnn/matmul_v2_transpose_reshape_fuse_pass.h" + #include + #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/ir/mkldnn/mkldnn_conv_bn_fuse_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/mkldnn_conv_bn_fuse_pass_tester.cc index 4236dc55d518686b97ea47aa12e756eb39304f35..06e0db4c93ea0d8c584a39fbcc6230830de6fb54 100644 --- a/paddle/fluid/framework/ir/mkldnn/mkldnn_conv_bn_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/mkldnn_conv_bn_fuse_pass_tester.cc @@ -12,12 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include #include #include #include -#include - #include "gtest/gtest.h" #include "paddle/fluid/framework/ir/graph_traits.h" #include "paddle/fluid/framework/ir/mkldnn/conv_elementwise_add_mkldnn_fuse_pass.h" diff --git a/paddle/fluid/framework/ir/mkldnn/mkldnn_fc_rnn_fuse_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/mkldnn_fc_rnn_fuse_pass_tester.cc index c4770a322db50c495f9d47aba3d338615fa36219..1ca9e76f79d6f73cb7c15641c47a4bb18f1f7ce3 100644 --- a/paddle/fluid/framework/ir/mkldnn/mkldnn_fc_rnn_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/mkldnn_fc_rnn_fuse_pass_tester.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/framework/ir/fc_gru_fuse_pass_tester.h" #include "paddle/fluid/framework/ir/fc_lstm_fuse_pass_tester.h" #include "paddle/fluid/framework/ir/mkldnn/mkldnn_placement_pass.h" diff --git a/paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass.cc b/paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass.cc index d2763bd6a6dc0fe9fac9cdc6b8abdf7ee0853c4b..ae8dbceb7a64cc22635cae4bbb90ff807beb4957 100644 --- a/paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass.cc @@ -13,12 +13,14 @@ // limitations under the License. #include "paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass.h" + #include #include #include #include #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/op_info.h" diff --git a/paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass.h b/paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass.h index 44b6d110db82c9331808c581d1c77ef118940012..880630055e91637a2baf67ee206f7dcbc5fc5a2e 100644 --- a/paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass.h +++ b/paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass.h @@ -13,6 +13,7 @@ // limitations under the License. #pragma once #include + #include "paddle/fluid/framework/ir/graph.h" #include "paddle/fluid/framework/ir/graph_pattern_detector.h" #include "paddle/fluid/framework/ir/pass.h" diff --git a/paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass_tester.cc index 7df957b2c0eca64bacd1b48065f37ddffec1770a..7f4e5d32536a08eecc5d5fb5c8e7c8f3a5cd8183 100644 --- a/paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass_tester.cc @@ -12,13 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass.h" - #include -#include #include +#include +#include "paddle/fluid/framework/ir/mkldnn/mkldnn_inplace_pass.h" #include "paddle/fluid/framework/ir/pass_tester_helper.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/framework/ir/mkldnn/mkldnn_pass_util.h b/paddle/fluid/framework/ir/mkldnn/mkldnn_pass_util.h index 505bb2739e1d45a0ff35e41a6324ee08275f8d1c..99a55b26e99dbd777954adfbe70cfcb1e81564c1 100644 --- a/paddle/fluid/framework/ir/mkldnn/mkldnn_pass_util.h +++ b/paddle/fluid/framework/ir/mkldnn/mkldnn_pass_util.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/framework/ir/graph_helper.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/mkldnn/mkldnn_placement_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/mkldnn_placement_pass_tester.cc index 4012e04f7d2af5ec434dfacba0cdb81f3a955575..671ad4c1c4b2f0125068f6179e6ddda463fe7a16 100644 --- a/paddle/fluid/framework/ir/mkldnn/mkldnn_placement_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/mkldnn_placement_pass_tester.cc @@ -12,11 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/mkldnn/mkldnn_placement_pass.h" - #include + #include +#include "paddle/fluid/framework/ir/mkldnn/mkldnn_placement_pass.h" + namespace paddle { namespace framework { namespace ir { diff --git a/paddle/fluid/framework/ir/mkldnn/multi_gru_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/multi_gru_fuse_pass.cc index 76a0c883c8923341f538a501ed8d0f091c35ee7c..73089df5717658b02844656063ecb04c545ef557 100644 --- a/paddle/fluid/framework/ir/mkldnn/multi_gru_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/multi_gru_fuse_pass.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/framework/ir/mkldnn/multi_gru_fuse_pass.h" + #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/ir/graph_pattern_detector.h" #include "paddle/fluid/platform/errors.h" diff --git a/paddle/fluid/framework/ir/mkldnn/multi_gru_fuse_pass.h b/paddle/fluid/framework/ir/mkldnn/multi_gru_fuse_pass.h index 70f88104b4b524ded7ab7acfafdd010a42036fa3..cf53ecec9262ea0fb1b7ef684412ce6c8996f0fc 100644 --- a/paddle/fluid/framework/ir/mkldnn/multi_gru_fuse_pass.h +++ b/paddle/fluid/framework/ir/mkldnn/multi_gru_fuse_pass.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/framework/ir/fuse_pass_base.h" #include "paddle/fluid/framework/ir/graph.h" diff --git a/paddle/fluid/framework/ir/mkldnn/multi_gru_fuse_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/multi_gru_fuse_pass_tester.cc index 7b6681ff967844f3bf99ce3cc8023e748784cf73..60890336b305268c26f3810b54efd18bc1200ead 100644 --- a/paddle/fluid/framework/ir/mkldnn/multi_gru_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/multi_gru_fuse_pass_tester.cc @@ -12,9 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/mkldnn/multi_gru_fuse_pass.h" #include +#include "paddle/fluid/framework/ir/mkldnn/multi_gru_fuse_pass.h" + namespace paddle { namespace framework { namespace ir { diff --git a/paddle/fluid/framework/ir/mkldnn/multi_gru_seq_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/multi_gru_seq_fuse_pass.cc index 7821501cc4b23ccdd50ac5bf9c187b2e19d488f9..06125e51fb65ec9c77bf9fab9571e24a8a8db43d 100644 --- a/paddle/fluid/framework/ir/mkldnn/multi_gru_seq_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/multi_gru_seq_fuse_pass.cc @@ -13,10 +13,12 @@ // limitations under the License. #include "paddle/fluid/framework/ir/mkldnn/multi_gru_seq_fuse_pass.h" + #include #include #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/ir/graph_pattern_detector.h" #include "paddle/fluid/platform/errors.h" diff --git a/paddle/fluid/framework/ir/mkldnn/multi_gru_seq_fuse_pass.h b/paddle/fluid/framework/ir/mkldnn/multi_gru_seq_fuse_pass.h index 546a3d6570b41ad0cf14115394a75aeb09a00131..af58ae2bda49c5e31904737c4cd6eb5ad743d16d 100644 --- a/paddle/fluid/framework/ir/mkldnn/multi_gru_seq_fuse_pass.h +++ b/paddle/fluid/framework/ir/mkldnn/multi_gru_seq_fuse_pass.h @@ -18,6 +18,7 @@ #include #include #include + #include "paddle/fluid/framework/ir/fuse_pass_base.h" #include "paddle/fluid/framework/ir/graph.h" #include "paddle/fluid/framework/ir/graph_pattern_detector.h" diff --git a/paddle/fluid/framework/ir/mkldnn/multi_gru_seq_fuse_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/multi_gru_seq_fuse_pass_tester.cc index 3738e3ebd68eba5cd9c3886ba57818eddb7e60eb..2924401bc2e6af8c71b36c083cd11b4e36971f07 100644 --- a/paddle/fluid/framework/ir/mkldnn/multi_gru_seq_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/multi_gru_seq_fuse_pass_tester.cc @@ -12,10 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/mkldnn/multi_gru_seq_fuse_pass.h" #include + #include +#include "paddle/fluid/framework/ir/mkldnn/multi_gru_seq_fuse_pass.h" + namespace paddle { namespace framework { namespace ir { diff --git a/paddle/fluid/framework/ir/mkldnn/quant_dequant_mkldnn_pass.cc b/paddle/fluid/framework/ir/mkldnn/quant_dequant_mkldnn_pass.cc index 63e402cb52983954da7daf7839fa9e7726c61af4..15100b23407b018e9c3b6ec2e35de6605941b9d4 100644 --- a/paddle/fluid/framework/ir/mkldnn/quant_dequant_mkldnn_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/quant_dequant_mkldnn_pass.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/framework/ir/mkldnn/quant_dequant_mkldnn_pass.h" + #include + #include "paddle/fluid/framework/ir/graph_helper.h" #include "paddle/fluid/framework/ir/mkldnn/mkldnn_pass_util.h" #include "paddle/fluid/framework/op_version_registry.h" @@ -124,10 +126,11 @@ void QuantDequantMkldnnPass::CollectInputScalesFromFake( auto* op_desc = op_node->Op(); const int bit_length = BOOST_GET_CONST(int, op_desc->GetAttr("bit_length")); - PADDLE_ENFORCE_EQ(bit_length, 8, platform::errors::InvalidArgument( - "Unsupported number quantization " - "bits: %d, only 8 is supported now.", - bit_length)); + PADDLE_ENFORCE_EQ(bit_length, 8, + platform::errors::InvalidArgument( + "Unsupported number quantization " + "bits: %d, only 8 is supported now.", + bit_length)); auto x_var_name = op_desc->Input("X")[0]; auto scale_name = op_desc->Input("InScale")[0]; diff --git a/paddle/fluid/framework/ir/mkldnn/quant_dequant_mkldnn_pass.h b/paddle/fluid/framework/ir/mkldnn/quant_dequant_mkldnn_pass.h index a9442f707402d922ac602fe64ba0eb1e35d9fa2b..5003e1878bfebccaf0727ae93ec857494b5c7090 100644 --- a/paddle/fluid/framework/ir/mkldnn/quant_dequant_mkldnn_pass.h +++ b/paddle/fluid/framework/ir/mkldnn/quant_dequant_mkldnn_pass.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/framework/ir/fuse_pass_base.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/mkldnn/reshape_transpose_matmul_mkldnn_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/reshape_transpose_matmul_mkldnn_fuse_pass.cc index 96f575745a3a2e3e9c2984941348ccea4ac8d4dd..05b1d419f6f4a0c960d61ca11049dfdcd5c0676a 100644 --- a/paddle/fluid/framework/ir/mkldnn/reshape_transpose_matmul_mkldnn_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/reshape_transpose_matmul_mkldnn_fuse_pass.cc @@ -13,9 +13,11 @@ // limitations under the License. #include "paddle/fluid/framework/ir/mkldnn/reshape_transpose_matmul_mkldnn_fuse_pass.h" + #include #include #include + #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/string/pretty_log.h" diff --git a/paddle/fluid/framework/ir/mkldnn/reshape_transpose_matmul_mkldnn_fuse_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/reshape_transpose_matmul_mkldnn_fuse_pass_tester.cc index e688635646001044cf682194e321e264fe5ee829..023dd6af7ee01c57a4f14dd476473e2eed174aca 100644 --- a/paddle/fluid/framework/ir/mkldnn/reshape_transpose_matmul_mkldnn_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/reshape_transpose_matmul_mkldnn_fuse_pass_tester.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + #include "paddle/fluid/framework/ir/mkldnn/reshape_transpose_matmul_mkldnn_fuse_pass.h" #include "paddle/fluid/framework/ir/mkldnn/reshape_transpose_matmul_v2_mkldnn_fuse_pass.h" - -#include #include "paddle/fluid/framework/ir/pass_tester_helper.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/mkldnn/reshape_transpose_matmul_v2_mkldnn_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/reshape_transpose_matmul_v2_mkldnn_fuse_pass.cc index 203966dc682f513989f5efc808f5c651526769f9..ed57be12c78e31a34918195ad2ff20747e1c39c6 100644 --- a/paddle/fluid/framework/ir/mkldnn/reshape_transpose_matmul_v2_mkldnn_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/reshape_transpose_matmul_v2_mkldnn_fuse_pass.cc @@ -13,9 +13,11 @@ // limitations under the License. #include "paddle/fluid/framework/ir/mkldnn/reshape_transpose_matmul_v2_mkldnn_fuse_pass.h" + #include #include #include + #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/string/pretty_log.h" diff --git a/paddle/fluid/framework/ir/mkldnn/scale_matmul_fuse_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/scale_matmul_fuse_pass_tester.cc index 60f844ffc80cea2bd1fefca31435575936f5bdf5..09bad959eb09fbc84966c27d36f9615b7c300571 100644 --- a/paddle/fluid/framework/ir/mkldnn/scale_matmul_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/scale_matmul_fuse_pass_tester.cc @@ -12,9 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/mkldnn/scale_matmul_fuse_pass.h" #include +#include "paddle/fluid/framework/ir/mkldnn/scale_matmul_fuse_pass.h" + namespace paddle { namespace framework { namespace ir { diff --git a/paddle/fluid/framework/ir/mkldnn/shuffle_channel_mkldnn_detect_pass.cc b/paddle/fluid/framework/ir/mkldnn/shuffle_channel_mkldnn_detect_pass.cc index bf603dc4bbcb9ddf6bfcff9326fa0cc05682050b..a7e0f3a583441ac5d9a6f05617d4b76dfb8fa9bd 100644 --- a/paddle/fluid/framework/ir/mkldnn/shuffle_channel_mkldnn_detect_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/shuffle_channel_mkldnn_detect_pass.cc @@ -12,9 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/framework/ir/mkldnn/shuffle_channel_mkldnn_detect_pass.h" + #include -#include "paddle/fluid/framework/ir/mkldnn/shuffle_channel_mkldnn_detect_pass.h" #include "paddle/fluid/framework/op_version_registry.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/mkldnn/shuffle_channel_mkldnn_detect_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/shuffle_channel_mkldnn_detect_pass_tester.cc index fe42e8f96f851c3b3a41d76fbab361dc4fae0347..86775e20aa73c74a83c8b43f2557c4a71618d058 100644 --- a/paddle/fluid/framework/ir/mkldnn/shuffle_channel_mkldnn_detect_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/shuffle_channel_mkldnn_detect_pass_tester.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include #include "paddle/fluid/framework/ir/mkldnn/shuffle_channel_mkldnn_detect_pass.h" diff --git a/paddle/fluid/framework/ir/mkldnn/softplus_activation_mkldnn_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/softplus_activation_mkldnn_fuse_pass.cc index 82d642264c2c4be4d82fed6bc68a3c985518f96e..cad92e3153b12e1534638aed0743c22e52b1387d 100644 --- a/paddle/fluid/framework/ir/mkldnn/softplus_activation_mkldnn_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/softplus_activation_mkldnn_fuse_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/mkldnn/softplus_activation_mkldnn_fuse_pass.h" + #include "paddle/fluid/framework/ir/graph_pattern_detector.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/ir/mkldnn/softplus_activation_mkldnn_fuse_pass_tester.cc b/paddle/fluid/framework/ir/mkldnn/softplus_activation_mkldnn_fuse_pass_tester.cc index 003a39f37d4a693787016e098fa4e1e3a38bda39..662dfb0f9d4f9e4a06a751cee448defa8cdfaccb 100644 --- a/paddle/fluid/framework/ir/mkldnn/softplus_activation_mkldnn_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/mkldnn/softplus_activation_mkldnn_fuse_pass_tester.cc @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/mkldnn/softplus_activation_mkldnn_fuse_pass.h" - #include + #include + +#include "paddle/fluid/framework/ir/mkldnn/softplus_activation_mkldnn_fuse_pass.h" #include "paddle/fluid/framework/op_proto_maker.h" namespace paddle { @@ -52,43 +53,27 @@ void MainTest(const std::string& activation_type) { } } -TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithTanh) { - MainTest("tanh") -} +TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithTanh){MainTest("tanh")} -TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithRelu) { - MainTest("relu") -} +TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithRelu){MainTest("relu")} -TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithLeakyRelu) { - MainTest("leaky_relu") -} +TEST(FuseSoftplusActivationOneDNNPass, + FuseSoftplusWithLeakyRelu){MainTest("leaky_relu")} -TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithSwish) { - MainTest("swish") -} +TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithSwish){MainTest("swish")} -TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithHardswish) { - MainTest("hardswish") -} +TEST(FuseSoftplusActivationOneDNNPass, + FuseSoftplusWithHardswish){MainTest("hardswish")} -TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithSqrt) { - MainTest("sqrt") -} +TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithSqrt){MainTest("sqrt")} -TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithAbs) { MainTest("abs") } +TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithAbs){MainTest("abs")} -TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithClip) { - MainTest("clip") -} +TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithClip){MainTest("clip")} -TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithGelu) { - MainTest("gelu") -} +TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithGelu){MainTest("gelu")} -TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithRelu6) { - MainTest("relu6") -} +TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithRelu6){MainTest("relu6")} TEST(FuseSoftplusActivationOneDNNPass, FuseSoftplusWithSigmoid) { MainTest("sigmoid") diff --git a/paddle/fluid/framework/ir/multi_batch_merge_pass.cc b/paddle/fluid/framework/ir/multi_batch_merge_pass.cc index 06af5eaec13bc84a480ff0f9bdc85fb7a7a43613..b849076935afeff47ecd4070f0d7e38dcf1c3102 100644 --- a/paddle/fluid/framework/ir/multi_batch_merge_pass.cc +++ b/paddle/fluid/framework/ir/multi_batch_merge_pass.cc @@ -15,6 +15,7 @@ #include "paddle/fluid/framework/ir/multi_batch_merge_pass.h" #include + #include "paddle/fluid/framework/ir/graph_helper.h" #include "paddle/fluid/framework/op_proto_maker.h" diff --git a/paddle/fluid/framework/ir/multi_devices_graph_pass/add_reader_dependency_pass.cc b/paddle/fluid/framework/ir/multi_devices_graph_pass/add_reader_dependency_pass.cc index abb1d062c96efe54b89583c6bedb56cdcf77256a..b907869b4a38e5e79350ca8c5faad8902d67d7b1 100644 --- a/paddle/fluid/framework/ir/multi_devices_graph_pass/add_reader_dependency_pass.cc +++ b/paddle/fluid/framework/ir/multi_devices_graph_pass/add_reader_dependency_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/framework/ir/pass.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/multi_devices_graph_pass/fix_op_run_order_pass.cc b/paddle/fluid/framework/ir/multi_devices_graph_pass/fix_op_run_order_pass.cc index 772b4c1c915cca917c0b3d1863182011a2e43595..55b6389768cb4a1a30d4b536eb8735baf19d8451 100644 --- a/paddle/fluid/framework/ir/multi_devices_graph_pass/fix_op_run_order_pass.cc +++ b/paddle/fluid/framework/ir/multi_devices_graph_pass/fix_op_run_order_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/framework/details/eager_deletion_op_handle.h" #include "paddle/fluid/framework/details/multi_devices_helper.h" #include "paddle/fluid/framework/details/op_handle_base.h" diff --git a/paddle/fluid/framework/ir/multi_devices_graph_pass/fuse_all_reduce_op_pass.cc b/paddle/fluid/framework/ir/multi_devices_graph_pass/fuse_all_reduce_op_pass.cc index 484d09fd4441de8f21192ce805ce9bd025d3fe8e..5189f410e3c7029c3629a5cd8827dcdd94b5aa01 100644 --- a/paddle/fluid/framework/ir/multi_devices_graph_pass/fuse_all_reduce_op_pass.cc +++ b/paddle/fluid/framework/ir/multi_devices_graph_pass/fuse_all_reduce_op_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/framework/details/all_reduce_op_handle.h" #include "paddle/fluid/framework/details/container_cast.h" #include "paddle/fluid/framework/details/fused_all_reduce_op_handle.h" diff --git a/paddle/fluid/framework/ir/multi_devices_graph_pass/multi_devices_graph_pass.cc b/paddle/fluid/framework/ir/multi_devices_graph_pass/multi_devices_graph_pass.cc index 1b6245928d377c7a1f972532e95954d3adee51e0..7180c3820c71eae53d1107c8c150a15ac519f824 100644 --- a/paddle/fluid/framework/ir/multi_devices_graph_pass/multi_devices_graph_pass.cc +++ b/paddle/fluid/framework/ir/multi_devices_graph_pass/multi_devices_graph_pass.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "paddle/fluid/framework/ir/multi_devices_graph_pass/multi_devices_graph_pass.h" + #include #include #include @@ -20,6 +21,7 @@ #include #include #include + #include "paddle/fluid/framework/details/all_reduce_op_handle.h" #include "paddle/fluid/framework/details/broadcast_op_handle.h" #include "paddle/fluid/framework/details/computation_op_handle.h" @@ -495,9 +497,9 @@ void MultiDevSSAGraphBuilderBase::CreateAllReduceOp(ir::Graph *result, "use_dgc=%d, use_grad_merge=%d", is_encoded, is_grad_merge)); - auto append_allreduce_op = [&]( - const std::vector &scopes, - const std::vector &places) -> details::OpHandleBase * { + auto append_allreduce_op = [&](const std::vector &scopes, + const std::vector &places) + -> details::OpHandleBase * { if (is_encoded) { #if defined(PADDLE_WITH_DGC) && \ (defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL)) @@ -758,13 +760,14 @@ int BalanceVarSSAGraphBuilder::GetOpDeviceID(ir::Node *node) const { "and Parameter@Grad.", node->Name(), OpProtoAndCheckerMaker::OpRoleVarAttrName())); int dev_id = GetVarDeviceID(param_grad[1]); - PADDLE_ENFORCE_NE(dev_id, -1, platform::errors::NotFound( - "Can not find Device ID, for NodeName:%s, " - "NodeType:%s, Param:%s, Param@Grad:%s" - "For this fault, you can consult the " - "Paddle technical personnel for answer ", - node->Name(), node->Op()->Type(), - param_grad[0], param_grad[1])); + PADDLE_ENFORCE_NE( + dev_id, -1, + platform::errors::NotFound("Can not find Device ID, for NodeName:%s, " + "NodeType:%s, Param:%s, Param@Grad:%s" + "For this fault, you can consult the " + "Paddle technical personnel for answer ", + node->Name(), node->Op()->Type(), + param_grad[0], param_grad[1])); return dev_id; } @@ -956,10 +959,11 @@ bool DistSSAGraphBuilder::DealWithSpecialOp(ir::Graph *result, bool insert_op = false; if (OpHaveRole(*node, OpRole::kRPC)) { int op_dev_id = CreateRPCOp(result, node); - PADDLE_ENFORCE_NE(op_dev_id, -1, platform::errors::InvalidArgument( - "Can not schedule the RPC operator to " - "the right place. NodeName:%s.", - node->Name())); + PADDLE_ENFORCE_NE(op_dev_id, -1, + platform::errors::InvalidArgument( + "Can not schedule the RPC operator to " + "the right place. NodeName:%s.", + node->Name())); if (node->Op()->Type() == "recv") { auto recv_vars_attr = BOOST_GET_CONST(std::vector, diff --git a/paddle/fluid/framework/ir/multi_devices_graph_pass/multi_devices_graph_pass.h b/paddle/fluid/framework/ir/multi_devices_graph_pass/multi_devices_graph_pass.h index c76f30016763a3bdd6c0fb7146bffe68e30bca3d..750807420776872a7cf0ec6b2e080e4c8efdff82 100644 --- a/paddle/fluid/framework/ir/multi_devices_graph_pass/multi_devices_graph_pass.h +++ b/paddle/fluid/framework/ir/multi_devices_graph_pass/multi_devices_graph_pass.h @@ -46,7 +46,7 @@ class NCCLContextMap; class BKCLContextMap; class BKCLCommunicator; #endif -} +} // namespace platform namespace framework { class Scope; diff --git a/paddle/fluid/framework/ir/multi_devices_graph_pass/set_reader_device_info_utils.cc b/paddle/fluid/framework/ir/multi_devices_graph_pass/set_reader_device_info_utils.cc index 09ef94c0826d78a798e0aa2313d41ce687db1595..c7b6e477fd5aa4c9daed07e094ad6fcf2e30c4fe 100644 --- a/paddle/fluid/framework/ir/multi_devices_graph_pass/set_reader_device_info_utils.cc +++ b/paddle/fluid/framework/ir/multi_devices_graph_pass/set_reader_device_info_utils.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/multi_devices_graph_pass/set_reader_device_info_utils.h" + #include "paddle/fluid/framework/details/computation_op_handle.h" #include "paddle/fluid/operators/reader/lod_tensor_blocking_queue.h" diff --git a/paddle/fluid/framework/ir/multihead_matmul_fuse_pass.cc b/paddle/fluid/framework/ir/multihead_matmul_fuse_pass.cc index 4a5947778056a162bf767102b674fa7f1a7d9d05..03d433f4db1658226631977209462b4c86ffe95c 100644 --- a/paddle/fluid/framework/ir/multihead_matmul_fuse_pass.cc +++ b/paddle/fluid/framework/ir/multihead_matmul_fuse_pass.cc @@ -51,11 +51,12 @@ static int BuildFusion(Graph* graph, const std::string& name_scope) { multihead_pattern(); // Create New OpDesc - auto fuse_creater = [&]( - Node* input0, Node* mul0, Node* mul1, Node* mul2, Node* mul0_out, - Node* mul1_out, Node* mul2_out, Node* eltadd0_b, Node* eltadd1_b, - Node* eltadd2_b, Node* eltadd_qk_b, Node* reshape2, - Node* reshape2_qkv_out, Node* scale, Node* scale_out) { + auto fuse_creater = [&](Node* input0, Node* mul0, Node* mul1, Node* mul2, + Node* mul0_out, Node* mul1_out, Node* mul2_out, + Node* eltadd0_b, Node* eltadd1_b, Node* eltadd2_b, + Node* eltadd_qk_b, Node* reshape2, + Node* reshape2_qkv_out, Node* scale, + Node* scale_out) { auto scale_attr = BOOST_GET_CONST(float, scale->Op()->GetAttr("scale")); // auto scale_bias = BOOST_GET_CONST(float, scale->Op()->GetAttr("bias")); // bool after_scale = @@ -756,13 +757,14 @@ int MultiHeadMatmulV2FusePass::BuildFusionV2(Graph* graph, multihead_pattern(); // Create New OpDesc - auto fuse_creater = [&]( - Node* input0, Node* mul0, Node* mul1, Node* mul2, Node* mul0_out, - Node* mul1_out, Node* mul2_out, Node* mul0_w, Node* mul1_w, Node* mul2_w, - Node* eltadd0_b, Node* eltadd1_b, Node* eltadd2_b, Node* eltadd_qk_b, - Node* reshape2, Node* reshape2_qkv_out, Node* scale, Node* scale_out, - Node* softmax_qk, Node* eltadd0, Node* eltadd1, Node* eltadd2, - Node* matmul_qk, Node* reshape2_qkv) { + auto fuse_creater = [&](Node* input0, Node* mul0, Node* mul1, Node* mul2, + Node* mul0_out, Node* mul1_out, Node* mul2_out, + Node* mul0_w, Node* mul1_w, Node* mul2_w, + Node* eltadd0_b, Node* eltadd1_b, Node* eltadd2_b, + Node* eltadd_qk_b, Node* reshape2, + Node* reshape2_qkv_out, Node* scale, Node* scale_out, + Node* softmax_qk, Node* eltadd0, Node* eltadd1, + Node* eltadd2, Node* matmul_qk, Node* reshape2_qkv) { auto scale_attr = BOOST_GET_CONST(float, scale->Op()->GetAttr("scale")); // mul (B * S * Hidden) x (Hidden * 3 * N * H) = (B * S * 3 * N * H) @@ -1207,11 +1209,12 @@ int MultiHeadMatmulV3FusePass::BuildFusionV3(Graph* graph, multihead_pattern(); // Create New OpDesc - auto fuse_creater = [&]( - Node* input0, Node* mul0, Node* mul1, Node* mul2, Node* mul0_out, - Node* mul1_out, Node* mul2_out, Node* mul0_w, Node* mul1_w, Node* mul2_w, - Node* eltadd0_b, Node* eltadd1_b, Node* eltadd2_b, Node* eltadd_qk_b, - Node* reshape2, Node* reshape2_qkv_out, Node* matmul_qk) { + auto fuse_creater = [&](Node* input0, Node* mul0, Node* mul1, Node* mul2, + Node* mul0_out, Node* mul1_out, Node* mul2_out, + Node* mul0_w, Node* mul1_w, Node* mul2_w, + Node* eltadd0_b, Node* eltadd1_b, Node* eltadd2_b, + Node* eltadd_qk_b, Node* reshape2, + Node* reshape2_qkv_out, Node* matmul_qk) { auto scale_attr = BOOST_GET_CONST(float, matmul_qk->Op()->GetAttr("alpha")); // mul (B * S * Hidden) x (Hidden * 3 * N * H) = (B * S * 3 * N * H) diff --git a/paddle/fluid/framework/ir/multihead_matmul_fuse_pass_tester.cc b/paddle/fluid/framework/ir/multihead_matmul_fuse_pass_tester.cc index b121436ee870b36052ae6195c26cadd90a299559..858ebf68b40fa4d33b7387b47831fd951e2aaf73 100644 --- a/paddle/fluid/framework/ir/multihead_matmul_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/multihead_matmul_fuse_pass_tester.cc @@ -9,8 +9,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/framework/ir/multihead_matmul_fuse_pass.h" // NOLINT #include + +#include "paddle/fluid/framework/ir/multihead_matmul_fuse_pass.h" // NOLINT #include "paddle/fluid/framework/ir/pass_tester_helper.h" #include "paddle/fluid/framework/op_version_registry.h" diff --git a/paddle/fluid/framework/ir/node_test.cc b/paddle/fluid/framework/ir/node_test.cc index 9c47df402bdf2d51b597e1771457f39f37e10ceb..2d84162e13aa6f193fe2f9248bd706e57fd95a03 100644 --- a/paddle/fluid/framework/ir/node_test.cc +++ b/paddle/fluid/framework/ir/node_test.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/ir/node.h" + #include "gtest/gtest.h" #include "paddle/fluid/framework/var_desc.h" diff --git a/paddle/fluid/framework/ir/op_compat_sensible_pass.cc b/paddle/fluid/framework/ir/op_compat_sensible_pass.cc index 73a8691f9e269000dfd3ff24e66b738646436df2..e309e068563e5a7c6c513f6015ec566e4d1f43f2 100644 --- a/paddle/fluid/framework/ir/op_compat_sensible_pass.cc +++ b/paddle/fluid/framework/ir/op_compat_sensible_pass.cc @@ -13,9 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/ir/op_compat_sensible_pass.h" + #include #include #include + #include "paddle/fluid/framework/op_def_api.h" #include "paddle/fluid/framework/op_info.h" diff --git a/paddle/fluid/framework/ir/op_compat_sensible_pass.h b/paddle/fluid/framework/ir/op_compat_sensible_pass.h index e24294a03a28a3b9fb16b17ddf921afc54509d87..393a2fb9392d5f7937e34858ce6371f9698ed553 100644 --- a/paddle/fluid/framework/ir/op_compat_sensible_pass.h +++ b/paddle/fluid/framework/ir/op_compat_sensible_pass.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/ir/graph.h" #include "paddle/fluid/framework/ir/graph_pattern_detector.h" #include "paddle/fluid/framework/ir/pass.h" diff --git a/paddle/fluid/framework/ir/op_compat_sensible_pass_tester.cc b/paddle/fluid/framework/ir/op_compat_sensible_pass_tester.cc index 756d3c2c7709636f36f98ad6dcdee1e67c53f5a3..4b106d75f1c75c11ec32015f0fd9995851bbee84 100644 --- a/paddle/fluid/framework/ir/op_compat_sensible_pass_tester.cc +++ b/paddle/fluid/framework/ir/op_compat_sensible_pass_tester.cc @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/framework/ir/op_compat_sensible_pass.h" #include "gtest/gtest.h" +#include "paddle/fluid/framework/ir/op_compat_sensible_pass.h" #include "paddle/fluid/framework/op_info.h" #include "paddle/fluid/framework/program_desc.h" diff --git a/paddle/fluid/framework/ir/pass.cc b/paddle/fluid/framework/ir/pass.cc index 2c10a68188eb49ac51c80b0503d0e8b0bd131475..85eecbd014e96b2c55ee0b2fd5f9dcfa9f746d75 100644 --- a/paddle/fluid/framework/ir/pass.cc +++ b/paddle/fluid/framework/ir/pass.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/fluid/framework/ir/pass.h" #include + #include "paddle/fluid/framework/ir/graph_helper.h" #include "paddle/fluid/framework/op_proto_maker.h" @@ -90,9 +91,10 @@ static void MergePrograms(ProgramDesc *dst, const details::ProgramDescs &srcs, bool reverse = !append; auto create_var_visitor = [dst](const ProgramDesc &src) { - PADDLE_ENFORCE_EQ(src.Size(), 1, platform::errors::Unimplemented( - "MergePrograms can only support to " - "merge program with only one block.")); + PADDLE_ENFORCE_EQ( + src.Size(), 1, + platform::errors::Unimplemented("MergePrograms can only support to " + "merge program with only one block.")); const auto &src_block = src.Block(0); auto *dst_block = dst->MutableBlock(0); for (const auto *src_new_var : src_block.AllVars()) { diff --git a/paddle/fluid/framework/ir/pass_test.cc b/paddle/fluid/framework/ir/pass_test.cc index 616ba7f1a97616fdc71ef7f313460ef003ab1e0a..8c368a796ed10aab28b5d1572e9f0b16e7f6567a 100644 --- a/paddle/fluid/framework/ir/pass_test.cc +++ b/paddle/fluid/framework/ir/pass_test.cc @@ -84,8 +84,9 @@ TEST(PassTest, TestPassAttrCheck) { } catch (paddle::platform::EnforceNotMet& e) { exception = std::string(e.what()); } - std::string msg = "Invalid type for attritube test_pass_attr, expected: " + - try_type + ", actual: int"; + std::string msg = + "Invalid type for attritube test_pass_attr, expected: " + try_type + + ", actual: int"; ASSERT_TRUE(exception.find(msg) != exception.npos); } @@ -168,8 +169,9 @@ TEST(PassTest, TestPassAttrCheckConvertAllBlocks) { } catch (paddle::platform::EnforceNotMet& e) { exception = std::string(e.what()); } - std::string msg = "Invalid type for attritube test_pass_attr, expected: " + - try_type + ", actual: int"; + std::string msg = + "Invalid type for attritube test_pass_attr, expected: " + try_type + + ", actual: int"; ASSERT_TRUE(exception.find(msg) != exception.npos); } diff --git a/paddle/fluid/framework/ir/pass_test_util.cc b/paddle/fluid/framework/ir/pass_test_util.cc index 4d8965918f889896db5f3f174d0b2c3219660992..40dcb3cf1dbd8a6efa2379ef03cb8b8a1f2f16d2 100644 --- a/paddle/fluid/framework/ir/pass_test_util.cc +++ b/paddle/fluid/framework/ir/pass_test_util.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/framework/ir/pass_test_util.h" + #include #include #include @@ -23,7 +25,6 @@ #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/ir/graph_traits.h" #include "paddle/fluid/framework/ir/pass.h" -#include "paddle/fluid/framework/ir/pass_test_util.h" #include "paddle/fluid/framework/ir/pass_tester_helper.h" #include "paddle/fluid/framework/op_proto_maker.h" diff --git a/paddle/fluid/framework/ir/pass_tester_helper.h b/paddle/fluid/framework/ir/pass_tester_helper.h index acefde9df68546f38123edff7d5a0d174274780b..ad58e4e4a0cf410e742671779ae72bef91b06c37 100644 --- a/paddle/fluid/framework/ir/pass_tester_helper.h +++ b/paddle/fluid/framework/ir/pass_tester_helper.h @@ -19,6 +19,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/ir/graph.h" #include "paddle/fluid/framework/op_proto_maker.h" #include "paddle/fluid/framework/operator.h" diff --git a/paddle/fluid/framework/ir/placement_pass_base.cc b/paddle/fluid/framework/ir/placement_pass_base.cc index 35ba92006077999a541e700c6884db0d32f0bfab..fd1b54f8c4d37817827660308cc29993762fa6a8 100644 --- a/paddle/fluid/framework/ir/placement_pass_base.cc +++ b/paddle/fluid/framework/ir/placement_pass_base.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/ir/placement_pass_base.h" + #include + #include "paddle/fluid/framework/operator.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/preln_skip_layernorm_fuse_pass.cc b/paddle/fluid/framework/ir/preln_skip_layernorm_fuse_pass.cc index 6c06b741adb907d48888535c731fd62ebf9571a4..80e6c2b7967981b30784ab8fa455feabd8df3f3d 100644 --- a/paddle/fluid/framework/ir/preln_skip_layernorm_fuse_pass.cc +++ b/paddle/fluid/framework/ir/preln_skip_layernorm_fuse_pass.cc @@ -43,8 +43,8 @@ struct PrelnSkipLayerNorm : public PatternBase { PATTERN_DECL_NODE(layer_norm); // declare variable node's name PATTERN_DECL_NODE( - elementwise_out); // (elementwise_input_x,elementwise_input_y) -> - // elementwise_out + elementwise_out); // (elementwise_input_x,elementwise_input_y) + // -> elementwise_out PATTERN_DECL_NODE(layer_norm_bias); PATTERN_DECL_NODE(layer_norm_scale); PATTERN_DECL_NODE(layer_norm_out); diff --git a/paddle/fluid/framework/ir/repeated_fc_relu_fuse_pass.cc b/paddle/fluid/framework/ir/repeated_fc_relu_fuse_pass.cc index a03a6f5b2c72c6e7d33c92e11915c15578f54b07..a2dd846ba52d50cdbb434f1b8d3dc137cd1d86a6 100644 --- a/paddle/fluid/framework/ir/repeated_fc_relu_fuse_pass.cc +++ b/paddle/fluid/framework/ir/repeated_fc_relu_fuse_pass.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/ir/repeated_fc_relu_fuse_pass.h" + #include #include "paddle/fluid/framework/op_version_registry.h" @@ -145,9 +146,9 @@ void BuildRepeatedFCReluPattern(PDPattern* pattern, return x->outputs[fc_idx]->outputs[0]; }; - auto var_next_is_fc_act_repeated_n_times = [=]( - Node* x, int repeated_times, const std::string& act_type = "relu", - bool check_in_has_only_one_out = true) -> bool { + auto var_next_is_fc_act_repeated_n_times = + [=](Node* x, int repeated_times, const std::string& act_type = "relu", + bool check_in_has_only_one_out = true) -> bool { for (int i = 0; i < repeated_times; ++i) { if (!var_next_is_fc_act(x, act_type, i == 0 && check_in_has_only_one_out)) { @@ -191,9 +192,9 @@ void BuildRepeatedFCReluPattern(PDPattern* pattern, return nullptr; }; - auto var_before_is_fc_act_repeated_n_times = [=]( - Node* x, int repeated_times, - const std::string& act_type = "relu") -> bool { + auto var_before_is_fc_act_repeated_n_times = [=](Node* x, int repeated_times, + const std::string& act_type = + "relu") -> bool { for (int i = 0; i < repeated_times; ++i) { if (!var_before_is_fc_act(x, act_type, i == repeated_times - 1)) { return false; diff --git a/paddle/fluid/framework/ir/repeated_fc_relu_fuse_pass_tester.cc b/paddle/fluid/framework/ir/repeated_fc_relu_fuse_pass_tester.cc index f0ff77acf9ff8cd83fb138c374ab6a21a08d6253..3112b776ae5e6034fbb3e05358adb6733d9792db 100644 --- a/paddle/fluid/framework/ir/repeated_fc_relu_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/repeated_fc_relu_fuse_pass_tester.cc @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/framework/ir/repeated_fc_relu_fuse_pass.h" - #include + #include "paddle/fluid/framework/ir/pass_tester_helper.h" +#include "paddle/fluid/framework/ir/repeated_fc_relu_fuse_pass.h" namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/ir/runtime_context_cache_pass.cc b/paddle/fluid/framework/ir/runtime_context_cache_pass.cc index 778e658354f26d1aac0d6ba89058e49bbb763dc2..451e41e767dc4ca882adedfeabf2fdcc142f53e1 100644 --- a/paddle/fluid/framework/ir/runtime_context_cache_pass.cc +++ b/paddle/fluid/framework/ir/runtime_context_cache_pass.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/ir/runtime_context_cache_pass.h" + #include "paddle/fluid/framework/operator.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/seqconv_eltadd_relu_fuse_pass.cc b/paddle/fluid/framework/ir/seqconv_eltadd_relu_fuse_pass.cc index 9fa951920f45a311314832cdaa0e61b5319a8551..2c0b142c98fbdf298c2beaaedeb324a32bdcaf87 100644 --- a/paddle/fluid/framework/ir/seqconv_eltadd_relu_fuse_pass.cc +++ b/paddle/fluid/framework/ir/seqconv_eltadd_relu_fuse_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/seqconv_eltadd_relu_fuse_pass.h" + #include #include "paddle/fluid/framework/op_version_registry.h" diff --git a/paddle/fluid/framework/ir/seqpool_concat_fuse_pass.cc b/paddle/fluid/framework/ir/seqpool_concat_fuse_pass.cc index 2b084bd5734b9c052f0a6657cd8e51f1081d734c..052b0a4bdc1b8e21c9bb5b3c059f686f487d7937 100644 --- a/paddle/fluid/framework/ir/seqpool_concat_fuse_pass.cc +++ b/paddle/fluid/framework/ir/seqpool_concat_fuse_pass.cc @@ -44,8 +44,8 @@ PDNode* BuildSeqPoolConcatPattern(PDPattern* pattern, is_concat_op_with_inputs(x->outputs[0], num_inputs); }; - auto is_seqpool_op_with_pootype_of_nth_input_of_concat = [=]( - Node* x, const std::string& type, int idx) -> bool { + auto is_seqpool_op_with_pootype_of_nth_input_of_concat = + [=](Node* x, const std::string& type, int idx) -> bool { bool this_is_seqpool_op = x && x->IsOp() && x->Op()->Type() == "sequence_pool" && x->Op()->HasAttr("pooltype") && diff --git a/paddle/fluid/framework/ir/seqpool_concat_fuse_pass_tester.cc b/paddle/fluid/framework/ir/seqpool_concat_fuse_pass_tester.cc index d3668038518429ee04b6abba5b1f7f09eea1c9f3..e56ba9ad1e7511f629e3034a566f619fcc814e71 100644 --- a/paddle/fluid/framework/ir/seqpool_concat_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/seqpool_concat_fuse_pass_tester.cc @@ -12,8 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/seqpool_concat_fuse_pass.h" #include + +#include "paddle/fluid/framework/ir/seqpool_concat_fuse_pass.h" #include "paddle/fluid/framework/op_proto_maker.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/seqpool_cvm_concat_fuse_pass.cc b/paddle/fluid/framework/ir/seqpool_cvm_concat_fuse_pass.cc index 7200e0ac1d469ae84879ac010a79a867336e59fa..916adbbe33720b15a7cd4d840e42d8dabca38735 100644 --- a/paddle/fluid/framework/ir/seqpool_cvm_concat_fuse_pass.cc +++ b/paddle/fluid/framework/ir/seqpool_cvm_concat_fuse_pass.cc @@ -44,11 +44,11 @@ static void GetConcatNodes(ir::Graph* graph, std::vector* concat_nodes) { GraphPatternDetector gpd; auto* pattern = gpd.mutable_pattern(); auto concat_op_node = BuildCVMConcatPattern(pattern); - GraphPatternDetector::handle_t handler = [&]( - const GraphPatternDetector::subgraph_t& subgraph, Graph* graph) { - Node* concat_op = subgraph.at(concat_op_node); - concat_nodes->push_back(concat_op); - }; + GraphPatternDetector::handle_t handler = + [&](const GraphPatternDetector::subgraph_t& subgraph, Graph* graph) { + Node* concat_op = subgraph.at(concat_op_node); + concat_nodes->push_back(concat_op); + }; gpd(graph, handler); } } // anonymous namespace @@ -148,19 +148,19 @@ void SeqPoolCVMConcatFusePass::ApplyImpl(ir::Graph* graph) const { Node* cvm_input_of_cvm; Node* concat_out_var = concat_node->outputs[0]; - GraphPatternDetector::handle_t handler = [&]( - const GraphPatternDetector::subgraph_t& subgraph, Graph* graph) { - Node* seqpool_in_var = subgraph.at(seqpool_in_var_node); - Node* seqpool_op = subgraph.at(seqpool_op_node); - Node* seqpool_out_var = subgraph.at(seqpool_out_var_node); - Node* seqpool_idx_out_var = subgraph.at(seqpool_idx_out_var_node); - Node* cvm_op = subgraph.at(cvm_op_node); - Node* cvm_out_var = subgraph.at(cvm_out_var_node); - cvm_input_of_cvm = subgraph.at(cvm_cvm_in_var_node); - marked_nodes.insert({seqpool_op, seqpool_out_var, seqpool_idx_out_var, - cvm_op, cvm_out_var, concat_node}); - ins_to_concat[cvm_out_var->Name()] = seqpool_in_var; - }; + GraphPatternDetector::handle_t handler = + [&](const GraphPatternDetector::subgraph_t& subgraph, Graph* graph) { + Node* seqpool_in_var = subgraph.at(seqpool_in_var_node); + Node* seqpool_op = subgraph.at(seqpool_op_node); + Node* seqpool_out_var = subgraph.at(seqpool_out_var_node); + Node* seqpool_idx_out_var = subgraph.at(seqpool_idx_out_var_node); + Node* cvm_op = subgraph.at(cvm_op_node); + Node* cvm_out_var = subgraph.at(cvm_out_var_node); + cvm_input_of_cvm = subgraph.at(cvm_cvm_in_var_node); + marked_nodes.insert({seqpool_op, seqpool_out_var, seqpool_idx_out_var, + cvm_op, cvm_out_var, concat_node}); + ins_to_concat[cvm_out_var->Name()] = seqpool_in_var; + }; gpd(graph, handler); if (!ins_to_concat.empty()) { diff --git a/paddle/fluid/framework/ir/seqpool_cvm_concat_fuse_pass_tester.cc b/paddle/fluid/framework/ir/seqpool_cvm_concat_fuse_pass_tester.cc index bba640cf148d1ebfc2583b420c3ffd8ff1d110f1..8d8ebc955d39e28efa8a7797f26d83931b2ed608 100644 --- a/paddle/fluid/framework/ir/seqpool_cvm_concat_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/seqpool_cvm_concat_fuse_pass_tester.cc @@ -12,8 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/ir/seqpool_cvm_concat_fuse_pass.h" #include + +#include "paddle/fluid/framework/ir/seqpool_cvm_concat_fuse_pass.h" #include "paddle/fluid/framework/op_proto_maker.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/shuffle_channel_detect_pass.cc b/paddle/fluid/framework/ir/shuffle_channel_detect_pass.cc index bcd7bedcc43a66564f5777cd139860bd546229e2..9007105950b47b807e7f39696e70f500853f65b2 100644 --- a/paddle/fluid/framework/ir/shuffle_channel_detect_pass.cc +++ b/paddle/fluid/framework/ir/shuffle_channel_detect_pass.cc @@ -12,9 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/framework/ir/shuffle_channel_detect_pass.h" + #include -#include "paddle/fluid/framework/ir/shuffle_channel_detect_pass.h" #include "paddle/fluid/framework/op_version_registry.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/simplify_with_basic_ops_pass_tester.cc b/paddle/fluid/framework/ir/simplify_with_basic_ops_pass_tester.cc index 80f387c442760db8217e152a9ae08ca3da7dc105..908797163d21ca397188182deb68bc698ea5e760 100644 --- a/paddle/fluid/framework/ir/simplify_with_basic_ops_pass_tester.cc +++ b/paddle/fluid/framework/ir/simplify_with_basic_ops_pass_tester.cc @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/framework/ir/simplify_with_basic_ops_pass.h" - #include + #include "paddle/fluid/framework/ir/pass_tester_helper.h" +#include "paddle/fluid/framework/ir/simplify_with_basic_ops_pass.h" namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/ir/skip_layernorm_fuse_pass.cc b/paddle/fluid/framework/ir/skip_layernorm_fuse_pass.cc index bfa14d9296b26e08f56e8ab2f30542524b786cf9..6bebe8de9f2e327b44b9f361d3f71930a7e8551e 100644 --- a/paddle/fluid/framework/ir/skip_layernorm_fuse_pass.cc +++ b/paddle/fluid/framework/ir/skip_layernorm_fuse_pass.cc @@ -43,8 +43,8 @@ struct SkipLayerNorm : public PatternBase { PATTERN_DECL_NODE(layer_norm); // declare variable node's name PATTERN_DECL_NODE( - elementwise_out); // (elementwise_input_x,elementwise_input_y) -> - // elementwise_out + elementwise_out); // (elementwise_input_x,elementwise_input_y) + // -> elementwise_out PATTERN_DECL_NODE(layer_norm_bias); PATTERN_DECL_NODE(layer_norm_scale); PATTERN_DECL_NODE(layer_norm_out); diff --git a/paddle/fluid/framework/ir/skip_layernorm_fuse_pass_tester.cc b/paddle/fluid/framework/ir/skip_layernorm_fuse_pass_tester.cc index 29be2c3cb09a7f659efaad0dfd197514d13d96a6..c95fd0abd529423a080973e52f0ff3381329b68f 100644 --- a/paddle/fluid/framework/ir/skip_layernorm_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/skip_layernorm_fuse_pass_tester.cc @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/framework/ir/skip_layernorm_fuse_pass.h" - #include + #include "paddle/fluid/framework/ir/pass_tester_helper.h" +#include "paddle/fluid/framework/ir/skip_layernorm_fuse_pass.h" #include "paddle/fluid/framework/op_version_registry.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/squared_mat_sub_fuse_pass.cc b/paddle/fluid/framework/ir/squared_mat_sub_fuse_pass.cc index 7c43b0221821346b1e0be26e6d61b4767ec3de84..a8c7150d6e3e0cbd3fd29fdb2b720c5b6af4492b 100644 --- a/paddle/fluid/framework/ir/squared_mat_sub_fuse_pass.cc +++ b/paddle/fluid/framework/ir/squared_mat_sub_fuse_pass.cc @@ -170,8 +170,9 @@ PDNode* BuildSquaredMatSubPattern(PDPattern* pattern, auto* matmul_xy_op = pattern->NewNode( [=](Node* x) { - return x && x->IsOp() && (x->Op()->Type() == "matmul_v2" || - x->Op()->Type() == "matmul") && + return x && x->IsOp() && + (x->Op()->Type() == "matmul_v2" || + x->Op()->Type() == "matmul") && is_fusion_first_mul_out(x->outputs[0]); }, name_scope + "/matmul_xy_op"); @@ -212,8 +213,9 @@ PDNode* BuildSquaredMatSubPattern(PDPattern* pattern, auto* matmul_squared_x_y_op = pattern->NewNode( [=](Node* x) { - return x && x->IsOp() && (x->Op()->Type() == "matmul_v2" || - x->Op()->Type() == "matmul") && + return x && x->IsOp() && + (x->Op()->Type() == "matmul_v2" || + x->Op()->Type() == "matmul") && is_fusion_mat_squared_x_y_op_out(x->outputs[0]); }, name_scope + "/matmul_squared_x_y_op"); diff --git a/paddle/fluid/framework/ir/sync_batch_norm_pass_tester.cc b/paddle/fluid/framework/ir/sync_batch_norm_pass_tester.cc index 94fb68506413c601e945bd8e5f49efad924dfa26..78dafaa1e2f1218308a2ea1b685423a6c87dd07d 100644 --- a/paddle/fluid/framework/ir/sync_batch_norm_pass_tester.cc +++ b/paddle/fluid/framework/ir/sync_batch_norm_pass_tester.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include #include "paddle/fluid/framework/ir/pass.h" diff --git a/paddle/fluid/framework/ir/transpose_flatten_concat_fuse_pass.cc b/paddle/fluid/framework/ir/transpose_flatten_concat_fuse_pass.cc index bda6b9038647585769ed2403419d7dc70c67ba9d..6802310383d37c1b2a2641839c3d3da9ed994873 100644 --- a/paddle/fluid/framework/ir/transpose_flatten_concat_fuse_pass.cc +++ b/paddle/fluid/framework/ir/transpose_flatten_concat_fuse_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/ir/transpose_flatten_concat_fuse_pass.h" + #include "paddle/fluid/framework/op_version_registry.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/trt_map_matmul_to_mul_pass.cc b/paddle/fluid/framework/ir/trt_map_matmul_to_mul_pass.cc index d3211c08414169299b0c8614f434dd11e9a6c402..a6e3780fd22c967a27c3c7e51d95ef7d17898b0c 100644 --- a/paddle/fluid/framework/ir/trt_map_matmul_to_mul_pass.cc +++ b/paddle/fluid/framework/ir/trt_map_matmul_to_mul_pass.cc @@ -16,9 +16,9 @@ #include #include + #include "paddle/fluid/framework/ir/graph_pattern_detector.h" #include "paddle/fluid/framework/op_proto_maker.h" - #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/ir/trt_multihead_matmul_fuse_pass.cc b/paddle/fluid/framework/ir/trt_multihead_matmul_fuse_pass.cc index 798a038f767c527f0056e2aa88c40d808ca9d49c..2e3e957fd15f17e291742d566c73a63515cce83f 100644 --- a/paddle/fluid/framework/ir/trt_multihead_matmul_fuse_pass.cc +++ b/paddle/fluid/framework/ir/trt_multihead_matmul_fuse_pass.cc @@ -51,11 +51,12 @@ static int BuildFusion(Graph* graph, const std::string& name_scope) { multihead_pattern(); // Create New OpDesc - auto fuse_creater = [&]( - Node* input0, Node* mul0, Node* mul1, Node* mul2, Node* mul0_out, - Node* mul1_out, Node* mul2_out, Node* eltadd0_b, Node* eltadd1_b, - Node* eltadd2_b, Node* eltadd_qk_b, Node* reshape2, - Node* reshape2_qkv_out, Node* scale, Node* scale_out) { + auto fuse_creater = [&](Node* input0, Node* mul0, Node* mul1, Node* mul2, + Node* mul0_out, Node* mul1_out, Node* mul2_out, + Node* eltadd0_b, Node* eltadd1_b, Node* eltadd2_b, + Node* eltadd_qk_b, Node* reshape2, + Node* reshape2_qkv_out, Node* scale, + Node* scale_out) { auto scale_attr = BOOST_GET_CONST(float, scale->Op()->GetAttr("scale")); // auto scale_bias = BOOST_GET_CONST(float, scale->Op()->GetAttr("bias")); // bool after_scale = @@ -756,13 +757,14 @@ int TrtMultiHeadMatmulV2FusePass::BuildFusionV2(Graph* graph, multihead_pattern(); // Create New OpDesc - auto fuse_creater = [&]( - Node* input0, Node* mul0, Node* mul1, Node* mul2, Node* mul0_out, - Node* mul1_out, Node* mul2_out, Node* mul0_w, Node* mul1_w, Node* mul2_w, - Node* eltadd0_b, Node* eltadd1_b, Node* eltadd2_b, Node* eltadd_qk_b, - Node* reshape2, Node* reshape2_qkv_out, Node* scale, Node* scale_out, - Node* softmax_qk, Node* eltadd0, Node* eltadd1, Node* eltadd2, - Node* matmul_qk, Node* reshape2_qkv) { + auto fuse_creater = [&](Node* input0, Node* mul0, Node* mul1, Node* mul2, + Node* mul0_out, Node* mul1_out, Node* mul2_out, + Node* mul0_w, Node* mul1_w, Node* mul2_w, + Node* eltadd0_b, Node* eltadd1_b, Node* eltadd2_b, + Node* eltadd_qk_b, Node* reshape2, + Node* reshape2_qkv_out, Node* scale, Node* scale_out, + Node* softmax_qk, Node* eltadd0, Node* eltadd1, + Node* eltadd2, Node* matmul_qk, Node* reshape2_qkv) { auto scale_attr = BOOST_GET_CONST(float, scale->Op()->GetAttr("scale")); // mul (B * S * Hidden) x (Hidden * 3 * N * H) = (B * S * 3 * N * H) @@ -1229,11 +1231,12 @@ int TrtMultiHeadMatmulV3FusePass::BuildFusionV3(Graph* graph, multihead_pattern(); // Create New OpDesc - auto fuse_creater = [&]( - Node* input0, Node* mul0, Node* mul1, Node* mul2, Node* mul0_out, - Node* mul1_out, Node* mul2_out, Node* mul0_w, Node* mul1_w, Node* mul2_w, - Node* eltadd0_b, Node* eltadd1_b, Node* eltadd2_b, Node* eltadd_qk_b, - Node* reshape2, Node* reshape2_qkv_out, Node* matmul_qk) { + auto fuse_creater = [&](Node* input0, Node* mul0, Node* mul1, Node* mul2, + Node* mul0_out, Node* mul1_out, Node* mul2_out, + Node* mul0_w, Node* mul1_w, Node* mul2_w, + Node* eltadd0_b, Node* eltadd1_b, Node* eltadd2_b, + Node* eltadd_qk_b, Node* reshape2, + Node* reshape2_qkv_out, Node* matmul_qk) { auto scale_attr = BOOST_GET_CONST(float, matmul_qk->Op()->GetAttr("alpha")); // mul (B * S * Hidden) x (Hidden * 3 * N * H) = (B * S * 3 * N * H) diff --git a/paddle/fluid/framework/ir/trt_skip_layernorm_fuse_pass.cc b/paddle/fluid/framework/ir/trt_skip_layernorm_fuse_pass.cc index 53452d4239a861125f17317c700fd903a478a531..13883909435f782477054e126334593c1671bc75 100644 --- a/paddle/fluid/framework/ir/trt_skip_layernorm_fuse_pass.cc +++ b/paddle/fluid/framework/ir/trt_skip_layernorm_fuse_pass.cc @@ -43,8 +43,8 @@ struct TrtSkipLayerNorm : public PatternBase { PATTERN_DECL_NODE(layer_norm); // declare variable node's name PATTERN_DECL_NODE( - elementwise_out); // (elementwise_input_x,elementwise_input_y) -> - // elementwise_out + elementwise_out); // (elementwise_input_x,elementwise_input_y) + // -> elementwise_out PATTERN_DECL_NODE(layer_norm_bias); PATTERN_DECL_NODE(layer_norm_scale); PATTERN_DECL_NODE(layer_norm_out); diff --git a/paddle/fluid/framework/ir/unsqueeze2_eltwise_fuse_pass_tester.cc b/paddle/fluid/framework/ir/unsqueeze2_eltwise_fuse_pass_tester.cc index 067a37c611a73c9ab08d3ebf396b877699d7823d..3ebd61ff575e3c344b9c829df8f9a4498164c858 100644 --- a/paddle/fluid/framework/ir/unsqueeze2_eltwise_fuse_pass_tester.cc +++ b/paddle/fluid/framework/ir/unsqueeze2_eltwise_fuse_pass_tester.cc @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/framework/ir/unsqueeze2_eltwise_fuse_pass.h" - #include + #include "paddle/fluid/framework/ir/pass_tester_helper.h" +#include "paddle/fluid/framework/ir/unsqueeze2_eltwise_fuse_pass.h" #include "paddle/fluid/framework/op_version_registry.h" namespace paddle { diff --git a/paddle/fluid/framework/ir/yolo_box_fuse_pass.cc b/paddle/fluid/framework/ir/yolo_box_fuse_pass.cc index 20075a49749f75fac347cb46b1ba2e5767f44975..19836b69ae9bf41eaab33047b358ec1a00ba8021 100644 --- a/paddle/fluid/framework/ir/yolo_box_fuse_pass.cc +++ b/paddle/fluid/framework/ir/yolo_box_fuse_pass.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/ir/yolo_box_fuse_pass.h" + #include + #include "glog/logging.h" #include "paddle/fluid/framework/ir/graph_pattern_detector.h" #include "paddle/fluid/framework/ir/pass.h" diff --git a/paddle/fluid/framework/lod_tensor.h b/paddle/fluid/framework/lod_tensor.h index 1c5c12b3d57df4b1fc38556a4cbb4c73379873d2..dd316a0979cc7b1bc31b688639dd60d93ce4111f 100644 --- a/paddle/fluid/framework/lod_tensor.h +++ b/paddle/fluid/framework/lod_tensor.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include #include #include diff --git a/paddle/fluid/framework/lod_tensor_array.h b/paddle/fluid/framework/lod_tensor_array.h index 36a5c3c5d601390beedaf37ceb98ee2c63ecf5a6..7aa180ed75ce217dcadb747f8014d92f6e4931fe 100644 --- a/paddle/fluid/framework/lod_tensor_array.h +++ b/paddle/fluid/framework/lod_tensor_array.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/lod_tensor.h" namespace paddle { diff --git a/paddle/fluid/framework/lod_tensor_test.cc b/paddle/fluid/framework/lod_tensor_test.cc index a89baac3e7a10889a0b742a153047c4ba4183ef0..254e70231ea4ede55302301ea5372087b6477be1 100644 --- a/paddle/fluid/framework/lod_tensor_test.cc +++ b/paddle/fluid/framework/lod_tensor_test.cc @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/framework/lod_tensor.h" + #include #include -#include "paddle/fluid/framework/lod_tensor.h" #include "paddle/phi/core/lod_utils.h" namespace paddle { diff --git a/paddle/fluid/framework/naive_executor.cc b/paddle/fluid/framework/naive_executor.cc index dba3b3ff1e6900a343fc2ff48dfb5f222257bc58..1c2740c2b2ee7d83fbaed2aaf01cbf18cce5cd5b 100644 --- a/paddle/fluid/framework/naive_executor.cc +++ b/paddle/fluid/framework/naive_executor.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/framework/naive_executor.h" + #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/variable_helper.h" #include "paddle/fluid/platform/denormal.h" diff --git a/paddle/fluid/framework/naive_executor_test.cc b/paddle/fluid/framework/naive_executor_test.cc index 2f3c3f3d06e327bc583c817bdfcc78345d8adff5..763e314d226e6e6e9c2f3ff9ab151d50adb41a93 100644 --- a/paddle/fluid/framework/naive_executor_test.cc +++ b/paddle/fluid/framework/naive_executor_test.cc @@ -13,8 +13,11 @@ // limitations under the License. #include "paddle/fluid/framework/naive_executor.h" + #include + #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/program_desc.h" diff --git a/paddle/fluid/framework/new_executor/data_transfer.cc b/paddle/fluid/framework/new_executor/data_transfer.cc index d0e5565139c54cdd96a02cf3eeff331b4b4c7762..171e15162fb454a1b95cc492908b9d2cd293a05e 100644 --- a/paddle/fluid/framework/new_executor/data_transfer.cc +++ b/paddle/fluid/framework/new_executor/data_transfer.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/new_executor/data_transfer.h" + #include "paddle/fluid/framework/convert_utils.h" namespace paddle { @@ -276,9 +277,9 @@ std::shared_ptr TransferDevice(const std::string& var_name, // 2. Construct VariableNameMap VariableNameMap in_name_map = {{"X", {var_name}}}; VariableNameMap out_name_map = {{"Out", {*new_var_name}}}; - int dst_place_type = platform::is_cpu_place(dst_place) - ? 0 - : platform::is_gpu_place(dst_place) ? 1 : -1; + int dst_place_type = platform::is_cpu_place(dst_place) ? 0 + : platform::is_gpu_place(dst_place) ? 1 + : -1; AttributeMap attr_map = {{"dst_place_type", dst_place_type}}; // 3. Create memcpy_d2h_op or memcpy_h2d_op diff --git a/paddle/fluid/framework/new_executor/event_manager.cc b/paddle/fluid/framework/new_executor/event_manager.cc index bca2264b66afcc9632689905f41ae0d7757795da..0bfa00494d611e9e2bcde0f8a1a68e3cbeeb092b 100644 --- a/paddle/fluid/framework/new_executor/event_manager.cc +++ b/paddle/fluid/framework/new_executor/event_manager.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/new_executor/event_manager.h" + #include "paddle/fluid/platform/profiler/event_tracing.h" namespace paddle { diff --git a/paddle/fluid/framework/new_executor/executor_statistics.cc b/paddle/fluid/framework/new_executor/executor_statistics.cc index fb79712d47d9ed27b09ab59104b58b17a0c8ca11..f6afcf2f24d183aa6e55a3447afe4b74836a9692 100644 --- a/paddle/fluid/framework/new_executor/executor_statistics.cc +++ b/paddle/fluid/framework/new_executor/executor_statistics.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/new_executor/executor_statistics.h" + #include #include #include @@ -21,6 +22,7 @@ #include #include #include + #include "glog/logging.h" #include "paddle/fluid/platform/flags.h" #include "paddle/fluid/platform/os_info.h" @@ -520,7 +522,7 @@ void StatisticsEngine::MergeEvents(std::function merger, int StatisticsEngine::MergeInnerthreadEvents( std::vector>* all_evts) { - auto merger = [& priorities = priorities_](size_t idx1, size_t idx2) { + auto merger = [&priorities = priorities_](size_t idx1, size_t idx2) { return priorities[idx1].innerthread_priority <= priorities[idx2].innerthread_priority ? idx1 @@ -541,7 +543,7 @@ int StatisticsEngine::MergeInnerthreadEvents( int StatisticsEngine::MergeInterthreadEvents( std::vector>* all_evts) { - auto merger = [& priorities = priorities_](size_t idx1, size_t idx2) { + auto merger = [&priorities = priorities_](size_t idx1, size_t idx2) { return priorities[idx1].interthread_priority <= priorities[idx2].interthread_priority ? idx1 diff --git a/paddle/fluid/framework/new_executor/executor_statistics.h b/paddle/fluid/framework/new_executor/executor_statistics.h index 530e9455968a80f0190eecf00b91f987cca54af3..ebe9d3a2e7925e6b682627a3bef04097d52985b5 100644 --- a/paddle/fluid/framework/new_executor/executor_statistics.h +++ b/paddle/fluid/framework/new_executor/executor_statistics.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/platform/profiler/event_node.h" namespace paddle { diff --git a/paddle/fluid/framework/new_executor/garbage_collector/event_garbage_collector.cc b/paddle/fluid/framework/new_executor/garbage_collector/event_garbage_collector.cc index 46c85a22dc3a30d8ede04b58ba21231f3b050f23..1ae9f4223d3d9c4e0d6817d4c49d7034f68227fd 100644 --- a/paddle/fluid/framework/new_executor/garbage_collector/event_garbage_collector.cc +++ b/paddle/fluid/framework/new_executor/garbage_collector/event_garbage_collector.cc @@ -110,7 +110,7 @@ void InterpreterCoreEventGarbageCollector::Free( const platform::DeviceContext* ctx) { event->Record(ctx); event->SetFininshed(); // Only for CPU Event - queue_->AddTask([ container = garbages, event = event ]() { + queue_->AddTask([container = garbages, event = event]() { while (!event->Query()) { #if defined(_WIN32) SleepEx(50, FALSE); @@ -128,7 +128,7 @@ void InterpreterCoreEventGarbageCollector::Free( const platform::DeviceContext* ctx) { event->Record(ctx); event->SetFininshed(); // Only for CPU Event - queue_->AddTask([ container = garbage, event = event ]() { + queue_->AddTask([container = garbage, event = event]() { while (!event->Query()) { #if defined(_WIN32) SleepEx(50, FALSE); diff --git a/paddle/fluid/framework/new_executor/garbage_collector/event_garbage_collector.h b/paddle/fluid/framework/new_executor/garbage_collector/event_garbage_collector.h index 33954713d4e9f342b4c6fe507cb3c0a1d4d50334..57963269663d0fab181e1c13ac7071c2c89bba15 100644 --- a/paddle/fluid/framework/new_executor/garbage_collector/event_garbage_collector.h +++ b/paddle/fluid/framework/new_executor/garbage_collector/event_garbage_collector.h @@ -14,6 +14,7 @@ #pragma once #include + #include "paddle/fluid/framework/new_executor/garbage_collector/garbage_collector.h" #include "paddle/fluid/framework/new_executor/workqueue/workqueue.h" diff --git a/paddle/fluid/framework/new_executor/garbage_collector/garbage_collector.cc b/paddle/fluid/framework/new_executor/garbage_collector/garbage_collector.cc index a20cd27539848f915405a5d6a5a21e9dad8f8ef5..8e849c79bd23539f4315a9c7fc82a75a2e54d900 100644 --- a/paddle/fluid/framework/new_executor/garbage_collector/garbage_collector.cc +++ b/paddle/fluid/framework/new_executor/garbage_collector/garbage_collector.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/new_executor/garbage_collector/garbage_collector.h" + #include "paddle/fluid/framework/garbage_collector.h" namespace paddle { diff --git a/paddle/fluid/framework/new_executor/garbage_collector/garbage_collector.h b/paddle/fluid/framework/new_executor/garbage_collector/garbage_collector.h index 34f95eee7316dc57609e8fc66c51726ca2756869..d0159c0ca83e55b15aa5ddc8c507da3f1cbdc2de 100644 --- a/paddle/fluid/framework/new_executor/garbage_collector/garbage_collector.h +++ b/paddle/fluid/framework/new_executor/garbage_collector/garbage_collector.h @@ -14,6 +14,7 @@ #pragma once #include + #include "paddle/fluid/memory/allocation/spin_lock.h" #include "paddle/fluid/platform/device_event.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/new_executor/interpretercore.cc b/paddle/fluid/framework/new_executor/interpretercore.cc index da2fd0c8c6114017fc72e4718ff4c4231517ceeb..fe0c7fe0721780401b903b05a8b0916f62360531 100644 --- a/paddle/fluid/framework/new_executor/interpretercore.cc +++ b/paddle/fluid/framework/new_executor/interpretercore.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/framework/new_executor/interpretercore.h" + #include + #include "paddle/fluid/framework/details/nan_inf_utils.h" #include "paddle/fluid/framework/details/share_tensor_buffer_functor.h" #include "paddle/fluid/framework/new_executor/garbage_collector/event_garbage_collector.h" @@ -585,10 +587,12 @@ void InterpreterCore::ExecuteInstructionList( for (size_t i = 0; i < dependecy_count_.size(); ++i) { if (dependecy_count_[i] == 0) { - async_work_queue_->AddTask(vec_instr.at(i).KernelType(), [ - this, i, atomic_deps = atomic_deps.get(), - atomic_var_ref = atomic_var_ref.get() - ] { RunInstructionAsync(i, atomic_deps, atomic_var_ref); }); + async_work_queue_->AddTask(vec_instr.at(i).KernelType(), + [this, i, atomic_deps = atomic_deps.get(), + atomic_var_ref = atomic_var_ref.get()] { + RunInstructionAsync(i, atomic_deps, + atomic_var_ref); + }); } } @@ -692,10 +696,10 @@ void InterpreterCore::RunInstructionAsync( ready_ops.pop(); auto& instr_node = vec_instruction_.at(instr_id); VLOG(5) << __func__ << " OP id:" << instr_node.Id() - << " name:" << instr_node.OpBase()->Type() - << " type:" << (instr_node.KernelType() == OpFuncType::kQueueSync - ? "kQueueSync" - : "kQueueAsync") + << " name:" << instr_node.OpBase()->Type() << " type:" + << (instr_node.KernelType() == OpFuncType::kQueueSync + ? "kQueueSync" + : "kQueueAsync") << " runs on " << platform::GetCurrentThreadName(); auto* op = instr_node.OpBase(); diff --git a/paddle/fluid/framework/new_executor/interpretercore_util.cc b/paddle/fluid/framework/new_executor/interpretercore_util.cc index f601a4ad28bd7a19cd20fd34153fa702e0b68ed5..0b75964b94e914c580b3f2ffb9e1538668702832 100644 --- a/paddle/fluid/framework/new_executor/interpretercore_util.cc +++ b/paddle/fluid/framework/new_executor/interpretercore_util.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "paddle/fluid/framework/new_executor/interpretercore_util.h" + #include #include "paddle/fluid/framework/executor_gc_helper.h" @@ -398,9 +399,10 @@ void build_op_func_list(const platform::Place& place, // But some OPs do have such behavior (e.g., cinn_launch OP). Here special // treatment for them. if (op_with_kernel->Type() == "cinn_launch") { - VLOG(6) << "OP(" << op_with_kernel->Type() << ") use scope in kernel, " - "so pass a real scope to " - "ExecutionContext"; + VLOG(6) << "OP(" << op_with_kernel->Type() + << ") use scope in kernel, " + "so pass a real scope to " + "ExecutionContext"; runtime_scope = local_scope; } @@ -747,8 +749,9 @@ std::map> get_downstream_map( std::map> build_op_downstream_map( const std::vector& vec_instruction, std::vector>* op_happens_before) { - auto var2min_rw_op = std::map< - int, std::list>(); // # map from variable id to read / write op id. + auto var2min_rw_op = + std::map>(); // # map from variable id to read / + // write op id. auto var2recent_write_op = std::map(); // # map from variable to recent write op. auto op2dependences = @@ -825,8 +828,14 @@ std::map> build_op_downstream_map( // add dependences for random op, make sure that the random op is scheduled // sequentially const std::set random_op_set = { - "bernoulli", "poisson", "multinomial", "gaussian_random", - "truncated_gaussian_random", "uniform_random", "randint", "randperm", + "bernoulli", + "poisson", + "multinomial", + "gaussian_random", + "truncated_gaussian_random", + "uniform_random", + "randint", + "randperm", "exponential", "sampling_id" "dropout", @@ -846,7 +855,10 @@ std::map> build_op_downstream_map( // add dependency for communication op auto is_comm_op = [](std::string op) -> bool { const std::set special_comm_op_set = { - "send", "recv", "send_v2", "recv_v2", + "send", + "recv", + "send_v2", + "recv_v2", }; const std::string communication_op_prefix = "c_"; if (op.find(communication_op_prefix) != std::string::npos || diff --git a/paddle/fluid/framework/new_executor/interpretercore_util.h b/paddle/fluid/framework/new_executor/interpretercore_util.h index 60ac3702f4b3c84facec7f08e82a8b214272ae93..3d5b067c18792c795c6ea0be910a0d5ecdb0fa3f 100644 --- a/paddle/fluid/framework/new_executor/interpretercore_util.h +++ b/paddle/fluid/framework/new_executor/interpretercore_util.h @@ -22,10 +22,9 @@ #include #include -#include - #include #include +#include #include #include diff --git a/paddle/fluid/framework/new_executor/new_executor_defs.cc b/paddle/fluid/framework/new_executor/new_executor_defs.cc index c75a7871d63e972abf1f209930897707822238c0..1a4dd2edf27931b6b2ace90ed5bb86338d43012d 100644 --- a/paddle/fluid/framework/new_executor/new_executor_defs.cc +++ b/paddle/fluid/framework/new_executor/new_executor_defs.cc @@ -12,12 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/framework/new_executor/new_executor_defs.h" + #include #include #include #include -#include "paddle/fluid/framework/new_executor/new_executor_defs.h" #include "paddle/phi/core/utils/rw_lock.h" // When in inference scenario, the scopes will not be written by two threads in @@ -385,10 +386,11 @@ InterpretercoreInferShapeContext::GetOutputsVarType( void InterpretercoreInferShapeContext::SetOutputDim(const std::string& name, const DDim& dim) { auto& vars = OutputVars(name); - PADDLE_ENFORCE_EQ(vars.size(), 1UL, platform::errors::InvalidArgument( - "Output(%s) should hold one element, " - "but now it holds %zu elements.", - name, vars.size())); + PADDLE_ENFORCE_EQ( + vars.size(), 1UL, + platform::errors::InvalidArgument("Output(%s) should hold one element, " + "but now it holds %zu elements.", + name, vars.size())); SetDim(vars[0], dim); } @@ -653,8 +655,9 @@ void VariableScope::CheckExist(int id) const { } void VariableScope::CheckExist(const std::string& name) const { - PADDLE_ENFORCE_EQ(HasVar(name), true, platform::errors::NotFound( - "%s not in VariableScope.", name)); + PADDLE_ENFORCE_EQ( + HasVar(name), true, + platform::errors::NotFound("%s not in VariableScope.", name)); } void VariableScope::ClearListener() { @@ -709,8 +712,9 @@ void VariableScopeListener::onClear() {} Instruction::Instruction(size_t id, OpFuncNode&& op_func_node, const platform::DeviceContext& dev_ctx) : id_(id), op_func_node_(op_func_node), dev_ctx_(dev_ctx) { - PADDLE_ENFORCE_GE(id, 0, platform::errors::PreconditionNotMet( - "Required id >= 0, but received id = %d", id)); + PADDLE_ENFORCE_GE(id, 0, + platform::errors::PreconditionNotMet( + "Required id >= 0, but received id = %d", id)); } size_t Instruction::Id() const { return id_; } diff --git a/paddle/fluid/framework/new_executor/standalone_executor.cc b/paddle/fluid/framework/new_executor/standalone_executor.cc index 31315df5701e500674a246c1fa35d551ee0d2d0f..64332d7fc90b08feefda3099f06de352eaab7c58 100644 --- a/paddle/fluid/framework/new_executor/standalone_executor.cc +++ b/paddle/fluid/framework/new_executor/standalone_executor.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "paddle/fluid/framework/new_executor/standalone_executor.h" + #include "paddle/fluid/framework/new_executor/interpretercore_util.h" #include "paddle/fluid/platform/profiler/event_tracing.h" diff --git a/paddle/fluid/framework/new_executor/standalone_executor_test.cc b/paddle/fluid/framework/new_executor/standalone_executor_test.cc index 23bd777fae1d5b1006bef5c0e4e3bd77ca9ff998..60d59899549fa866bd82e7e8000e6a9f8ac13b6d 100644 --- a/paddle/fluid/framework/new_executor/standalone_executor_test.cc +++ b/paddle/fluid/framework/new_executor/standalone_executor_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include #include #include diff --git a/paddle/fluid/framework/new_executor/stream_analyzer.cc b/paddle/fluid/framework/new_executor/stream_analyzer.cc index fdcd19b03098c6c068d844caf979f2e92ddea598..6c689c8548b90244e6ba667c227aa194b44ada1b 100644 --- a/paddle/fluid/framework/new_executor/stream_analyzer.cc +++ b/paddle/fluid/framework/new_executor/stream_analyzer.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/new_executor/stream_analyzer.h" + #include namespace paddle { diff --git a/paddle/fluid/framework/new_executor/stream_analyzer.h b/paddle/fluid/framework/new_executor/stream_analyzer.h index 2a276c6f5097a0c8bc21779ae477208a449330f6..8a6552c6883c5bd9916d5e2c8b1685e4a5c8aac5 100644 --- a/paddle/fluid/framework/new_executor/stream_analyzer.h +++ b/paddle/fluid/framework/new_executor/stream_analyzer.h @@ -15,6 +15,7 @@ #pragma once #include #include + #include "paddle/fluid/framework/new_executor/new_executor_defs.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/device_event.h" diff --git a/paddle/fluid/framework/new_executor/workqueue/event_count.h b/paddle/fluid/framework/new_executor/workqueue/event_count.h index 7a826c3990713d272e85c688ec20134cf4ba9ac3..7c20e12ff1f94cc2319414190fb7647d62dad648 100644 --- a/paddle/fluid/framework/new_executor/workqueue/event_count.h +++ b/paddle/fluid/framework/new_executor/workqueue/event_count.h @@ -54,6 +54,7 @@ #include #include #include + #include "glog/logging.h" namespace paddle { diff --git a/paddle/fluid/framework/new_executor/workqueue/events_waiter.cc b/paddle/fluid/framework/new_executor/workqueue/events_waiter.cc index 346e20d811e84f70726b36b06b61c3d55b11a6ec..dbe609427adcf9ad50fe0adef22dfc2255141a3e 100644 --- a/paddle/fluid/framework/new_executor/workqueue/events_waiter.cc +++ b/paddle/fluid/framework/new_executor/workqueue/events_waiter.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/framework/new_executor/workqueue/events_waiter.h" + #include + #include "paddle/fluid/platform/enforce.h" namespace paddle { diff --git a/paddle/fluid/framework/new_executor/workqueue/events_waiter.h b/paddle/fluid/framework/new_executor/workqueue/events_waiter.h index 9d85f4a27242c9f9c8ed7ffa80879d626527dd35..9284ffa853a85293add925e85a71dce9b3f9807e 100644 --- a/paddle/fluid/framework/new_executor/workqueue/events_waiter.h +++ b/paddle/fluid/framework/new_executor/workqueue/events_waiter.h @@ -20,6 +20,7 @@ #include #include #include + #include "paddle/fluid/framework/new_executor/workqueue/event_count.h" #include "paddle/fluid/memory/allocation/spin_lock.h" diff --git a/paddle/fluid/framework/new_executor/workqueue/nonblocking_threadpool.h b/paddle/fluid/framework/new_executor/workqueue/nonblocking_threadpool.h index 559eb6a7490cda70e39489b9683cfea59d9970ab..20aebfba8e8f833d9078f8e7079ce9d9da65bc7d 100644 --- a/paddle/fluid/framework/new_executor/workqueue/nonblocking_threadpool.h +++ b/paddle/fluid/framework/new_executor/workqueue/nonblocking_threadpool.h @@ -12,6 +12,7 @@ #include #include #include + #include "glog/logging.h" #include "paddle/fluid/framework/new_executor/workqueue/event_count.h" #include "paddle/fluid/framework/new_executor/workqueue/run_queue.h" diff --git a/paddle/fluid/framework/new_executor/workqueue/run_queue.h b/paddle/fluid/framework/new_executor/workqueue/run_queue.h index 2fc42cf308ab85e07a15bb74fcf0ef4e681f045c..7644425a4849115f482e0189032adbcbd971bc12 100644 --- a/paddle/fluid/framework/new_executor/workqueue/run_queue.h +++ b/paddle/fluid/framework/new_executor/workqueue/run_queue.h @@ -42,6 +42,7 @@ #include #include #include + #include "paddle/fluid/framework/new_executor/workqueue/workqueue_utils.h" #include "paddle/fluid/memory/allocation/spin_lock.h" @@ -76,9 +77,8 @@ class RunQueue { unsigned front = front_.load(std::memory_order_relaxed); Elem* e = &array_[front & kMask]; uint8_t s = e->state.load(std::memory_order_relaxed); - if (s != kEmpty || - !e->state.compare_exchange_strong(s, kBusy, - std::memory_order_acquire)) { + if (s != kEmpty || !e->state.compare_exchange_strong( + s, kBusy, std::memory_order_acquire)) { return w; } front_.store(front + 1 + (kSize << 1), std::memory_order_relaxed); @@ -93,9 +93,8 @@ class RunQueue { unsigned front = front_.load(std::memory_order_relaxed); Elem* e = &array_[(front - 1) & kMask]; uint8_t s = e->state.load(std::memory_order_relaxed); - if (s != kReady || - !e->state.compare_exchange_strong(s, kBusy, - std::memory_order_acquire)) { + if (s != kReady || !e->state.compare_exchange_strong( + s, kBusy, std::memory_order_acquire)) { return Work(); } Work w = std::move(e->w); @@ -112,9 +111,8 @@ class RunQueue { unsigned back = back_.load(std::memory_order_relaxed); Elem* e = &array_[(back - 1) & kMask]; uint8_t s = e->state.load(std::memory_order_relaxed); - if (s != kEmpty || - !e->state.compare_exchange_strong(s, kBusy, - std::memory_order_acquire)) { + if (s != kEmpty || !e->state.compare_exchange_strong( + s, kBusy, std::memory_order_acquire)) { return w; } back = ((back - 1) & kMask2) | (back & ~kMask2); @@ -134,9 +132,8 @@ class RunQueue { unsigned back = back_.load(std::memory_order_relaxed); Elem* e = &array_[back & kMask]; uint8_t s = e->state.load(std::memory_order_relaxed); - if (s != kReady || - !e->state.compare_exchange_strong(s, kBusy, - std::memory_order_acquire)) { + if (s != kReady || !e->state.compare_exchange_strong( + s, kBusy, std::memory_order_acquire)) { return Work(); } Work w = std::move(e->w); @@ -163,9 +160,8 @@ class RunQueue { Elem* e = &array_[mid & kMask]; uint8_t s = e->state.load(std::memory_order_relaxed); if (n == 0) { - if (s != kReady || - !e->state.compare_exchange_strong(s, kBusy, - std::memory_order_acquire)) + if (s != kReady || !e->state.compare_exchange_strong( + s, kBusy, std::memory_order_acquire)) continue; start = mid; } else { diff --git a/paddle/fluid/framework/new_executor/workqueue/workqueue.cc b/paddle/fluid/framework/new_executor/workqueue/workqueue.cc index 0f0de8ef9b05d5572bd1c84cc6fb38acffdbe882..b06c540b756da406cd802d18e21df556c5b96abc 100644 --- a/paddle/fluid/framework/new_executor/workqueue/workqueue.cc +++ b/paddle/fluid/framework/new_executor/workqueue/workqueue.cc @@ -5,6 +5,7 @@ // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. #include "paddle/fluid/framework/new_executor/workqueue/workqueue.h" + #include "paddle/fluid/framework/new_executor/workqueue/nonblocking_threadpool.h" #include "paddle/fluid/framework/new_executor/workqueue/workqueue_utils.h" #include "paddle/fluid/platform/enforce.h" @@ -64,11 +65,8 @@ class WorkQueueImpl : public WorkQueue { platform::TracerEventType::UserDefined, 10 /*level*/); if (tracker_ != nullptr) { - fn = [ - task = std::move(fn), raii = CounterGuard(tracker_) - ]() mutable { - task(); - }; + fn = [task = std::move(fn), + raii = CounterGuard(tracker_)]() mutable { task(); }; } queue_->AddTask(std::move(fn)); } @@ -158,11 +156,8 @@ void WorkQueueGroupImpl::AddTask(size_t queue_idx, std::function fn) { 10 /*level*/); assert(queue_idx < queues_.size()); if (queues_options_.at(queue_idx).track_task) { - fn = [ - task = std::move(fn), raii = CounterGuard(tracker_) - ]() mutable { - task(); - }; + fn = [task = std::move(fn), + raii = CounterGuard(tracker_)]() mutable { task(); }; } queues_[queue_idx]->AddTask(std::move(fn)); } diff --git a/paddle/fluid/framework/new_executor/workqueue/workqueue.h b/paddle/fluid/framework/new_executor/workqueue/workqueue.h index 2c2576528fe0ef5331d6d7e93a83be0752a3e359..1a1900c56872dd41e5e9ce8e09873bf6216c881a 100644 --- a/paddle/fluid/framework/new_executor/workqueue/workqueue.h +++ b/paddle/fluid/framework/new_executor/workqueue/workqueue.h @@ -20,6 +20,7 @@ #include #include #include + #include "paddle/fluid/platform/enforce.h" namespace paddle { @@ -118,10 +119,10 @@ class WorkQueue { std::bind(std::forward(f), std::forward(args)...); std::promise prom; std::future res = prom.get_future(); - AddTask([ - t = std::move(task), - p = FakeCopyable>(std::move(prom)) - ]() mutable { p.Get().set_value(t()); }); + AddTask([t = std::move(task), p = FakeCopyable>( + std::move(prom))]() mutable { + p.Get().set_value(t()); + }); return res; } @@ -158,10 +159,9 @@ class WorkQueueGroup { std::bind(std::forward(f), std::forward(args)...); std::promise prom; std::future res = prom.get_future(); - AddTask(queue_idx, [ - t = std::move(task), - p = FakeCopyable>(std::move(prom)) - ]() mutable { p.Get().set_value(t()); }); + AddTask(queue_idx, [t = std::move(task), + p = FakeCopyable>(std::move( + prom))]() mutable { p.Get().set_value(t()); }); return res; } diff --git a/paddle/fluid/framework/new_executor/workqueue/workqueue_test.cc b/paddle/fluid/framework/new_executor/workqueue/workqueue_test.cc index 857eaead5b6582da8c0aedab726c0eb4f8d8d044..3e38d0dbbf9a31d042681f6081a36d4041060319 100644 --- a/paddle/fluid/framework/new_executor/workqueue/workqueue_test.cc +++ b/paddle/fluid/framework/new_executor/workqueue/workqueue_test.cc @@ -13,8 +13,10 @@ // limitations under the License. #include "paddle/fluid/framework/new_executor/workqueue/workqueue.h" + #include #include + #include "glog/logging.h" #include "gtest/gtest.h" #include "paddle/fluid/framework/new_executor/workqueue/workqueue_utils.h" @@ -37,10 +39,10 @@ TEST(WorkQueueUtils, TestEventsWaiter) { TEST(WorkQueue, TestSingleThreadedWorkQueue) { VLOG(1) << "In Test"; - using paddle::framework::WorkQueueOptions; - using paddle::framework::WorkQueue; using paddle::framework::CreateSingleThreadedWorkQueue; using paddle::framework::EventsWaiter; + using paddle::framework::WorkQueue; + using paddle::framework::WorkQueueOptions; std::atomic finished{false}; std::atomic counter{0}; constexpr unsigned kLoopNum = 1000000; @@ -83,10 +85,10 @@ TEST(WorkQueue, TestSingleThreadedWorkQueue) { TEST(WorkQueue, TestMultiThreadedWorkQueue) { VLOG(1) << "In Test"; - using paddle::framework::WorkQueueOptions; - using paddle::framework::WorkQueue; using paddle::framework::CreateMultiThreadedWorkQueue; using paddle::framework::EventsWaiter; + using paddle::framework::WorkQueue; + using paddle::framework::WorkQueueOptions; std::atomic finished{false}; std::atomic counter{0}; constexpr unsigned kExternalLoopNum = 100; @@ -136,10 +138,10 @@ TEST(WorkQueue, TestMultiThreadedWorkQueue) { } TEST(WorkQueue, TestWorkQueueGroup) { - using paddle::framework::WorkQueueOptions; - using paddle::framework::WorkQueueGroup; using paddle::framework::CreateWorkQueueGroup; using paddle::framework::EventsWaiter; + using paddle::framework::WorkQueueGroup; + using paddle::framework::WorkQueueOptions; std::atomic finished{false}; std::atomic counter{0}; constexpr unsigned kExternalLoopNum = 100; diff --git a/paddle/fluid/framework/new_executor/workqueue/workqueue_utils.cc b/paddle/fluid/framework/new_executor/workqueue/workqueue_utils.cc index 82dcbbd509dd510449e820fe50ba2deab0683583..152f89d9ef0b58fed27243205f2c4036455d3fe3 100644 --- a/paddle/fluid/framework/new_executor/workqueue/workqueue_utils.cc +++ b/paddle/fluid/framework/new_executor/workqueue/workqueue_utils.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/new_executor/workqueue/workqueue_utils.h" + #include #include diff --git a/paddle/fluid/framework/new_executor/workqueue/workqueue_utils.h b/paddle/fluid/framework/new_executor/workqueue/workqueue_utils.h index b6e6ede8c334fa58b6bacec9876a287a5bd0b3e0..380746c05d60468dbe37afcbd234ef81c28cd9d1 100644 --- a/paddle/fluid/framework/new_executor/workqueue/workqueue_utils.h +++ b/paddle/fluid/framework/new_executor/workqueue/workqueue_utils.h @@ -21,6 +21,7 @@ #include #include #include + #include "paddle/fluid/framework/new_executor/workqueue/events_waiter.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/no_need_buffer_vars_inference.cc b/paddle/fluid/framework/no_need_buffer_vars_inference.cc index 25f64838c6d39f45ecca41954f57f78f893be1ad..665c9b811faee4fa172d802d35f82a05b4b2d9ee 100644 --- a/paddle/fluid/framework/no_need_buffer_vars_inference.cc +++ b/paddle/fluid/framework/no_need_buffer_vars_inference.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/framework/no_need_buffer_vars_inference.h" + #include + #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/imperative/saved_variable_wrapper_list.h" diff --git a/paddle/fluid/framework/no_need_buffer_vars_inference_test.cc b/paddle/fluid/framework/no_need_buffer_vars_inference_test.cc index a92d52fd2e9ea191193bf39335030b82f9fd6613..a2c7df763a7ef750cc00d730372b6e07a2f9795a 100644 --- a/paddle/fluid/framework/no_need_buffer_vars_inference_test.cc +++ b/paddle/fluid/framework/no_need_buffer_vars_inference_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/no_need_buffer_vars_inference.h" + #include "gtest/gtest.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/imperative/layer.h" diff --git a/paddle/fluid/framework/op_def_api.cc b/paddle/fluid/framework/op_def_api.cc index 73f1409ae690e1eecdb3078d943bf9fd495e7106..b62f17987e651bc842296b9b5120837baa986545 100644 --- a/paddle/fluid/framework/op_def_api.cc +++ b/paddle/fluid/framework/op_def_api.cc @@ -17,6 +17,7 @@ #define _LINUX #endif #include "paddle/fluid/framework/op_def_api.h" + #include #include #include @@ -28,6 +29,7 @@ #endif #include #include + #include "glog/logging.h" #include "paddle/fluid/framework/op_def.pb.h" diff --git a/paddle/fluid/framework/op_def_api.h b/paddle/fluid/framework/op_def_api.h index 1ef2254d0da361915f29b713e2d9a53d5c35cb8a..754b76663df1a06b579a89661f73bdf490b6108a 100644 --- a/paddle/fluid/framework/op_def_api.h +++ b/paddle/fluid/framework/op_def_api.h @@ -21,5 +21,5 @@ namespace framework { const proto::OpDef& GetOpDef(const std::string& op_name); bool HasOpDef(const std::string& op_name); -} -} +} // namespace framework +} // namespace paddle diff --git a/paddle/fluid/framework/op_desc.cc b/paddle/fluid/framework/op_desc.cc index 87d3a048d0be0977e05bb210287d378f3d779095..db2a411da008656eecf415d29c0d42b6fa319215 100644 --- a/paddle/fluid/framework/op_desc.cc +++ b/paddle/fluid/framework/op_desc.cc @@ -495,8 +495,9 @@ bool OpDesc::HasProtoAttr(const std::string &name) const { proto::AttrType OpDesc::GetAttrType(const std::string &name) const { auto it = attrs_.find(name); - PADDLE_ENFORCE_NE(it, attrs_.end(), platform::errors::NotFound( - "Attribute %s is not found.", name)); + PADDLE_ENFORCE_NE( + it, attrs_.end(), + platform::errors::NotFound("Attribute %s is not found.", name)); return static_cast(it->second.which() - 1); } @@ -599,8 +600,9 @@ void OpDesc::SetAttrMap( Attribute OpDesc::GetAttr(const std::string &name) const { auto it = attrs_.find(name); - PADDLE_ENFORCE_NE(it, attrs_.end(), platform::errors::NotFound( - "Attribute %s is not found.", name)); + PADDLE_ENFORCE_NE( + it, attrs_.end(), + platform::errors::NotFound("Attribute %s is not found.", name)); return it->second; } @@ -854,10 +856,11 @@ bool CompileTimeInferShapeContext::HasInput(const std::string &name) const { if (length == 0) { return false; } - PADDLE_ENFORCE_EQ(length, 1UL, platform::errors::InvalidArgument( - "Input(%s) should have only one value, " - "but it has %d values now.", - name, length)); + PADDLE_ENFORCE_EQ( + length, 1UL, + platform::errors::InvalidArgument("Input(%s) should have only one value, " + "but it has %d values now.", + name, length)); return block_.HasVarRecursive(input_names[0]); } @@ -870,10 +873,11 @@ bool CompileTimeInferShapeContext::HasOutput(const std::string &name) const { if (length == 0) { return false; } - PADDLE_ENFORCE_EQ(length, 1UL, platform::errors::InvalidArgument( - "Output(%s) should have only one value, " - "but it has %d values now.", - name, length)); + PADDLE_ENFORCE_EQ(length, 1UL, + platform::errors::InvalidArgument( + "Output(%s) should have only one value, " + "but it has %d values now.", + name, length)); return block_.HasVarRecursive(output_names[0]); } diff --git a/paddle/fluid/framework/op_proto_maker.h b/paddle/fluid/framework/op_proto_maker.h index 903ee73b2c01364b482983d14ecb7af8e43066d5..51aeed2e5d734ebf9d5018eaf2d2fce50dcd005e 100644 --- a/paddle/fluid/framework/op_proto_maker.h +++ b/paddle/fluid/framework/op_proto_maker.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "glog/logging.h" #include "paddle/fluid/framework/attribute.h" namespace paddle { diff --git a/paddle/fluid/framework/op_registry_test.cc b/paddle/fluid/framework/op_registry_test.cc index 889b6b0c86b2fabe3bfe0bece0301e7878990eed..8b77b1d260c42b364b6ccb1d3ab318fc9233a7c2 100644 --- a/paddle/fluid/framework/op_registry_test.cc +++ b/paddle/fluid/framework/op_registry_test.cc @@ -12,11 +12,11 @@ See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/framework/op_registry.h" + #include #include -#include "paddle/fluid/framework/op_registry.h" - namespace pd = paddle::framework; namespace paddle { @@ -58,8 +58,9 @@ class MyTestOpProtoAndCheckerMaker : public OpProtoAndCheckerMaker { AddInput("input", "input of cosine op").AsDuplicable(); AddOutput("output", "output of cosine op").AsIntermediate(); auto my_checker = [](int i) { - PADDLE_ENFORCE_EQ(i % 2, 0, platform::errors::InvalidArgument( - "'test_attr' must be even!")); + PADDLE_ENFORCE_EQ( + i % 2, 0, + platform::errors::InvalidArgument("'test_attr' must be even!")); }; AddAttr("test_attr", "a simple test attribute") .AddCustomChecker(my_checker); diff --git a/paddle/fluid/framework/op_version_proto.h b/paddle/fluid/framework/op_version_proto.h index 9b70bb93bb967f0e23257201ebd2a79248317381..022531d53de1c9cfe473354896d8e3da15593f45 100644 --- a/paddle/fluid/framework/op_version_proto.h +++ b/paddle/fluid/framework/op_version_proto.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include #include "paddle/fluid/framework/framework.pb.h" diff --git a/paddle/fluid/framework/op_version_registry_test.cc b/paddle/fluid/framework/op_version_registry_test.cc index e66d0dc5a1f79108168337ef1f4b08344d6e3063..8f83631c272eec43d4a36902e73784ce66c35976 100644 --- a/paddle/fluid/framework/op_version_registry_test.cc +++ b/paddle/fluid/framework/op_version_registry_test.cc @@ -12,10 +12,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -#include - #include "paddle/fluid/framework/op_version_registry.h" +#include + namespace paddle { namespace framework { namespace compatible { diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index 69f14d7903c0bc6e2ad86ab53197a2b70d3c9d72..7395a8e0da8e81c37a8828839254560744ab93f3 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -12,6 +12,7 @@ limitations under the License. */ #include "paddle/fluid/framework/operator.h" #include + #include #include @@ -1205,10 +1206,11 @@ bool OperatorWithKernel::SupportsMKLDNN( const proto::VarType::Type data_type) const { auto op_kernel_iter = OperatorWithKernel::AllOpKernels().find(type_); if (op_kernel_iter == OperatorWithKernel::AllOpKernels().end()) { - VLOG(6) << "Warning: " << type_ << " don't find its MKLDNN Kernel in Fluid " - "Registered Kernels. And We don't " - "search its kernels in phi lib, " - "SupportsMKLDNN() return false."; + VLOG(6) << "Warning: " << type_ + << " don't find its MKLDNN Kernel in Fluid " + "Registered Kernels. And We don't " + "search its kernels in phi lib, " + "SupportsMKLDNN() return false."; return false; } auto& op_kernels = op_kernel_iter->second; @@ -1440,7 +1442,7 @@ void OperatorWithKernel::RunImpl(const Scope& scope, #if defined(PADDLE_WITH_XPU_KP) && (!is_xpu_unsupport || use_phi_xpu_kp) #endif - ) { + ) { run_phi_kernel_ = true; } else { auto& all_op_kernels = AllOpKernels(); @@ -1464,7 +1466,7 @@ void OperatorWithKernel::RunImpl(const Scope& scope, #if defined(PADDLE_WITH_XPU_KP) || (is_xpu_unsupport && !is_xpu_kp_support) #endif - ) { + ) { auto pt_cpu_kernel_key = FallBackToCpu(*kernel_type_.get(), pt_kernel_key, *this); pt_kernel_.reset( @@ -2238,8 +2240,9 @@ phi::KernelSignature OperatorWithKernel::GetExpectedPhiKernelArgs( if (arg_map_fn) { arg_map_fn_.reset(new phi::ArgumentMappingFn(*arg_map_fn)); } else { - auto func = [this]( - const phi::ArgumentMappingContext& ctx) -> phi::KernelSignature { + auto func = + [this]( + const phi::ArgumentMappingContext& ctx) -> phi::KernelSignature { return phi::DefaultKernelSignatureMap::Instance().Get(type_); }; arg_map_fn_.reset(new phi::ArgumentMappingFn(func)); diff --git a/paddle/fluid/framework/operator.h b/paddle/fluid/framework/operator.h index 2efa2e4bd8a759bfe69ac057f5e0ec652a55a4ed..dc13287b5aad394d9ecf0db18e1e9839596fa24d 100644 --- a/paddle/fluid/framework/operator.h +++ b/paddle/fluid/framework/operator.h @@ -27,6 +27,7 @@ limitations under the License. */ #include "glog/logging.h" // For VLOG #include "paddle/fluid/framework/attribute.h" #include "paddle/fluid/framework/block_desc.h" +#include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/op_info.h" #include "paddle/fluid/framework/op_kernel_type.h" @@ -38,12 +39,10 @@ limitations under the License. */ #include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/variant.h" -#include "paddle/utils/flat_hash_map.h" - -#include "paddle/fluid/framework/convert_utils.h" #include "paddle/phi/core/compat/arg_map_context.h" #include "paddle/phi/core/compat/op_utils.h" #include "paddle/phi/core/kernel_factory.h" +#include "paddle/utils/flat_hash_map.h" namespace paddle { namespace framework { @@ -610,12 +609,12 @@ class OperatorWithKernel : public OperatorBase { /* member functions for adapting to phi lib */ /** In the Tensor calculation library, the new Kernel adopts a clearer and - * more streamlined design. The arguments of the Kernel and the input and - * output arguments registered in the original OpMaker do not match in some - * cases, so we use map to record the arguments required by the kernel. - * When selecting Kernel during Op execution, select the arguments of the - * original Op according to the GetExpectedPhiKernelArgs returned arguments. - */ + * more streamlined design. The arguments of the Kernel and the input and + * output arguments registered in the original OpMaker do not match in some + * cases, so we use map to record the arguments required by the kernel. + * When selecting Kernel during Op execution, select the arguments of the + * original Op according to the GetExpectedPhiKernelArgs returned arguments. + */ phi::KernelSignature GetExpectedPhiKernelArgs( const ExecutionContext& ctx) const; diff --git a/paddle/fluid/framework/operator_exception_test.cc b/paddle/fluid/framework/operator_exception_test.cc index 7b513996fb40eac57c14916e80a801aeecfcd0a4..0f635d170de2f8fbe54462e09e8684352a4cf8f6 100644 --- a/paddle/fluid/framework/operator_exception_test.cc +++ b/paddle/fluid/framework/operator_exception_test.cc @@ -12,12 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/framework/operator.h" #include #include #include #include + #include "gtest/gtest.h" +#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/framework/operator_kernel_configs.h b/paddle/fluid/framework/operator_kernel_configs.h index ab812a30981f0d931ac44c03479e456b5746e6b1..57d377f1389cfee99e6cefdd4f406eb8107f0ea1 100644 --- a/paddle/fluid/framework/operator_kernel_configs.h +++ b/paddle/fluid/framework/operator_kernel_configs.h @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include + #include "glog/logging.h" namespace paddle { diff --git a/paddle/fluid/framework/operator_test.cc b/paddle/fluid/framework/operator_test.cc index 24e09bcd463dc7407c3e18bd9e1154a13bc07d13..3dda60de12ad4f0d1b271702b40e0b3362508005 100644 --- a/paddle/fluid/framework/operator_test.cc +++ b/paddle/fluid/framework/operator_test.cc @@ -11,11 +11,11 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "gtest/gtest.h" +#include "paddle/fluid/framework/operator.h" +#include "gtest/gtest.h" #include "paddle/fluid/framework/op_info.h" #include "paddle/fluid/framework/op_registry.h" -#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/platform/errors.h" #include "paddle/fluid/platform/init.h" diff --git a/paddle/fluid/framework/paddle2cinn/build_cinn_pass.cc b/paddle/fluid/framework/paddle2cinn/build_cinn_pass.cc index 295510cdb1cf214f3ec2899575ef98ae48fef969..a2bdd2bc4c105abd0eb39758ee1a4a9cc4e8d42b 100644 --- a/paddle/fluid/framework/paddle2cinn/build_cinn_pass.cc +++ b/paddle/fluid/framework/paddle2cinn/build_cinn_pass.cc @@ -334,7 +334,7 @@ std::unique_ptr CreateNewSubGraph(const GraphNodeSet& cluster, } GraphNodeSet need_feed_vars; - std::unordered_set param_vars, output_vars; + std::unordered_set param_vars, output_vars; // the subgraph is independently, so here we only need link // to the node in new subgraph, and discard the link to // out-graph. @@ -386,18 +386,18 @@ std::unique_ptr CreateNewSubGraph(const GraphNodeSet& cluster, subgraph.get()); // Save lists of input variables, internal variables and output variables // of the cluster as attributes of the subgraph for convenience. - auto collect_names_fn = []( - const GraphNodeSet& nodes, - const std::unordered_set& ignore_names) { - auto result = std::make_unique>(); - for (auto* node : nodes) { - if (!node->Var() || ignore_names.count(node->Name())) { - continue; - } - result->emplace_back(node->Name()); - } - return result; - }; + auto collect_names_fn = + [](const GraphNodeSet& nodes, + const std::unordered_set& ignore_names) { + auto result = std::make_unique>(); + for (auto* node : nodes) { + if (!node->Var() || ignore_names.count(node->Name())) { + continue; + } + result->emplace_back(node->Name()); + } + return result; + }; subgraph->Set>( kInternalVars, collect_names_fn(cluster_internals, {}).release()); subgraph->Set>( diff --git a/paddle/fluid/framework/paddle2cinn/build_cinn_pass_test.cc b/paddle/fluid/framework/paddle2cinn/build_cinn_pass_test.cc index d593aadc02c73adddf0e2cace9741834412c6e2c..e9c517af2c3959da5b9d9740f1b3052c63aa8001 100644 --- a/paddle/fluid/framework/paddle2cinn/build_cinn_pass_test.cc +++ b/paddle/fluid/framework/paddle2cinn/build_cinn_pass_test.cc @@ -19,7 +19,6 @@ limitations under the License. */ #include #include "gtest/gtest.h" - #include "paddle/fluid/framework/details/build_strategy.h" #include "paddle/fluid/framework/ir/graph.h" #include "paddle/fluid/framework/ir/node.h" diff --git a/paddle/fluid/framework/paddle2cinn/cinn_cache_key.cc b/paddle/fluid/framework/paddle2cinn/cinn_cache_key.cc index 9b5ce876c256f44429ce4e95631ceefd87c4f76c..585f9edce868a3a8f890cf508ffa19f0efc6c1a9 100644 --- a/paddle/fluid/framework/paddle2cinn/cinn_cache_key.cc +++ b/paddle/fluid/framework/paddle2cinn/cinn_cache_key.cc @@ -100,7 +100,7 @@ size_t CinnCacheKeyByStructure::HashGraph(const ir::Graph& graph) { // graph.Nodes() return unordered_set, here using set to avoid the same graph // may return different result - std::set node_set(compare), + std::set node_set(compare), output_set(compare); node_set.insert(graph.Nodes().begin(), graph.Nodes().end()); diff --git a/paddle/fluid/framework/paddle2cinn/cinn_cache_key_test.cc b/paddle/fluid/framework/paddle2cinn/cinn_cache_key_test.cc index 1ebeecbff954a5b6c3dc205d6e3b42c3a89709f0..24e65599018fa7a3508c1c865ef1c15d82105517 100644 --- a/paddle/fluid/framework/paddle2cinn/cinn_cache_key_test.cc +++ b/paddle/fluid/framework/paddle2cinn/cinn_cache_key_test.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// clang-format off #include #include @@ -21,6 +22,7 @@ #include "paddle/fluid/framework/paddle2cinn/cinn_cache_key.h" #include "paddle/fluid/framework/program_desc.h" #include "paddle/phi/core/ddim.h" +// clang-format on namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/paddle2cinn/cinn_compiler.cc b/paddle/fluid/framework/paddle2cinn/cinn_compiler.cc index 12f603542066fe113d252494fc17c24618352be1..2a6a51d73f2b88b06936949968fc21fd8ffd3632 100644 --- a/paddle/fluid/framework/paddle2cinn/cinn_compiler.cc +++ b/paddle/fluid/framework/paddle2cinn/cinn_compiler.cc @@ -51,14 +51,14 @@ namespace paddle { namespace framework { namespace paddle2cinn { -using ir::Graph; -using ir::Node; -using inference::analysis::Dot; using ::cinn::auto_schedule::AutoTuner; using ::cinn::common::Target; using ::cinn::frontend::Optimize; using ::cinn::hlir::framework::BuildScope; using ::cinn::hlir::framework::GraphCompiler; +using inference::analysis::Dot; +using ir::Graph; +using ir::Node; CinnCompiler* CinnCompiler::GetInstance() { static CinnCompiler* instance = new CinnCompiler(); diff --git a/paddle/fluid/framework/paddle2cinn/cinn_compiler.h b/paddle/fluid/framework/paddle2cinn/cinn_compiler.h index a38e8b4c5f6745b4612599364864868802470a43..91c559767642a1617d91338bf85beecc26cc3d6b 100644 --- a/paddle/fluid/framework/paddle2cinn/cinn_compiler.h +++ b/paddle/fluid/framework/paddle2cinn/cinn_compiler.h @@ -20,6 +20,7 @@ #include #include #include + #include "paddle/fluid/framework/ir/graph.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/paddle2cinn/cinn_cache_key.h" diff --git a/paddle/fluid/framework/paddle2cinn/cinn_compiler_test.cc b/paddle/fluid/framework/paddle2cinn/cinn_compiler_test.cc index 255e318c9fa69bb81882de92106528fb9c07117e..5a84a97ee8da7a06148730bd03d10dd32f3e3454 100644 --- a/paddle/fluid/framework/paddle2cinn/cinn_compiler_test.cc +++ b/paddle/fluid/framework/paddle2cinn/cinn_compiler_test.cc @@ -44,8 +44,8 @@ DECLARE_string(deny_cinn_ops); namespace paddle { namespace framework { namespace paddle2cinn { -using ir::Graph; using ::cinn::common::Target; +using ir::Graph; namespace { template > diff --git a/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.cc b/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.cc index 31bf8d9b726d8e0f6bfb55de834f1c2cfab8ac1d..4e362057c915f23f3eef55c43391f37b2ca59d8c 100644 --- a/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.cc +++ b/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.cc @@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +// clang-format off #include "paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.h" #include @@ -30,6 +31,7 @@ limitations under the License. */ #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/errors.h" +// clang-format on namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.h b/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.h index 526eb65a56ede730c5be473d1700f1c441d1a21a..4155147da4b8fe8327679fc3d9d5b510ff314f35 100644 --- a/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.h +++ b/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once +// clang-format off #include #include #include @@ -26,6 +27,7 @@ limitations under the License. */ #include "cinn/frontend/net_builder.h" #include "cinn/frontend/op_mapper_registry.h" +// clang-format on namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization_test.cc b/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization_test.cc index c0e1ca8f0d123379f3363afc45dd083b4a5dc951..8a6f92a6f45d04d0256e14cc7e185dac431774f1 100644 --- a/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization_test.cc +++ b/paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization_test.cc @@ -12,18 +12,20 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +// clang-format off #include "gtest/gtest.h" #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/paddle2cinn/cinn_graph_symbolization.h" +// clang-format on namespace paddle { namespace framework { namespace paddle2cinn { +using ::cinn::frontend::NetBuilder; using ir::Graph; using ir::Node; -using ::cinn::frontend::NetBuilder; using CinnTensor = ::cinn::hlir::framework::Tensor; using OpMapperContext = CinnGraphSymbolization::OpMapperContext; using CinnOpDesc = CinnGraphSymbolization::CinnOpDesc; diff --git a/paddle/fluid/framework/paddle2cinn/transform_desc.h b/paddle/fluid/framework/paddle2cinn/transform_desc.h index 76a4f812730dfa5e02e56d44066eceb767d45450..6f0931b6d038d0dd2173e11c0ea4ec795aaf8dc8 100644 --- a/paddle/fluid/framework/paddle2cinn/transform_desc.h +++ b/paddle/fluid/framework/paddle2cinn/transform_desc.h @@ -14,6 +14,8 @@ #pragma once +// The headers cant be sorted by clang-format or compilint error occurs. +// clang-format off #include "paddle/fluid/framework/block_desc.h" #include "paddle/fluid/framework/op_desc.h" #include "paddle/fluid/framework/program_desc.h" @@ -24,6 +26,7 @@ #include "cinn/frontend/paddle/cpp/op_desc.h" #include "cinn/frontend/paddle/cpp/program_desc.h" #include "cinn/frontend/paddle/cpp/var_desc.h" +// clang-format on namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/paddle2cinn/transform_desc_test.cc b/paddle/fluid/framework/paddle2cinn/transform_desc_test.cc index ba324295cad7234fcf3d2e5bbd040d207fb3adeb..ae9f51c3f6790e3d59b0cec9e1ac8203b274e274 100644 --- a/paddle/fluid/framework/paddle2cinn/transform_desc_test.cc +++ b/paddle/fluid/framework/paddle2cinn/transform_desc_test.cc @@ -12,10 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +// clang-format off #include #include "gtest/gtest.h" #include "paddle/fluid/framework/paddle2cinn/transform_desc.h" +// clang-format on namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/paddle2cinn/transform_type.cc b/paddle/fluid/framework/paddle2cinn/transform_type.cc index 0e348084d254e08894109eda2f5e407d03f75dea..60502edd99acf94de2d0cdada3c3545692ec5f81 100644 --- a/paddle/fluid/framework/paddle2cinn/transform_type.cc +++ b/paddle/fluid/framework/paddle2cinn/transform_type.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/paddle2cinn/transform_type.h" + #include "cinn/common/type.h" #include "cinn/runtime/cinn_runtime.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/framework/paddle2cinn/transform_type.h b/paddle/fluid/framework/paddle2cinn/transform_type.h index e44960abbd98d56e2e9a3e22b3cc9ec1e443e8b9..f0b08ba1e00a4edc39d2c653826d95578b4ed409 100644 --- a/paddle/fluid/framework/paddle2cinn/transform_type.h +++ b/paddle/fluid/framework/paddle2cinn/transform_type.h @@ -19,7 +19,7 @@ struct cinn_type_t; namespace cinn::common { struct Type; -} // ::cinn::common +} // namespace cinn::common namespace paddle::framework::paddle2cinn { diff --git a/paddle/fluid/framework/paddle2cinn/transform_type_test.cc b/paddle/fluid/framework/paddle2cinn/transform_type_test.cc index 6c5d360d34cdd8d4b151c1dd981585d1229caa6f..4456642b3e9a0771ebac956117491b081224c834 100644 --- a/paddle/fluid/framework/paddle2cinn/transform_type_test.cc +++ b/paddle/fluid/framework/paddle2cinn/transform_type_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/paddle2cinn/transform_type.h" + #include "cinn/common/type.h" #include "cinn/runtime/cinn_runtime.h" #include "gtest/gtest.h" diff --git a/paddle/fluid/framework/parallel_executor.cc b/paddle/fluid/framework/parallel_executor.cc index b088a535a12329f71d308417bb2d52a54466e967..00d48098a13f606b1323bc9792e4c605814c5732 100644 --- a/paddle/fluid/framework/parallel_executor.cc +++ b/paddle/fluid/framework/parallel_executor.cc @@ -666,8 +666,9 @@ ParallelExecutor::ParallelExecutor(const std::vector &places, ir::Graph *graph) : member_(new ParallelExecutorPrivate(places, scope)) { PADDLE_ENFORCE_EQ(places.size() > 0 && !platform::is_npu_place(places[0]), - true, platform::errors::Unavailable( - "NPU is not supported in ParallelExecutor.")); + true, + platform::errors::Unavailable( + "NPU is not supported in ParallelExecutor.")); InitP2P(places); ir::InitReaderQueueDeviceCount(graph, *(member_->global_scope_), member_->places_.size()); diff --git a/paddle/fluid/framework/parallel_executor.h b/paddle/fluid/framework/parallel_executor.h index 18d0ee78ffbbc7b063a1f8fcaf90c825d5965228..3dc9fbcfbf312362645835b8b8894360aa644c90 100644 --- a/paddle/fluid/framework/parallel_executor.h +++ b/paddle/fluid/framework/parallel_executor.h @@ -42,9 +42,9 @@ namespace framework { class ParallelExecutorPrivate; -using details::VariableInfo; using details::BuildStrategy; using details::ExecutionStrategy; +using details::VariableInfo; namespace p = paddle::platform; using DeviceType = paddle::platform::DeviceType; diff --git a/paddle/fluid/framework/phi_utils.cc b/paddle/fluid/framework/phi_utils.cc index 3eda00006f959704f8f8ed75597050cb63f1cece..19f7b024b27f2426df8f9474c227d8f4e65542f8 100644 --- a/paddle/fluid/framework/phi_utils.cc +++ b/paddle/fluid/framework/phi_utils.cc @@ -12,11 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/framework/phi_utils.h" + #include #include "paddle/fluid/framework/convert_utils.h" -#include "paddle/fluid/framework/phi_utils.h" - #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/op_info.h" #include "paddle/fluid/framework/selected_rows_utils.h" diff --git a/paddle/fluid/framework/phi_utils.h b/paddle/fluid/framework/phi_utils.h index 785ede5c601759423008bb842a569fa80fd76dcc..535672f2e128840fae16049115318e8ebe1a9401 100644 --- a/paddle/fluid/framework/phi_utils.h +++ b/paddle/fluid/framework/phi_utils.h @@ -21,11 +21,10 @@ limitations under the License. */ #include "paddle/fluid/framework/framework.pb.h" #include "paddle/fluid/framework/op_kernel_type.h" +#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/platform/macros.h" #include "paddle/fluid/platform/place.h" - -#include "paddle/fluid/framework/operator.h" #include "paddle/phi/api/lib/utils/tensor_utils.h" #include "paddle/phi/common/backend.h" #include "paddle/phi/core/compat/arg_map_context.h" diff --git a/paddle/fluid/framework/phi_utils_test.cc b/paddle/fluid/framework/phi_utils_test.cc index cbcdf24c9f32b47f3337b4f176753328497d8c85..02eb23f8ac17b02f82ebbee7d0a11b3d11b0949b 100644 --- a/paddle/fluid/framework/phi_utils_test.cc +++ b/paddle/fluid/framework/phi_utils_test.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/phi_utils.h" + #include "gtest/gtest.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/selected_rows_utils.h" diff --git a/paddle/fluid/framework/program_desc.cc b/paddle/fluid/framework/program_desc.cc index 4a31adcca65ec824ea96e6dadad0b8a1f8f1a27d..88738255af78e11035e83fb31d416f9302b48428 100644 --- a/paddle/fluid/framework/program_desc.cc +++ b/paddle/fluid/framework/program_desc.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/program_desc.h" + #include "paddle/fluid/framework/feed_fetch_type.h" #include "paddle/fluid/framework/version.h" diff --git a/paddle/fluid/framework/program_desc.h b/paddle/fluid/framework/program_desc.h index 4ceb0c5c8248143791238a7b9077e402a7c1b832..7e1c12f4ac5b19a4bf1efdb75c81ce78304f4294 100644 --- a/paddle/fluid/framework/program_desc.h +++ b/paddle/fluid/framework/program_desc.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include #include #include diff --git a/paddle/fluid/framework/program_processing.cc b/paddle/fluid/framework/program_processing.cc index 3bcf6f8f3855f0edd857cca37bd1497e2fd9ab2f..95b28b79dcf36707b8ed18ae87d143192f73b986 100644 --- a/paddle/fluid/framework/program_processing.cc +++ b/paddle/fluid/framework/program_processing.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/program_processing.h" + #include "paddle/fluid/framework/block_desc.h" namespace paddle { diff --git a/paddle/fluid/framework/prune.cc b/paddle/fluid/framework/prune.cc index 4c95f01ae569f952c87a5b24a2e43fe0204554d1..fbeedcc311ac75e343da001b518a6c490b64fd5e 100644 --- a/paddle/fluid/framework/prune.cc +++ b/paddle/fluid/framework/prune.cc @@ -17,6 +17,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_proto_maker.h" namespace paddle { diff --git a/paddle/fluid/framework/prune_test.cc b/paddle/fluid/framework/prune_test.cc index 64b30878150d0f77c0340aab04785e30e44a5be3..5fbfda716b437cbb628ab0143c1216ce2fc2f7a7 100644 --- a/paddle/fluid/framework/prune_test.cc +++ b/paddle/fluid/framework/prune_test.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/fluid/framework/prune.h" #include + #include #include "paddle/fluid/framework/block_desc.h" diff --git a/paddle/fluid/framework/ps_gpu_trainer.cc b/paddle/fluid/framework/ps_gpu_trainer.cc index aec40a5a7ebdd9f60d23eca3c6060a0063c5363b..c86bfbc43bfb9c8a7a07c9121259fa759d722f50 100644 --- a/paddle/fluid/framework/ps_gpu_trainer.cc +++ b/paddle/fluid/framework/ps_gpu_trainer.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include #include #include diff --git a/paddle/fluid/framework/pull_dense_worker.cc b/paddle/fluid/framework/pull_dense_worker.cc index a12079a135dbd41a286f7b8f893e30ea04b11b0e..7a0fe65182d137efa61c2eef0f8192fc012d7cfd 100644 --- a/paddle/fluid/framework/pull_dense_worker.cc +++ b/paddle/fluid/framework/pull_dense_worker.cc @@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/device_worker.h" namespace phi { diff --git a/paddle/fluid/framework/reader.cc b/paddle/fluid/framework/reader.cc index b418339bf32965a454e5b240bb728c4cb41e03ba..27940f726dca1d8acbe2d42efd153801f909ea2b 100644 --- a/paddle/fluid/framework/reader.cc +++ b/paddle/fluid/framework/reader.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/reader.h" + #include namespace paddle { diff --git a/paddle/fluid/framework/save_load_util.cc b/paddle/fluid/framework/save_load_util.cc index 44488fca01c021612525e1a12ebd2f2a9565ea66..284965fdfe9a88bd53ed6b3a73b6eb5e8c5bfd9c 100644 --- a/paddle/fluid/framework/save_load_util.cc +++ b/paddle/fluid/framework/save_load_util.cc @@ -342,8 +342,9 @@ bool LoadTensorFromDisk( uint32_t version; fin.read(reinterpret_cast(&version), sizeof(version)); CheckInStreamState(fin, sizeof(version)); - PADDLE_ENFORCE_EQ(version, 0U, platform::errors::InvalidArgument( - "Only version 0 tensor is supported.")); + PADDLE_ENFORCE_EQ(version, 0U, + platform::errors::InvalidArgument( + "Only version 0 tensor is supported.")); proto::VarType::TensorDesc desc; { // int32_t size diff --git a/paddle/fluid/framework/save_load_util_test.cc b/paddle/fluid/framework/save_load_util_test.cc index 10a34d7ce91ad27a271b8a112a1af1e39da52e31..623f0f27bdaa204ba4dd1b66990a01d2ff27cfa6 100644 --- a/paddle/fluid/framework/save_load_util_test.cc +++ b/paddle/fluid/framework/save_load_util_test.cc @@ -11,11 +11,12 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/framework/save_load_util.h" + #include #include #include "gtest/gtest.h" -#include "paddle/fluid/framework/save_load_util.h" namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/scope_guard.h b/paddle/fluid/framework/scope_guard.h index 83387842e94ef1944fb0bbbbac5b27c27ed85d2d..9c741f7bfc5734e4966d12d409d4d8fbc8d2a350 100644 --- a/paddle/fluid/framework/scope_guard.h +++ b/paddle/fluid/framework/scope_guard.h @@ -16,6 +16,7 @@ #include #include + #include "paddle/fluid/platform/macros.h" namespace paddle { @@ -41,12 +42,12 @@ class ScopeGuard { #define _PADDLE_CONCAT_TOKEN(x, y) x##y #define PADDLE_CONCAT_TOKEN(x, y) _PADDLE_CONCAT_TOKEN(x, y) -#define DEFINE_PADDLE_SCOPE_GUARD(...) \ - auto PADDLE_CONCAT_TOKEN(__scope_guard_func, __LINE__) = __VA_ARGS__; \ - ::paddle::framework::ScopeGuard::type> \ - PADDLE_CONCAT_TOKEN(__scope_guard, __LINE__)( \ - PADDLE_CONCAT_TOKEN(__scope_guard_func, __LINE__)) +#define DEFINE_PADDLE_SCOPE_GUARD(...) \ + auto PADDLE_CONCAT_TOKEN(__scope_guard_func, __LINE__) = __VA_ARGS__; \ + ::paddle::framework::ScopeGuard::type> \ + PADDLE_CONCAT_TOKEN(__scope_guard, __LINE__)( \ + PADDLE_CONCAT_TOKEN(__scope_guard_func, __LINE__)) } // namespace framework } // namespace paddle diff --git a/paddle/fluid/framework/scope_guard_test.cc b/paddle/fluid/framework/scope_guard_test.cc index d7a7a6168a3687af95803eb584246556eb30fa0b..793b3a1652a1c19d9983519ed01e51319e5cd47f 100644 --- a/paddle/fluid/framework/scope_guard_test.cc +++ b/paddle/fluid/framework/scope_guard_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/scope_guard.h" + #include "gtest/gtest.h" namespace paddle { diff --git a/paddle/fluid/framework/section_worker.cc b/paddle/fluid/framework/section_worker.cc index 1f821720d64d21b375e009275c4a62f89c86429a..7bb8550926d63221394f491dbd2104858c822356 100644 --- a/paddle/fluid/framework/section_worker.cc +++ b/paddle/fluid/framework/section_worker.cc @@ -12,6 +12,7 @@ limitations under the License. */ #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) || \ defined(PADDLE_WITH_ASCEND_CL) #include + #include "paddle/fluid/framework/device_worker.h" #include "paddle/fluid/framework/executor_gc_helper.h" #include "paddle/fluid/platform/device_context.h" diff --git a/paddle/fluid/framework/selected_rows_utils.h b/paddle/fluid/framework/selected_rows_utils.h index 8606295c451998705377067955662b8c6cd1d083..9ecff5719fb9149a7719fdbf3766ab09b7e37a1e 100644 --- a/paddle/fluid/framework/selected_rows_utils.h +++ b/paddle/fluid/framework/selected_rows_utils.h @@ -21,10 +21,9 @@ limitations under the License. */ #include #include -#include "paddle/phi/core/selected_rows.h" - #include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/platform/device_context.h" +#include "paddle/phi/core/selected_rows.h" namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/selected_rows_utils_test.cc b/paddle/fluid/framework/selected_rows_utils_test.cc index f23510c721e24458812602d561b9b6fd1897c903..db2c6c1f991b7c6b2116acdc3c08fc576d1b4155 100644 --- a/paddle/fluid/framework/selected_rows_utils_test.cc +++ b/paddle/fluid/framework/selected_rows_utils_test.cc @@ -9,11 +9,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/framework/selected_rows_utils.h" + #include + #include // NOLINT #include "gtest/gtest.h" -#include "paddle/fluid/framework/selected_rows_utils.h" namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/string_array.cc b/paddle/fluid/framework/string_array.cc old mode 100755 new mode 100644 index 3071e6bf4cff3356e4746c44d336c0a06fed58b1..f6aee9b82f2c6afec98e753cdf905c76eaa75eab --- a/paddle/fluid/framework/string_array.cc +++ b/paddle/fluid/framework/string_array.cc @@ -12,12 +12,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/framework/string_array.h" + #include #include #include "glog/logging.h" -#include "paddle/fluid/framework/string_array.h" namespace paddle { namespace framework { diff --git a/paddle/fluid/framework/tensor.h b/paddle/fluid/framework/tensor.h index 57eddf782f06bfce1d42c26e68c7789207bcf37f..7ad9839d79dcaaf6a3bd453ac12a2e6b256c14fe 100644 --- a/paddle/fluid/framework/tensor.h +++ b/paddle/fluid/framework/tensor.h @@ -23,15 +23,14 @@ limitations under the License. */ #include "paddle/fluid/framework/data_layout.h" #include "paddle/fluid/framework/framework.pb.h" +#include "paddle/fluid/framework/mixed_vector.h" #include "paddle/fluid/memory/memory.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/place.h" #include "paddle/phi/core/ddim.h" -#include "paddle/phi/core/stream.h" - -#include "paddle/fluid/framework/mixed_vector.h" #include "paddle/phi/core/dense_tensor.h" +#include "paddle/phi/core/stream.h" namespace paddle { diff --git a/paddle/fluid/framework/tensor_impl.h b/paddle/fluid/framework/tensor_impl.h index f5e230773fb2fc3d4543d684a8e127785211378a..946b119ecb39f9ff557cdc17fae9f97d9efe18da 100644 --- a/paddle/fluid/framework/tensor_impl.h +++ b/paddle/fluid/framework/tensor_impl.h @@ -24,12 +24,13 @@ namespace framework { inline Tensor ReshapeToMatrix(const Tensor& src, int num_col_dims) { int rank = src.dims().size(); PADDLE_ENFORCE_GE( - rank, 2, platform::errors::InvalidArgument( - "'ReshapeToMatrix()' is only used for flatten high rank " - "tensors to matrixs. The dimensions of Tensor must be " - "greater or equal than 2. " - "But received dimensions of Tensor is %d", - rank)); + rank, 2, + platform::errors::InvalidArgument( + "'ReshapeToMatrix()' is only used for flatten high rank " + "tensors to matrixs. The dimensions of Tensor must be " + "greater or equal than 2. " + "But received dimensions of Tensor is %d", + rank)); if (rank == 2) { return src; } diff --git a/paddle/fluid/framework/tensor_test.cc b/paddle/fluid/framework/tensor_test.cc index 3e104807535e918bcd0a7cf67615e8b9ca6ce63a..05dd41eb6ffc56cf9fb945b5e4e06157e5b27fde 100644 --- a/paddle/fluid/framework/tensor_test.cc +++ b/paddle/fluid/framework/tensor_test.cc @@ -15,6 +15,7 @@ #include "paddle/fluid/framework/tensor.h" #include + #include namespace framework = paddle::framework; diff --git a/paddle/fluid/framework/tensor_util.cc b/paddle/fluid/framework/tensor_util.cc index 1159280762f5a3763c10a0ccf3516250c4721c21..1e25acb2c4ecbbb4de34d24013f22c2557ac77c9 100644 --- a/paddle/fluid/framework/tensor_util.cc +++ b/paddle/fluid/framework/tensor_util.cc @@ -12,6 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/framework/tensor_util.h" + #include #include #include @@ -21,10 +23,8 @@ limitations under the License. */ #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/data_type.h" -#include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/platform/complex.h" #include "paddle/fluid/platform/profiler/event_tracing.h" - #include "paddle/phi/core/dense_tensor.h" #ifdef PADDLE_WITH_MKLDNN @@ -1249,10 +1249,12 @@ void TensorFromStream(std::istream& is, Tensor* tensor, // proto buffer int32_t size = -1; is.read(reinterpret_cast(&size), sizeof(size)); - PADDLE_ENFORCE_EQ(is.good(), true, platform::errors::Unavailable( - "Cannot read tensor desc size")); - PADDLE_ENFORCE_GE(size, 0, platform::errors::InvalidArgument( - "Tensor desc size should >= 0")); + PADDLE_ENFORCE_EQ( + is.good(), true, + platform::errors::Unavailable("Cannot read tensor desc size")); + PADDLE_ENFORCE_GE( + size, 0, + platform::errors::InvalidArgument("Tensor desc size should >= 0")); std::unique_ptr buf(new char[size]); is.read(reinterpret_cast(buf.get()), size); PADDLE_ENFORCE_EQ( diff --git a/paddle/fluid/framework/tensor_util_test.cc b/paddle/fluid/framework/tensor_util_test.cc index 5e6e1227b1aacc95f3e9d0103e0888639e582fe1..2511fdf27ce69d5f51f96a7c7d67f5c6e9c07dac 100644 --- a/paddle/fluid/framework/tensor_util_test.cc +++ b/paddle/fluid/framework/tensor_util_test.cc @@ -15,6 +15,7 @@ #include "paddle/fluid/framework/tensor_util.h" #include + #include namespace paddle { @@ -254,64 +255,61 @@ TEST(TensorToVector, Tensor) { #endif } -TEST(TensorToVector, Tensor_bool) { - { - paddle::framework::Tensor src; - bool* src_ptr = - src.mutable_data({3, 3}, paddle::platform::CPUPlace()); - for (int i = 0; i < 3 * 3; ++i) { - src_ptr[i] = static_cast(i % 2); - } +TEST(TensorToVector, Tensor_bool){{paddle::framework::Tensor src; +bool* src_ptr = src.mutable_data({3, 3}, paddle::platform::CPUPlace()); +for (int i = 0; i < 3 * 3; ++i) { + src_ptr[i] = static_cast(i % 2); +} - paddle::platform::CPUPlace place; - std::vector dst; - paddle::framework::TensorToVector(src, &dst); +paddle::platform::CPUPlace place; +std::vector dst; +paddle::framework::TensorToVector(src, &dst); - for (int i = 0; i < 3 * 3; ++i) { - EXPECT_EQ(src_ptr[i], dst[i]); - } - } +for (int i = 0; i < 3 * 3; ++i) { + EXPECT_EQ(src_ptr[i], dst[i]); +} +} // namespace framework #ifdef PADDLE_WITH_CUDA - { - std::vector src_vec = { - false, true, false, true, false, true, false, true, false, - }; - paddle::framework::Tensor gpu_tensor; - paddle::platform::CUDAPlace place; - paddle::platform::CUDADeviceContext gpu_ctx(place); - gpu_ctx.SetAllocator(paddle::memory::allocation::AllocatorFacade::Instance() - .GetAllocator(place, gpu_ctx.stream()) - .get()); - gpu_ctx.PartialInitWithAllocator(); - paddle::framework::TensorFromVector(src_vec, gpu_ctx, &gpu_tensor); - - std::vector dst; - paddle::framework::TensorToVector(gpu_tensor, gpu_ctx, &dst); - - for (int i = 0; i < 3 * 3; ++i) { - EXPECT_EQ(src_vec[i], dst[i]); - } +{ + std::vector src_vec = { + false, true, false, true, false, true, false, true, false, + }; + paddle::framework::Tensor gpu_tensor; + paddle::platform::CUDAPlace place; + paddle::platform::CUDADeviceContext gpu_ctx(place); + gpu_ctx.SetAllocator(paddle::memory::allocation::AllocatorFacade::Instance() + .GetAllocator(place, gpu_ctx.stream()) + .get()); + gpu_ctx.PartialInitWithAllocator(); + paddle::framework::TensorFromVector(src_vec, gpu_ctx, &gpu_tensor); + + std::vector dst; + paddle::framework::TensorToVector(gpu_tensor, gpu_ctx, &dst); + + for (int i = 0; i < 3 * 3; ++i) { + EXPECT_EQ(src_vec[i], dst[i]); } +} #endif #ifdef PADDLE_WITH_ASCEND_CL - { - std::vector src_vec = { - false, true, false, true, false, true, false, true, false, - }; - paddle::framework::Tensor npu_tensor; - paddle::platform::NPUPlace place(0); - paddle::platform::NPUDeviceContext npu_ctx(place); - paddle::framework::TensorFromVector(src_vec, npu_ctx, &npu_tensor); - - std::vector dst; - paddle::framework::TensorToVector(npu_tensor, npu_ctx, &dst); - - for (int i = 0; i < 3 * 3; ++i) { - EXPECT_EQ(src_vec[i], dst[i]); - } +{ + std::vector src_vec = { + false, true, false, true, false, true, false, true, false, + }; + paddle::framework::Tensor npu_tensor; + paddle::platform::NPUPlace place(0); + paddle::platform::NPUDeviceContext npu_ctx(place); + paddle::framework::TensorFromVector(src_vec, npu_ctx, &npu_tensor); + + std::vector dst; + paddle::framework::TensorToVector(npu_tensor, npu_ctx, &dst); + + for (int i = 0; i < 3 * 3; ++i) { + EXPECT_EQ(src_vec[i], dst[i]); } -#endif } +#endif +} // namespace paddle TEST(TensorFromDLPack, Tensor) { { diff --git a/paddle/fluid/framework/threadpool.cc b/paddle/fluid/framework/threadpool.cc index 33533b1d10febe7760cdd38ade502ff169bf28cc..b704ac4329dc87c032c0fced316d2012f20ea606 100644 --- a/paddle/fluid/framework/threadpool.cc +++ b/paddle/fluid/framework/threadpool.cc @@ -43,8 +43,9 @@ void ThreadPool::Init() { num_threads = FLAGS_dist_threadpool_size; VLOG(1) << "set dist_threadpool_size to " << num_threads; } - PADDLE_ENFORCE_GT(num_threads, 0, platform::errors::InvalidArgument( - "The number of threads is 0.")); + PADDLE_ENFORCE_GT( + num_threads, 0, + platform::errors::InvalidArgument("The number of threads is 0.")); threadpool_.reset(new ThreadPool(num_threads)); } } diff --git a/paddle/fluid/framework/threadpool_test.cc b/paddle/fluid/framework/threadpool_test.cc index 1278a0f0643f4a70407ad3eebdf11e0ca68f8a46..0b6e12967fe1be3e0da1a71def998f58d01bf090 100644 --- a/paddle/fluid/framework/threadpool_test.cc +++ b/paddle/fluid/framework/threadpool_test.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/threadpool.h" + #include + #include namespace framework = paddle::framework; diff --git a/paddle/fluid/framework/trainer.cc b/paddle/fluid/framework/trainer.cc index b033f9a99d6d9b031a9055414ea19538afc796da..dc48a8f8d8f2feaa94dcb7f2f692b9ff8e8c737f 100644 --- a/paddle/fluid/framework/trainer.cc +++ b/paddle/fluid/framework/trainer.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/trainer.h" + #include "io/fs.h" namespace paddle { diff --git a/paddle/fluid/framework/trainer_factory.cc b/paddle/fluid/framework/trainer_factory.cc index 1f1122d32f5c3d07414dd9240ee590fa07cb84c8..48ea9143d621a710f8c47fed890a607a115b4ac7 100644 --- a/paddle/fluid/framework/trainer_factory.cc +++ b/paddle/fluid/framework/trainer_factory.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/fluid/framework/trainer_factory.h" #include + #include #include diff --git a/paddle/fluid/framework/trainer_test.cc b/paddle/fluid/framework/trainer_test.cc index f689679d48696ced2ff1fe5c2d3706e3ed2190a4..1f4a162f906161d2b6a7f14068fccc15dfc0b70d 100644 --- a/paddle/fluid/framework/trainer_test.cc +++ b/paddle/fluid/framework/trainer_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/trainer.h" + #include namespace paddle { @@ -23,5 +24,5 @@ TEST() { // create dataset // train for a while } -} -} +} // namespace framework +} // namespace paddle diff --git a/paddle/fluid/framework/type_defs.h b/paddle/fluid/framework/type_defs.h index 0937d96ad4c204f23c3aa63b8c7a47f23ef590fa..5feedb2c3d67098713fab689f9310dc8e70af4b0 100644 --- a/paddle/fluid/framework/type_defs.h +++ b/paddle/fluid/framework/type_defs.h @@ -21,6 +21,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/imperative/type_defs.h" #include "paddle/fluid/platform/variant.h" #include "paddle/utils/small_vector.h" diff --git a/paddle/fluid/framework/unused_var_check.cc b/paddle/fluid/framework/unused_var_check.cc index 2f03dc41ce0027bcc3cc28cb30ff740cdb22754b..43c44ff525fca577dc5e205e2f24b0d379b061f9 100644 --- a/paddle/fluid/framework/unused_var_check.cc +++ b/paddle/fluid/framework/unused_var_check.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/fluid/framework/unused_var_check.h" #include + #include #include "gflags/gflags.h" diff --git a/paddle/fluid/framework/unused_var_check.h b/paddle/fluid/framework/unused_var_check.h index 95f6917fbcde70a92ddd8a804f440d5d5f59cac3..cc4977e439c4cc7aca6b291eef9136912b199773 100644 --- a/paddle/fluid/framework/unused_var_check.h +++ b/paddle/fluid/framework/unused_var_check.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include #include diff --git a/paddle/fluid/framework/var_desc.cc b/paddle/fluid/framework/var_desc.cc index 0a24efd003bcfba9b9c25b71debaee074d0a2931..3a3edc9b4c64efbdd237b72ae1c3d7059c425614 100644 --- a/paddle/fluid/framework/var_desc.cc +++ b/paddle/fluid/framework/var_desc.cc @@ -318,18 +318,20 @@ void VarDesc::SetAttr(const std::string &name, const Attribute &v) { bool valid = attr_type == proto::AttrType::INT || attr_type == proto::AttrType::STRING || attr_type == proto::AttrType::INTS; - PADDLE_ENFORCE_EQ(valid, true, platform::errors::InvalidArgument( - "The value for attr (%s) must be " - "one of list or int or string.", - name)); + PADDLE_ENFORCE_EQ( + valid, true, + platform::errors::InvalidArgument("The value for attr (%s) must be " + "one of list or int or string.", + name)); this->attrs_[name] = v; } Attribute VarDesc::GetAttr(const std::string &name) const { auto it = attrs_.find(name); - PADDLE_ENFORCE_NE(it, attrs_.end(), platform::errors::NotFound( - "Attribute %s is not found.", name)); + PADDLE_ENFORCE_NE( + it, attrs_.end(), + platform::errors::NotFound("Attribute %s is not found.", name)); return it->second; } diff --git a/paddle/fluid/framework/var_type_inference_test.cc b/paddle/fluid/framework/var_type_inference_test.cc index 5483ef01c08445b1ee2e44a5288994d7769cf303..ce489a57a019efc4b6b4637357fd74821b73f0b9 100644 --- a/paddle/fluid/framework/var_type_inference_test.cc +++ b/paddle/fluid/framework/var_type_inference_test.cc @@ -245,9 +245,12 @@ TEST(InferVarType, multiple_api) { ASSERT_ANY_THROW(infer.SetDataTypes(&ctx, "test2_a_out", {})); ASSERT_EQ(0u, infer.GetShape(&ctx, "test2_a_out").size()); - infer.SetShape(&ctx, "test2_a_out", { - 1, 3, 3, - }); + infer.SetShape(&ctx, "test2_a_out", + { + 1, + 3, + 3, + }); ASSERT_EQ(3u, infer.GetShape(&ctx, "test2_a_out").size()); ASSERT_EQ(0, infer.GetLoDLevel(&ctx, "test2_a_out")); diff --git a/paddle/fluid/framework/var_type_traits.cc b/paddle/fluid/framework/var_type_traits.cc index ec664b4513f2cd41816985d289954779792e7ecf..345928666bd522cd9842e6f9e0411460fb9cdbce 100644 --- a/paddle/fluid/framework/var_type_traits.cc +++ b/paddle/fluid/framework/var_type_traits.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/var_type_traits.h" + #include "paddle/fluid/framework/lod_rank_table.h" #include "paddle/fluid/framework/reader.h" #include "paddle/fluid/framework/scope.h" @@ -25,6 +26,7 @@ #include "paddle/fluid/platform/device/gpu/nccl_helper.h" #endif #include + #include "paddle/fluid/operators/conv_cudnn_op_cache.h" #include "paddle/fluid/operators/cudnn_rnn_cache.h" #endif diff --git a/paddle/fluid/framework/var_type_traits_test.cc b/paddle/fluid/framework/var_type_traits_test.cc index 00ae5154f83abd2a1eaaf6e82fc495f8fb2ab078..4a81f66948de32391d620925f49c1aa9a561e37a 100644 --- a/paddle/fluid/framework/var_type_traits_test.cc +++ b/paddle/fluid/framework/var_type_traits_test.cc @@ -12,13 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/framework/var_type_traits.h" + #include #include "paddle/fluid/framework/lod_rank_table.h" #include "paddle/fluid/framework/reader.h" #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/framework/selected_rows_utils.h" -#include "paddle/fluid/framework/var_type_traits.h" #include "paddle/fluid/operators/reader/lod_tensor_blocking_queue.h" #ifdef PADDLE_WITH_CUDA #if defined(PADDLE_WITH_NCCL) diff --git a/paddle/fluid/framework/version.cc b/paddle/fluid/framework/version.cc index 92042e47259861151333e3c1073fc2a85a5f68f2..c01bef79cdccd7ffa793bfeba812f646e91ef86a 100644 --- a/paddle/fluid/framework/version.cc +++ b/paddle/fluid/framework/version.cc @@ -24,7 +24,7 @@ bool IsProgramVersionSupported(int64_t version) { * new version. The compatibility judgment cannot be made only * by the version number. Please do not use this interface, * it may be discarded because backward compatibility. - */ + */ return true; } @@ -33,7 +33,7 @@ bool IsTensorVersionSupported(uint32_t version) { * new version. The compatibility judgment cannot be made only * by the version number. Please do not use this interface, * it may be discarded because backward compatibility. - */ + */ return true; } diff --git a/paddle/fluid/framework/version_test.cc b/paddle/fluid/framework/version_test.cc index ec5a340ee6ef3bb7b3360640db8fe5b75840a63f..7c52209981ff9af7d543508eda6befd35a29fef4 100644 --- a/paddle/fluid/framework/version_test.cc +++ b/paddle/fluid/framework/version_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/framework/version.h" + #include "gtest/gtest.h" namespace paddle { diff --git a/paddle/fluid/imperative/all_reduce.cc b/paddle/fluid/imperative/all_reduce.cc index 436e22f00c303d59652db33a723fe727b63657ef..f6484d5cdda08ca979003cf5584d938acf51b012 100644 --- a/paddle/fluid/imperative/all_reduce.cc +++ b/paddle/fluid/imperative/all_reduce.cc @@ -15,6 +15,7 @@ #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) #include "paddle/fluid/imperative/all_reduce.h" + #include "paddle/fluid/framework/convert_utils.h" #ifdef PADDLE_WITH_NCCL diff --git a/paddle/fluid/imperative/amp_auto_cast.cc b/paddle/fluid/imperative/amp_auto_cast.cc index 3f6863d642cc82db3ff34e0c386310572d4d6068..ff6e297ba8003e86d06360de7b7f5d715cbeeec9 100644 --- a/paddle/fluid/imperative/amp_auto_cast.cc +++ b/paddle/fluid/imperative/amp_auto_cast.cc @@ -13,8 +13,10 @@ // limitations under the License. #include "paddle/fluid/imperative/amp_auto_cast.h" + #include #include + #include "paddle/fluid/eager/eager_tensor.h" #include "paddle/fluid/imperative/tracer.h" #include "paddle/fluid/imperative/type_defs.h" @@ -302,9 +304,8 @@ static inline framework::proto::VarType::Type GetPromoteType( // dtype of input(X) if (op_type == "moving_average_abs_max_scale") { for (const auto& pair : ins) { - if (pair.first == "X" && - GetDataType(pair.second.front()) == - framework::proto::VarType::FP16) { + if (pair.first == "X" && GetDataType(pair.second.front()) == + framework::proto::VarType::FP16) { dst_type = framework::proto::VarType::FP16; } } diff --git a/paddle/fluid/imperative/basic_engine.h b/paddle/fluid/imperative/basic_engine.h index 49761a8df0b6b1d8494e72b6ea7b67c0fa15eb6b..fcc30b2590a6cb0d985458fcd7ff0580b15a4641 100644 --- a/paddle/fluid/imperative/basic_engine.h +++ b/paddle/fluid/imperative/basic_engine.h @@ -19,6 +19,7 @@ #include #include #include + #include "paddle/fluid/imperative/engine.h" #include "paddle/fluid/imperative/gradient_accumulator.h" diff --git a/paddle/fluid/imperative/bkcl_context.cc b/paddle/fluid/imperative/bkcl_context.cc index 11abbfe7cf6a321fca1a0e1ac93e13a47f6f118c..9990fde95ce64ee35afd80f02589328f364fdd1e 100644 --- a/paddle/fluid/imperative/bkcl_context.cc +++ b/paddle/fluid/imperative/bkcl_context.cc @@ -14,13 +14,14 @@ #if defined(PADDLE_WITH_XPU_BKCL) +#include "paddle/fluid/imperative/bkcl_context.h" + #include #include #include #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/variable.h" -#include "paddle/fluid/imperative/bkcl_context.h" #include "paddle/fluid/platform/collective_helper.h" #include "paddle/fluid/platform/device/xpu/bkcl_helper.h" #include "paddle/fluid/platform/device_context.h" @@ -46,10 +47,11 @@ static void AllReduce(const framework::Tensor &src, framework::Tensor *dst, auto bkcl_dtype = platform::ToBKCLDataType(framework::TransToProtoVarType(src.dtype())); - PADDLE_ENFORCE_EQ(bkcl_all_reduce(comm->comm(), src_ptr, dst_ptr, src.numel(), - bkcl_dtype, BKCL_ADD, stream), - BKCL_SUCCESS, platform::errors::PreconditionNotMet( - "BKCL all reduce failed")); + PADDLE_ENFORCE_EQ( + bkcl_all_reduce(comm->comm(), src_ptr, dst_ptr, src.numel(), bkcl_dtype, + BKCL_ADD, stream), + BKCL_SUCCESS, + platform::errors::PreconditionNotMet("BKCL all reduce failed")); } /* Baidu Kunlun Communication Library(BKCL) is designed for multi Baidu Kunlun diff --git a/paddle/fluid/imperative/cncl_context.cc b/paddle/fluid/imperative/cncl_context.cc index 779b748c2d2d43db1019bf60d063a21eb209b6bb..19f22e7402989d44a15c9ad522953fa822266ef7 100644 --- a/paddle/fluid/imperative/cncl_context.cc +++ b/paddle/fluid/imperative/cncl_context.cc @@ -18,14 +18,12 @@ limitations under the License. */ #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/framework/variable.h" - -#include "paddle/fluid/platform/device_context.h" -#include "paddle/fluid/platform/gen_comm_id_helper.h" -#include "paddle/fluid/platform/place.h" - #include "paddle/fluid/platform/collective_helper.h" #include "paddle/fluid/platform/device/mlu/cncl_helper.h" #include "paddle/fluid/platform/device/mlu/mlu_info.h" +#include "paddle/fluid/platform/device_context.h" +#include "paddle/fluid/platform/gen_comm_id_helper.h" +#include "paddle/fluid/platform/place.h" namespace paddle { namespace framework { @@ -184,8 +182,9 @@ paddle::platform::DeviceContext *CNCLParallelContext::GetDeviceContext( } void CNCLParallelContext::WaitCompute(int ring_id) { - PADDLE_ENFORCE_GE(ring_id, 0, platform::errors::OutOfRange( - "ring id must >= 0, but got %d", ring_id)); + PADDLE_ENFORCE_GE( + ring_id, 0, + platform::errors::OutOfRange("ring id must >= 0, but got %d", ring_id)); PADDLE_ENFORCE_LT(ring_id, compute_events_.size(), platform::errors::OutOfRange( "ring id must < compute events size," @@ -205,8 +204,9 @@ void CNCLParallelContext::WaitCompute(int ring_id) { } void CNCLParallelContext::WaitComm(int ring_id) { - PADDLE_ENFORCE_GE(ring_id, 0, platform::errors::OutOfRange( - "ring id must >= 0, but got %d", ring_id)); + PADDLE_ENFORCE_GE( + ring_id, 0, + platform::errors::OutOfRange("ring id must >= 0, but got %d", ring_id)); PADDLE_ENFORCE_LT(ring_id, comm_events_.size(), platform::errors::OutOfRange( "ring id must < comm events size," diff --git a/paddle/fluid/imperative/data_loader.cc b/paddle/fluid/imperative/data_loader.cc index c43149c9b563e73d7bdc8cbb39b8303083d2ac84..66eed2981062a81927da9835b2e3f981526c5987 100644 --- a/paddle/fluid/imperative/data_loader.cc +++ b/paddle/fluid/imperative/data_loader.cc @@ -19,6 +19,7 @@ #include #include #include + #include #include "glog/logging.h" diff --git a/paddle/fluid/imperative/data_loader.h b/paddle/fluid/imperative/data_loader.h index fdfa117eafe762c58e55e4b2eecc42beafa11dc6..e66a3b9edc3ffd036d6aab5dfd03319e508d9977 100644 --- a/paddle/fluid/imperative/data_loader.h +++ b/paddle/fluid/imperative/data_loader.h @@ -17,6 +17,7 @@ #ifndef _WIN32 #include + #include #include diff --git a/paddle/fluid/imperative/execution_context.h b/paddle/fluid/imperative/execution_context.h index 124c31df733492190997ebd8cc95aec5071d866b..fe426a76b32920cb30bd843566994a3798b4d35b 100644 --- a/paddle/fluid/imperative/execution_context.h +++ b/paddle/fluid/imperative/execution_context.h @@ -16,6 +16,7 @@ #include #include + #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/type_defs.h" #include "paddle/fluid/framework/variable.h" diff --git a/paddle/fluid/imperative/flags.cc b/paddle/fluid/imperative/flags.cc index c2d668eccdaf9377d1ec2a62e50648bf48c67c00..df424b32fcadf042243de00d94b61b1ae0c41a7c 100644 --- a/paddle/fluid/imperative/flags.cc +++ b/paddle/fluid/imperative/flags.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/imperative/flags.h" + #include "paddle/fluid/platform/flags.h" PADDLE_DEFINE_EXPORTED_uint64(dygraph_debug, 0, diff --git a/paddle/fluid/imperative/gloo_context.cc b/paddle/fluid/imperative/gloo_context.cc index dd34b8b619f80a0e7cb5f122d10850482b1b74ad..c5bcab4daa9a90be5a8ab814cdb95ab7af9c3a5d 100644 --- a/paddle/fluid/imperative/gloo_context.cc +++ b/paddle/fluid/imperative/gloo_context.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/imperative/gloo_context.h" + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/fleet/gloo_wrapper.h" #include "paddle/fluid/framework/tensor_util.h" diff --git a/paddle/fluid/imperative/gloo_context.h b/paddle/fluid/imperative/gloo_context.h index 23e4e02945bf6f8d997857ff8ade35a4bdb7164c..5e0973e7e99135a5d407c587e904c7d1059a55a0 100644 --- a/paddle/fluid/imperative/gloo_context.h +++ b/paddle/fluid/imperative/gloo_context.h @@ -16,6 +16,7 @@ #include #include #include + #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/framework/selected_rows_utils.h" #include "paddle/fluid/framework/variable.h" diff --git a/paddle/fluid/imperative/gradient_accumulator.cc b/paddle/fluid/imperative/gradient_accumulator.cc index 499cf4d8ad6d82dd554fa4f5bbcf39833fed0eab..36e6f551dc63b3bf47f2d179d0c37209fbc0f5b7 100644 --- a/paddle/fluid/imperative/gradient_accumulator.cc +++ b/paddle/fluid/imperative/gradient_accumulator.cc @@ -874,8 +874,9 @@ void SortedGradientAccumulator::SumGrad(std::shared_ptr var, } PADDLE_ENFORCE_EQ(var_info.var->Var().IsType(), - true, platform::errors::PermissionDenied( - "Gradient var must be LoDTensor")); + true, + platform::errors::PermissionDenied( + "Gradient var must be LoDTensor")); if (CurCnt() == 0) { MoveOrCopyVar(dst_var->MutableVar(), var_info.var->MutableVar(), var_info.unchange_input); @@ -896,9 +897,10 @@ void SortedGradientAccumulator::SumGrad(std::shared_ptr var, PADDLE_ENFORCE_EQ( var_info.var->Var().IsType() || var_info.var->Var().IsType(), - true, platform::errors::PermissionDenied("The type of Gradient " - "var must be LoDTensor " - "or SelectedRows")); + true, + platform::errors::PermissionDenied("The type of Gradient " + "var must be LoDTensor " + "or SelectedRows")); if (CurCnt() == 0) { MoveOrCopyVar(dst_var->MutableVar(), var_info.var->MutableVar(), var_info.unchange_input); diff --git a/paddle/fluid/imperative/gradient_accumulator.h b/paddle/fluid/imperative/gradient_accumulator.h index 03f6775defc2f8fccba0654ae5d366d66ad88fc0..382623b6276238f8627c041dac01c5e1def2e271 100644 --- a/paddle/fluid/imperative/gradient_accumulator.h +++ b/paddle/fluid/imperative/gradient_accumulator.h @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/fluid/eager/eager_tensor.h" #include "paddle/fluid/imperative/hooks.h" #include "paddle/fluid/imperative/layer.h" diff --git a/paddle/fluid/imperative/hccl_context.cc b/paddle/fluid/imperative/hccl_context.cc index 31d988753f23c31da46050fabf1fcc1b1a86c7ab..8fb434cbc2aeed9341e58a301e7c7c4bcb0e3769 100644 --- a/paddle/fluid/imperative/hccl_context.cc +++ b/paddle/fluid/imperative/hccl_context.cc @@ -13,18 +13,16 @@ // limitations under the License. #include "paddle/fluid/imperative/hccl_context.h" -#include "paddle/fluid/framework/convert_utils.h" +#include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/framework/variable.h" - +#include "paddle/fluid/platform/collective_helper.h" +#include "paddle/fluid/platform/device/npu/hccl_helper.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/gen_comm_id_helper.h" #include "paddle/fluid/platform/place.h" -#include "paddle/fluid/platform/collective_helper.h" -#include "paddle/fluid/platform/device/npu/hccl_helper.h" - namespace paddle { namespace framework { class Variable; @@ -193,8 +191,9 @@ paddle::platform::DeviceContext *HCCLParallelContext::GetDeviceContext( } void HCCLParallelContext::WaitCompute(int ring_id) { - PADDLE_ENFORCE_GE(ring_id, 0, platform::errors::OutOfRange( - "ring id must >= 0, but got %d", ring_id)); + PADDLE_ENFORCE_GE( + ring_id, 0, + platform::errors::OutOfRange("ring id must >= 0, but got %d", ring_id)); PADDLE_ENFORCE_LT(ring_id, compute_events_.size(), platform::errors::OutOfRange( "ring id must < compute events size," @@ -214,8 +213,9 @@ void HCCLParallelContext::WaitCompute(int ring_id) { } void HCCLParallelContext::WaitComm(int ring_id) { - PADDLE_ENFORCE_GE(ring_id, 0, platform::errors::OutOfRange( - "ring id must >= 0, but got %d", ring_id)); + PADDLE_ENFORCE_GE( + ring_id, 0, + platform::errors::OutOfRange("ring id must >= 0, but got %d", ring_id)); PADDLE_ENFORCE_LT(ring_id, comm_events_.size(), platform::errors::OutOfRange( "ring id must < comm events size," diff --git a/paddle/fluid/imperative/infer_var_type_context.h b/paddle/fluid/imperative/infer_var_type_context.h index 297ec840db4c030477e37a6d2d78efaefffba736..079e180c2a70dafab23dd91af32f1605508da055 100644 --- a/paddle/fluid/imperative/infer_var_type_context.h +++ b/paddle/fluid/imperative/infer_var_type_context.h @@ -18,6 +18,7 @@ #include #include #include + #include "paddle/fluid/framework/type_defs.h" #include "paddle/fluid/framework/var_type_inference.h" #include "paddle/fluid/imperative/type_defs.h" diff --git a/paddle/fluid/imperative/jit/program_desc_tracer.cc b/paddle/fluid/imperative/jit/program_desc_tracer.cc index 35ff262fe3d86a06bd809b571fbe9b1cd0367970..e0f52beb6e555335cc2bc6d75b8c884d567c5985 100644 --- a/paddle/fluid/imperative/jit/program_desc_tracer.cc +++ b/paddle/fluid/imperative/jit/program_desc_tracer.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/imperative/jit/program_desc_tracer.h" + #include "paddle/fluid/framework/convert_utils.h" namespace paddle { diff --git a/paddle/fluid/imperative/layer.cc b/paddle/fluid/imperative/layer.cc index 76f64ab73a64bd6672b036bc6f197a1f4a965a13..7357db4e2001bc89a9527267822dba821ac33ad2 100644 --- a/paddle/fluid/imperative/layer.cc +++ b/paddle/fluid/imperative/layer.cc @@ -16,7 +16,6 @@ #include "paddle/fluid/eager/eager_tensor.h" #include "paddle/fluid/framework/convert_utils.h" - #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/imperative/infer_var_type_context.h" #include "paddle/fluid/imperative/op_base.h" @@ -284,9 +283,10 @@ std::shared_ptr VarBase::NewVarBase(const platform::Place& dst_place, PADDLE_ENFORCE_EQ( Var().IsInitialized() && (Var().IsType() || Var().IsType()), - true, platform::errors::InvalidArgument( - "Variable is not initialized or Variable's type is not " - "LoDTensor or SelectedRows when getting numpy tensor")); + true, + platform::errors::InvalidArgument( + "Variable is not initialized or Variable's type is not " + "LoDTensor or SelectedRows when getting numpy tensor")); if (Var().IsType()) { auto& src_tensor = Var().Get(); diff --git a/paddle/fluid/imperative/layout_autotune.cc b/paddle/fluid/imperative/layout_autotune.cc index ed0526eaad316e547d258a6647d47ed1e077522f..e936505b2ae032018cb3b94a223d2990e6670148 100644 --- a/paddle/fluid/imperative/layout_autotune.cc +++ b/paddle/fluid/imperative/layout_autotune.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/imperative/layout_autotune.h" + #include "paddle/fluid/framework/op_info.h" #include "paddle/fluid/imperative/layout_transformer.h" #include "paddle/phi/backends/gpu/gpu_info.h" @@ -119,8 +120,9 @@ paddle::imperative::NameVarMap AutoTuneLayout( LayoutAutoTune::Instance().SetDesiredLayout(DataLayout::NHWC); VLOG(3) << "Tune the layout from " << BOOST_GET_CONST(std::string, (*attrs)["data_format"]) - << " to " << paddle::framework::DataLayoutToString( - LayoutAutoTune::Instance().GetDesiredLayout()); + << " to " + << paddle::framework::DataLayoutToString( + LayoutAutoTune::Instance().GetDesiredLayout()); } else { LayoutAutoTune::Instance().DisableLayoutAutoTune(); return ins; diff --git a/paddle/fluid/imperative/layout_autotune.h b/paddle/fluid/imperative/layout_autotune.h index df3772b826da1ec09c84057c48cb87d301a697ca..2da368910e6c38d17a774bf92098cdcc8dc93a15 100644 --- a/paddle/fluid/imperative/layout_autotune.h +++ b/paddle/fluid/imperative/layout_autotune.h @@ -14,8 +14,10 @@ #pragma once #include + #include #include + #include "paddle/fluid/framework/type_defs.h" #include "paddle/phi/common/layout.h" diff --git a/paddle/fluid/imperative/nccl_context.cc b/paddle/fluid/imperative/nccl_context.cc index e9d987cc7045f95947c88ea3347b3ae2c3897761..4a0dcb1b3bbea39e8c785c02dbf21a22d4e587bd 100644 --- a/paddle/fluid/imperative/nccl_context.cc +++ b/paddle/fluid/imperative/nccl_context.cc @@ -22,6 +22,7 @@ #ifdef PADDLE_WITH_NCCL #include + #include "paddle/fluid/platform/dynload/nccl.h" #endif @@ -159,8 +160,9 @@ paddle::platform::DeviceContext *NCCLParallelContext::GetDeviceContext( } void NCCLParallelContext::WaitCompute(int ring_id) { - PADDLE_ENFORCE_GE(ring_id, 0, platform::errors::OutOfRange( - "ring id must >= 0, but got %d", ring_id)); + PADDLE_ENFORCE_GE( + ring_id, 0, + platform::errors::OutOfRange("ring id must >= 0, but got %d", ring_id)); PADDLE_ENFORCE_LT(ring_id, compute_events_.size(), platform::errors::OutOfRange( "ring id must < compute events size," @@ -185,8 +187,9 @@ void NCCLParallelContext::WaitCompute(int ring_id) { } void NCCLParallelContext::WaitComm(int ring_id) { - PADDLE_ENFORCE_GE(ring_id, 0, platform::errors::OutOfRange( - "ring id must >= 0, but got %d", ring_id)); + PADDLE_ENFORCE_GE( + ring_id, 0, + platform::errors::OutOfRange("ring id must >= 0, but got %d", ring_id)); PADDLE_ENFORCE_LT(ring_id, comm_events_.size(), platform::errors::OutOfRange( "ring id must < comm events size," diff --git a/paddle/fluid/imperative/op_base.h b/paddle/fluid/imperative/op_base.h index b8a616ae67d210772ec9ade7c9e4333fa2944711..ba0221a1729fa282cc8da8f70e1d0c29855ffb7b 100644 --- a/paddle/fluid/imperative/op_base.h +++ b/paddle/fluid/imperative/op_base.h @@ -20,6 +20,7 @@ #include #include #include + #include "paddle/fluid/framework/type_defs.h" #include "paddle/fluid/imperative/saved_variable_wrapper_list.h" #include "paddle/fluid/imperative/type_defs.h" diff --git a/paddle/fluid/imperative/partial_grad_engine.cc b/paddle/fluid/imperative/partial_grad_engine.cc index f2f64d92a23fc92dd028e0038affbd86915008be..a4baca6f25724c579b49fdf20b0c76c71207a5d9 100644 --- a/paddle/fluid/imperative/partial_grad_engine.cc +++ b/paddle/fluid/imperative/partial_grad_engine.cc @@ -24,6 +24,7 @@ #include #include #include + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/imperative/gradient_accumulator.h" #include "paddle/fluid/imperative/layer.h" diff --git a/paddle/fluid/imperative/partial_grad_engine.h b/paddle/fluid/imperative/partial_grad_engine.h index b5da39f8d4237130fd4674eacb479aaf6b9ba348..4ec6cdb3fcd5d549019ca70c24ae96917dd64e8f 100644 --- a/paddle/fluid/imperative/partial_grad_engine.h +++ b/paddle/fluid/imperative/partial_grad_engine.h @@ -16,6 +16,7 @@ #include #include + #include "paddle/fluid/imperative/engine.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/imperative/prepared_operator.cc b/paddle/fluid/imperative/prepared_operator.cc index cfd3813d60d44f0cd6de613f444351f102bc56a2..ac997557863590c4e33f7249a693927fcb7bb471 100644 --- a/paddle/fluid/imperative/prepared_operator.cc +++ b/paddle/fluid/imperative/prepared_operator.cc @@ -258,7 +258,7 @@ PreparedOp PrepareImpl( #if defined(PADDLE_WITH_XPU) && !defined(PADDLE_WITH_XPU_KP) && !is_xpu_unsupport #endif - ) { + ) { VLOG(6) << "Dynamic mode PrepareImpl - kernel name: " << pt_kernel_name << " | kernel key: " << pt_kernel_key << " | kernel: " << phi_kernel; @@ -306,7 +306,7 @@ PreparedOp PrepareImpl( #if defined(PADDLE_WITH_XPU_KP) || (is_xpu_unsupport && !is_xpu_kp_support) #endif - ) { + ) { if (has_phi_kernel) { auto pt_cpu_kernel_key = FallBackToCpu(expected_kernel_key, pt_kernel_key, op); diff --git a/paddle/fluid/imperative/prepared_operator.h b/paddle/fluid/imperative/prepared_operator.h index ccc8d64517f9596873849f978508e61f4791d32f..0c2d70dfe3c82ad7cba4084991671cb485fa95c0 100644 --- a/paddle/fluid/imperative/prepared_operator.h +++ b/paddle/fluid/imperative/prepared_operator.h @@ -19,6 +19,7 @@ #include #include "paddle/fluid/eager/eager_tensor.h" +#include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/data_transform.h" #include "paddle/fluid/framework/op_kernel_type.h" #include "paddle/fluid/framework/operator.h" @@ -28,8 +29,6 @@ #include "paddle/fluid/imperative/layer.h" #include "paddle/fluid/imperative/type_defs.h" #include "paddle/fluid/imperative/var_helper.h" - -#include "paddle/fluid/framework/convert_utils.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/kernel_context.h" #include "paddle/phi/core/selected_rows.h" diff --git a/paddle/fluid/imperative/profiler.cc b/paddle/fluid/imperative/profiler.cc index 48af63056c5e361736046aa47d83735190d85c20..097f62fe422586f9a556fa175fe6a6a96beac4f3 100644 --- a/paddle/fluid/imperative/profiler.cc +++ b/paddle/fluid/imperative/profiler.cc @@ -18,7 +18,9 @@ #include "gperftools/profiler.h" #endif #include + #include // NOLINT + #include "paddle/fluid/platform/flags.h" PADDLE_DEFINE_EXPORTED_string( diff --git a/paddle/fluid/imperative/py_layer_fwd.h b/paddle/fluid/imperative/py_layer_fwd.h index 2d7d319203833337abd52371730bc409ad8e0a1f..f5951a52d718e4319b0480f47da233de62c4f1e2 100644 --- a/paddle/fluid/imperative/py_layer_fwd.h +++ b/paddle/fluid/imperative/py_layer_fwd.h @@ -16,12 +16,12 @@ #include #include -#include "paddle/fluid/imperative/layer.h" -#include "paddle/fluid/imperative/prepared_operator.h" -#include "paddle/fluid/imperative/tracer.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/type_defs.h" +#include "paddle/fluid/imperative/layer.h" +#include "paddle/fluid/imperative/prepared_operator.h" +#include "paddle/fluid/imperative/tracer.h" #include "paddle/fluid/operators/py_layer_op.h" namespace paddle { diff --git a/paddle/fluid/imperative/reducer.cc b/paddle/fluid/imperative/reducer.cc index c7fd2215eb42a49579e1edb396380b66f03bafb5..47d7b6366f700bbcd2c0915a7f5991c722ae8bb9 100644 --- a/paddle/fluid/imperative/reducer.cc +++ b/paddle/fluid/imperative/reducer.cc @@ -18,13 +18,10 @@ #include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/imperative/layer.h" -#include "paddle/fluid/string/string_helper.h" - +#include "paddle/fluid/imperative/parallel_context.h" #include "paddle/fluid/operators/math/concat_and_split.h" #include "paddle/fluid/operators/strided_memcpy.h" - -#include "paddle/fluid/imperative/parallel_context.h" - +#include "paddle/fluid/string/string_helper.h" #include "paddle/phi/core/dense_tensor.h" namespace paddle { namespace imperative { @@ -452,8 +449,9 @@ void Reducer::InitializeDenseGroups( "Tensor %s is not initialized.", var_name)); const auto size = lod_tensor->numel(); PADDLE_ENFORCE_GT( - size, 0, platform::errors::PreconditionNotMet( - "The number of tensor %s's elements is 0.", var_name)); + size, 0, + platform::errors::PreconditionNotMet( + "The number of tensor %s's elements is 0.", var_name)); all_length += size; p_group->length_.push_back(size); diff --git a/paddle/fluid/imperative/reducer.h b/paddle/fluid/imperative/reducer.h index 9fac4b41cbde01f365dcc603844b06c473a58843..852d8cf076acbf0d575d3db4bd42ca88ce8bde39 100644 --- a/paddle/fluid/imperative/reducer.h +++ b/paddle/fluid/imperative/reducer.h @@ -14,6 +14,7 @@ #pragma once #include + #include #include #include diff --git a/paddle/fluid/imperative/tests/bkcl_context_test.cc b/paddle/fluid/imperative/tests/bkcl_context_test.cc index 580d86b1696bcf6f834936c850f96c956202c787..b4d299ba829d95685bb7ac9c05bdd7814e31b6cd 100644 --- a/paddle/fluid/imperative/tests/bkcl_context_test.cc +++ b/paddle/fluid/imperative/tests/bkcl_context_test.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include // NOLINT - #include "paddle/fluid/imperative/bkcl_context.h" +#include // NOLINT + #include "gtest/gtest.h" namespace imperative = paddle::imperative; diff --git a/paddle/fluid/imperative/tests/cncl_context_test.cc b/paddle/fluid/imperative/tests/cncl_context_test.cc index 1d5ee8e7fc899f2b5496fd808b39c1bf4be69e73..1019d4eacdc9f6947881bdc88b45b6303a1b67d5 100644 --- a/paddle/fluid/imperative/tests/cncl_context_test.cc +++ b/paddle/fluid/imperative/tests/cncl_context_test.cc @@ -12,15 +12,15 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/imperative/cncl_context.h" + #include // NOLINT +#include "gtest/gtest.h" #include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/framework/variable.h" -#include "paddle/fluid/imperative/cncl_context.h" #include "paddle/fluid/platform/gen_comm_id_helper.h" -#include "gtest/gtest.h" - namespace imperative = paddle::imperative; namespace platform = paddle::platform; namespace framework = paddle::framework; diff --git a/paddle/fluid/imperative/tests/heter_ccl_context_test.cc b/paddle/fluid/imperative/tests/heter_ccl_context_test.cc index 91f38f82ed058893b3f862b41c072dddadc7c81a..67059916d03176c01d5f7f68b1c358d2533846f2 100644 --- a/paddle/fluid/imperative/tests/heter_ccl_context_test.cc +++ b/paddle/fluid/imperative/tests/heter_ccl_context_test.cc @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/imperative/heter_ccl_context.h" + #include #include // NOLINT +#include "gtest/gtest.h" #include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/framework/variable.h" -#include "paddle/fluid/imperative/heter_ccl_context.h" - -#include "gtest/gtest.h" namespace imperative = paddle::imperative; namespace platform = paddle::platform; diff --git a/paddle/fluid/imperative/tests/nccl_context_test.cc b/paddle/fluid/imperative/tests/nccl_context_test.cc index 9ee083626c5b80f38fa1391aca81158cbce463a8..48479e1412b4b1ebf1c2cc81b7411ebb65b78833 100644 --- a/paddle/fluid/imperative/tests/nccl_context_test.cc +++ b/paddle/fluid/imperative/tests/nccl_context_test.cc @@ -12,15 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/imperative/nccl_context.h" + #include // NOLINT +#include "gtest/gtest.h" #include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/framework/variable.h" -#include "paddle/fluid/imperative/nccl_context.h" #include "paddle/fluid/platform/gen_comm_id_helper.h" -#include "gtest/gtest.h" - namespace imperative = paddle::imperative; namespace platform = paddle::platform; namespace framework = paddle::framework; diff --git a/paddle/fluid/imperative/tests/test_eager.cc b/paddle/fluid/imperative/tests/test_eager.cc index 3def103ae9aa5c68932b717190b7972fd3660d36..1d6ec7330756fe856a52be0eb67cfe7d8ba8c201 100644 --- a/paddle/fluid/imperative/tests/test_eager.cc +++ b/paddle/fluid/imperative/tests/test_eager.cc @@ -88,8 +88,9 @@ TEST(test_var_helper, eager_var_helper) { egr_tensor, framework::OpKernelType(framework::proto::VarType::FP32, platform::CPUPlace())); SetCachedValue( - egr_tensor, framework::OpKernelType(framework::proto::VarType::FP32, - platform::CPUPlace()), + egr_tensor, + framework::OpKernelType(framework::proto::VarType::FP32, + platform::CPUPlace()), egr_tensor2); ASSERT_ANY_THROW(GetPlace(egr_tensor2)); ASSERT_ANY_THROW(SetType( diff --git a/paddle/fluid/imperative/tests/test_gradient_accmulator.cc b/paddle/fluid/imperative/tests/test_gradient_accmulator.cc index 88b18a4c176209a0de33a6f40ff7d2f5a9231fdc..d2e768d6ef11400cf2438b86ccf28b5dec853c17 100644 --- a/paddle/fluid/imperative/tests/test_gradient_accmulator.cc +++ b/paddle/fluid/imperative/tests/test_gradient_accmulator.cc @@ -384,7 +384,7 @@ static void TestGradientAccumulatorTestUnchangeInput( for (auto use_tensor2 : use_tensors) { /** g_accum1 && g_accum2: has not been initialized * test accumulate on this graph - */ + */ auto g_var1 = std::make_shared("g_var1"); g_var1->SetOverridedStopGradient(false); auto g_accum1 = CreateAccumulator(g_var1, sort_gradient); @@ -437,7 +437,7 @@ static void TestGradientAccumulatorTestUnchangeInput( /** g_accum3 && g_accum4: has been initialized * test accumulate on previous graph - */ + */ auto var3 = create_var(use_tensor1); auto var_wrapper3_3 = std::make_shared("tmp1_3"); auto var_wrapper4_3 = std::make_shared("tmp2_3"); diff --git a/paddle/fluid/imperative/tests/test_group.cc b/paddle/fluid/imperative/tests/test_group.cc index 5e674af1a08a87c11bfab1080be42e623661b38e..0025103c53196a6d960998d49a39237fd36914c9 100644 --- a/paddle/fluid/imperative/tests/test_group.cc +++ b/paddle/fluid/imperative/tests/test_group.cc @@ -14,8 +14,8 @@ #include #include -#include "gtest/gtest.h" +#include "gtest/gtest.h" #include "paddle/fluid/imperative/reducer.h" namespace paddle { diff --git a/paddle/fluid/imperative/tests/test_prepare_op.cc b/paddle/fluid/imperative/tests/test_prepare_op.cc index 4cda3f32fdf3fdd2d14b201fa902c1f50f3ff98d..cfda7a0cac4e9b128e5ca2126c43945a394afea3 100644 --- a/paddle/fluid/imperative/tests/test_prepare_op.cc +++ b/paddle/fluid/imperative/tests/test_prepare_op.cc @@ -17,9 +17,11 @@ // #include + #include #include #include + #include "gtest/gtest.h" #include "paddle/fluid/framework/op_info.h" #include "paddle/fluid/imperative/prepared_operator.h" diff --git a/paddle/fluid/imperative/tracer.cc b/paddle/fluid/imperative/tracer.cc index 350263bc5457d6dd66cca3defd7f5c098c99fd4a..2295ea4bf67c90e96ba261f73ef69414b0176e00 100644 --- a/paddle/fluid/imperative/tracer.cc +++ b/paddle/fluid/imperative/tracer.cc @@ -12,10 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "paddle/fluid/imperative/tracer.h" + #include #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/imperative/amp_auto_cast.h" #include "paddle/fluid/imperative/execution_context.h" diff --git a/paddle/fluid/imperative/tracer.h b/paddle/fluid/imperative/tracer.h index 4e671d52457e203b7d64420490d9420db013b673..b9048c4847075e2a4035b3e129feeb9d491a66ef 100644 --- a/paddle/fluid/imperative/tracer.h +++ b/paddle/fluid/imperative/tracer.h @@ -21,6 +21,7 @@ #include #include #include + #include "ThreadPool.h" #include "paddle/fluid/framework/garbage_collector.h" #include "paddle/fluid/imperative/amp_auto_cast.h" diff --git a/paddle/fluid/imperative/var_helper.h b/paddle/fluid/imperative/var_helper.h index 9ce456b1103b3b93974995c90a38fb9ef96828a6..91788e73fa583fc47a8d42094363a9ead4b993b1 100644 --- a/paddle/fluid/imperative/var_helper.h +++ b/paddle/fluid/imperative/var_helper.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/framework/variable.h" namespace egr { diff --git a/paddle/fluid/inference/analysis/analysis_pass.h b/paddle/fluid/inference/analysis/analysis_pass.h index 14a1c3eea3417432c76ce03d41b558577d2aa037..a95498d82d0e6f75f26f9652e8ec5cfcf85b5d37 100644 --- a/paddle/fluid/inference/analysis/analysis_pass.h +++ b/paddle/fluid/inference/analysis/analysis_pass.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include #include diff --git a/paddle/fluid/inference/analysis/analyzer.cc b/paddle/fluid/inference/analysis/analyzer.cc index be7d6ab868022b5e9e1f073aad441decba0dbf00..2b56f8e00d6446f4a110ea7254d4cabb69f0d8ba 100644 --- a/paddle/fluid/inference/analysis/analyzer.cc +++ b/paddle/fluid/inference/analysis/analyzer.cc @@ -13,8 +13,10 @@ // limitations under the License. #include "paddle/fluid/inference/analysis/analyzer.h" + #include #include + #include "paddle/fluid/inference/analysis/passes/passes.h" #include "paddle/fluid/string/pretty_log.h" diff --git a/paddle/fluid/inference/analysis/analyzer.h b/paddle/fluid/inference/analysis/analyzer.h index 4db54706285d457a9ae435892dab143f81aa2111..95a985158e6783dfa12615779e36b3283e979631 100644 --- a/paddle/fluid/inference/analysis/analyzer.h +++ b/paddle/fluid/inference/analysis/analyzer.h @@ -37,6 +37,7 @@ limitations under the License. */ #include #include + #include "gflags/gflags.h" #include "paddle/fluid/inference/analysis/analysis_pass.h" #include "paddle/fluid/inference/analysis/flags.h" diff --git a/paddle/fluid/inference/analysis/analyzer_tester.cc b/paddle/fluid/inference/analysis/analyzer_tester.cc index 3f96fd69e4ee11c725c268067d9bfce337a0e426..84fcd4e3c396f243c0d5ef234d056b75feb0a310 100644 --- a/paddle/fluid/inference/analysis/analyzer_tester.cc +++ b/paddle/fluid/inference/analysis/analyzer_tester.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/inference/analysis/analyzer.h" - #include #include + +#include "paddle/fluid/inference/analysis/analyzer.h" #include "paddle/fluid/inference/analysis/ut_helper.h" #include "paddle/fluid/inference/api/paddle_inference_api.h" #include "paddle/fluid/inference/api/paddle_inference_pass.h" diff --git a/paddle/fluid/inference/analysis/dot.h b/paddle/fluid/inference/analysis/dot.h index 6d883f558709b70df885ac8d6c5fba0f5474b3d5..619e3461d3ea50b3da25fc65bc97b6d73d4863b0 100644 --- a/paddle/fluid/inference/analysis/dot.h +++ b/paddle/fluid/inference/analysis/dot.h @@ -20,6 +20,7 @@ #pragma once #include + #include #include #include diff --git a/paddle/fluid/inference/analysis/dot_tester.cc b/paddle/fluid/inference/analysis/dot_tester.cc index c785a312bf96c3586ea990fd9028cfd3b930d577..0b669093a1f32c52d559c49c2396314afeb360aa 100644 --- a/paddle/fluid/inference/analysis/dot_tester.cc +++ b/paddle/fluid/inference/analysis/dot_tester.cc @@ -12,11 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/inference/analysis/dot.h" - #include + #include +#include "paddle/fluid/inference/analysis/dot.h" + namespace paddle { namespace inference { namespace analysis { diff --git a/paddle/fluid/inference/analysis/helper.h b/paddle/fluid/inference/analysis/helper.h index 88ae61ff1fc98c8962e095a075d64b780eb6ee5b..f9520165161847f2e5aca5f2801f05845deba320 100644 --- a/paddle/fluid/inference/analysis/helper.h +++ b/paddle/fluid/inference/analysis/helper.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include #include #include @@ -72,8 +73,9 @@ struct DataTypeNamer { template const std::string &repr() const { auto x = std::type_index(typeid(T)); - PADDLE_ENFORCE_GT(dic_.count(x), 0, platform::errors::PreconditionNotMet( - "unknown type for representation")); + PADDLE_ENFORCE_GT(dic_.count(x), 0, + platform::errors::PreconditionNotMet( + "unknown type for representation")); return dic_.at(x); } diff --git a/paddle/fluid/inference/analysis/ir_pass_manager.cc b/paddle/fluid/inference/analysis/ir_pass_manager.cc index c5c60564b0fa3bf18876b6f12f8875b3bcc6a966..6c74d7b738cf678dcbf38cdcc3f8a734152a0c35 100644 --- a/paddle/fluid/inference/analysis/ir_pass_manager.cc +++ b/paddle/fluid/inference/analysis/ir_pass_manager.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/inference/analysis/ir_pass_manager.h" + #include #include #include @@ -20,6 +21,7 @@ #include #include #include + #include "paddle/fluid/framework/ir/fuse_pass_base.h" #include "paddle/fluid/framework/ir/graph.h" #include "paddle/fluid/framework/scope.h" @@ -29,8 +31,8 @@ namespace paddle { namespace inference { namespace analysis { -using string::PrettyLogEndl; using string::PrettyLog; +using string::PrettyLogEndl; using string::Style; IRPassManager::IRPassManager(Argument *argument) { diff --git a/paddle/fluid/inference/analysis/ir_pass_manager.h b/paddle/fluid/inference/analysis/ir_pass_manager.h index 823dc8907ea532b510e8d643c361b98c863404e3..9f9a5fc347123b91cd86db495c2b2e0c7a6a6518 100644 --- a/paddle/fluid/inference/analysis/ir_pass_manager.h +++ b/paddle/fluid/inference/analysis/ir_pass_manager.h @@ -27,6 +27,7 @@ #include #include #include + #include "paddle/fluid/framework/ir/graph.h" #include "paddle/fluid/framework/ir/pass.h" #include "paddle/fluid/framework/program_desc.h" diff --git a/paddle/fluid/inference/analysis/ir_passes/dlnne_subgraph_pass.cc b/paddle/fluid/inference/analysis/ir_passes/dlnne_subgraph_pass.cc index 8f789139af9bfc35841f284d043a2c86f5803e93..b2a07722829beb9da7d6132932ed4545ee18daa6 100644 --- a/paddle/fluid/inference/analysis/ir_passes/dlnne_subgraph_pass.cc +++ b/paddle/fluid/inference/analysis/ir_passes/dlnne_subgraph_pass.cc @@ -11,19 +11,19 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#include -#include -#include +#include "paddle/fluid/inference/analysis/ir_passes/dlnne_subgraph_pass.h" +#include #include #include +#include +#include #include "paddle/fluid/framework/ir/graph_pattern_detector.h" #include "paddle/fluid/framework/ir/subgraph_detector.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/inference/analysis/helper.h" #include "paddle/fluid/inference/analysis/ir_passes/dlnne_reg_py.h" -#include "paddle/fluid/inference/analysis/ir_passes/dlnne_subgraph_pass.h" #include "paddle/fluid/string/pretty_log.h" namespace paddle { @@ -52,18 +52,39 @@ using framework::ir::Node; void analysis::DlnneSubgraphPass::ApplyImpl(framework::ir::Graph *graph) const { static std::unordered_set teller_set{ - "mul", "matmul", "conv2d", "pool2d", "relu", "softmax", "sigmoid", - "hard_swish", "depthwise_conv2d", "batch_norm", "concat", "tanh", "pad", - "elementwise_add", "elementwise_mul", "dropout", "prelu", - "conv2d_transpose", "leaky_relu", + "mul", + "matmul", + "conv2d", + "pool2d", + "relu", + "softmax", + "sigmoid", + "hard_swish", + "depthwise_conv2d", + "batch_norm", + "concat", + "tanh", + "pad", + "elementwise_add", + "elementwise_mul", + "dropout", + "prelu", + "conv2d_transpose", + "leaky_relu", // "fc", - "shuffle_channel", "swish", "split", + "shuffle_channel", + "swish", + "split", // "instance_norm", "gelu", // "layer_norm", // "scale", // "stack", - "relu6", "reshape2", "transpose2", "concat", "slice", + "relu6", + "reshape2", + "transpose2", + "concat", + "slice", }; framework::ir::FusePassBase::Init("dlnne_subgraph_pass", graph); diff --git a/paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass.cc b/paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass.cc index 083fc8991192eb16798a955b83cd4096c1911d1c..b5ddacd440e25d0543a4cf71c3aff8d7c49c0501 100644 --- a/paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass.cc +++ b/paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass.cc @@ -12,7 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass.h" + #include +#include +#include #include #include #include @@ -21,28 +25,22 @@ #include #include -#include -#include - +#include "paddle/fluid/framework/ir/graph_pattern_detector.h" +#include "paddle/fluid/framework/ir/subgraph_detector.h" #include "paddle/fluid/framework/lod_tensor.h" +#include "paddle/fluid/inference/lite/engine.h" #include "paddle/fluid/inference/lite/op_teller.h" #include "paddle/fluid/inference/utils/singleton.h" - -#include "paddle/fluid/framework/ir/graph_pattern_detector.h" -#include "paddle/fluid/framework/ir/subgraph_detector.h" -#include "paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass.h" #include "paddle/fluid/string/pretty_log.h" -#include "paddle/fluid/inference/lite/engine.h" - namespace paddle { namespace inference { namespace analysis { -using framework::ir::Node; using framework::ir::Agent; -using framework::ir::SubGraphFuser; using framework::ir::Graph; +using framework::ir::Node; +using framework::ir::SubGraphFuser; namespace lite { diff --git a/paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass.h b/paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass.h index e79a64f0f72cfcafa4b81109e184e0368e1739e9..198a86c185bc6811b1217008e2f2dd189de1c3b6 100644 --- a/paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass.h +++ b/paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass.h @@ -14,10 +14,12 @@ #pragma once #include + #include #include #include #include + #include "paddle/fluid/framework/ir/pass.h" #include "paddle/fluid/inference/analysis/ir_passes/subgraph_util.h" diff --git a/paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass_tester.cc b/paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass_tester.cc index 90ad7ec0b443781c6329472f139b1d092d3a89a7..8c88e2869cce3215c6bf4375e5c5238b66622d7b 100644 --- a/paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass_tester.cc +++ b/paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass_tester.cc @@ -12,8 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass.h" #include + +#include "paddle/fluid/inference/analysis/ir_passes/lite_subgraph_pass.h" #include "paddle/fluid/inference/io.h" #include "paddle/fluid/inference/lite/op_teller.h" @@ -29,7 +30,7 @@ void AppendLiteSubBlocks(const std::vector& subgraph_ops, framework::ProgramDesc* engine_program, framework::ProgramDesc* host_program, const int32_t host_sub_id); -} +} // namespace lite TEST(LiteSubgraphPass, basic) { framework::ProgramDesc host_program; diff --git a/paddle/fluid/inference/analysis/passes/ir_analysis_pass.cc b/paddle/fluid/inference/analysis/passes/ir_analysis_pass.cc index 34192965297a6b88c7905a2b1d7b1857d842f06a..05bda4e75c9bd1e48adf0e94c2293cd1601dccb3 100644 --- a/paddle/fluid/inference/analysis/passes/ir_analysis_pass.cc +++ b/paddle/fluid/inference/analysis/passes/ir_analysis_pass.cc @@ -13,8 +13,10 @@ // limitations under the License. #include "paddle/fluid/inference/analysis/passes/ir_analysis_pass.h" + #include #include + #include "paddle/fluid/framework/ir/fuse_pass_base.h" #include "paddle/fluid/inference/analysis/ir_pass_manager.h" diff --git a/paddle/fluid/inference/analysis/passes/ir_analysis_pass.h b/paddle/fluid/inference/analysis/passes/ir_analysis_pass.h index 2c2113c06d917b5473e68935889e4a7b16b6cfc1..fca431b5d7779838b940209099eaab0d6e3e707e 100644 --- a/paddle/fluid/inference/analysis/passes/ir_analysis_pass.h +++ b/paddle/fluid/inference/analysis/passes/ir_analysis_pass.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/inference/analysis/analysis_pass.h" namespace paddle { diff --git a/paddle/fluid/inference/analysis/passes/ir_graph_build_pass.cc b/paddle/fluid/inference/analysis/passes/ir_graph_build_pass.cc index 321716b1c8a1849c394850a874cd5d20e88c4a9a..fca5e2563424e957b78ed24fa217cccf44cc901b 100644 --- a/paddle/fluid/inference/analysis/passes/ir_graph_build_pass.cc +++ b/paddle/fluid/inference/analysis/passes/ir_graph_build_pass.cc @@ -13,8 +13,10 @@ // limitations under the License. #include "paddle/fluid/inference/analysis/passes/ir_graph_build_pass.h" + #include #include + #include "paddle/fluid/framework/executor.h" #include "paddle/fluid/framework/ir/fuse_pass_base.h" #include "paddle/fluid/inference/io.h" diff --git a/paddle/fluid/inference/analysis/passes/ir_graph_build_pass.h b/paddle/fluid/inference/analysis/passes/ir_graph_build_pass.h index adbde0433fad28b006b18b47c8fd0a8946d21a98..e7ef23e791e9de3bfcf5e68d51619e1de244a194 100644 --- a/paddle/fluid/inference/analysis/passes/ir_graph_build_pass.h +++ b/paddle/fluid/inference/analysis/passes/ir_graph_build_pass.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/inference/analysis/analysis_pass.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/inference/analysis/passes/ir_graph_to_program_pass.cc b/paddle/fluid/inference/analysis/passes/ir_graph_to_program_pass.cc index 0f3633ca6fa4bbd96ba6bc13928bfcda1e026ed7..999fb4ad8d7642fc1acc7d3b4ae3b6334a33125f 100644 --- a/paddle/fluid/inference/analysis/passes/ir_graph_to_program_pass.cc +++ b/paddle/fluid/inference/analysis/passes/ir_graph_to_program_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/inference/analysis/passes/ir_graph_to_program_pass.h" + #include "paddle/fluid/framework/ir/graph_to_program_pass.h" #include "paddle/fluid/framework/ir/pass.h" #include "paddle/fluid/framework/program_desc.h" diff --git a/paddle/fluid/inference/analysis/passes/ir_graph_to_program_pass.h b/paddle/fluid/inference/analysis/passes/ir_graph_to_program_pass.h index 613eb04497e61824e1b64b5dbfb4c80c81932227..5b20667d62ab60681d515a994e99e8c58429ccd5 100644 --- a/paddle/fluid/inference/analysis/passes/ir_graph_to_program_pass.h +++ b/paddle/fluid/inference/analysis/passes/ir_graph_to_program_pass.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/inference/analysis/analysis_pass.h" namespace paddle { diff --git a/paddle/fluid/inference/analysis/passes/ir_params_sync_among_devices_pass.cc b/paddle/fluid/inference/analysis/passes/ir_params_sync_among_devices_pass.cc index 614eea24a0e2ee9d4fabd68a9374fa7c44b63ad7..a0c7a94cd1b30107e7556ff586d1e90b7b8774d4 100644 --- a/paddle/fluid/inference/analysis/passes/ir_params_sync_among_devices_pass.cc +++ b/paddle/fluid/inference/analysis/passes/ir_params_sync_among_devices_pass.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/inference/analysis/passes/ir_params_sync_among_devices_pass.h" + #include "paddle/fluid/framework/data_layout.h" #include "paddle/fluid/framework/ir/graph_helper.h" #include "paddle/fluid/framework/lod_tensor.h" diff --git a/paddle/fluid/inference/analysis/passes/memory_optimize_pass.cc b/paddle/fluid/inference/analysis/passes/memory_optimize_pass.cc index 3fa417c2ea6311a1c1886c3cc887a32e45aad3d1..70620e8692cd843dc02874fc8bfce4febc1e5e12 100644 --- a/paddle/fluid/inference/analysis/passes/memory_optimize_pass.cc +++ b/paddle/fluid/inference/analysis/passes/memory_optimize_pass.cc @@ -61,7 +61,8 @@ void MemoryOptimizePass::CollectLifeCycle( auto reads = op_node->inputs; auto writes = op_node->outputs; - std::vector requires(reads.begin(), reads.end()); + std::vector + requires(reads.begin(), reads.end()); requires.insert(requires.end(), writes.begin(), writes.end()); // Disable reuse of feed variables. diff --git a/paddle/fluid/inference/analysis/passes/memory_optimize_pass.h b/paddle/fluid/inference/analysis/passes/memory_optimize_pass.h index 8ca5ffa2581f1ecb65ae8904a2e199fe9c43bbae..5dcd8b1059ebc2690a38ab7e2d201161345d762d 100644 --- a/paddle/fluid/inference/analysis/passes/memory_optimize_pass.h +++ b/paddle/fluid/inference/analysis/passes/memory_optimize_pass.h @@ -35,16 +35,15 @@ namespace inference { namespace analysis { /* Memory optimization. -* We will perform the following operation: -* 1. Collect all var's lifetime. -* 2. Make reuse plan: the vars can be reused if there is no overlap(on lifetime) -* between -* them. -* The final plan is a mapping table in which the key represents the original -* name of var and the value in the table represents the current name of var. -* 3. Perform reuse plan: Replace all var's name in the model according to the -* mapping table. -*/ + * We will perform the following operation: + * 1. Collect all var's lifetime. + * 2. Make reuse plan: the vars can be reused if there is no overlap(on + * lifetime) between them. The final plan is a mapping table in which the key + * represents the original name of var and the value in the table represents the + * current name of var. + * 3. Perform reuse plan: Replace all var's name in the model according to the + * mapping table. + */ class MemoryOptimizePass : public AnalysisPass { public: using space_table_t = std::unordered_map; diff --git a/paddle/fluid/inference/analysis/passes/passes.cc b/paddle/fluid/inference/analysis/passes/passes.cc index ca0b25c29d495dc0e71e69a6d7d2a10f0f8c2254..19aab1a948dd2d10b599c20d46feb0feb5204b9e 100644 --- a/paddle/fluid/inference/analysis/passes/passes.cc +++ b/paddle/fluid/inference/analysis/passes/passes.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/inference/analysis/passes/passes.h" + #include "paddle/fluid/inference/analysis/passes/adjust_cudnn_workspace_size_pass.h" #include "paddle/fluid/inference/analysis/passes/inference_op_replace_pass.h" #include "paddle/fluid/inference/analysis/passes/ir_analysis_pass.h" diff --git a/paddle/fluid/inference/analysis/passes/passes.h b/paddle/fluid/inference/analysis/passes/passes.h index 8a13091d083e51ecc84e6790f973ffa39ba5a6b9..b3b240c280c9674cf3ce6cf3d1688d9c91e934dc 100644 --- a/paddle/fluid/inference/analysis/passes/passes.h +++ b/paddle/fluid/inference/analysis/passes/passes.h @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/fluid/inference/analysis/analysis_pass.h" namespace paddle { diff --git a/paddle/fluid/inference/analysis/ut_helper.h b/paddle/fluid/inference/analysis/ut_helper.h index 56565c8f3f72abe5925b64199c428f378dfca136..6c7690a4779bf94f87255b8200c0ec3a384026a2 100644 --- a/paddle/fluid/inference/analysis/ut_helper.h +++ b/paddle/fluid/inference/analysis/ut_helper.h @@ -14,8 +14,10 @@ limitations under the License. */ #pragma once #include + #include #include + #include "gflags/gflags.h" #include "paddle/fluid/framework/executor.h" #include "paddle/fluid/inference/analysis/helper.h" diff --git a/paddle/fluid/inference/api/analysis_config.cc b/paddle/fluid/inference/api/analysis_config.cc index 5bb26d8f0804d79c174827d7f60555f051caf141..c23397a08286049d06033877ced0545e47f5d595 100644 --- a/paddle/fluid/inference/api/analysis_config.cc +++ b/paddle/fluid/inference/api/analysis_config.cc @@ -15,6 +15,7 @@ #include #include #include + #include "paddle/fluid/inference/api/paddle_analysis_config.h" #include "paddle/fluid/inference/api/paddle_pass_builder.h" #include "paddle/fluid/inference/utils/table_printer.h" @@ -1105,8 +1106,9 @@ LiteNNAdapterConfig &LiteNNAdapterConfig::SetModelCacheBuffers( platform::errors::InvalidArgument( "model_cache_buffer should not be empty.")); PADDLE_ENFORCE_EQ(nnadapter_model_cache_buffers.count(model_cache_token), - false, platform::errors::InvalidArgument( - "model_cache_token has already been set.")); + false, + platform::errors::InvalidArgument( + "model_cache_token has already been set.")); nnadapter_model_cache_buffers[model_cache_token] = model_cache_buffer; return *this; diff --git a/paddle/fluid/inference/api/analysis_predictor.cc b/paddle/fluid/inference/api/analysis_predictor.cc index b40377855bd3ea6445129847972dc5e54a6f3289..5f9051ff2fdb9e45249232e4c7d1e26bca462d2b 100644 --- a/paddle/fluid/inference/api/analysis_predictor.cc +++ b/paddle/fluid/inference/api/analysis_predictor.cc @@ -83,9 +83,9 @@ namespace paddle { using inference::Singleton; #if PADDLE_WITH_TENSORRT -using inference::tensorrt::TRTInt8Calibrator; using inference::tensorrt::TRTCalibratorEngine; using inference::tensorrt::TRTCalibratorEngineManager; +using inference::tensorrt::TRTInt8Calibrator; #endif int AnalysisPredictor::clone_num_ = 1; @@ -1027,8 +1027,9 @@ void AnalysisPredictor::OptimizeInferenceProgram() { } template <> -std::unique_ptr CreatePaddlePredictor< - AnalysisConfig, PaddleEngineKind::kAnalysis>(const AnalysisConfig &config) { +std::unique_ptr +CreatePaddlePredictor( + const AnalysisConfig &config) { // TODO(NHZlX): Should add the link to the doc of // paddle_infer::CreatePredictor if (config.glog_info_disabled()) { diff --git a/paddle/fluid/inference/api/analysis_predictor.h b/paddle/fluid/inference/api/analysis_predictor.h index e96526730fdeafdd329e226ae9b24c0b197818fc..1cfdaf1a5586457cc398be22909fd74c78f36cb4 100644 --- a/paddle/fluid/inference/api/analysis_predictor.h +++ b/paddle/fluid/inference/api/analysis_predictor.h @@ -41,7 +41,7 @@ using float16 = paddle::platform::float16; namespace experimental { class InternalUtils; }; -} +} // namespace paddle_infer /// /// \file analysis_predictor.h /// @@ -55,10 +55,10 @@ class InternalUtils; namespace paddle { -using inference::analysis::Argument; -using inference::analysis::Analyzer; -using framework::proto::ProgramDesc; using framework::NaiveExecutor; +using framework::proto::ProgramDesc; +using inference::analysis::Analyzer; +using inference::analysis::Argument; /// /// \class AnalysisPredictor diff --git a/paddle/fluid/inference/api/analysis_predictor_tester.cc b/paddle/fluid/inference/api/analysis_predictor_tester.cc index e8a1384166aff9777c1c9973d766b1376d187253..f16054565a7fc315a8ac77148d2a2cc05bcb5ed3 100644 --- a/paddle/fluid/inference/api/analysis_predictor_tester.cc +++ b/paddle/fluid/inference/api/analysis_predictor_tester.cc @@ -18,7 +18,9 @@ #endif #include #include + #include // NOLINT + #include "paddle/fluid/framework/ir/pass.h" #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/inference/api/helper.h" diff --git a/paddle/fluid/inference/api/api.cc b/paddle/fluid/inference/api/api.cc index e2befadf0a89b2477ffde62da24dfc9059ee022f..9e4633774a2fc139ac2db14c035f9bb146525edc 100644 --- a/paddle/fluid/inference/api/api.cc +++ b/paddle/fluid/inference/api/api.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "gflags/gflags.h" #include "paddle/fluid/framework/commit.h" #include "paddle/fluid/framework/lod_tensor.h" diff --git a/paddle/fluid/inference/api/api_impl.cc b/paddle/fluid/inference/api/api_impl.cc index 1c4369af646afa84f78bd34b3943406fb5f9c49e..38960aecb703b062f02e526874148e12458cc8b8 100644 --- a/paddle/fluid/inference/api/api_impl.cc +++ b/paddle/fluid/inference/api/api_impl.cc @@ -12,13 +12,15 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/inference/api/api_impl.h" + #include + #include #include #include #include "paddle/fluid/framework/feed_fetch_method.h" -#include "paddle/fluid/inference/api/api_impl.h" #include "paddle/fluid/inference/api/helper.h" #include "paddle/fluid/platform/cpu_helper.h" #include "paddle/fluid/platform/place.h" @@ -348,8 +350,9 @@ bool NativePaddlePredictor::GetFetch(std::vector *outputs, } template <> -std::unique_ptr CreatePaddlePredictor< - NativeConfig, PaddleEngineKind::kNative>(const NativeConfig &config) { +std::unique_ptr +CreatePaddlePredictor( + const NativeConfig &config) { // TODO(NHZlX): Should add the link to the doc of // paddle_infer::CreatePredictor VLOG(3) << "create NativePaddlePredictor"; diff --git a/paddle/fluid/inference/api/api_impl.h b/paddle/fluid/inference/api/api_impl.h index b91eff4573ed0b0545409c99d71577feca2b32c2..d503d2581392a59b206fa3191ed06991791c1275 100644 --- a/paddle/fluid/inference/api/api_impl.h +++ b/paddle/fluid/inference/api/api_impl.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include #include #include diff --git a/paddle/fluid/inference/api/api_tester.cc b/paddle/fluid/inference/api/api_tester.cc index 46724fa6b1acac594a0f674cc72d5f38013bf393..1faf46fad2be6e62543dd415d902ac702d23b340 100644 --- a/paddle/fluid/inference/api/api_tester.cc +++ b/paddle/fluid/inference/api/api_tester.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include #include diff --git a/paddle/fluid/inference/api/demo_ci/onnxruntime_mobilenet_demo.cc b/paddle/fluid/inference/api/demo_ci/onnxruntime_mobilenet_demo.cc index ef5c08cd041eb7af4c7f17a95c4fd9b8601e4bad..f9ac07a830459a6a6b9da566b38bc09621d74418 100644 --- a/paddle/fluid/inference/api/demo_ci/onnxruntime_mobilenet_demo.cc +++ b/paddle/fluid/inference/api/demo_ci/onnxruntime_mobilenet_demo.cc @@ -17,7 +17,9 @@ limitations under the License. */ */ #include // use glog instead of CHECK to avoid importing other paddle header files. + #include + #include "gflags/gflags.h" #include "utils.h" // NOLINT diff --git a/paddle/fluid/inference/api/demo_ci/trt_mobilenet_demo.cc b/paddle/fluid/inference/api/demo_ci/trt_mobilenet_demo.cc index 9edb4ecbfd228915778c454728ca92bf6538efca..551b66fcaf7fafa30fdc2b80db6d7e3e7a5fec9f 100644 --- a/paddle/fluid/inference/api/demo_ci/trt_mobilenet_demo.cc +++ b/paddle/fluid/inference/api/demo_ci/trt_mobilenet_demo.cc @@ -17,6 +17,7 @@ limitations under the License. */ */ #include // use glog instead of CHECK to avoid importing other paddle header files. + #include "gflags/gflags.h" #include "utils.h" // NOLINT diff --git a/paddle/fluid/inference/api/demo_ci/utils.h b/paddle/fluid/inference/api/demo_ci/utils.h index b4f40194aa9476ebee505e300f4e4e6a139211d7..dfba4b8ebf6cd309221a9a1476009409f7c4b481 100644 --- a/paddle/fluid/inference/api/demo_ci/utils.h +++ b/paddle/fluid/inference/api/demo_ci/utils.h @@ -14,11 +14,13 @@ #pragma once #include + #include #include #include #include #include + #include "paddle/include/paddle_inference_api.h" namespace paddle { diff --git a/paddle/fluid/inference/api/demo_ci/vis_demo.cc b/paddle/fluid/inference/api/demo_ci/vis_demo.cc index 818444fbcb6489dbaf5e25600bb67f5ea093e055..352efc1e63dbd2a7d5888d7203465c1d4977ce60 100644 --- a/paddle/fluid/inference/api/demo_ci/vis_demo.cc +++ b/paddle/fluid/inference/api/demo_ci/vis_demo.cc @@ -17,6 +17,7 @@ limitations under the License. */ */ #include + #include "gflags/gflags.h" #include "utils.h" // NOLINT diff --git a/paddle/fluid/inference/api/demo_ci/windows_mobilenet.cc b/paddle/fluid/inference/api/demo_ci/windows_mobilenet.cc index 8d0538f8fa52d4655810093aa45de43e3c7bd023..b1f770066e7be2fe099684f0e2f8bf880711e7fd 100644 --- a/paddle/fluid/inference/api/demo_ci/windows_mobilenet.cc +++ b/paddle/fluid/inference/api/demo_ci/windows_mobilenet.cc @@ -13,14 +13,15 @@ // limitations under the License. #include + #include #include #include #include #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/include/paddle_inference_api.h" DEFINE_string(modeldir, "", "Directory of the inference model."); diff --git a/paddle/fluid/inference/api/details/zero_copy_tensor.cc b/paddle/fluid/inference/api/details/zero_copy_tensor.cc index bb966dc5c6c1b5b4377c54f9f615775e212675d9..661d9def40653955015da86f939006b3a23eb06f 100644 --- a/paddle/fluid/inference/api/details/zero_copy_tensor.cc +++ b/paddle/fluid/inference/api/details/zero_copy_tensor.cc @@ -340,8 +340,9 @@ void Tensor::CopyToCpuImpl(T *data, void *exec_stream, CallbackFunc cb, #ifdef PADDLE_WITH_MKLDNN if (tensor->layout() == paddle::framework::DataLayout::kMKLDNN) paddle::framework::innerTransDataLayoutFromMKLDNN( - tensor->layout(), paddle::platform::MKLDNNDeviceContext::tls() - .get_cur_paddle_data_layout(), + tensor->layout(), + paddle::platform::MKLDNNDeviceContext::tls() + .get_cur_paddle_data_layout(), *tensor, &out, paddle::platform::CPUPlace(), true); else std::memcpy(static_cast(data), t_data, ele_num * sizeof(T)); @@ -852,8 +853,9 @@ void InternalUtils::CopyToCpuWithIoStream(paddle_infer::Tensor *t, T *data, #ifdef PADDLE_WITH_MKLDNN if (tensor->layout() == paddle::framework::DataLayout::kMKLDNN) paddle::framework::innerTransDataLayoutFromMKLDNN( - tensor->layout(), paddle::platform::MKLDNNDeviceContext::tls() - .get_cur_paddle_data_layout(), + tensor->layout(), + paddle::platform::MKLDNNDeviceContext::tls() + .get_cur_paddle_data_layout(), *tensor, &out, paddle::platform::CPUPlace(), true); else std::memcpy(static_cast(data), t_data, ele_num * sizeof(T)); diff --git a/paddle/fluid/inference/api/helper.cc b/paddle/fluid/inference/api/helper.cc index b9e0e90a403169127a0649921e1f54febed9c586..3454c5c8fd17b5221c4ace93d56a88fc574526d1 100644 --- a/paddle/fluid/inference/api/helper.cc +++ b/paddle/fluid/inference/api/helper.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/inference/api/helper.h" + #include "paddle/fluid/framework/custom_operator.h" #include "paddle/fluid/framework/operator.h" #include "paddle/phi/api/ext/op_meta_info.h" diff --git a/paddle/fluid/inference/api/helper.h b/paddle/fluid/inference/api/helper.h index acc52ac046815a212d1a63deb30e7032ceb165da..1c58b004e6d316567f96c5f24d7d40c6750de70b 100644 --- a/paddle/fluid/inference/api/helper.h +++ b/paddle/fluid/inference/api/helper.h @@ -15,6 +15,7 @@ #pragma once #include + #include #if !defined(_WIN32) #include @@ -377,8 +378,9 @@ static void PrintTime(int batch_size, int repeat, int num_threads, int tid, double batch_latency, int epoch = 1, const framework::proto::VarType::Type data_type = framework::proto::VarType::FP32) { - PADDLE_ENFORCE_GT(batch_size, 0, platform::errors::InvalidArgument( - "Non-positive batch size.")); + PADDLE_ENFORCE_GT( + batch_size, 0, + platform::errors::InvalidArgument("Non-positive batch size.")); double sample_latency = batch_latency / batch_size; LOG(INFO) << "====== threads: " << num_threads << ", thread id: " << tid << " ======"; diff --git a/paddle/fluid/inference/api/infer_context.h b/paddle/fluid/inference/api/infer_context.h index b7a8bf637d872c47176af70e1bad1df7aef868de..c2a23a7ca2ce5d027093b68e4d25892255fa9046 100644 --- a/paddle/fluid/inference/api/infer_context.h +++ b/paddle/fluid/inference/api/infer_context.h @@ -25,21 +25,21 @@ class InferCPUContext : public phi::CPUContext { #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) class InferGPUContext : public phi::GPUContext { public: - using phi::GPUContext::SetStream; - using phi::GPUContext::SetEigenDevice; using phi::GPUContext::SetBlasHandle; using phi::GPUContext::SetBlasTensorCoreHandle; using phi::GPUContext::SetBlasTF32Handle; using phi::GPUContext::SetDnnHandle; + using phi::GPUContext::SetEigenDevice; using phi::GPUContext::SetSolverHandle; using phi::GPUContext::SetSparseHandle; + using phi::GPUContext::SetStream; // using phi::GPUContext::SetDnnWorkspaceHandle; using phi::GPUContext::SetComputeCapability; + using phi::GPUContext::SetDriverVersion; + using phi::GPUContext::SetMaxGridDimSize; + using phi::GPUContext::SetMaxThreadsPerBlock; using phi::GPUContext::SetMaxThreadsPerMultiProcessor; using phi::GPUContext::SetMultiProcessors; - using phi::GPUContext::SetMaxThreadsPerBlock; - using phi::GPUContext::SetMaxGridDimSize; - using phi::GPUContext::SetDriverVersion; using phi::GPUContext::SetRuntimeVersion; }; #endif diff --git a/paddle/fluid/inference/api/mkldnn_quantizer.cc b/paddle/fluid/inference/api/mkldnn_quantizer.cc index 4dc80a1d75390a0c6f353c8c9a20428d49d4a94f..73096973c381cf42975027f9ebe5971336ec2f30 100644 --- a/paddle/fluid/inference/api/mkldnn_quantizer.cc +++ b/paddle/fluid/inference/api/mkldnn_quantizer.cc @@ -13,12 +13,14 @@ // limitations under the License. #include "paddle/fluid/inference/api/mkldnn_quantizer.h" + #include #include #include #include #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/ir/fuse_pass_base.h" #include "paddle/fluid/framework/ir/graph.h" @@ -33,10 +35,10 @@ namespace paddle { -using platform::CPUPlace; using framework::LoDTensor; using framework::Variable; using framework::ir::Graph; +using platform::CPUPlace; using ConstEigenVectorArrayMap = Eigen::Map>; using EigenMatrixDoubleArray = @@ -57,8 +59,9 @@ static void check_var(const Variable* var, const std::string& var_name) { } static void check_tensor(const LoDTensor& tensor) { - PADDLE_ENFORCE_GT(tensor.dims().size(), 0, platform::errors::InvalidArgument( - "Tensor dimension is empty.")); + PADDLE_ENFORCE_GT( + tensor.dims().size(), 0, + platform::errors::InvalidArgument("Tensor dimension is empty.")); } void AnalysisPredictor::MkldnnQuantizer::CalculateScalesForRNNWeights( @@ -531,8 +534,9 @@ AnalysisPredictor::MkldnnQuantizer::Histogram( PADDLE_ENFORCE_GE(max_val, min_val, platform::errors::InvalidArgument( "MkldnnQuantizer: To calculate Histogram, max_val (" + - std::to_string(max_val) + ") must be greater or equal" - "to min_val (" + + std::to_string(max_val) + + ") must be greater or equal" + "to min_val (" + std::to_string(min_val) + ").")); ConstEigenVectorArrayMap eigen_tensor{var_tensor.data(), var_tensor.numel(), 1}; @@ -570,7 +574,8 @@ void AnalysisPredictor::MkldnnQuantizer::PrepareArgument() const { auto* builder = predictor_.config_.pass_builder(); builder->SetPasses({ - "cpu_quantize_pass", "cpu_quantize_squash_pass", + "cpu_quantize_pass", + "cpu_quantize_squash_pass", "int8_scale_calculation_mkldnn_pass", }); if (predictor_.config_.ir_debug_) builder->TurnOnDebug(); diff --git a/paddle/fluid/inference/api/mkldnn_quantizer.h b/paddle/fluid/inference/api/mkldnn_quantizer.h index 5e7aa39de52bc74d424c53fc593452e56bd7e6ba..811f2941a7d14212d75388dfe21313c8383ab34c 100644 --- a/paddle/fluid/inference/api/mkldnn_quantizer.h +++ b/paddle/fluid/inference/api/mkldnn_quantizer.h @@ -20,6 +20,7 @@ #include #include #include + #include "paddle/fluid/framework/naive_executor.h" #include "paddle/fluid/inference/analysis/analyzer.h" #include "paddle/fluid/inference/api/analysis_predictor.h" diff --git a/paddle/fluid/inference/api/mkldnn_quantizer_tester.cc b/paddle/fluid/inference/api/mkldnn_quantizer_tester.cc index 2bee4763d4fe965d5c404906b3b3514cf6c0b8ce..05077f8ba34cc61b25600a5d121e8bdecccedbc6 100644 --- a/paddle/fluid/inference/api/mkldnn_quantizer_tester.cc +++ b/paddle/fluid/inference/api/mkldnn_quantizer_tester.cc @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/inference/api/mkldnn_quantizer.h" #include + #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/inference/api/analysis_predictor.h" +#include "paddle/fluid/inference/api/mkldnn_quantizer.h" #include "paddle/fluid/inference/api/paddle_inference_api.h" DEFINE_string(dirname, "", "dirname to tests."); diff --git a/paddle/fluid/inference/api/onnxruntime_predictor.h b/paddle/fluid/inference/api/onnxruntime_predictor.h index d01756e4b96b132e3f9c3815e96f612433616ff2..294a83a4335ba1b43f7919b9bef9fb563d5678c7 100644 --- a/paddle/fluid/inference/api/onnxruntime_predictor.h +++ b/paddle/fluid/inference/api/onnxruntime_predictor.h @@ -18,6 +18,9 @@ #include #include #include + +#include "onnxruntime_c_api.h" // NOLINT +#include "onnxruntime_cxx_api.h" // NOLINT #include "paddle/fluid/framework/naive_executor.h" #include "paddle/fluid/framework/op_compatible_info.h" #include "paddle/fluid/inference/analysis/analyzer.h" @@ -27,9 +30,6 @@ #include "paddle/fluid/inference/api/paddle_inference_api.h" #include "paddle/fluid/platform/device/gpu/gpu_types.h" #include "paddle/fluid/string/printf.h" - -#include "onnxruntime_c_api.h" // NOLINT -#include "onnxruntime_cxx_api.h" // NOLINT #include "paddle2onnx/converter.h" #ifdef PADDLE_WITH_TESTING diff --git a/paddle/fluid/inference/api/onnxruntime_predictor_tester.cc b/paddle/fluid/inference/api/onnxruntime_predictor_tester.cc index 4a702edacc903cb9bea53d71b365481f14847c0e..ff8528c085009e755212177717d233369a745c76 100644 --- a/paddle/fluid/inference/api/onnxruntime_predictor_tester.cc +++ b/paddle/fluid/inference/api/onnxruntime_predictor_tester.cc @@ -12,16 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/inference/api/onnxruntime_predictor.h" - #include #include + #include #include // NOLINT #include + #include "paddle/fluid/framework/ir/pass.h" #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/inference/api/helper.h" +#include "paddle/fluid/inference/api/onnxruntime_predictor.h" #include "paddle/fluid/inference/api/paddle_api.h" #include "paddle/fluid/inference/api/paddle_inference_api.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/api/paddle_analysis_config.h b/paddle/fluid/inference/api/paddle_analysis_config.h index ab2265bff24cd0da40bc697c716eaadc5a1f014f..489c32bc59d17fce6a1a731a4ba42a3467cd693f 100644 --- a/paddle/fluid/inference/api/paddle_analysis_config.h +++ b/paddle/fluid/inference/api/paddle_analysis_config.h @@ -912,11 +912,18 @@ struct PD_INFER_DECL AnalysisConfig { bool thread_local_stream_{false}; bool use_gpu_fp16_{false}; std::unordered_set gpu_fp16_disabled_op_types_{ - "conv2d_fusion", "conv2d", "roll", "strided_slice", "depthwise_conv2d", - "unfold", "generate_proposals_v2", "nearest_interp_v2", + "conv2d_fusion", + "conv2d", + "roll", + "strided_slice", + "depthwise_conv2d", + "unfold", + "generate_proposals_v2", + "nearest_interp_v2", "bilinear_interp_v2" "yolo_box", - "multiclass_nms3", "matrix_nms"}; + "multiclass_nms3", + "matrix_nms"}; bool use_cudnn_{false}; diff --git a/paddle/fluid/inference/api/paddle_api.h b/paddle/fluid/inference/api/paddle_api.h index 711998e9956c6f12d9c2a3e924217e58db2aa6d8..78af756c24b0345295b943d67fa1a0307ee9d075 100644 --- a/paddle/fluid/inference/api/paddle_api.h +++ b/paddle/fluid/inference/api/paddle_api.h @@ -27,6 +27,7 @@ #include #include #include + #include "crypto/cipher.h" #include "paddle_infer_declare.h" // NOLINT #include "paddle_tensor.h" // NOLINT @@ -391,12 +392,14 @@ PD_INFER_DECL std::unique_ptr CreatePaddlePredictor( const ConfigT& config); template <> -PD_INFER_DECL std::unique_ptr CreatePaddlePredictor< - NativeConfig, PaddleEngineKind::kNative>(const NativeConfig& config); +PD_INFER_DECL std::unique_ptr +CreatePaddlePredictor( + const NativeConfig& config); template <> -PD_INFER_DECL std::unique_ptr CreatePaddlePredictor< - AnalysisConfig, PaddleEngineKind::kAnalysis>(const AnalysisConfig& config); +PD_INFER_DECL std::unique_ptr +CreatePaddlePredictor( + const AnalysisConfig& config); template <> PD_INFER_DECL std::unique_ptr diff --git a/paddle/fluid/inference/api/paddle_infer_contrib.cc b/paddle/fluid/inference/api/paddle_infer_contrib.cc index d27f20a93b3a4bfccb6640282dc63855de31a487..e785e91a67139b0fc744dc63182377361c636a13 100644 --- a/paddle/fluid/inference/api/paddle_infer_contrib.cc +++ b/paddle/fluid/inference/api/paddle_infer_contrib.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/inference/api/paddle_infer_contrib.h" + #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/memory/memcpy.h" #include "paddle/fluid/platform/device_context.h" diff --git a/paddle/fluid/inference/api/paddle_pass_builder.cc b/paddle/fluid/inference/api/paddle_pass_builder.cc index 04e77faf2e34f2909c618322612f5f60bcc5e4ba..9e5b76db4ac16173da020735e8a28dce24bb02ed 100644 --- a/paddle/fluid/inference/api/paddle_pass_builder.cc +++ b/paddle/fluid/inference/api/paddle_pass_builder.cc @@ -20,6 +20,7 @@ #include #endif #include + #include #include diff --git a/paddle/fluid/inference/api/resource_manager.h b/paddle/fluid/inference/api/resource_manager.h index c41968dc58590a17cf9b3f230ef559ddcbbbdde7..24e76598e400b6dfc0c02285dd14f3bb8488ab68 100644 --- a/paddle/fluid/inference/api/resource_manager.h +++ b/paddle/fluid/inference/api/resource_manager.h @@ -15,6 +15,7 @@ #include #include + #include "paddle/phi/api/include/tensor.h" #include "paddle/phi/backends/cpu/forwards.h" diff --git a/paddle/fluid/inference/capi/c_api.cc b/paddle/fluid/inference/capi/c_api.cc index 07493c742c4fa906e7c4817e328e7d4f81afbffa..f2a9838f4bc7dd1f4b79bf61ab64fbe81552362b 100644 --- a/paddle/fluid/inference/capi/c_api.cc +++ b/paddle/fluid/inference/capi/c_api.cc @@ -14,6 +14,7 @@ #include #include + #include "paddle/fluid/inference/capi/c_api_internal.h" #include "paddle/fluid/inference/capi/paddle_c_api.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/inference/capi/c_api_internal.h b/paddle/fluid/inference/capi/c_api_internal.h index 7e69b7210768e5af9e8f4150883a608a1517a13c..11728fb9878fcaf3b6f62418e841be605d5de9fb 100644 --- a/paddle/fluid/inference/capi/c_api_internal.h +++ b/paddle/fluid/inference/capi/c_api_internal.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/inference/api/paddle_analysis_config.h" #include "paddle/fluid/inference/api/paddle_api.h" #include "paddle/fluid/inference/capi/paddle_c_api.h" diff --git a/paddle/fluid/inference/capi/pd_config.cc b/paddle/fluid/inference/capi/pd_config.cc index 9bb52ba57802512f393c23f957cc38ddabb878b1..2bacc94c0d1189fbddc85d408b8043e355c8e267 100644 --- a/paddle/fluid/inference/capi/pd_config.cc +++ b/paddle/fluid/inference/capi/pd_config.cc @@ -18,6 +18,7 @@ #include #include #include + #include "paddle/fluid/inference/capi/c_api_internal.h" #include "paddle/fluid/inference/capi/paddle_c_api.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/inference/capi/pd_predictor.cc b/paddle/fluid/inference/capi/pd_predictor.cc index 12d7f78e169ccdaedd29e07dc9d5538415453390..e88fbfc5a86a345ef40661a99e6024fdd518ee65 100644 --- a/paddle/fluid/inference/capi/pd_predictor.cc +++ b/paddle/fluid/inference/capi/pd_predictor.cc @@ -19,6 +19,7 @@ #include #include #include + #include "paddle/fluid/inference/api/paddle_api.h" #include "paddle/fluid/inference/capi/c_api_internal.h" #include "paddle/fluid/inference/capi/paddle_c_api.h" diff --git a/paddle/fluid/inference/capi/pd_tensor.cc b/paddle/fluid/inference/capi/pd_tensor.cc index 9b1eedd7c5a8106a6f6b7be3f682913e2431a3e5..199db92d1b0d3933fc4378ea510d3899cf22c045 100644 --- a/paddle/fluid/inference/capi/pd_tensor.cc +++ b/paddle/fluid/inference/capi/pd_tensor.cc @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/fluid/inference/capi/c_api_internal.h" #include "paddle/fluid/inference/capi/paddle_c_api.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/inference/capi_exp/lod_demo.cc b/paddle/fluid/inference/capi_exp/lod_demo.cc index 2b049e992e71dd64c6616b2ac5c951ee10ea7909..c67d6f870bdd9cfba55b93c086ae209542a5e0b6 100644 --- a/paddle/fluid/inference/capi_exp/lod_demo.cc +++ b/paddle/fluid/inference/capi_exp/lod_demo.cc @@ -27,8 +27,10 @@ #include #include #include + #include #include + #include "paddle/fluid/inference/capi_exp/pd_inference_api.h" int main(int argc, char *argv[]) { diff --git a/paddle/fluid/inference/capi_exp/pd_config.cc b/paddle/fluid/inference/capi_exp/pd_config.cc index d290f44d2ee480c57b09cdc879f9117f633e527a..4e1c5a2a0ddd01dd22cd7f7515ec1d8264fb7a39 100644 --- a/paddle/fluid/inference/capi_exp/pd_config.cc +++ b/paddle/fluid/inference/capi_exp/pd_config.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/inference/capi_exp/pd_config.h" + #include "paddle/fluid/inference/api/paddle_inference_api.h" #include "paddle/fluid/inference/capi_exp/pd_types.h" #include "paddle/fluid/inference/capi_exp/utils_internal.h" diff --git a/paddle/fluid/inference/capi_exp/pd_predictor.cc b/paddle/fluid/inference/capi_exp/pd_predictor.cc index 5ca58b0e4138b274c67cbd988388acc30a0368ae..c85dfdf522e67f5da3437dc1bd7de129b2ec1295 100644 --- a/paddle/fluid/inference/capi_exp/pd_predictor.cc +++ b/paddle/fluid/inference/capi_exp/pd_predictor.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/inference/capi_exp/pd_predictor.h" + #include "paddle/fluid/inference/api/paddle_inference_api.h" #include "paddle/fluid/inference/capi_exp/pd_types.h" #include "paddle/fluid/inference/capi_exp/pd_utils.h" diff --git a/paddle/fluid/inference/capi_exp/pd_tensor.cc b/paddle/fluid/inference/capi_exp/pd_tensor.cc index 9c661dea6f2bb2dcb168e5d08e80794195ef2710..520cfa813f47e212afeee99610a78ddbf67d0de2 100644 --- a/paddle/fluid/inference/capi_exp/pd_tensor.cc +++ b/paddle/fluid/inference/capi_exp/pd_tensor.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/inference/capi_exp/pd_tensor.h" + #include "paddle/fluid/inference/api/paddle_inference_api.h" #include "paddle/fluid/inference/capi_exp/pd_types.h" #include "paddle/fluid/inference/capi_exp/pd_utils.h" diff --git a/paddle/fluid/inference/capi_exp/pd_utils.cc b/paddle/fluid/inference/capi_exp/pd_utils.cc index efca350fbaf49b9113729b008820240c0c5ceef6..7942a860c4ee898c0f2a402eaae469b95e549ead 100644 --- a/paddle/fluid/inference/capi_exp/pd_utils.cc +++ b/paddle/fluid/inference/capi_exp/pd_utils.cc @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/inference/capi_exp/pd_utils.h" + #include #include "paddle/fluid/inference/api/paddle_inference_api.h" -#include "paddle/fluid/inference/capi_exp/pd_utils.h" #include "paddle/fluid/inference/capi_exp/utils_internal.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/inference/experimental/javaapi/native/com_baidu_paddle_inference_Config.cpp b/paddle/fluid/inference/experimental/javaapi/native/com_baidu_paddle_inference_Config.cpp index 593ba3cb51d8ce6e19e64a074d6b8bfb057b3268..efea093fa245a2fdb94c8d7b68fe8d264df560c7 100644 --- a/paddle/fluid/inference/experimental/javaapi/native/com_baidu_paddle_inference_Config.cpp +++ b/paddle/fluid/inference/experimental/javaapi/native/com_baidu_paddle_inference_Config.cpp @@ -13,9 +13,10 @@ // limitations under the License. #include "com_baidu_paddle_inference_Config.h" + #include -#include "jni_convert_util.h" // NOLINT +#include "jni_convert_util.h" // NOLINT #include "pd_inference_api.h" // NOLINT JNIEXPORT void JNICALL Java_com_baidu_paddle_inference_Config_cppConfigDestroy( diff --git a/paddle/fluid/inference/experimental/javaapi/native/com_baidu_paddle_inference_Predictor.cpp b/paddle/fluid/inference/experimental/javaapi/native/com_baidu_paddle_inference_Predictor.cpp index 7eff03690ae8ebbda28fe955214654816333cf98..0912c2ad57a68d1836e1484ad2f50626d197c3ca 100644 --- a/paddle/fluid/inference/experimental/javaapi/native/com_baidu_paddle_inference_Predictor.cpp +++ b/paddle/fluid/inference/experimental/javaapi/native/com_baidu_paddle_inference_Predictor.cpp @@ -13,7 +13,9 @@ // limitations under the License. #include "com_baidu_paddle_inference_Predictor.h" + #include + #include "jni_convert_util.h" // NOLINT #include "pd_inference_api.h" // NOLINT diff --git a/paddle/fluid/inference/experimental/javaapi/native/com_baidu_paddle_inference_Tensor.cpp b/paddle/fluid/inference/experimental/javaapi/native/com_baidu_paddle_inference_Tensor.cpp index b9be4a73ac2ce78a30ffb48373fd914f5deeaa72..a90ae165ebd51f9e20573ac8afe8d8c3d6699307 100644 --- a/paddle/fluid/inference/experimental/javaapi/native/com_baidu_paddle_inference_Tensor.cpp +++ b/paddle/fluid/inference/experimental/javaapi/native/com_baidu_paddle_inference_Tensor.cpp @@ -13,7 +13,9 @@ // limitations under the License. #include "com_baidu_paddle_inference_Tensor.h" + #include + #include "pd_inference_api.h" // NOLINT JNIEXPORT void JNICALL Java_com_baidu_paddle_inference_Tensor_cppTensorDestroy( diff --git a/paddle/fluid/inference/experimental/javaapi/native/jni_convert_util.h b/paddle/fluid/inference/experimental/javaapi/native/jni_convert_util.h index 0026ec2f4102c829b6237361350b264cc9842388..c363559298f1835646576752156a472489aa5e7a 100644 --- a/paddle/fluid/inference/experimental/javaapi/native/jni_convert_util.h +++ b/paddle/fluid/inference/experimental/javaapi/native/jni_convert_util.h @@ -17,6 +17,7 @@ #include #include + #include #include @@ -54,8 +55,8 @@ inline jstring cpp_string_to_jstring(JNIEnv *env, std::string str) { reinterpret_cast(data)); jstring encoding = env->NewStringUTF("UTF-8"); - jstring res = (jstring)( - env->NewObject(strClass, strClassInitMethodID, bytes, encoding)); + jstring res = (jstring)(env->NewObject(strClass, strClassInitMethodID, bytes, + encoding)); env->DeleteLocalRef(strClass); env->DeleteLocalRef(encoding); diff --git a/paddle/fluid/inference/io.h b/paddle/fluid/inference/io.h index 317ef9d93acf3af174cb44da6099425fff1418eb..1106ad261ec41d75b4e0d4ad66e265fc8ab32c98 100644 --- a/paddle/fluid/inference/io.h +++ b/paddle/fluid/inference/io.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/executor.h" #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/scope.h" diff --git a/paddle/fluid/inference/lite/engine.cc b/paddle/fluid/inference/lite/engine.cc index cd78cfecd863577e61bd90e70cecfcc3e562f1da..8f8f68b170b62ceab743e824fd157d1f74e91da9 100644 --- a/paddle/fluid/inference/lite/engine.cc +++ b/paddle/fluid/inference/lite/engine.cc @@ -25,6 +25,7 @@ #endif #include "paddle/fluid/inference/lite/engine.h" + #include namespace paddle { diff --git a/paddle/fluid/inference/lite/op_teller.cc b/paddle/fluid/inference/lite/op_teller.cc index 3a162c3fde13f61fae5aba7a7da0bbfdc5f20801..3d2ed0a5c9890075ef6d9d71536f0da763493a60 100644 --- a/paddle/fluid/inference/lite/op_teller.cc +++ b/paddle/fluid/inference/lite/op_teller.cc @@ -12,12 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/inference/lite/op_teller.h" + #include #include "paddle/fluid/framework/block_desc.h" #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/inference/lite/engine.h" -#include "paddle/fluid/inference/lite/op_teller.h" namespace paddle { namespace inference { diff --git a/paddle/fluid/inference/lite/op_teller.h b/paddle/fluid/inference/lite/op_teller.h index b9391a98a2ee36b95f5188e78929cf8b3c72eb80..1a969f1293dd25d95d352d052cf9cf0ebf63d0e5 100644 --- a/paddle/fluid/inference/lite/op_teller.h +++ b/paddle/fluid/inference/lite/op_teller.h @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/fluid/framework/op_desc.h" namespace paddle { diff --git a/paddle/fluid/inference/lite/tensor_utils.cc b/paddle/fluid/inference/lite/tensor_utils.cc index eeaa128290339ce8c2ac6961c575d64abaa3c1db..f70455f18ebfdbda5b86022676aefaf848653a95 100644 --- a/paddle/fluid/inference/lite/tensor_utils.cc +++ b/paddle/fluid/inference/lite/tensor_utils.cc @@ -13,9 +13,11 @@ // limitations under the License. #include "paddle/fluid/inference/lite/tensor_utils.h" + #include #include #include + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/inference/lite/engine.h" @@ -26,9 +28,9 @@ namespace inference { namespace lite { namespace utils { -using paddle::lite_api::TargetType; -using paddle::lite_api::PrecisionType; using paddle::lite_api::DataLayoutType; +using paddle::lite_api::PrecisionType; +using paddle::lite_api::TargetType; template void SetLoD(DstLoD* dst, const SrcLoD& src) { diff --git a/paddle/fluid/inference/lite/test_engine_lite.cc b/paddle/fluid/inference/lite/test_engine_lite.cc index 85f7d3ee363a76a9291f85de9c56f04e497e8cbf..dee83f70ba2a2feea5f65ad693b23ebc93d2c344 100644 --- a/paddle/fluid/inference/lite/test_engine_lite.cc +++ b/paddle/fluid/inference/lite/test_engine_lite.cc @@ -14,14 +14,12 @@ #include -#include "paddle/fluid/inference/utils/singleton.h" - #include "paddle/fluid/framework/block_desc.h" #include "paddle/fluid/framework/op_desc.h" #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/scope.h" - #include "paddle/fluid/inference/lite/engine.h" +#include "paddle/fluid/inference/utils/singleton.h" #include "paddle/fluid/operators/lite/ut_helper.h" namespace paddle { @@ -29,9 +27,9 @@ namespace inference { namespace lite { using inference::lite::AddTensorToBlockDesc; -using paddle::inference::lite::AddFetchListToBlockDesc; using inference::lite::CreateTensor; using inference::lite::serialize_params; +using paddle::inference::lite::AddFetchListToBlockDesc; void make_fake_model(std::string* model, std::string* param) { framework::ProgramDesc program; diff --git a/paddle/fluid/inference/lite/test_tensor_utils.cc b/paddle/fluid/inference/lite/test_tensor_utils.cc index b0c7c7448a50ef11b4c457c8f4c55196ceb0d453..09a6cda62b3528874b02bafbd859f65a051fd6c3 100644 --- a/paddle/fluid/inference/lite/test_tensor_utils.cc +++ b/paddle/fluid/inference/lite/test_tensor_utils.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/inference/lite/tensor_utils.h" @@ -21,9 +22,9 @@ namespace inference { namespace lite { namespace utils { -using paddle::lite_api::TargetType; -using paddle::lite_api::PrecisionType; using paddle::lite_api::DataLayoutType; +using paddle::lite_api::PrecisionType; +using paddle::lite_api::TargetType; TEST(LiteEngineOp, GetNativePlace) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; diff --git a/paddle/fluid/inference/tensorrt/convert/activation_op.cc b/paddle/fluid/inference/tensorrt/convert/activation_op.cc index b86351e394bd1232492860ff58f4e1c57a2f2b82..2ef8ec16c76df87ebbed29ed49e3c2b667436c34 100644 --- a/paddle/fluid/inference/tensorrt/convert/activation_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/activation_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include #include "glog/logging.h" diff --git a/paddle/fluid/inference/tensorrt/convert/deformable_conv_op.cc b/paddle/fluid/inference/tensorrt/convert/deformable_conv_op.cc index 2bbe6ea3d2fa891def4acefe85e367f350b6b799..df6c601500c3b188661ef4a9a23f76ee741fc2be 100644 --- a/paddle/fluid/inference/tensorrt/convert/deformable_conv_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/deformable_conv_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" #include "paddle/fluid/inference/tensorrt/plugin/deformable_conv_op_plugin.h" diff --git a/paddle/fluid/inference/tensorrt/convert/flatten_contiguous_range_op.cc b/paddle/fluid/inference/tensorrt/convert/flatten_contiguous_range_op.cc index e08f50833ed991f162dc232818427b97fa6bcd4f..c293282b761d36e941ea4340a4727c89858edc3d 100644 --- a/paddle/fluid/inference/tensorrt/convert/flatten_contiguous_range_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/flatten_contiguous_range_op.cc @@ -50,10 +50,11 @@ class FlattenContiguousRangeOpConverter : public OpConverter { for (int i = 0, j = 0; i < dims; ++i) { if (start_axis <= i + 1 && i + 1 <= stop_axis) { int dim_i = input_dim.d[i]; - PADDLE_ENFORCE_GT(dim_i, 0, platform::errors::InvalidArgument( - "flatten_contiguous_range input dim " - "should be > 0, but got %d.", - dim_i)); + PADDLE_ENFORCE_GT(dim_i, 0, + platform::errors::InvalidArgument( + "flatten_contiguous_range input dim " + "should be > 0, but got %d.", + dim_i)); dim_prod *= dim_i; if (i + 1 == stop_axis) { flatten_dim.d[j++] = dim_prod; diff --git a/paddle/fluid/inference/tensorrt/convert/group_norm_op.cc b/paddle/fluid/inference/tensorrt/convert/group_norm_op.cc index 910a807d3626ae104384628bb4a0f28f82241f0f..2a62f9009e209cfc577f961e5460556f0ef7fc9e 100644 --- a/paddle/fluid/inference/tensorrt/convert/group_norm_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/group_norm_op.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" namespace paddle { diff --git a/paddle/fluid/inference/tensorrt/convert/io_converter.cc b/paddle/fluid/inference/tensorrt/convert/io_converter.cc index b468518fa5a3cbdfd88e6632ba43f1e86a54e912..02e9610ea1ec4de48d2256c8a29f71e922b091ae 100644 --- a/paddle/fluid/inference/tensorrt/convert/io_converter.cc +++ b/paddle/fluid/inference/tensorrt/convert/io_converter.cc @@ -13,15 +13,17 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/inference/tensorrt/convert/io_converter.h" + #include + #include "paddle/fluid/platform/enforce.h" namespace paddle { namespace inference { namespace tensorrt { -using platform::is_gpu_place; using platform::is_cpu_place; +using platform::is_gpu_place; class DefaultIOConverter : public EngineIOConverter { public: @@ -49,8 +51,9 @@ class DefaultIOConverter : public EngineIOConverter { out, in.data(), size, cudaMemcpyHostToDevice, *stream_)); } else if (is_gpu_place(place)) { PADDLE_ENFORCE_EQ( - 0, cudaMemcpyAsync(out, in.data(), size, - cudaMemcpyDeviceToDevice, *stream_), + 0, + cudaMemcpyAsync(out, in.data(), size, cudaMemcpyDeviceToDevice, + *stream_), platform::errors::External( "cudaMemcpyAsync(cudaMemcpyDeviceToDevice) error.")); } else { @@ -78,14 +81,16 @@ class DefaultIOConverter : public EngineIOConverter { "But out's memory_size = %u, max_size = %u.", size, max_size)); if (is_cpu_place(place)) { - PADDLE_ENFORCE_EQ(0, cudaMemcpyAsync(out->data(), in, size, - cudaMemcpyDeviceToHost, *stream_), + PADDLE_ENFORCE_EQ(0, + cudaMemcpyAsync(out->data(), in, size, + cudaMemcpyDeviceToHost, *stream_), platform::errors::External( "cudaMemcpyAsync(cudaMemcpyDeviceToHost) error.")); } else if (is_gpu_place(place)) { PADDLE_ENFORCE_EQ( - 0, cudaMemcpyAsync(out->data(), in, size, - cudaMemcpyDeviceToDevice, *stream_), + 0, + cudaMemcpyAsync(out->data(), in, size, + cudaMemcpyDeviceToDevice, *stream_), platform::errors::External( "cudaMemcpyAsync(cudaMemcpyDeviceToDevice) error.")); } else { diff --git a/paddle/fluid/inference/tensorrt/convert/io_converter.h b/paddle/fluid/inference/tensorrt/convert/io_converter.h index 58c178028b8b275b57f5c298534bd1d31aede234..3ff78a6dc7a3b149dfd1e523acf1a417d8eb62b4 100644 --- a/paddle/fluid/inference/tensorrt/convert/io_converter.h +++ b/paddle/fluid/inference/tensorrt/convert/io_converter.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/inference/utils/singleton.h" diff --git a/paddle/fluid/inference/tensorrt/convert/multiclass_nms3_op.cc b/paddle/fluid/inference/tensorrt/convert/multiclass_nms3_op.cc index a968ea2a2c48408d42946e82aed34d94855295b2..ae39267533928c952253222fe2e3efca1d56b22e 100644 --- a/paddle/fluid/inference/tensorrt/convert/multiclass_nms3_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/multiclass_nms3_op.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" namespace paddle { diff --git a/paddle/fluid/inference/tensorrt/convert/multiclass_nms_op.cc b/paddle/fluid/inference/tensorrt/convert/multiclass_nms_op.cc index b0d67a5bf90ca9fcad742367a4c1a3c2c3eb0ee2..d630f7e9967a7a38f1713dab3914c88a8d3e703b 100644 --- a/paddle/fluid/inference/tensorrt/convert/multiclass_nms_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/multiclass_nms_op.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" namespace paddle { diff --git a/paddle/fluid/inference/tensorrt/convert/op_converter.h b/paddle/fluid/inference/tensorrt/convert/op_converter.h index 0a99b12edc25c0b27fbccdc2972f3f653bd2111f..077ba32ba89c1b406e3fc2813bfc4c993ac4f951 100644 --- a/paddle/fluid/inference/tensorrt/convert/op_converter.h +++ b/paddle/fluid/inference/tensorrt/convert/op_converter.h @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/block_desc.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/scope.h" @@ -268,14 +269,16 @@ class OpConverter { } } engine->DeclareInput( - input, FluidDataType2TRT( - var->Proto()->type().lod_tensor().tensor().data_type()), + input, + FluidDataType2TRT( + var->Proto()->type().lod_tensor().tensor().data_type()), Vec2TRT_Dims(input_shape, input, true)); #endif } else { engine->DeclareInput( - input, FluidDataType2TRT( - var->Proto()->type().lod_tensor().tensor().data_type()), + input, + FluidDataType2TRT( + var->Proto()->type().lod_tensor().tensor().data_type()), Vec2TRT_Dims(var_shape, input)); } } diff --git a/paddle/fluid/inference/tensorrt/convert/softmax_op.cc b/paddle/fluid/inference/tensorrt/convert/softmax_op.cc index 46e6c18bfb8e31ee3b8bd8f225ebe15443eb9efc..66acee964cdbc00bae67fe3c7d658124b9f97703 100644 --- a/paddle/fluid/inference/tensorrt/convert/softmax_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/softmax_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" namespace paddle { diff --git a/paddle/fluid/inference/tensorrt/convert/test_activation_op.cc b/paddle/fluid/inference/tensorrt/convert/test_activation_op.cc index 1ad82df41737c4093d0b5518c754ed85c505b8be..7a034f2c166ddcb4bddbd5a62fb2963d5944a79d 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_activation_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_activation_op.cc @@ -13,6 +13,7 @@ limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_batch_norm_op.cc b/paddle/fluid/inference/tensorrt/convert/test_batch_norm_op.cc index 92e34e48bdb295eca9e8ce7a86a7d7435a37bab7..caa9e9ee2898d060de5ffb2b1165ace6ec5c611a 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_batch_norm_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_batch_norm_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_concat_op.cc b/paddle/fluid/inference/tensorrt/convert/test_concat_op.cc index 6c876964297f94db27b0d683571f99f0605a68f3..b1319312adfe095a4773c7950539c9e1dc9c5819 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_concat_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_concat_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_conv2d_op.cc b/paddle/fluid/inference/tensorrt/convert/test_conv2d_op.cc index a856d1414446914909a1801d4175431896ee8de1..0b9f4a5fd84dbe048649fd2845101450f9fde5c8 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_conv2d_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_conv2d_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_dropout_op.cc b/paddle/fluid/inference/tensorrt/convert/test_dropout_op.cc index cf377396087637f115523ddc60a468e2a23d57d4..2d77b9b32db2c28528928d3f08b3685d92c6cbd7 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_dropout_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_dropout_op.cc @@ -12,6 +12,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_elementwise_op.cc b/paddle/fluid/inference/tensorrt/convert/test_elementwise_op.cc index 9c6ea51fe5a356d0dfd1d551819114a6c4549c3c..5221843db19d82de7024bb16388ca533f6c8550e 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_elementwise_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_elementwise_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_fc_op.cc b/paddle/fluid/inference/tensorrt/convert/test_fc_op.cc index 8134d389469cbe7d654fd675a75a8123257339b1..4647521dd32b08caeb29185759bcd6c42273b6f0 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_fc_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_fc_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_io_converter.cc b/paddle/fluid/inference/tensorrt/convert/test_io_converter.cc index 8f91309a0a00d5131268f026c319e25ba3cb964a..a2fe32b75f3de55363ef1942ceb156f79452af4f 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_io_converter.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_io_converter.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/inference/tensorrt/convert/io_converter.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_leaky_relu_op.cc b/paddle/fluid/inference/tensorrt/convert/test_leaky_relu_op.cc index f17e00de0eeb7c8f4d782f0a4eaecc2fc1df268b..f7984dd0ab75024a9e7821411b2aeaace901719a 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_leaky_relu_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_leaky_relu_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_mish_op.cc b/paddle/fluid/inference/tensorrt/convert/test_mish_op.cc index c84c30255fa962cf466dadf33c6b32ea953c8362..d2dbb7fb5920c91aac4a371c67018a8bb1bc8915 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_mish_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_mish_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_mul_op.cc b/paddle/fluid/inference/tensorrt/convert/test_mul_op.cc index 86cb7543d42da65cc9f82cd13b06610fe532c164..35b8fe1ee6ad7c28551c4196ab4722f6b99bc0b5 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_mul_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_mul_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_nearest_interp_v2_op.cc b/paddle/fluid/inference/tensorrt/convert/test_nearest_interp_v2_op.cc index f5ab6a992493140736b5051e7a50ddfc271e2a9f..96b14c4e40cb0d55d4b32696ccb64e3f5247d5c3 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_nearest_interp_v2_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_nearest_interp_v2_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_op_converter.cc b/paddle/fluid/inference/tensorrt/convert/test_op_converter.cc index 9bfae64fe80e332d8dd010a5c8427aead2126581..9a4d4db3435a26d1b51ebb26ae9657d064395b0b 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_op_converter.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_op_converter.cc @@ -12,11 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/inference/tensorrt/convert/op_converter.h" - #include // NOLINT #include "paddle/fluid/framework/program_desc.h" +#include "paddle/fluid/inference/tensorrt/convert/op_converter.h" namespace paddle { namespace inference { diff --git a/paddle/fluid/inference/tensorrt/convert/test_pad_op.cc b/paddle/fluid/inference/tensorrt/convert/test_pad_op.cc index ba35d7ddbb2f4e6062713bd82be277e7ad0cb341..a8e36f827d8e30bea505cfa5ac71994133e4b241 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_pad_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_pad_op.cc @@ -13,6 +13,7 @@ limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_pool2d_op.cc b/paddle/fluid/inference/tensorrt/convert/test_pool2d_op.cc index 36f13262a73d703a6d9776855adbab3c44075aa7..b917aa865d28f61105e2c237ac2089d6cdcd2ce6 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_pool2d_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_pool2d_op.cc @@ -12,7 +12,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_prelu_op.cc b/paddle/fluid/inference/tensorrt/convert/test_prelu_op.cc index f2541ff7c0b5e5a49b78a700f1fccfed377e4acc..d71cf051972d168550f8a3f919a19ac3e6330d45 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_prelu_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_prelu_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_shuffle_channel_op.cc b/paddle/fluid/inference/tensorrt/convert/test_shuffle_channel_op.cc index 3ebb51afdf44f488d5acb7481be0ce6714324454..b5e640ea244122fffc869f0351e6180b96258ecb 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_shuffle_channel_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_shuffle_channel_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_softmax_op.cc b/paddle/fluid/inference/tensorrt/convert/test_softmax_op.cc index 9cd5e81141598dda6ead275457c53feeb84c5fb8..babe682ab4e48247f098935debaa5126aa2050e3 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_softmax_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_softmax_op.cc @@ -12,6 +12,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_split_op.cc b/paddle/fluid/inference/tensorrt/convert/test_split_op.cc index 3b6a4a80044eb6853e3e689b9d2f71317a7d7839..1d23aeedc5a8d77ee29ecdc76e7e77ea109c2f27 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_split_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_split_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/test_swish_op.cc b/paddle/fluid/inference/tensorrt/convert/test_swish_op.cc index 7a5a886affed33bdb35b741889f7a2635576543a..94ca6f0ed4627a203bbe2de52d4a09b790c24343 100644 --- a/paddle/fluid/inference/tensorrt/convert/test_swish_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/test_swish_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" #include "paddle/fluid/inference/tensorrt/convert/ut_helper.h" diff --git a/paddle/fluid/inference/tensorrt/convert/unary_op.cc b/paddle/fluid/inference/tensorrt/convert/unary_op.cc index aa3d38ebe20736ba7b05e76859ef9afafa1c14df..72d5cb2aeb4d3c07d4a4057230931ffa02337abb 100644 --- a/paddle/fluid/inference/tensorrt/convert/unary_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/unary_op.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include + #include "glog/logging.h" #include "paddle/fluid/framework/op_desc.h" #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" diff --git a/paddle/fluid/inference/tensorrt/convert/yolo_box_op.cc b/paddle/fluid/inference/tensorrt/convert/yolo_box_op.cc index 17d217dff43fdb581a5df36c46fb9c1b292066a0..f5ab63daa88df61a9f28bbcb9b515c5ab2f35c34 100644 --- a/paddle/fluid/inference/tensorrt/convert/yolo_box_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/yolo_box_op.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/convert/op_converter.h" #include "paddle/fluid/inference/tensorrt/plugin/yolo_box_op_plugin.h" diff --git a/paddle/fluid/inference/tensorrt/engine.cc b/paddle/fluid/inference/tensorrt/engine.cc index 00a6b2ffbf92307dc9ee877b3fbc64b0142ecb9c..7f308fd3a04d5e33f93ea15380655f712763548a 100644 --- a/paddle/fluid/inference/tensorrt/engine.cc +++ b/paddle/fluid/inference/tensorrt/engine.cc @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include #include "cuda_runtime_api.h" // NOLINT diff --git a/paddle/fluid/inference/tensorrt/engine.h b/paddle/fluid/inference/tensorrt/engine.h index 598d751ad5f3628ac161adb45af652a2a35341a3..b28fe827156c3f0cdf624b9079cac9ce2f374c9f 100644 --- a/paddle/fluid/inference/tensorrt/engine.h +++ b/paddle/fluid/inference/tensorrt/engine.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include #include #include // NOLINT @@ -151,7 +152,7 @@ nvinfer1::Dims Vec2TRT_Dims(const std::vector& shape, std::string input, return dims; } } -} // NOLINT +} // namespace class TRTInt8Calibrator; diff --git a/paddle/fluid/inference/tensorrt/helper.h b/paddle/fluid/inference/tensorrt/helper.h index b8051d8610442f4d672cb6488a52ce26ed79163b..e283000cdace59222e818d45fbe21c0e74a47e57 100644 --- a/paddle/fluid/inference/tensorrt/helper.h +++ b/paddle/fluid/inference/tensorrt/helper.h @@ -17,9 +17,11 @@ #include #include #include + #include #include #include + #include "paddle/fluid/platform/dynload/tensorrt.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/inference/tensorrt/op_teller.cc b/paddle/fluid/inference/tensorrt/op_teller.cc index 79a5e7d7a6a133b5b259108a3c71f75f0c4e4927..dc7c77bc66acf5544c7a4a31112a2b284d8e3259 100644 --- a/paddle/fluid/inference/tensorrt/op_teller.cc +++ b/paddle/fluid/inference/tensorrt/op_teller.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/inference/tensorrt/op_teller.h" + #include + #include "paddle/fluid/framework/block_desc.h" #include "paddle/fluid/framework/data_layout.h" diff --git a/paddle/fluid/inference/tensorrt/op_teller.h b/paddle/fluid/inference/tensorrt/op_teller.h index 0a0cbeae51b021430301fb03528031b18ff7b31d..40f1a0055c78b933b8462404cf3a5dd7f53f55d6 100644 --- a/paddle/fluid/inference/tensorrt/op_teller.h +++ b/paddle/fluid/inference/tensorrt/op_teller.h @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/fluid/framework/ir/node.h" #include "paddle/fluid/framework/op_desc.h" #include "paddle/fluid/inference/tensorrt/engine.h" diff --git a/paddle/fluid/inference/tensorrt/plugin/anchor_generator_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/anchor_generator_op_plugin.cu index e5584f26580679ff0d472ecc31a2444557931ff7..a339f880ac388358e7e558a89f23319a3de01d1e 100644 --- a/paddle/fluid/inference/tensorrt/plugin/anchor_generator_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/anchor_generator_op_plugin.cu @@ -14,6 +14,7 @@ #include #include + #include #include diff --git a/paddle/fluid/inference/tensorrt/plugin/deformable_conv_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/deformable_conv_op_plugin.cu index 6128f8f0e4134cb11669d5400858b9a0325025e8..7ea664ded66f28a0345b9ec34603b3088ef27efd 100644 --- a/paddle/fluid/inference/tensorrt/plugin/deformable_conv_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/deformable_conv_op_plugin.cu @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include #include @@ -88,9 +89,10 @@ DeformableConvPlugin::DeformableConvPlugin( dilations_.insert(dilations_.end(), dilations.cbegin(), dilations.cend()); PADDLE_ENFORCE_EQ(data_type_ == nvinfer1::DataType::kFLOAT || data_type_ == nvinfer1::DataType::kHALF, - true, platform::errors::InvalidArgument( - "The DeformableConv TRT Plugin's input type " - "should be float or half.")); + true, + platform::errors::InvalidArgument( + "The DeformableConv TRT Plugin's input type " + "should be float or half.")); PADDLE_ENFORCE_EQ( paddings_.size(), strides_.size(), platform::errors::InvalidArgument( @@ -124,9 +126,10 @@ DeformableConvPlugin::DeformableConvPlugin( output_dim_.insert(output_dim_.end(), output_dim.cbegin(), output_dim.cend()); PADDLE_ENFORCE_EQ(data_type_ == nvinfer1::DataType::kFLOAT || data_type_ == nvinfer1::DataType::kHALF, - true, platform::errors::InvalidArgument( - "The DeformableConv TRT Plugin's input type " - "should be float or half.")); + true, + platform::errors::InvalidArgument( + "The DeformableConv TRT Plugin's input type " + "should be float or half.")); PADDLE_ENFORCE_EQ( paddings_.size(), strides_.size(), platform::errors::InvalidArgument( @@ -363,13 +366,11 @@ __global__ void ModulatedDeformableIm2colGpuKernel( const float* data_im_ptr = data_im + (b_col * num_channels + c_im) * height * width; const float* data_offset_ptr = - data_offset + - (b_col * deformable_group + deformable_group_index) * 2 * kernel_h * - kernel_w * height_col * width_col; + data_offset + (b_col * deformable_group + deformable_group_index) * 2 * + kernel_h * kernel_w * height_col * width_col; const float* data_mask_ptr = - data_mask + - (b_col * deformable_group + deformable_group_index) * kernel_h * - kernel_w * height_col * width_col; + data_mask + (b_col * deformable_group + deformable_group_index) * + kernel_h * kernel_w * height_col * width_col; for (int i = 0; i < kernel_h; ++i) { for (int j = 0; j < kernel_w; ++j) { @@ -432,13 +433,11 @@ __global__ void ModulatedDeformableIm2colGpuKernel( const half* data_im_ptr = data_im + (b_col * num_channels + c_im) * height * width; const half* data_offset_ptr = - data_offset + - (b_col * deformable_group + deformable_group_index) * 2 * kernel_h * - kernel_w * height_col * width_col; + data_offset + (b_col * deformable_group + deformable_group_index) * 2 * + kernel_h * kernel_w * height_col * width_col; const half* data_mask_ptr = - data_mask + - (b_col * deformable_group + deformable_group_index) * kernel_h * - kernel_w * height_col * width_col; + data_mask + (b_col * deformable_group + deformable_group_index) * + kernel_h * kernel_w * height_col * width_col; for (int i = 0; i < kernel_h; ++i) { for (int j = 0; j < kernel_w; ++j) { diff --git a/paddle/fluid/inference/tensorrt/plugin/elementwise_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/elementwise_op_plugin.cu index 1070a88cee7372cdbe6bcbef83681c624b7470a2..5f4abee2838f711ae56f03ea6fb0a9fa50255712 100644 --- a/paddle/fluid/inference/tensorrt/plugin/elementwise_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/elementwise_op_plugin.cu @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/plugin/elementwise_op_plugin.h" namespace paddle { @@ -67,14 +68,16 @@ __global__ void elementwise_kernel(const size_t total, const T *x_data, nvinfer1::Dims ElementWisePlugin::getOutputDimensions( int index, const nvinfer1::Dims *input_dims, int num_inputs) TRT_NOEXCEPT { - PADDLE_ENFORCE_EQ(index, 0, platform::errors::InvalidArgument( - "There is only one output in TRT elementwise " - "op plugin, but got output index: %d.", - index)); - PADDLE_ENFORCE_EQ(num_inputs, 2, platform::errors::InvalidArgument( - "There are 2 inputs in TRT elementwise " - "op plugin, but got input number: %d.", - num_inputs)); + PADDLE_ENFORCE_EQ(index, 0, + platform::errors::InvalidArgument( + "There is only one output in TRT elementwise " + "op plugin, but got output index: %d.", + index)); + PADDLE_ENFORCE_EQ( + num_inputs, 2, + platform::errors::InvalidArgument("There are 2 inputs in TRT elementwise " + "op plugin, but got input number: %d.", + num_inputs)); PADDLE_ENFORCE_NOT_NULL( input_dims, platform::errors::InvalidArgument( diff --git a/paddle/fluid/inference/tensorrt/plugin/elementwise_op_plugin.h b/paddle/fluid/inference/tensorrt/plugin/elementwise_op_plugin.h index aa1ab5389a5720e457f46486263b262c10818c05..51fc1bebd90be8a2949e6b6215b8a717ce48bca9 100644 --- a/paddle/fluid/inference/tensorrt/plugin/elementwise_op_plugin.h +++ b/paddle/fluid/inference/tensorrt/plugin/elementwise_op_plugin.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h" namespace paddle { diff --git a/paddle/fluid/inference/tensorrt/plugin/emb_eltwise_layernorm_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/emb_eltwise_layernorm_plugin.cu index 82f4420a2a04cd5593b0f330713b422b79a00ee2..6c7530cdc1f05f772f3f60b9a2bd2acbb94b9284 100644 --- a/paddle/fluid/inference/tensorrt/plugin/emb_eltwise_layernorm_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/emb_eltwise_layernorm_plugin.cu @@ -13,9 +13,11 @@ // limitations under the License. #include + #include #include // NOLINT #include + #include "glog/logging.h" #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/framework/tensor_util.h" @@ -253,10 +255,11 @@ nvinfer1::DataType EmbEltwiseLayernormPluginDynamic::getOutputDataType( int index, const nvinfer1::DataType *input_types, int nb_inputs) const TRT_NOEXCEPT { PADDLE_ENFORCE_EQ( - index, 0, platform::errors::InvalidArgument( - "The EmbEltwiseLayernorm Plugin only has one input, so the " - "index value should be 0, but get %d.", - index)); + index, 0, + platform::errors::InvalidArgument( + "The EmbEltwiseLayernorm Plugin only has one input, so the " + "index value should be 0, but get %d.", + index)); if (with_fp16_) return nvinfer1::DataType::kHALF; else diff --git a/paddle/fluid/inference/tensorrt/plugin/gather_nd_op_plugin.h b/paddle/fluid/inference/tensorrt/plugin/gather_nd_op_plugin.h index 841fb2f6fe399fd44ac91d29a15825ec53c93b69..f27b66b03f544a763233c8f7c8456b341c0ecdd2 100644 --- a/paddle/fluid/inference/tensorrt/plugin/gather_nd_op_plugin.h +++ b/paddle/fluid/inference/tensorrt/plugin/gather_nd_op_plugin.h @@ -15,9 +15,11 @@ #pragma once #include + #include #include #include + #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h" diff --git a/paddle/fluid/inference/tensorrt/plugin/gelu_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/gelu_op_plugin.cu index 08b259e0f952e1b41c3256960f6185eaec66204e..cba1bb04c3654b5e86ecbbd592763827c5d99ea3 100644 --- a/paddle/fluid/inference/tensorrt/plugin/gelu_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/gelu_op_plugin.cu @@ -15,6 +15,7 @@ #include #include #include + #include "paddle/fluid/inference/tensorrt/plugin/gelu_op_plugin.h" #include "paddle/fluid/platform/float16.h" @@ -112,15 +113,15 @@ int GeluPlugin::enqueue(int batch_size, const void* const* inputs, VLOG(1) << "TRT Plugin DataType selected. Gelu-->fp32"; const float* input = static_cast(inputs[0]); float* output = static_cast(outputs[0]); - gelu_kernel<<>>( - kA, num, input, output); + gelu_kernel + <<>>(kA, num, input, output); } else if (type == nvinfer1::DataType::kHALF) { VLOG(1) << "TRT Plugin DataType selected. Gelu-->fp16"; const half* input = static_cast(inputs[0]); half* output = static_cast(outputs[0]); - no_exact_gelu_kernel<<>>( - kAT, kBT, kCT, num, input, output); + no_exact_gelu_kernel + <<>>(kAT, kBT, kCT, num, input, + output); } else { PADDLE_THROW(platform::errors::InvalidArgument( "The Gelu TRT Plugin's input type should be float or half.")); @@ -170,10 +171,11 @@ bool GeluPluginDynamic::supportsFormatCombination( nvinfer1::DataType GeluPluginDynamic::getOutputDataType( int index, const nvinfer1::DataType* input_types, int nb_inputs) const TRT_NOEXCEPT { - PADDLE_ENFORCE_EQ(index, 0, platform::errors::InvalidArgument( - "The Gelu Plugin only has one input, so the " - "index value should be 0, but get %d.", - index)); + PADDLE_ENFORCE_EQ(index, 0, + platform::errors::InvalidArgument( + "The Gelu Plugin only has one input, so the " + "index value should be 0, but get %d.", + index)); return input_types[0]; } @@ -192,15 +194,15 @@ int GeluPluginDynamic::enqueue(const nvinfer1::PluginTensorDesc* input_desc, VLOG(1) << "TRT Plugin DataType selected. Gelu-->fp32"; const float* input = static_cast(inputs[0]); float* output = static_cast(outputs[0]); - gelu_kernel<<>>( - kA, num, input, output); + gelu_kernel + <<>>(kA, num, input, output); } else if (input_type == nvinfer1::DataType::kHALF) { VLOG(1) << "TRT Plugin DataType selected. Gelu-->fp16"; const half* input = static_cast(inputs[0]); half* output = static_cast(outputs[0]); - no_exact_gelu_kernel<<>>( - kAT, kBT, kCT, num, input, output); + no_exact_gelu_kernel + <<>>(kAT, kBT, kCT, num, input, + output); } else { PADDLE_THROW(platform::errors::InvalidArgument( "The Gelu TRT Plugin's input type should be float or half.")); diff --git a/paddle/fluid/inference/tensorrt/plugin/gelu_op_plugin.h b/paddle/fluid/inference/tensorrt/plugin/gelu_op_plugin.h index 7efdd2798b26404ea7e2eaf03baad8bf12fb2268..8436ccad78a2ce33e7bf5e47de8fc5fb452b5326 100644 --- a/paddle/fluid/inference/tensorrt/plugin/gelu_op_plugin.h +++ b/paddle/fluid/inference/tensorrt/plugin/gelu_op_plugin.h @@ -14,9 +14,11 @@ #pragma once #include + #include #include #include + #include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h" namespace paddle { diff --git a/paddle/fluid/inference/tensorrt/plugin/hard_swish_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/hard_swish_op_plugin.cu index 9872b1ff8d957230d2507f863ca84cb1f26015a2..05ed76bd3c983e4ceb8ff2067dec4037b6b87551 100644 --- a/paddle/fluid/inference/tensorrt/plugin/hard_swish_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/hard_swish_op_plugin.cu @@ -14,6 +14,7 @@ #include #include + #include "paddle/fluid/inference/tensorrt/plugin/hard_swish_op_plugin.h" namespace paddle { diff --git a/paddle/fluid/inference/tensorrt/plugin/hard_swish_op_plugin.h b/paddle/fluid/inference/tensorrt/plugin/hard_swish_op_plugin.h index 475c908c13bbf2314354ed8de8ae103431b978e1..b1e693799bd77746650653f4b7cd447a2414d801 100644 --- a/paddle/fluid/inference/tensorrt/plugin/hard_swish_op_plugin.h +++ b/paddle/fluid/inference/tensorrt/plugin/hard_swish_op_plugin.h @@ -14,9 +14,11 @@ #pragma once #include + #include #include #include + #include "paddle/fluid/inference/tensorrt/engine.h" #include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h" diff --git a/paddle/fluid/inference/tensorrt/plugin/instance_norm_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/instance_norm_op_plugin.cu index 03686aefc13701115be97cf2ed804758fe93688f..9acd688f707a39162712e149a6df3ebca4a1a131 100644 --- a/paddle/fluid/inference/tensorrt/plugin/instance_norm_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/instance_norm_op_plugin.cu @@ -13,8 +13,10 @@ // limitations under the License. #include + #include #include + #include "glog/logging.h" #include "paddle/fluid/inference/tensorrt/plugin/instance_norm_op_plugin.h" #include "paddle/fluid/platform/device/gpu/gpu_dnn.h" diff --git a/paddle/fluid/inference/tensorrt/plugin/layer_norm_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/layer_norm_op_plugin.cu index 67d44184a76d0552b667c6d5a3d9466582e33558..16e2a284d4bf2f17354d31d70ca58d290b842a07 100644 --- a/paddle/fluid/inference/tensorrt/plugin/layer_norm_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/layer_norm_op_plugin.cu @@ -13,8 +13,10 @@ // limitations under the License. #include + #include #include + #include "glog/logging.h" #include "paddle/fluid/inference/tensorrt/plugin/layer_norm_op_plugin.h" #include "paddle/phi/kernels/layer_norm_kernel.h" diff --git a/paddle/fluid/inference/tensorrt/plugin/layer_norm_op_plugin.h b/paddle/fluid/inference/tensorrt/plugin/layer_norm_op_plugin.h index 9e8ce302833731005d37f989b18d414a792549d5..42dfa2b8aa02b013075ed9b55d10f5bb2023f9f8 100644 --- a/paddle/fluid/inference/tensorrt/plugin/layer_norm_op_plugin.h +++ b/paddle/fluid/inference/tensorrt/plugin/layer_norm_op_plugin.h @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/inference/tensorrt/engine.h" diff --git a/paddle/fluid/inference/tensorrt/plugin/matmul_op_int8_plugin.h b/paddle/fluid/inference/tensorrt/plugin/matmul_op_int8_plugin.h index be8f1c418fc7faa4b72f9f0a0a076ac69376996e..9ca6ff29240d40f9bb337d790e830b2810b16450 100644 --- a/paddle/fluid/inference/tensorrt/plugin/matmul_op_int8_plugin.h +++ b/paddle/fluid/inference/tensorrt/plugin/matmul_op_int8_plugin.h @@ -14,9 +14,9 @@ limitations under the License. */ #pragma once #include - #include #include + #include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h" #include "paddle/fluid/platform/dynload/cublasLt.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/inference/tensorrt/plugin/mish_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/mish_op_plugin.cu index 6e268e7b0b330de6d4f67cb99c872fe60dfb9e5f..f655d23e62810465e8d34b77c799a13262ee834c 100644 --- a/paddle/fluid/inference/tensorrt/plugin/mish_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/mish_op_plugin.cu @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "glog/logging.h" #include "paddle/fluid/inference/tensorrt/plugin/mish_op_plugin.h" @@ -38,11 +39,12 @@ bool MishPlugin::supportsFormat( nvinfer1::Dims MishPlugin::getOutputDimensions(int index, const nvinfer1::Dims* in_dims, int nb_inputs) TRT_NOEXCEPT { - PADDLE_ENFORCE_EQ(nb_inputs, 1, platform::errors::InvalidArgument( - "We expect [number of inputs] == 1" - "in TRT Mish op plugin, but got " - "[number of inputs] = %d.", - nb_inputs)); + PADDLE_ENFORCE_EQ( + nb_inputs, 1, + platform::errors::InvalidArgument("We expect [number of inputs] == 1" + "in TRT Mish op plugin, but got " + "[number of inputs] = %d.", + nb_inputs)); PADDLE_ENFORCE_LT(index, this->getNbOutputs(), platform::errors::InvalidArgument( "We expect [index] < [number of outputs]" @@ -123,14 +125,14 @@ int MishPlugin::enqueue(int batchSize, const void* const* inputs, VLOG(1) << "TRT Plugin DataType selected. Mish-->fp32"; const float* input = static_cast(inputs[0]); float* output = static_cast(outputs[0]); - mish_kernel<<>>(threshold_, num, - input, output); + mish_kernel + <<>>(threshold_, num, input, output); } else if (type == nvinfer1::DataType::kHALF) { VLOG(1) << "TRT Plugin DataType selected. Mish-->fp16"; const half* input = static_cast(inputs[0]); half* output = static_cast(outputs[0]); - mish_kernel<<>>(threshold_, num, - input, output); + mish_kernel + <<>>(threshold_, num, input, output); } else { PADDLE_THROW(platform::errors::InvalidArgument( "The Mish TRT Plugin's input type should be float or half.")); @@ -192,10 +194,11 @@ bool MishPluginDynamic::supportsFormatCombination( nvinfer1::DataType MishPluginDynamic::getOutputDataType( int index, const nvinfer1::DataType* input_types, int nb_inputs) const TRT_NOEXCEPT { - PADDLE_ENFORCE_EQ(index, 0, platform::errors::InvalidArgument( - "The Mish Plugin only has one input, so the " - "index value should be 0, but get %d.", - index)); + PADDLE_ENFORCE_EQ(index, 0, + platform::errors::InvalidArgument( + "The Mish Plugin only has one input, so the " + "index value should be 0, but get %d.", + index)); return input_types[0]; } @@ -214,14 +217,14 @@ int MishPluginDynamic::enqueue(const nvinfer1::PluginTensorDesc* input_desc, VLOG(1) << "TRT Plugin DataType selected. Mish-->fp32"; const float* input = static_cast(inputs[0]); float* output = static_cast(outputs[0]); - mish_kernel<<>>(threshold_, num, - input, output); + mish_kernel + <<>>(threshold_, num, input, output); } else if (input_type == nvinfer1::DataType::kHALF) { VLOG(1) << "TRT Plugin DataType selected. Mish-->fp16"; const half* input = static_cast(inputs[0]); half* output = static_cast(outputs[0]); - mish_kernel<<>>(threshold_, num, - input, output); + mish_kernel + <<>>(threshold_, num, input, output); } else { PADDLE_THROW(platform::errors::InvalidArgument( "The Mish TRT Plugin's input type should be float or half.")); diff --git a/paddle/fluid/inference/tensorrt/plugin/mish_op_plugin.h b/paddle/fluid/inference/tensorrt/plugin/mish_op_plugin.h index 75390666ea097feeed1a94cb42f18cab02ccf334..fdef7b93f32fd37506427d2f5e5cd170316dbb7e 100644 --- a/paddle/fluid/inference/tensorrt/plugin/mish_op_plugin.h +++ b/paddle/fluid/inference/tensorrt/plugin/mish_op_plugin.h @@ -14,8 +14,10 @@ #pragma once #include + #include #include + #include "paddle/fluid/inference/tensorrt/engine.h" #include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/inference/tensorrt/plugin/pool3d_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/pool3d_op_plugin.cu index 5596a89a083fe9ff177aa9abc769b8fa27105c1f..40cb2b88e711c5dadeb6e2d758d435b5b4ea8e27 100644 --- a/paddle/fluid/inference/tensorrt/plugin/pool3d_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/pool3d_op_plugin.cu @@ -70,10 +70,11 @@ nvinfer1::Dims Pool3DPlugin::getOutputDimensions( "The Pool3D Plugin only has one input, so the nbInputs " "value should be 1, but get %d.", nbInputs)); - PADDLE_ENFORCE_EQ(index, 0, platform::errors::InvalidArgument( - "The Pool3D Plugin only has one input, so " - "the index value should be 0, but get %d.", - index)); + PADDLE_ENFORCE_EQ(index, 0, + platform::errors::InvalidArgument( + "The Pool3D Plugin only has one input, so " + "the index value should be 0, but get %d.", + index)); PADDLE_ENFORCE_EQ(inputDims[0].nbDims, 4, platform::errors::InvalidArgument( "The Pool3D Plugin only has four Dimensions, so the " diff --git a/paddle/fluid/inference/tensorrt/plugin/pool3d_op_plugin.h b/paddle/fluid/inference/tensorrt/plugin/pool3d_op_plugin.h index 7c9a8625d70f3b003e7fbfe4c6e9352afddfc938..d54ce067e5ef3d5e1c62c2c562590a0a4999b6fc 100644 --- a/paddle/fluid/inference/tensorrt/plugin/pool3d_op_plugin.h +++ b/paddle/fluid/inference/tensorrt/plugin/pool3d_op_plugin.h @@ -14,9 +14,11 @@ #pragma once #include + #include #include #include + #include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h" namespace paddle { diff --git a/paddle/fluid/inference/tensorrt/plugin/pool_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/pool_op_plugin.cu index 9bfe98d759d8e29bc34b42fa667e5cda5f1493de..80f7e349dac4ae9199e3660cb5c926d3f421365e 100644 --- a/paddle/fluid/inference/tensorrt/plugin/pool_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/pool_op_plugin.cu @@ -240,10 +240,11 @@ bool PoolPluginDynamic::supportsFormatCombination( nvinfer1::DataType PoolPluginDynamic::getOutputDataType( int index, const nvinfer1::DataType *input_types, int nb_inputs) const TRT_NOEXCEPT { - PADDLE_ENFORCE_EQ(index, 0, platform::errors::InvalidArgument( - "The Pool Plugin only has one input, so the " - "index value should be 0, but get %d.", - index)); + PADDLE_ENFORCE_EQ(index, 0, + platform::errors::InvalidArgument( + "The Pool Plugin only has one input, so the " + "index value should be 0, but get %d.", + index)); PADDLE_ENFORCE_EQ((input_types[0] == nvinfer1::DataType::kFLOAT), true, platform::errors::InvalidArgument( "The input type should be half or float")); diff --git a/paddle/fluid/inference/tensorrt/plugin/pool_op_plugin.h b/paddle/fluid/inference/tensorrt/plugin/pool_op_plugin.h index d1bf2cd02e84f3cff3f61702160fcfa7e53f023f..155d69cc45784d8775e1d64c50be36b9a9de4b26 100644 --- a/paddle/fluid/inference/tensorrt/plugin/pool_op_plugin.h +++ b/paddle/fluid/inference/tensorrt/plugin/pool_op_plugin.h @@ -14,9 +14,11 @@ #pragma once #include + #include #include #include + #include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h" namespace paddle { diff --git a/paddle/fluid/inference/tensorrt/plugin/prelu_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/prelu_op_plugin.cu index 1ea2b8b5f6ec4b6444b054f23e373f460a3db7e4..72c1d546e9a2e83ee32d314677667266c08f5378 100644 --- a/paddle/fluid/inference/tensorrt/plugin/prelu_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/prelu_op_plugin.cu @@ -144,10 +144,11 @@ bool PReluPluginDynamic::supportsFormatCombination( nvinfer1::DataType PReluPluginDynamic::getOutputDataType( int index, const nvinfer1::DataType *input_types, int nb_inputs) const TRT_NOEXCEPT { - PADDLE_ENFORCE_EQ(index, 0, platform::errors::InvalidArgument( - "The PRelu Plugin only has one input, so the " - "index value should be 0, but get %d.", - index)); + PADDLE_ENFORCE_EQ(index, 0, + platform::errors::InvalidArgument( + "The PRelu Plugin only has one input, so the " + "index value should be 0, but get %d.", + index)); PADDLE_ENFORCE_EQ((input_types[0] == nvinfer1::DataType::kFLOAT), true, platform::errors::InvalidArgument( "The input type should be half or float")); diff --git a/paddle/fluid/inference/tensorrt/plugin/prelu_op_plugin.h b/paddle/fluid/inference/tensorrt/plugin/prelu_op_plugin.h index e0a77de6f5491109ca1ea1bc7c6a6fa39c2e94b2..0025e1ee5b4366b610b8a97e685524533f2af14d 100644 --- a/paddle/fluid/inference/tensorrt/plugin/prelu_op_plugin.h +++ b/paddle/fluid/inference/tensorrt/plugin/prelu_op_plugin.h @@ -17,9 +17,9 @@ #include #include #include + #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/framework/tensor_util.h" - #include "paddle/fluid/inference/tensorrt/engine.h" #include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h" diff --git a/paddle/fluid/inference/tensorrt/plugin/qkv_to_context_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/qkv_to_context_plugin.cu index e2f1aab9b6460de6a3502c2837b648eaa7c9d606..d3da5d7225d3375dc172e8f659974edb516d9b8c 100644 --- a/paddle/fluid/inference/tensorrt/plugin/qkv_to_context_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/qkv_to_context_plugin.cu @@ -13,9 +13,11 @@ // limitations under the License. #include + #include #include // NOLINT #include + #include "glog/logging.h" #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/framework/tensor_util.h" @@ -103,8 +105,8 @@ inline void TransposeQKV(const int batch, const int seq_len, platform::errors::InvalidArgument( "head_num (%d) * head_size (%d) should <= %d", head_num, head_size, 1024)); - TransposeQkvKernel<<>>(head_size, input, - output); + TransposeQkvKernel + <<>>(head_size, input, output); } } @@ -142,8 +144,8 @@ inline void TransposeQKV(const int batch, const int seq_len, platform::errors::InvalidArgument( "head_num (%d) * head_size (%d) should <= %d", head_num, head_size, 1024)); - TransposeQkvKernel<<>>(head_size, input, - output); + TransposeQkvKernel + <<>>(head_size, input, output); } } @@ -218,10 +220,11 @@ nvinfer1::DataType QkvToContextPluginDynamic::getOutputDataType( int index, const nvinfer1::DataType *input_types, int nb_inputs) const TRT_NOEXCEPT { PADDLE_ENFORCE_EQ( - index, 0, platform::errors::InvalidArgument( - "The EmbEltwiseLayernorm Plugin only has one input, so the " - "index value should be 0, but get %d.", - index)); + index, 0, + platform::errors::InvalidArgument( + "The EmbEltwiseLayernorm Plugin only has one input, so the " + "index value should be 0, but get %d.", + index)); return input_types[0]; } diff --git a/paddle/fluid/inference/tensorrt/plugin/recover_padding_plugin.h b/paddle/fluid/inference/tensorrt/plugin/recover_padding_plugin.h index 896cd05eef10a6d2e273d36f8680b077906a3183..71b576610e25c370294af3a366b60d99e475200c 100644 --- a/paddle/fluid/inference/tensorrt/plugin/recover_padding_plugin.h +++ b/paddle/fluid/inference/tensorrt/plugin/recover_padding_plugin.h @@ -14,8 +14,8 @@ limitations under the License. */ #pragma once #include - #include + #include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/inference/tensorrt/plugin/remove_padding_plugin.h b/paddle/fluid/inference/tensorrt/plugin/remove_padding_plugin.h index 6679f2f081968fd7cc3ddf10788820e827e0ee26..89fda3dd775c16c537ace65a8b5f3a21c8e96031 100644 --- a/paddle/fluid/inference/tensorrt/plugin/remove_padding_plugin.h +++ b/paddle/fluid/inference/tensorrt/plugin/remove_padding_plugin.h @@ -14,8 +14,8 @@ limitations under the License. */ #pragma once #include - #include + #include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/inference/tensorrt/plugin/roi_align_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/roi_align_op_plugin.cu index 7dc31fb44719a84298f89dd480b1c1b1b1f9cec2..7eded9e823e2edf64b8ab7a7eec316eb5cb0635c 100644 --- a/paddle/fluid/inference/tensorrt/plugin/roi_align_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/roi_align_op_plugin.cu @@ -14,6 +14,7 @@ #include #include + #include #include "paddle/fluid/inference/tensorrt/plugin/roi_align_op_plugin.h" @@ -281,13 +282,12 @@ int RoiAlignPluginDynamic::enqueue_impl( width, pooled_height_, pooled_width_, sampling_ratio_, rois_num / batch, aligned_, static_cast(outputs[0])); } else { - GPUROIAlignOpt< - T, OutT, - false><<>>( - output_size, static_cast(inputs[0]), - static_cast(inputs[1]), spatial_scale_, channels, height, - width, pooled_height_, pooled_width_, sampling_ratio_, rois_num / batch, - aligned_, static_cast(outputs[0])); + GPUROIAlignOpt + <<>>( + output_size, static_cast(inputs[0]), + static_cast(inputs[1]), spatial_scale_, channels, height, + width, pooled_height_, pooled_width_, sampling_ratio_, + rois_num / batch, aligned_, static_cast(outputs[0])); } return cudaGetLastError() != cudaSuccess; diff --git a/paddle/fluid/inference/tensorrt/plugin/skip_layernorm_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/skip_layernorm_op_plugin.cu index fb14749f3d1dba991ef6a0eac1459413a7d363b1..e1527f85088adfd843a89df0d92af9e86da03513 100644 --- a/paddle/fluid/inference/tensorrt/plugin/skip_layernorm_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/skip_layernorm_op_plugin.cu @@ -14,9 +14,11 @@ #include #include + #include #include // NOLINT #include + #include "glog/logging.h" #include "paddle/fluid/inference/tensorrt/plugin/skip_layernorm_op_plugin.h" #include "paddle/fluid/operators/math/bert_encoder_functor.h" @@ -105,8 +107,9 @@ nvinfer1::DataType SkipLayerNormPluginDynamic::getOutputDataType( index)); PADDLE_ENFORCE_EQ((input_types[0] == nvinfer1::DataType::kFLOAT || input_types[0] == nvinfer1::DataType::kHALF), - true, platform::errors::InvalidArgument( - "The input type should be half or float")); + true, + platform::errors::InvalidArgument( + "The input type should be half or float")); return input_types[0]; } diff --git a/paddle/fluid/inference/tensorrt/plugin/slice_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/slice_op_plugin.cu index 0a6d24f90722ee271800bd7fdd48589965568d5c..ad426204d5aa18921d037a912fdf756edc361949 100644 --- a/paddle/fluid/inference/tensorrt/plugin/slice_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/slice_op_plugin.cu @@ -14,9 +14,11 @@ #include #include + #include #include // NOLINT #include + #include "glog/logging.h" #include "paddle/fluid/inference/tensorrt/plugin/slice_op_plugin.h" @@ -301,14 +303,16 @@ bool SlicePluginDynamic::supportsFormatCombination( nvinfer1::DataType SlicePluginDynamic::getOutputDataType( int index, const nvinfer1::DataType *input_types, int nb_inputs) const TRT_NOEXCEPT { - PADDLE_ENFORCE_EQ(index, 0, platform::errors::InvalidArgument( - "The Slice Plugin only has one input, so the " - "index value should be 0, but get %d.", - index)); + PADDLE_ENFORCE_EQ(index, 0, + platform::errors::InvalidArgument( + "The Slice Plugin only has one input, so the " + "index value should be 0, but get %d.", + index)); PADDLE_ENFORCE_EQ((input_types[0] == nvinfer1::DataType::kFLOAT || input_types[0] == nvinfer1::DataType::kHALF), - true, platform::errors::InvalidArgument( - "The input type should be half or float")); + true, + platform::errors::InvalidArgument( + "The input type should be half or float")); return input_types[0]; } diff --git a/paddle/fluid/inference/tensorrt/plugin/split_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/split_op_plugin.cu index ec4fcca6d74d0c5157e993a0be6b30640eb0b324..1cfc9fade7b152033d895e41f3056fae20939b35 100644 --- a/paddle/fluid/inference/tensorrt/plugin/split_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/split_op_plugin.cu @@ -13,7 +13,9 @@ // limitations under the License. #include + #include + #include "paddle/fluid/inference/tensorrt/plugin/split_op_plugin.h" namespace paddle { diff --git a/paddle/fluid/inference/tensorrt/plugin/split_op_plugin.h b/paddle/fluid/inference/tensorrt/plugin/split_op_plugin.h index 7a41fe1d1eef2367aede87c578746ffc970f0e31..49f028493ee87f02d994768c061a72fed3796c36 100644 --- a/paddle/fluid/inference/tensorrt/plugin/split_op_plugin.h +++ b/paddle/fluid/inference/tensorrt/plugin/split_op_plugin.h @@ -15,9 +15,11 @@ #pragma once #include + #include #include #include + #include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h" namespace paddle { diff --git a/paddle/fluid/inference/tensorrt/plugin/stack_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/stack_op_plugin.cu index 74a6c3cdf3e4e7abf78f1c15631056ee701f1f2f..1c6dae78b387dd63e58c089d1e36428598962cd1 100644 --- a/paddle/fluid/inference/tensorrt/plugin/stack_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/stack_op_plugin.cu @@ -15,6 +15,7 @@ #include #include #include + #include "paddle/fluid/inference/tensorrt/plugin/stack_op_plugin.h" namespace paddle { @@ -128,8 +129,9 @@ bool StackPluginDynamic::supportsFormatCombination( nvinfer1::DataType StackPluginDynamic::getOutputDataType( int index, const nvinfer1::DataType* input_types, int nb_inputs) const TRT_NOEXCEPT { - PADDLE_ENFORCE_EQ(index, 0, platform::errors::InvalidArgument( - "The index should be equal to 0")); + PADDLE_ENFORCE_EQ( + index, 0, + platform::errors::InvalidArgument("The index should be equal to 0")); return input_types[0]; } diff --git a/paddle/fluid/inference/tensorrt/plugin/stack_op_plugin.h b/paddle/fluid/inference/tensorrt/plugin/stack_op_plugin.h index 965c53e2698778b672a0d83d580023c176ebca89..12beafdadb316ab4175e415a1a8f6ba98ae0892c 100644 --- a/paddle/fluid/inference/tensorrt/plugin/stack_op_plugin.h +++ b/paddle/fluid/inference/tensorrt/plugin/stack_op_plugin.h @@ -14,9 +14,11 @@ #pragma once #include + #include #include #include + #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h" diff --git a/paddle/fluid/inference/tensorrt/plugin/swish_op_plugin.cu b/paddle/fluid/inference/tensorrt/plugin/swish_op_plugin.cu index 2c2fad74b9a2d98a0bf292593860cb47ddda9099..1992dd57d68fea672b3427f2fb9e930973d5b0ac 100644 --- a/paddle/fluid/inference/tensorrt/plugin/swish_op_plugin.cu +++ b/paddle/fluid/inference/tensorrt/plugin/swish_op_plugin.cu @@ -13,8 +13,10 @@ // limitations under the License. #include + #include #include + #include "glog/logging.h" #include "paddle/fluid/inference/tensorrt/plugin/swish_op_plugin.h" @@ -181,10 +183,11 @@ bool SwishPluginDynamic::supportsFormatCombination( nvinfer1::DataType SwishPluginDynamic::getOutputDataType( int index, const nvinfer1::DataType *input_types, int nb_inputs) const TRT_NOEXCEPT { - PADDLE_ENFORCE_EQ(index, 0, platform::errors::InvalidArgument( - "The Swish Plugin only has one input, so the " - "index value should be 0, but get %d.", - index)); + PADDLE_ENFORCE_EQ(index, 0, + platform::errors::InvalidArgument( + "The Swish Plugin only has one input, so the " + "index value should be 0, but get %d.", + index)); return input_types[0]; } @@ -203,8 +206,8 @@ int SwishPluginDynamic::enqueue(const nvinfer1::PluginTensorDesc *input_desc, VLOG(1) << "TRT Plugin DataType selected. Swish-->fp32"; const float *input = static_cast(inputs[0]); float *output = static_cast(outputs[0]); - swish_kernel<<>>(num, input, output, - beta_); + swish_kernel + <<>>(num, input, output, beta_); } else if (input_type == nvinfer1::DataType::kHALF) { VLOG(1) << "TRT Plugin DataType selected. Swish-->fp16"; const half *input = static_cast(inputs[0]); diff --git a/paddle/fluid/inference/tensorrt/plugin/test_split_plugin.cc b/paddle/fluid/inference/tensorrt/plugin/test_split_plugin.cc index 46f585e6557460c850b6419049b4dbf31d592509..9cb680da5a95d9017e1f4029d79fe23a79235b72 100644 --- a/paddle/fluid/inference/tensorrt/plugin/test_split_plugin.cc +++ b/paddle/fluid/inference/tensorrt/plugin/test_split_plugin.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/inference/tensorrt/plugin/split_op_plugin.h" namespace paddle { diff --git a/paddle/fluid/inference/tensorrt/plugin/transformer_input_convert_plugin.h b/paddle/fluid/inference/tensorrt/plugin/transformer_input_convert_plugin.h index 87dc876fa9c09e293863398d5006b94e512ebd71..92aa0c48a49ce56ea18c236d743f7d4b04d1d25f 100644 --- a/paddle/fluid/inference/tensorrt/plugin/transformer_input_convert_plugin.h +++ b/paddle/fluid/inference/tensorrt/plugin/transformer_input_convert_plugin.h @@ -14,8 +14,8 @@ limitations under the License. */ #pragma once #include - #include + #include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/inference/tensorrt/plugin/trt_plugin.h b/paddle/fluid/inference/tensorrt/plugin/trt_plugin.h index 9210cd48d078b32976cdef5f6a6379dc324de650..a1316384cd491f1ce6aa32a92cd8f11cdb88a50a 100644 --- a/paddle/fluid/inference/tensorrt/plugin/trt_plugin.h +++ b/paddle/fluid/inference/tensorrt/plugin/trt_plugin.h @@ -15,6 +15,7 @@ #pragma once #include + #include #include #include diff --git a/paddle/fluid/inference/tensorrt/plugin/trt_plugin_utils.h b/paddle/fluid/inference/tensorrt/plugin/trt_plugin_utils.h index 16751c764bd03af9bbb7cbd77dd9287c17150dd5..cf9c66f0eb3fc702e8cf63459d9425defe728690 100644 --- a/paddle/fluid/inference/tensorrt/plugin/trt_plugin_utils.h +++ b/paddle/fluid/inference/tensorrt/plugin/trt_plugin_utils.h @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/fluid/platform/enforce.h" namespace paddle { diff --git a/paddle/fluid/inference/tensorrt/plugin/yolo_box_head_op_plugin.h b/paddle/fluid/inference/tensorrt/plugin/yolo_box_head_op_plugin.h index 2094dbfc9db4b014ddd61fd33c1e6780a4f75938..7116093ae36e65cdb302c0d1371548a1e37d33ca 100644 --- a/paddle/fluid/inference/tensorrt/plugin/yolo_box_head_op_plugin.h +++ b/paddle/fluid/inference/tensorrt/plugin/yolo_box_head_op_plugin.h @@ -15,6 +15,7 @@ #pragma once #include #include + #include "paddle/fluid/inference/tensorrt/engine.h" #include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h" diff --git a/paddle/fluid/inference/tensorrt/test_tensorrt.cc b/paddle/fluid/inference/tensorrt/test_tensorrt.cc index 2f5b75c1020041f350f694bbe249da1982bca5fb..70f36ec34b7083ee5bb5cb6b5db8253c5ec91d13 100644 --- a/paddle/fluid/inference/tensorrt/test_tensorrt.cc +++ b/paddle/fluid/inference/tensorrt/test_tensorrt.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include #include #include + #include "NvInfer.h" #include "paddle/fluid/inference/tensorrt/helper.h" #include "paddle/fluid/platform/dynload/tensorrt.h" diff --git a/paddle/fluid/inference/tensorrt/trt_int8_calibrator.h b/paddle/fluid/inference/tensorrt/trt_int8_calibrator.h index c84cb45b7ecbad6318d57ee8d2bdd2b49a9157a6..35c776b9e532ce7da84f0972e6da1e0af0477b13 100644 --- a/paddle/fluid/inference/tensorrt/trt_int8_calibrator.h +++ b/paddle/fluid/inference/tensorrt/trt_int8_calibrator.h @@ -16,6 +16,7 @@ #include #include + #include #include #include // NOLINT diff --git a/paddle/fluid/inference/tests/api/analyzer_capi_exp_gpu_tester.cc b/paddle/fluid/inference/tests/api/analyzer_capi_exp_gpu_tester.cc index d11d09458e48dffab9930ce3e8be30a6b4c28966..ae838955adc02ca4c62ff46c5528f2130b59f30c 100644 --- a/paddle/fluid/inference/tests/api/analyzer_capi_exp_gpu_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_capi_exp_gpu_tester.cc @@ -15,8 +15,10 @@ limitations under the License. */ #include #include #include + #include #include + #include "paddle/fluid/inference/capi_exp/pd_inference_api.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_capi_exp_int_tester.cc b/paddle/fluid/inference/tests/api/analyzer_capi_exp_int_tester.cc index d3a15cb285772d5cc75a460c388223c8da663119..dfcf5fda4763eb0ff4457552465e5946597e20a7 100644 --- a/paddle/fluid/inference/tests/api/analyzer_capi_exp_int_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_capi_exp_int_tester.cc @@ -15,8 +15,10 @@ limitations under the License. */ #include #include #include + #include #include + #include "paddle/fluid/inference/capi_exp/pd_inference_api.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_capi_exp_ner_tester.cc b/paddle/fluid/inference/tests/api/analyzer_capi_exp_ner_tester.cc index 4369cd78dfa3746677d0916ad3a5c106da412ff0..db5406b8ef6af3fa5553eae29c4ad27fb87e178b 100644 --- a/paddle/fluid/inference/tests/api/analyzer_capi_exp_ner_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_capi_exp_ner_tester.cc @@ -15,8 +15,10 @@ #include #include #include + #include #include + #include "paddle/fluid/inference/capi_exp/pd_inference_api.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_capi_exp_pd_config_tester.cc b/paddle/fluid/inference/tests/api/analyzer_capi_exp_pd_config_tester.cc index a341ffd7a081c24500e3b061b0ce3510a2aaacbc..8b094e8a6cb9b992754e9ba2aa8f9ee4650161f1 100644 --- a/paddle/fluid/inference/tests/api/analyzer_capi_exp_pd_config_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_capi_exp_pd_config_tester.cc @@ -15,8 +15,10 @@ limitations under the License. */ #include #include #include + #include #include + #include "paddle/fluid/inference/capi_exp/pd_inference_api.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_capi_exp_pd_tensor_tester.cc b/paddle/fluid/inference/tests/api/analyzer_capi_exp_pd_tensor_tester.cc index f4017fc5a7f3408b99bb664d52192f7cb35f9144..33685e6a96060d1722be341e6f5a96c2877d7d0c 100644 --- a/paddle/fluid/inference/tests/api/analyzer_capi_exp_pd_tensor_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_capi_exp_pd_tensor_tester.cc @@ -15,11 +15,13 @@ limitations under the License. */ #include #include #include + #include #include #include #include #include + #include "paddle/fluid/inference/capi_exp/pd_inference_api.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_capi_exp_pd_threads_tester.cc b/paddle/fluid/inference/tests/api/analyzer_capi_exp_pd_threads_tester.cc index 8951c446b1f83a952abaf55767a3cea52d8f0463..f59b337d6afe55aced74af1cd369b3985a3d37cc 100644 --- a/paddle/fluid/inference/tests/api/analyzer_capi_exp_pd_threads_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_capi_exp_pd_threads_tester.cc @@ -15,11 +15,13 @@ limitations under the License. */ #include #include #include + #include #include #include #include #include + #include "paddle/fluid/inference/capi_exp/pd_inference_api.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_capi_exp_xpu_tester.cc b/paddle/fluid/inference/tests/api/analyzer_capi_exp_xpu_tester.cc index a84c19de255161653dfd021205db450ad4452985..347f0e6e2532a578b1b6f52760f66e36e56f6b79 100644 --- a/paddle/fluid/inference/tests/api/analyzer_capi_exp_xpu_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_capi_exp_xpu_tester.cc @@ -15,8 +15,10 @@ limitations under the License. */ #include #include #include + #include #include + #include "paddle/fluid/inference/capi_exp/pd_inference_api.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_capi_gpu_tester.cc b/paddle/fluid/inference/tests/api/analyzer_capi_gpu_tester.cc index c60e0a25f28c01c453276a8ef04eb79b35b7dda2..524d39854debe4e74ca8bc88351f02bd1dcb9aef 100644 --- a/paddle/fluid/inference/tests/api/analyzer_capi_gpu_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_capi_gpu_tester.cc @@ -15,8 +15,10 @@ limitations under the License. */ #include #include #include + #include #include + #include "paddle/fluid/inference/capi/paddle_c_api.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_capi_int_tester.cc b/paddle/fluid/inference/tests/api/analyzer_capi_int_tester.cc index c0c8ff083de57fb26578cfda4533e74ad52dba15..cf8582ee778e9635cbc8b888be34b9cc812add42 100644 --- a/paddle/fluid/inference/tests/api/analyzer_capi_int_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_capi_int_tester.cc @@ -15,8 +15,10 @@ limitations under the License. */ #include #include #include + #include #include + #include "paddle/fluid/inference/capi/paddle_c_api.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_capi_ner_tester.cc b/paddle/fluid/inference/tests/api/analyzer_capi_ner_tester.cc index bf0576f9f93b19221b147137b47bd0944ccf4479..b74f51af980db3fa2de769f67d8fe23d31ac4572 100644 --- a/paddle/fluid/inference/tests/api/analyzer_capi_ner_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_capi_ner_tester.cc @@ -15,8 +15,10 @@ #include #include #include + #include #include + #include "paddle/fluid/inference/capi/paddle_c_api.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_capi_pd_tensor_tester.cc b/paddle/fluid/inference/tests/api/analyzer_capi_pd_tensor_tester.cc index a9c24c4503f9f1b803c0d9fcde21199ef4089c41..d0cd55e918e659326f47178fa4f68ce36e2fb12c 100644 --- a/paddle/fluid/inference/tests/api/analyzer_capi_pd_tensor_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_capi_pd_tensor_tester.cc @@ -15,11 +15,13 @@ limitations under the License. */ #include #include #include + #include #include #include #include #include + #include "paddle/fluid/inference/capi/c_api_internal.h" #include "paddle/fluid/inference/capi/paddle_c_api.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" @@ -69,8 +71,9 @@ void PD_run() { PD_DeletePaddleTensor(input); int size; const int* out_shape = PD_GetPaddleTensorShape(out_data, &size); - PADDLE_ENFORCE_EQ(size, 2, paddle::platform::errors::InvalidArgument( - "The Output shape's size is NOT match.")); + PADDLE_ENFORCE_EQ(size, 2, + paddle::platform::errors::InvalidArgument( + "The Output shape's size is NOT match.")); std::vector ref_outshape_size({9, 6}); for (int i = 0; i < 2; ++i) { PADDLE_ENFORCE_EQ(out_shape[i], ref_outshape_size[i], diff --git a/paddle/fluid/inference/tests/api/analyzer_capi_tester.cc b/paddle/fluid/inference/tests/api/analyzer_capi_tester.cc index 0b2be0076fdb122307a4fafde808d20edec905e9..4ff3e27f420be3c175209e83e5bdfe2f830978fa 100644 --- a/paddle/fluid/inference/tests/api/analyzer_capi_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_capi_tester.cc @@ -15,8 +15,10 @@ limitations under the License. */ #include #include #include + #include #include + #include "paddle/fluid/inference/capi/paddle_c_api.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_capi_xpu_tester.cc b/paddle/fluid/inference/tests/api/analyzer_capi_xpu_tester.cc index 33a67d8140575b96c4e09edeebcda7924893b298..e6a6a8c1037a0d4d4a8ab29f67ae8708c1ed83b2 100644 --- a/paddle/fluid/inference/tests/api/analyzer_capi_xpu_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_capi_xpu_tester.cc @@ -15,8 +15,10 @@ limitations under the License. */ #include #include #include + #include #include + #include "paddle/fluid/inference/capi/paddle_c_api.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_dam_tester.cc b/paddle/fluid/inference/tests/api/analyzer_dam_tester.cc index 820bbf0701778f29b3431a93d81dfd0b5d2f408d..e3bdb98ec522b80bde7af55f206a893ae07fd88d 100644 --- a/paddle/fluid/inference/tests/api/analyzer_dam_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_dam_tester.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/inference/analysis/helper.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_detect_functional_mkldnn_tester.cc b/paddle/fluid/inference/tests/api/analyzer_detect_functional_mkldnn_tester.cc index 384bef8a4b439d8543127d5e7a1110525f06d282..c21785f7ce7a31d0f4e5568129efef9d77d9e6bd 100644 --- a/paddle/fluid/inference/tests/api/analyzer_detect_functional_mkldnn_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_detect_functional_mkldnn_tester.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include #include + #include "paddle/fluid/inference/tests/api/tester_helper.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_detect_tester.cc b/paddle/fluid/inference/tests/api/analyzer_detect_tester.cc index 5333f0052d74250204daa09117602bf8bfe2aae1..166bdc621c19835b5fb6dd7c0a834af9abc9817f 100644 --- a/paddle/fluid/inference/tests/api/analyzer_detect_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_detect_tester.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include #include + #include "paddle/fluid/inference/tests/api/tester_helper.h" DEFINE_string(infer_shape, "", "data shape file"); diff --git a/paddle/fluid/inference/tests/api/analyzer_image_classification_tester.cc b/paddle/fluid/inference/tests/api/analyzer_image_classification_tester.cc index af0a51e4ddbb4b49fbc9e7e72adc91f03279b283..cf3380d0406d0966ce818694f941313ba445e8ba 100644 --- a/paddle/fluid/inference/tests/api/analyzer_image_classification_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_image_classification_tester.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/inference/tests/api/tester_helper.h" DEFINE_bool(disable_mkldnn_fc, false, "Disable usage of MKL-DNN's FC op"); diff --git a/paddle/fluid/inference/tests/api/analyzer_int8_image_classification_tester.cc b/paddle/fluid/inference/tests/api/analyzer_int8_image_classification_tester.cc index d11b5f0c218f22e53a43959799e57e25baba941f..c6d266ceb21ebadab101a2d2010df26ed93ed405 100644 --- a/paddle/fluid/inference/tests/api/analyzer_int8_image_classification_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_int8_image_classification_tester.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/inference/api/paddle_analysis_config.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_int8_object_detection_tester.cc b/paddle/fluid/inference/tests/api/analyzer_int8_object_detection_tester.cc index 57ab1b00908b1d4974b8a4de68d013b61555f1a9..18990dba3148e1c4b324d2261c24aa6330d3bb3f 100644 --- a/paddle/fluid/inference/tests/api/analyzer_int8_object_detection_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_int8_object_detection_tester.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/inference/api/paddle_analysis_config.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_lac_tester.cc b/paddle/fluid/inference/tests/api/analyzer_lac_tester.cc index bd3a1d737afb1ba230015fbd602c493f33952ffb..2b69a15e26a8aa82f76c164881c11ccf2a7aaddf 100644 --- a/paddle/fluid/inference/tests/api/analyzer_lac_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_lac_tester.cc @@ -148,8 +148,9 @@ TEST(Analyzer_LAC, profile) { "The size of output should be equal to 1.")); size_t size = GetSize(output[0]); size_t batch1_size = sizeof(lac_ref_data) / sizeof(int64_t); - PADDLE_ENFORCE_GE(size, batch1_size, paddle::platform::errors::Fatal( - "The size of batch is invaild.")); + PADDLE_ENFORCE_GE( + size, batch1_size, + paddle::platform::errors::Fatal("The size of batch is invaild.")); int64_t *pdata = static_cast(output[0].data.data()); for (size_t i = 0; i < batch1_size; ++i) { EXPECT_EQ(pdata[i], lac_ref_data[i]); diff --git a/paddle/fluid/inference/tests/api/analyzer_lexical_analysis_gru_tester.cc b/paddle/fluid/inference/tests/api/analyzer_lexical_analysis_gru_tester.cc index 141e60513eb955e581e2d343cbbcafdb62a88ac4..7e754ad93bc3dc328a8119f9d5ca01fa41ca86d9 100644 --- a/paddle/fluid/inference/tests/api/analyzer_lexical_analysis_gru_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_lexical_analysis_gru_tester.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/inference/api/paddle_analysis_config.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" @@ -211,18 +212,15 @@ std::vector Lexical_Test( } } // nums_infer, nums_label, nums_correct - auto precision = - acc_sum[0] - ? static_cast(acc_sum[2]) / static_cast(acc_sum[0]) - : 0; - auto recall = - acc_sum[1] - ? static_cast(acc_sum[2]) / static_cast(acc_sum[1]) - : 0; - auto f1_score = - acc_sum[2] - ? static_cast(2 * precision * recall) / (precision + recall) - : 0; + auto precision = acc_sum[0] ? static_cast(acc_sum[2]) / + static_cast(acc_sum[0]) + : 0; + auto recall = acc_sum[1] ? static_cast(acc_sum[2]) / + static_cast(acc_sum[1]) + : 0; + auto f1_score = acc_sum[2] ? static_cast(2 * precision * recall) / + (precision + recall) + : 0; LOG(INFO) << "Precision: " << std::fixed << std::setw(6) << std::setprecision(5) << precision; diff --git a/paddle/fluid/inference/tests/api/analyzer_mmp_tester.cc b/paddle/fluid/inference/tests/api/analyzer_mmp_tester.cc index 4a5ec95934a9a28779d05f5780f9bcebd0985a68..43fed05db133c4a80d040aefa7c6e106f5424d6b 100644 --- a/paddle/fluid/inference/tests/api/analyzer_mmp_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_mmp_tester.cc @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + #include "paddle/fluid/framework/transfer_scope_cache.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" -#include - // Here add missing commands DEFINE_string(infer_model2, "", "model path"); DEFINE_string(infer_model3, "", "model path"); @@ -96,8 +96,9 @@ void compare(bool use_mkldnn = false) { xx_output.begin(), xx_output.end(), xx2_output.begin(), [](const float& l, const float& r) { return fabs(l - r) < 1e-4; }); - PADDLE_ENFORCE_EQ(result, true, paddle::platform::errors::Fatal( - "Results of model run independently " + PADDLE_ENFORCE_EQ( + result, true, + paddle::platform::errors::Fatal("Results of model run independently " "differs from results of the same model " "run as a sequence of models")); } diff --git a/paddle/fluid/inference/tests/api/analyzer_paddle_tensor_tester.cc b/paddle/fluid/inference/tests/api/analyzer_paddle_tensor_tester.cc index 2eb75c4dc5369abc0cec6b887283521c7535457f..2c02b87ba2be4ce961bb2bceeec550cfe5fa90f6 100644 --- a/paddle/fluid/inference/tests/api/analyzer_paddle_tensor_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_paddle_tensor_tester.cc @@ -16,9 +16,8 @@ #include "paddle/fluid/framework/op_desc.h" #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/scope.h" -#include "paddle/fluid/inference/utils/singleton.h" - #include "paddle/fluid/inference/tests/api/tester_helper.h" +#include "paddle/fluid/inference/utils/singleton.h" namespace paddle { namespace inference { diff --git a/paddle/fluid/inference/tests/api/analyzer_quant_image_classification_tester.cc b/paddle/fluid/inference/tests/api/analyzer_quant_image_classification_tester.cc index 4bb59f3c8df42563c9c47c6aba9f85a643a619fd..1618ba575a26ed33c6e4e345049cdb90516f25a8 100644 --- a/paddle/fluid/inference/tests/api/analyzer_quant_image_classification_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_quant_image_classification_tester.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/inference/api/paddle_analysis_config.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_seq_conv1_tester.cc b/paddle/fluid/inference/tests/api/analyzer_seq_conv1_tester.cc index 978aaf1c6a32d5b4ec8f2d06b8873af892705da5..883d946dff54e1e7baf83f9dadb67482b1f66d46 100644 --- a/paddle/fluid/inference/tests/api/analyzer_seq_conv1_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_seq_conv1_tester.cc @@ -47,8 +47,9 @@ struct DataRecord { num_lines++; std::vector data; split(line, '\t', &data); - PADDLE_ENFORCE_GT(data.size(), 4, paddle::platform::errors::Fatal( - "The size of data is invaild.")); + PADDLE_ENFORCE_GT( + data.size(), 4, + paddle::platform::errors::Fatal("The size of data is invaild.")); // load title1 data std::vector title1_data; split_to_int64(data[0], ' ', &title1_data); diff --git a/paddle/fluid/inference/tests/api/analyzer_seq_pool1_compare_determine_tester.cc b/paddle/fluid/inference/tests/api/analyzer_seq_pool1_compare_determine_tester.cc index 8f0778b83e52e93b1b30c06cf2bd950bdb62f3b8..1ef5e81e18a38c973803ce99cbb94529c46929c7 100644 --- a/paddle/fluid/inference/tests/api/analyzer_seq_pool1_compare_determine_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_seq_pool1_compare_determine_tester.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/inference/tests/api/analyzer_seq_pool1_tester_helper.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_seq_pool1_compare_tester.cc b/paddle/fluid/inference/tests/api/analyzer_seq_pool1_compare_tester.cc index 099ff1f31a759a694ff81aa98b961f935f0d2109..5a78d36276cb92a86c237aed0f7e091f48ab69ed 100644 --- a/paddle/fluid/inference/tests/api/analyzer_seq_pool1_compare_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_seq_pool1_compare_tester.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/inference/tests/api/analyzer_seq_pool1_tester_helper.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_seq_pool1_fuse_compare_zero_copy_tester.cc b/paddle/fluid/inference/tests/api/analyzer_seq_pool1_fuse_compare_zero_copy_tester.cc index 1fbcbf1a3f4275ae7973ca33f85d886c40bb1da4..30cea4f69bdd0d0ee0460a422a6628ed5e03b9a9 100644 --- a/paddle/fluid/inference/tests/api/analyzer_seq_pool1_fuse_compare_zero_copy_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_seq_pool1_fuse_compare_zero_copy_tester.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/inference/tests/api/analyzer_seq_pool1_tester_helper.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_seq_pool1_fuse_statis_tester.cc b/paddle/fluid/inference/tests/api/analyzer_seq_pool1_fuse_statis_tester.cc index d33b11c389a095bf2b67fcfaba58df1e1069cada..15f4b3a3a5bf07b22b36f5bd5bb49717299a4291 100644 --- a/paddle/fluid/inference/tests/api/analyzer_seq_pool1_fuse_statis_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_seq_pool1_fuse_statis_tester.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/inference/tests/api/analyzer_seq_pool1_tester_helper.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_seq_pool1_profile_tester.cc b/paddle/fluid/inference/tests/api/analyzer_seq_pool1_profile_tester.cc index 0ccd95f2a176de5b822eba98be7f53d779927e9f..063d29abee9a2d2371efaec33b45c26f18b54790 100644 --- a/paddle/fluid/inference/tests/api/analyzer_seq_pool1_profile_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_seq_pool1_profile_tester.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/inference/tests/api/analyzer_seq_pool1_tester_helper.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" diff --git a/paddle/fluid/inference/tests/api/analyzer_seq_pool1_tester_helper.h b/paddle/fluid/inference/tests/api/analyzer_seq_pool1_tester_helper.h index 5d7f7c290f6a2f25af4ea95ebae7177c5ee2a27c..ef00c0209738e3f364211822cd75d2b6ffb26133 100644 --- a/paddle/fluid/inference/tests/api/analyzer_seq_pool1_tester_helper.h +++ b/paddle/fluid/inference/tests/api/analyzer_seq_pool1_tester_helper.h @@ -19,6 +19,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/inference/tests/api/tester_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/analyzer_transformer_tester_helper.h b/paddle/fluid/inference/tests/api/analyzer_transformer_tester_helper.h index e43456ed8322e759e1e7f56c11621d696b8efb82..a384c75e0bb4581eedcec92ce99cb2cb99cbbd10 100644 --- a/paddle/fluid/inference/tests/api/analyzer_transformer_tester_helper.h +++ b/paddle/fluid/inference/tests/api/analyzer_transformer_tester_helper.h @@ -15,6 +15,7 @@ #include #include #include + #include "paddle/fluid/inference/tests/api/tester_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/analyzer_vis_tester.cc b/paddle/fluid/inference/tests/api/analyzer_vis_tester.cc index faa15fc4f0a178be7b3d217ce8a19832676dcbf6..0a43d166e93cfa4ae1ec2a8e5f1a0bf32d92043c 100644 --- a/paddle/fluid/inference/tests/api/analyzer_vis_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_vis_tester.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include #include + #include "paddle/fluid/inference/tests/api/tester_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/analyzer_vit_ocr_tester.cc b/paddle/fluid/inference/tests/api/analyzer_vit_ocr_tester.cc index 029f2f0421d153cdd7fefdd1c48a1d699fbb9723..08f26bae37beaebcbc17affc15a508450774b61f 100644 --- a/paddle/fluid/inference/tests/api/analyzer_vit_ocr_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_vit_ocr_tester.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/inference/tests/api/tester_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/analyzer_zerocopy_tensor_tester.cc b/paddle/fluid/inference/tests/api/analyzer_zerocopy_tensor_tester.cc index e1ee1b196e4d37b2ecb3a863cd3bb74fef1307eb..d8ba615c8ed772e358658709bf40b044baca4408 100644 --- a/paddle/fluid/inference/tests/api/analyzer_zerocopy_tensor_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_zerocopy_tensor_tester.cc @@ -16,9 +16,8 @@ #include "paddle/fluid/framework/op_desc.h" #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/scope.h" -#include "paddle/fluid/inference/utils/singleton.h" - #include "paddle/fluid/inference/tests/api/tester_helper.h" +#include "paddle/fluid/inference/utils/singleton.h" namespace paddle { namespace inference { diff --git a/paddle/fluid/inference/tests/api/config_printer.h b/paddle/fluid/inference/tests/api/config_printer.h index b952b62f13ed6c1b6bd0b90bdc5898e9b8ef6f20..6ef3eb95dd2222f5dc9be61527d31f2cc2201683 100644 --- a/paddle/fluid/inference/tests/api/config_printer.h +++ b/paddle/fluid/inference/tests/api/config_printer.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/inference/api/paddle_inference_api.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/ipu_resnet50_fp16_test.cc b/paddle/fluid/inference/tests/api/ipu_resnet50_fp16_test.cc index 1d69069da0716017a8dd4ce62fbe2a083516a40c..38cf475d3da6f2ef6b0bc7639aed18563ee5d49c 100644 --- a/paddle/fluid/inference/tests/api/ipu_resnet50_fp16_test.cc +++ b/paddle/fluid/inference/tests/api/ipu_resnet50_fp16_test.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include #include "gflags/gflags.h" diff --git a/paddle/fluid/inference/tests/api/ipu_resnet50_test.cc b/paddle/fluid/inference/tests/api/ipu_resnet50_test.cc index 5fde8e6a5e1e676d5dacfb9c4c0c1d876130844b..cbfe8229d31a1a03196a6088a7cac456a9faf21a 100644 --- a/paddle/fluid/inference/tests/api/ipu_resnet50_test.cc +++ b/paddle/fluid/inference/tests/api/ipu_resnet50_test.cc @@ -11,6 +11,7 @@ limitations under the License. */ #include #include + #include #include "gflags/gflags.h" diff --git a/paddle/fluid/inference/tests/api/ipu_word2vec_sample.cc b/paddle/fluid/inference/tests/api/ipu_word2vec_sample.cc index d38c5c3416351ae6b55d3e5ea8632290e8e202a7..a0e36e9779da8ba9c11ee7dffb06682ff1256bb1 100644 --- a/paddle/fluid/inference/tests/api/ipu_word2vec_sample.cc +++ b/paddle/fluid/inference/tests/api/ipu_word2vec_sample.cc @@ -31,8 +31,8 @@ limitations under the License. */ DEFINE_string(infer_model, "", "Directory of the inference model."); using paddle_infer::Config; -using paddle_infer::Predictor; using paddle_infer::CreatePredictor; +using paddle_infer::Predictor; void inference(std::string model_path, bool use_ipu, std::vector *out_data) { diff --git a/paddle/fluid/inference/tests/api/lite_mul_model_test.cc b/paddle/fluid/inference/tests/api/lite_mul_model_test.cc index 9211ea246a5c5e0cdc75e6fef72ae0e4e40d69af..1adbf0ec7a552dc418d4ea4fc875f3f95d938278 100644 --- a/paddle/fluid/inference/tests/api/lite_mul_model_test.cc +++ b/paddle/fluid/inference/tests/api/lite_mul_model_test.cc @@ -14,11 +14,12 @@ limitations under the License. */ #include #include + #include #include // NOLINT #include // NOLINT -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/lite_resnet50_test.cc b/paddle/fluid/inference/tests/api/lite_resnet50_test.cc index 59bbaa2b78fb00428aa61bde3c65998721e757f3..169d0b9987d793f048eedca2f3a885f772afa7db 100644 --- a/paddle/fluid/inference/tests/api/lite_resnet50_test.cc +++ b/paddle/fluid/inference/tests/api/lite_resnet50_test.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include #include "gflags/gflags.h" diff --git a/paddle/fluid/inference/tests/api/mkldnn_quantizer_config_tester.cc b/paddle/fluid/inference/tests/api/mkldnn_quantizer_config_tester.cc index 4a2527a217f8b6bcd0e88f73191f05e58e350c11..d972945db7d8c3e9270299b046522ea526eab349 100644 --- a/paddle/fluid/inference/tests/api/mkldnn_quantizer_config_tester.cc +++ b/paddle/fluid/inference/tests/api/mkldnn_quantizer_config_tester.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/inference/api/paddle_mkldnn_quantizer_config.h" #include "paddle/fluid/inference/tests/api/tester_helper.h" @@ -90,9 +91,10 @@ TEST(Mkldnn_quantizer_config, configuration) { PADDLE_ENFORCE_EQ( cfg.mkldnn_quantizer_config()->scale_algo("conv2d", "Input"), - conv2d_scale_algo, platform::errors::InvalidArgument( - "Scale algorithm got from config differs with the " - "one set previously.")); + conv2d_scale_algo, + platform::errors::InvalidArgument( + "Scale algorithm got from config differs with the " + "one set previously.")); PADDLE_ENFORCE_EQ( cfg.mkldnn_quantizer_config()->scale_algo("unknown", "unknown"), diff --git a/paddle/fluid/inference/tests/api/paddle_infer_api_copy_tensor_tester.cc b/paddle/fluid/inference/tests/api/paddle_infer_api_copy_tensor_tester.cc index 2be69781c4e60bd7058e3a1ef4a9c27c23def9d4..38bcb7645abb5951a270a6a47bd5c430401d5da7 100644 --- a/paddle/fluid/inference/tests/api/paddle_infer_api_copy_tensor_tester.cc +++ b/paddle/fluid/inference/tests/api/paddle_infer_api_copy_tensor_tester.cc @@ -14,8 +14,10 @@ limitations under the License. */ #include #include + #include #include + #include "gflags/gflags.h" #include "glog/logging.h" #include "paddle/fluid/inference/api/paddle_infer_contrib.h" diff --git a/paddle/fluid/inference/tests/api/paddle_infer_api_errors_tester.cc b/paddle/fluid/inference/tests/api/paddle_infer_api_errors_tester.cc index c5a0746c4d7600566077af95492dab19d5c313bc..ab82c82b1e3b3ec6c27d0fde5623feb961c8e5ea 100644 --- a/paddle/fluid/inference/tests/api/paddle_infer_api_errors_tester.cc +++ b/paddle/fluid/inference/tests/api/paddle_infer_api_errors_tester.cc @@ -15,7 +15,6 @@ #include "gflags/gflags.h" #include "glog/logging.h" #include "gtest/gtest.h" - #include "paddle/fluid/inference/api/paddle_infer_contrib.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/inference/tests/api/paddle_infer_api_test.cc b/paddle/fluid/inference/tests/api/paddle_infer_api_test.cc index 88ebd85c79a13d2c375b05f708e50d53a464e926..8cbc410eb5ff3dccfd229f75e2cd02e154098a3e 100644 --- a/paddle/fluid/inference/tests/api/paddle_infer_api_test.cc +++ b/paddle/fluid/inference/tests/api/paddle_infer_api_test.cc @@ -15,10 +15,11 @@ limitations under the License. */ #include #include #include + #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/trt_test_helper.h" namespace paddle_infer { diff --git a/paddle/fluid/inference/tests/api/tester_helper.h b/paddle/fluid/inference/tests/api/tester_helper.h index f2df018f4978aeb4482aca4c70b10278f8daaef8..d7784a909afd460b3afddb679fb61cd132d6e6b4 100644 --- a/paddle/fluid/inference/tests/api/tester_helper.h +++ b/paddle/fluid/inference/tests/api/tester_helper.h @@ -1081,7 +1081,7 @@ static bool CompareTensor(const framework::LoDTensor &a, } void ConvertFP32toFP16(paddle::PaddleTensor &tensor // NOLINT - ) { +) { int num = 1; for (auto dim : tensor.shape) { num *= dim; @@ -1101,7 +1101,7 @@ void ConvertFP32toFP16(paddle::PaddleTensor &tensor // NOLINT } void ConvertFP16toFP32(paddle::PaddleTensor &tensor // NOLINT - ) { +) { int num = 1; for (auto dim : tensor.shape) { num *= dim; diff --git a/paddle/fluid/inference/tests/api/trt_cascade_rcnn_test.cc b/paddle/fluid/inference/tests/api/trt_cascade_rcnn_test.cc index a1f31c3108ba55e370a554667668f204604b2bb0..ab059496ad8a70141e0d53ef724b62a51dac2751 100644 --- a/paddle/fluid/inference/tests/api/trt_cascade_rcnn_test.cc +++ b/paddle/fluid/inference/tests/api/trt_cascade_rcnn_test.cc @@ -14,8 +14,8 @@ limitations under the License. */ #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/trt_test_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_fp16_serialize_deserialize_test.cc b/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_fp16_serialize_deserialize_test.cc index 7e9f71c8b3c0c95ed5f1340961d9387adcd6a3a7..b0c4c13dbbc631f99f72a038f0429c6530a26aa7 100644 --- a/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_fp16_serialize_deserialize_test.cc +++ b/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_fp16_serialize_deserialize_test.cc @@ -22,8 +22,8 @@ limitations under the License. */ #define GLOG_NO_ABBREVIATED_SEVERITIES #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.cc b/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.cc index 209dd90c480702ada5772687c8c943f611bcd03f..f269432d4da1e3f961956f9c56f0a80ea3a09d23 100644 --- a/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.cc +++ b/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.cc @@ -22,8 +22,8 @@ limitations under the License. */ #define GLOG_NO_ABBREVIATED_SEVERITIES #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.h b/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.h index 5ae14576dfeb027bb321c06159ed2890a0189ee3..3ca62afba1d056f84df05d629026f303c43aea46 100644 --- a/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.h +++ b/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_serialize_deserialize_test.h @@ -24,8 +24,8 @@ limitations under the License. */ #include #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/trt_test_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_test.cc b/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_test.cc index 262b7269cb30fac86d9e38efbba3ec185a88cf44..977c6856f8c08c3f9269fbe778523e5576ffc982 100644 --- a/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_test.cc +++ b/paddle/fluid/inference/tests/api/trt_dynamic_shape_ernie_test.cc @@ -14,8 +14,8 @@ limitations under the License. */ #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/inference/tensorrt/helper.h" #include "paddle/fluid/inference/tests/api/trt_test_helper.h" @@ -226,13 +226,78 @@ void run(paddle_infer::Predictor* predictor, std::vector* out_data) { int32_t i1[run_seq_len] = { // sentence 1 - 1, 3558, 4, 75, 491, 89, 340, 313, 93, 4, 255, 10, 75, 321, 4095, 1902, 4, - 134, 49, 75, 311, 14, 44, 178, 543, 15, 12043, 2, 75, 201, 340, 9, 14, 44, - 486, 218, 1140, 279, 12043, 2, + 1, + 3558, + 4, + 75, + 491, + 89, + 340, + 313, + 93, + 4, + 255, + 10, + 75, + 321, + 4095, + 1902, + 4, + 134, + 49, + 75, + 311, + 14, + 44, + 178, + 543, + 15, + 12043, + 2, + 75, + 201, + 340, + 9, + 14, + 44, + 486, + 218, + 1140, + 279, + 12043, + 2, // sentence 2 - 101, 2054, 2234, 2046, 2486, 2044, 1996, 2047, 4552, 2001, 9536, 1029, - 102, 2004, 1997, 2008, 2154, 1010, 1996, 2047, 4552, 9536, 2075, 1996, - 2117, 3072, 2234, 2046, 2486, 1012, 102, + 101, + 2054, + 2234, + 2046, + 2486, + 2044, + 1996, + 2047, + 4552, + 2001, + 9536, + 1029, + 102, + 2004, + 1997, + 2008, + 2154, + 1010, + 1996, + 2047, + 4552, + 9536, + 2075, + 1996, + 2117, + 3072, + 2234, + 2046, + 2486, + 1012, + 102, }; int32_t i2[run_seq_len] = { // sentence 1 diff --git a/paddle/fluid/inference/tests/api/trt_dynamic_shape_test.cc b/paddle/fluid/inference/tests/api/trt_dynamic_shape_test.cc index ccdf237ffa54d46e7dd8a94a343bafd09e68e865..4b22bba2bcc974c2d3bfd6129b33b2c5d03da1f9 100644 --- a/paddle/fluid/inference/tests/api/trt_dynamic_shape_test.cc +++ b/paddle/fluid/inference/tests/api/trt_dynamic_shape_test.cc @@ -14,8 +14,8 @@ limitations under the License. */ #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/trt_test_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/trt_dynamic_shape_transformer_prune_test.cc b/paddle/fluid/inference/tests/api/trt_dynamic_shape_transformer_prune_test.cc index 2d7aa72a036fd47aff748ec892cdc8a781689699..a238e62fc7cc0afc4aa6573538a17d40e20e06f5 100644 --- a/paddle/fluid/inference/tests/api/trt_dynamic_shape_transformer_prune_test.cc +++ b/paddle/fluid/inference/tests/api/trt_dynamic_shape_transformer_prune_test.cc @@ -14,8 +14,8 @@ limitations under the License. */ #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/trt_test_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/trt_fc_prelu_test.cc b/paddle/fluid/inference/tests/api/trt_fc_prelu_test.cc index c0be194493112ca2da4da1abaece95583ce72b11..93d4a88383c33fb029c610e05f54d7b035420d3c 100644 --- a/paddle/fluid/inference/tests/api/trt_fc_prelu_test.cc +++ b/paddle/fluid/inference/tests/api/trt_fc_prelu_test.cc @@ -14,8 +14,8 @@ limitations under the License. */ #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/trt_test_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/trt_instance_norm_converter_test.cc b/paddle/fluid/inference/tests/api/trt_instance_norm_converter_test.cc index ceb8b99774e484240e186378aa13de53408d79bd..243be1d33193c6beefaed32cc5da184a9ef0147c 100644 --- a/paddle/fluid/inference/tests/api/trt_instance_norm_converter_test.cc +++ b/paddle/fluid/inference/tests/api/trt_instance_norm_converter_test.cc @@ -14,8 +14,8 @@ limitations under the License. */ #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/trt_test_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/trt_mobilenet_test.cc b/paddle/fluid/inference/tests/api/trt_mobilenet_test.cc index a87bf7b085bd89f77f0e8a51dcd6869b273dd3ab..bcf8a23b9b922565230f50812b392f60077bdb11 100644 --- a/paddle/fluid/inference/tests/api/trt_mobilenet_test.cc +++ b/paddle/fluid/inference/tests/api/trt_mobilenet_test.cc @@ -14,8 +14,8 @@ limitations under the License. */ #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/trt_test_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/trt_quant_int8_test.cc b/paddle/fluid/inference/tests/api/trt_quant_int8_test.cc index ca25967b59a6a5fbbfaf23f29516f143f1aebe51..3a884abe8888903d4758189b4837af4818058962 100644 --- a/paddle/fluid/inference/tests/api/trt_quant_int8_test.cc +++ b/paddle/fluid/inference/tests/api/trt_quant_int8_test.cc @@ -14,9 +14,10 @@ limitations under the License. */ #include #include + #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/trt_test_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/trt_quant_int8_yolov3_r50_test.cc b/paddle/fluid/inference/tests/api/trt_quant_int8_yolov3_r50_test.cc index 1fa24dddead88a1dcf43109e257e4486992a749b..d9e1e3f8c9e8a9b4ee31333c51b916a8794755d3 100644 --- a/paddle/fluid/inference/tests/api/trt_quant_int8_yolov3_r50_test.cc +++ b/paddle/fluid/inference/tests/api/trt_quant_int8_yolov3_r50_test.cc @@ -11,9 +11,10 @@ limitations under the License. */ #include #include + #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/trt_test_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/trt_resnet50_test.cc b/paddle/fluid/inference/tests/api/trt_resnet50_test.cc index 2975967e0c0de839aa2c815e220eef29caef31a4..cdc6586f1272b2e3e5ea164d28198306f7cbdfe4 100644 --- a/paddle/fluid/inference/tests/api/trt_resnet50_test.cc +++ b/paddle/fluid/inference/tests/api/trt_resnet50_test.cc @@ -14,8 +14,8 @@ limitations under the License. */ #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/trt_test_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/trt_resnext_test.cc b/paddle/fluid/inference/tests/api/trt_resnext_test.cc index b525a1b706858be015e69af6c90a8f8bf37c947f..374074957c870a6b747eac5c20bb105db7b2f32d 100644 --- a/paddle/fluid/inference/tests/api/trt_resnext_test.cc +++ b/paddle/fluid/inference/tests/api/trt_resnext_test.cc @@ -14,8 +14,8 @@ limitations under the License. */ #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/trt_test_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/trt_split_converter_test.cc b/paddle/fluid/inference/tests/api/trt_split_converter_test.cc index c00b36b520bcd14f90b3e45b1492f11d4bba7d3f..0726db28343bc008bfe78243b99003c7cc1326c1 100644 --- a/paddle/fluid/inference/tests/api/trt_split_converter_test.cc +++ b/paddle/fluid/inference/tests/api/trt_split_converter_test.cc @@ -14,8 +14,8 @@ limitations under the License. */ #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/inference/tests/api/trt_test_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/api/trt_test_helper.h b/paddle/fluid/inference/tests/api/trt_test_helper.h index aaa285b2fc2c9e991ac6c4433a5dc82dcb353ca4..cadf996e071d8490bd3cfad2fde55b7a0623b0f1 100644 --- a/paddle/fluid/inference/tests/api/trt_test_helper.h +++ b/paddle/fluid/inference/tests/api/trt_test_helper.h @@ -13,13 +13,13 @@ See the License for the specific language governing permissions and limitations under the License. */ #pragma once #include + #include #include #include "gflags/gflags.h" #include "glog/logging.h" #include "gtest/gtest.h" - #include "paddle/fluid/inference/tests/api/tester_helper.h" namespace paddle { diff --git a/paddle/fluid/inference/tests/infer_ut/test_suite.h b/paddle/fluid/inference/tests/infer_ut/test_suite.h index a5c8c52402180adafd25255cf754e1af3a5a5498..8737afa809933227ca1d7206ddbb62ce4271c9f5 100644 --- a/paddle/fluid/inference/tests/infer_ut/test_suite.h +++ b/paddle/fluid/inference/tests/infer_ut/test_suite.h @@ -13,6 +13,7 @@ // limitations under the License. #pragma once #include + #include #include #include @@ -26,7 +27,6 @@ #include "gflags/gflags.h" #include "glog/logging.h" #include "gtest/gtest.h" - #include "paddle/include/paddle_inference_api.h" namespace paddle { @@ -64,7 +64,7 @@ void SingleThreadPrediction(paddle_infer::Predictor *predictor, int repeat_times = 2) { // prepare input tensor auto input_names = predictor->GetInputNames(); - for (const auto & [ key, value ] : *input_data_map) { + for (const auto &[key, value] : *input_data_map) { switch (value.type) { case paddle::PaddleDType::INT64: { std::vector input_value = @@ -150,7 +150,7 @@ void SingleThreadPrediction(paddle_infer::Predictor *predictor, void CompareRecord(std::map *truth_output_data, std::map *infer_output_data, float epislon = 1e-5) { - for (const auto & [ key, value ] : *infer_output_data) { + for (const auto &[key, value] : *infer_output_data) { auto truth_record = (*truth_output_data)[key]; VLOG(1) << "output name: " << key; size_t numel = value.data.size() / sizeof(float); @@ -190,7 +190,7 @@ double SingleThreadProfile(paddle_infer::Predictor *predictor, int repeat_times = 2) { // prepare input tensor auto input_names = predictor->GetInputNames(); - for (const auto & [ key, value ] : *input_data_map) { + for (const auto &[key, value] : *input_data_map) { switch (value.type) { case paddle::PaddleDType::INT64: { std::vector input_value = diff --git a/paddle/fluid/inference/utils/benchmark_tester.cc b/paddle/fluid/inference/utils/benchmark_tester.cc index 0c48c2db9b691ae8cf587f2729c2789d4ce2dbe1..8f7614cb10a44ec9270e7958e7febd03c1bbd0b4 100644 --- a/paddle/fluid/inference/utils/benchmark_tester.cc +++ b/paddle/fluid/inference/utils/benchmark_tester.cc @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/inference/utils/benchmark.h" #include #include +#include "paddle/fluid/inference/utils/benchmark.h" + using namespace paddle::inference; // NOLINT TEST(Benchmark, basic) { Benchmark benchmark; diff --git a/paddle/fluid/inference/utils/io_utils.cc b/paddle/fluid/inference/utils/io_utils.cc index 87331e1978f95edc722f6cb7bb968c355cf9e78b..425c67d2fd2404f2f7fe140f78d9505474281218 100644 --- a/paddle/fluid/inference/utils/io_utils.cc +++ b/paddle/fluid/inference/utils/io_utils.cc @@ -158,8 +158,9 @@ void SerializePDTensorsToFile(const std::string &path, void DeserializePDTensorsToFile(const std::string &path, std::vector *tensors) { bool is_present = analysis::FileExists(path); - PADDLE_ENFORCE_EQ(is_present, true, platform::errors::InvalidArgument( - "Cannot open %s to read", path)); + PADDLE_ENFORCE_EQ( + is_present, true, + platform::errors::InvalidArgument("Cannot open %s to read", path)); std::ifstream fin(path, std::ios::binary); DeserializePDTensorsToStream(fin, tensors); fin.close(); diff --git a/paddle/fluid/inference/utils/io_utils_tester.cc b/paddle/fluid/inference/utils/io_utils_tester.cc index ffd97232652fd9d8fc16beda49a2276c92c245b0..e8ebb72acc32226a1c603bd2f1562816a76f5d4f 100644 --- a/paddle/fluid/inference/utils/io_utils_tester.cc +++ b/paddle/fluid/inference/utils/io_utils_tester.cc @@ -12,11 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/inference/utils/io_utils.h" #include #include + #include + #include "paddle/fluid/inference/api/helper.h" +#include "paddle/fluid/inference/utils/io_utils.h" namespace paddle { namespace inference { diff --git a/paddle/fluid/inference/utils/singleton.h b/paddle/fluid/inference/utils/singleton.h index 6828924c300fdfec6640e7b19a2c06b0826aa455..5fccd3458a1d052cffa9edd83efa29eda0e1a11e 100644 --- a/paddle/fluid/inference/utils/singleton.h +++ b/paddle/fluid/inference/utils/singleton.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/platform/enforce.h" namespace paddle { diff --git a/paddle/fluid/inference/utils/table_printer_tester.cc b/paddle/fluid/inference/utils/table_printer_tester.cc index 8faac79c51718a2fa1fee7a86b7a39a866763667..fc482807b2854ca9ea8e973044520cb68712da01 100644 --- a/paddle/fluid/inference/utils/table_printer_tester.cc +++ b/paddle/fluid/inference/utils/table_printer_tester.cc @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/inference/utils/table_printer.h" #include #include +#include "paddle/fluid/inference/utils/table_printer.h" + namespace paddle { namespace inference {} // namespace inference } // namespace paddle diff --git a/paddle/fluid/memory/allocation/allocator_facade.cc b/paddle/fluid/memory/allocation/allocator_facade.cc index 7cd5fffea2ad6da4ec2ddd49e8750081ef88040e..d72af70657a29faad1ae905266cf8b47d9867f4b 100644 --- a/paddle/fluid/memory/allocation/allocator_facade.cc +++ b/paddle/fluid/memory/allocation/allocator_facade.cc @@ -28,6 +28,7 @@ #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) #include + #include "paddle/fluid/memory/allocation/cuda_allocator.h" #include "paddle/fluid/memory/allocation/cuda_managed_allocator.h" #include "paddle/fluid/memory/allocation/pinned_allocator.h" diff --git a/paddle/fluid/memory/allocation/allocator_facade.h b/paddle/fluid/memory/allocation/allocator_facade.h index 94b07e3e6c1efc591b9e75475786fbb375dc771e..a37c11c0c048b91b7f1e1550ef220280283d678d 100644 --- a/paddle/fluid/memory/allocation/allocator_facade.h +++ b/paddle/fluid/memory/allocation/allocator_facade.h @@ -14,6 +14,7 @@ #pragma once #include + #include "paddle/fluid/memory/allocation/allocator.h" #ifdef PADDLE_WITH_ASCEND_CL #include "paddle/fluid/memory/allocation/npu_pinned_allocator.h" diff --git a/paddle/fluid/memory/allocation/allocator_facade_abs_flags_test.cc b/paddle/fluid/memory/allocation/allocator_facade_abs_flags_test.cc index fca07ba8e251124db4f55dd6c339d4b5961b8fe2..d3f16ec6286605707a01e36e08ff0c7f12eff12c 100644 --- a/paddle/fluid/memory/allocation/allocator_facade_abs_flags_test.cc +++ b/paddle/fluid/memory/allocation/allocator_facade_abs_flags_test.cc @@ -12,9 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/memory/allocation/allocator_facade.h" #include +#include "paddle/fluid/memory/allocation/allocator_facade.h" + #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) DECLARE_double(fraction_of_gpu_memory_to_use); DECLARE_double(fraction_of_cuda_pinned_memory_to_use); diff --git a/paddle/fluid/memory/allocation/auto_growth_best_fit_allocator.cc b/paddle/fluid/memory/allocation/auto_growth_best_fit_allocator.cc index 782062283e9859b0c5f63203acffd779ae492e39..d460480bc734fc6321ada11e47cf8a13c137b1c7 100644 --- a/paddle/fluid/memory/allocation/auto_growth_best_fit_allocator.cc +++ b/paddle/fluid/memory/allocation/auto_growth_best_fit_allocator.cc @@ -16,6 +16,7 @@ #include #include // NOLINT + #include "paddle/fluid/memory/allocation/aligned_allocator.h" #include "paddle/fluid/platform/flags.h" #include "paddle/fluid/platform/profiler/event_tracing.h" diff --git a/paddle/fluid/memory/allocation/auto_growth_best_fit_allocator_facade_test.cc b/paddle/fluid/memory/allocation/auto_growth_best_fit_allocator_facade_test.cc index 4469673b305bfea7b27b12972908d7f56c543f2f..70c43145cc85d88a106bf9b9004fe2f756b17777 100644 --- a/paddle/fluid/memory/allocation/auto_growth_best_fit_allocator_facade_test.cc +++ b/paddle/fluid/memory/allocation/auto_growth_best_fit_allocator_facade_test.cc @@ -13,10 +13,12 @@ // limitations under the License. #include + #include // NOLINT #include // NOLINT #include #include // NOLINT + #include "gflags/gflags.h" #include "paddle/fluid/memory/allocation/allocator_facade.h" #include "paddle/fluid/platform/device/gpu/gpu_info.h" diff --git a/paddle/fluid/memory/allocation/auto_growth_best_fit_allocator_test.cc b/paddle/fluid/memory/allocation/auto_growth_best_fit_allocator_test.cc index 8d2f6e07a2901dc6433ca4b1146fcc489be44e4b..441e80dfa4f8def84f7a97e438722af30c9798ef 100644 --- a/paddle/fluid/memory/allocation/auto_growth_best_fit_allocator_test.cc +++ b/paddle/fluid/memory/allocation/auto_growth_best_fit_allocator_test.cc @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - -#include "paddle/fluid/memory/allocation/aligned_allocator.h" #include "paddle/fluid/memory/allocation/auto_growth_best_fit_allocator.h" +#include + #include "gtest/gtest.h" +#include "paddle/fluid/memory/allocation/aligned_allocator.h" DECLARE_bool(free_idle_chunk); DECLARE_bool(free_when_no_cache_hit); diff --git a/paddle/fluid/memory/allocation/best_fit_allocator.cc b/paddle/fluid/memory/allocation/best_fit_allocator.cc index 4cfe3997d89a91fe8cc5424fbd50ca3c017cef6f..c93645bf7a00dd99caee0ddaaa525fbf5603c637 100644 --- a/paddle/fluid/memory/allocation/best_fit_allocator.cc +++ b/paddle/fluid/memory/allocation/best_fit_allocator.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/memory/allocation/best_fit_allocator.h" + #include #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/memory/allocation/best_fit_allocator.h b/paddle/fluid/memory/allocation/best_fit_allocator.h index 69cb7c2708f9d4c73f27e8adf7b768f7c9faf212..64ee632c3879aa0e70870274d0f201af14747bef 100644 --- a/paddle/fluid/memory/allocation/best_fit_allocator.h +++ b/paddle/fluid/memory/allocation/best_fit_allocator.h @@ -14,6 +14,7 @@ #pragma once #include + #include #include #include diff --git a/paddle/fluid/memory/allocation/cuda_allocator.cc b/paddle/fluid/memory/allocation/cuda_allocator.cc index 62a2dd78128bb9336f8f7d7bd45ba247787fa144..de6cac63e9ddba002c7db6d33dcd680959218034 100644 --- a/paddle/fluid/memory/allocation/cuda_allocator.cc +++ b/paddle/fluid/memory/allocation/cuda_allocator.cc @@ -24,6 +24,7 @@ #endif #include + #include "paddle/fluid/platform/cuda_device_guard.h" #include "paddle/fluid/platform/device/gpu/gpu_info.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/memory/allocation/cuda_allocator.h b/paddle/fluid/memory/allocation/cuda_allocator.h index 522b1d623e83ba11ccb5e624679febc6690ac437..f3df30827417d489ac28f3a46fc1d1c8067a0887 100644 --- a/paddle/fluid/memory/allocation/cuda_allocator.h +++ b/paddle/fluid/memory/allocation/cuda_allocator.h @@ -14,6 +14,7 @@ #pragma once #include // NOLINT + #include "paddle/fluid/memory/allocation/allocator.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/memory/allocation/cuda_ipc_allocator.cc b/paddle/fluid/memory/allocation/cuda_ipc_allocator.cc index b2f24d5aed1eb827b4857f5936a19b206a38c788..dff93736a6e705e106cdb946ed16d19be73f27a5 100644 --- a/paddle/fluid/memory/allocation/cuda_ipc_allocator.cc +++ b/paddle/fluid/memory/allocation/cuda_ipc_allocator.cc @@ -15,15 +15,16 @@ #ifndef _WIN32 #include "paddle/fluid/memory/allocation/cuda_ipc_allocator.h" -#include "paddle/fluid/platform/cuda_device_guard.h" #include #include #include + #include #include #include "glog/logging.h" +#include "paddle/fluid/platform/cuda_device_guard.h" #include "paddle/fluid/platform/enforce.h" namespace paddle { diff --git a/paddle/fluid/memory/allocation/cuda_managed_allocator.cc b/paddle/fluid/memory/allocation/cuda_managed_allocator.cc index 0c83d4d36634e9e1d6844449dae78a4f58e1c68b..ac62b10c0e07a579163d32631ef19050fb52058c 100644 --- a/paddle/fluid/memory/allocation/cuda_managed_allocator.cc +++ b/paddle/fluid/memory/allocation/cuda_managed_allocator.cc @@ -24,6 +24,7 @@ #endif #include + #include "paddle/fluid/platform/cuda_device_guard.h" #include "paddle/fluid/platform/device/gpu/gpu_info.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/memory/allocation/cuda_virtual_mem_allocator.cc b/paddle/fluid/memory/allocation/cuda_virtual_mem_allocator.cc index a235b3871b3e65900f89bed32195b1378cc08968..9494141615f343dfb8a57d6f1dbd746fc375f80f 100644 --- a/paddle/fluid/memory/allocation/cuda_virtual_mem_allocator.cc +++ b/paddle/fluid/memory/allocation/cuda_virtual_mem_allocator.cc @@ -18,6 +18,7 @@ #endif #include + #include "paddle/fluid/memory/allocation/cuda_virtual_mem_allocator.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/memory/allocation/cuda_virtual_mem_allocator.h b/paddle/fluid/memory/allocation/cuda_virtual_mem_allocator.h index e7b296e6a5a110d56233b5f2e9f2ada14ae0c48d..ff26a96a0e1015a5c56669b4c555fd230078a6a9 100644 --- a/paddle/fluid/memory/allocation/cuda_virtual_mem_allocator.h +++ b/paddle/fluid/memory/allocation/cuda_virtual_mem_allocator.h @@ -16,10 +16,12 @@ #ifdef PADDLE_WITH_CUDA #include + #include "paddle/fluid/platform/cuda_device_guard.h" #endif #include // NOLINT + #include "paddle/fluid/memory/allocation/allocator.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/memory/allocation/custom_allocator.cc b/paddle/fluid/memory/allocation/custom_allocator.cc index e53d7b1cc766a3e277ef0a773671ef678bcb3ac7..2cd969e2bd17fa81eb4a4c49f89de7c5017e2072 100644 --- a/paddle/fluid/memory/allocation/custom_allocator.cc +++ b/paddle/fluid/memory/allocation/custom_allocator.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/memory/allocation/custom_allocator.h" + #include "paddle/fluid/platform/device/device_wrapper.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/memory/allocation/custom_allocator.h b/paddle/fluid/memory/allocation/custom_allocator.h index 0f34bc156c872a2bbeace1a6edda08275da2bfa4..b10f840f60d94e8d621f2de0e499b197fc5f71fe 100644 --- a/paddle/fluid/memory/allocation/custom_allocator.h +++ b/paddle/fluid/memory/allocation/custom_allocator.h @@ -14,6 +14,7 @@ #pragma once #include // NOLINT + #include "paddle/fluid/memory/allocation/allocator.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/memory/allocation/mmap_allocator.cc b/paddle/fluid/memory/allocation/mmap_allocator.cc index 25c2235cce85369babc4d601de96c7475a0b1fbd..6fd87fb6a7748c58cc51a0429f05f6e4643d13e3 100644 --- a/paddle/fluid/memory/allocation/mmap_allocator.cc +++ b/paddle/fluid/memory/allocation/mmap_allocator.cc @@ -19,6 +19,7 @@ #include #include #include + #include #include @@ -217,9 +218,9 @@ std::shared_ptr AllocateMemoryMapWriterAllocation( const std::string &ipc_name = GetIPCName(); int flags = O_RDWR | O_CREAT; int fd = shm_open(ipc_name.c_str(), flags, 0600); - PADDLE_ENFORCE_NE( - fd, -1, platform::errors::Unavailable("File descriptor %s open failed", - ipc_name.c_str())); + PADDLE_ENFORCE_NE(fd, -1, + platform::errors::Unavailable( + "File descriptor %s open failed", ipc_name.c_str())); PADDLE_ENFORCE_EQ(ftruncate(fd, size), 0, platform::errors::Unavailable( "Fruncate a file to a specified length failed!")); @@ -239,9 +240,9 @@ std::shared_ptr RebuildMemoryMapReaderAllocation( flags &= ~O_CREAT; int fd = shm_open(ipc_name.c_str(), flags, 0600); - PADDLE_ENFORCE_NE( - fd, -1, platform::errors::Unavailable("File descriptor %s open failed", - ipc_name.c_str())); + PADDLE_ENFORCE_NE(fd, -1, + platform::errors::Unavailable( + "File descriptor %s open failed", ipc_name.c_str())); void *ptr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); PADDLE_ENFORCE_NE(ptr, MAP_FAILED, platform::errors::Unavailable( diff --git a/paddle/fluid/memory/allocation/naive_best_fit_allocator.cc b/paddle/fluid/memory/allocation/naive_best_fit_allocator.cc index 5efbfce7fedd600a4e679e5b10ee67454a569f4f..7cc95de83101b87d7ac34d22b6306fcd618336d9 100644 --- a/paddle/fluid/memory/allocation/naive_best_fit_allocator.cc +++ b/paddle/fluid/memory/allocation/naive_best_fit_allocator.cc @@ -24,7 +24,6 @@ #include "paddle/fluid/platform/device/gpu/gpu_info.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/profiler.h" - #include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/split.h" #include "paddle/phi/common/place.h" diff --git a/paddle/fluid/memory/allocation/naive_best_fit_allocator.h b/paddle/fluid/memory/allocation/naive_best_fit_allocator.h index 05db0d7341aca2448b42cf97e3d4f5e87375e9e6..3d6500d0f564260805018366517194f60b6da67f 100644 --- a/paddle/fluid/memory/allocation/naive_best_fit_allocator.h +++ b/paddle/fluid/memory/allocation/naive_best_fit_allocator.h @@ -14,6 +14,7 @@ #pragma once #include + #include #include // NOLINT #include diff --git a/paddle/fluid/memory/allocation/npu_allocator.cc b/paddle/fluid/memory/allocation/npu_allocator.cc index d69663f636e3223a313bc5b5caf931449dc903e7..1c277c5db84d63818c421c5d7134b1104e1a9dda 100644 --- a/paddle/fluid/memory/allocation/npu_allocator.cc +++ b/paddle/fluid/memory/allocation/npu_allocator.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/memory/allocation/npu_allocator.h" + #include + #include "paddle/fluid/platform/device/npu/npu_info.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/memory/allocation/npu_allocator.h b/paddle/fluid/memory/allocation/npu_allocator.h index ff55ba70c520fdb678fccf7bd5d97a41fdda9945..04832c6fd9b63aa390bd534862aca45b17cfc4dc 100644 --- a/paddle/fluid/memory/allocation/npu_allocator.h +++ b/paddle/fluid/memory/allocation/npu_allocator.h @@ -14,6 +14,7 @@ #pragma once #include // NOLINT + #include "paddle/fluid/memory/allocation/allocator.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/memory/allocation/pinned_allocator.cc b/paddle/fluid/memory/allocation/pinned_allocator.cc index 5e5aea6dab2cc411a7b4570cddac67c605db3202..ad11d81875231ab489e1321382c30e748d1366a6 100644 --- a/paddle/fluid/memory/allocation/pinned_allocator.cc +++ b/paddle/fluid/memory/allocation/pinned_allocator.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/memory/allocation/pinned_allocator.h" + #include "paddle/fluid/memory/stats.h" namespace paddle { namespace memory { diff --git a/paddle/fluid/memory/allocation/retry_allocator.cc b/paddle/fluid/memory/allocation/retry_allocator.cc index d6074975720c5d7f4a04ff2e886e8d2810261633..2914da4f6361ccd73b39e6721f0498b9164fbb35 100644 --- a/paddle/fluid/memory/allocation/retry_allocator.cc +++ b/paddle/fluid/memory/allocation/retry_allocator.cc @@ -44,8 +44,9 @@ void RetryAllocator::FreeImpl(phi::Allocation* allocation) { size_t size = allocation->size(); underlying_allocator_->Free(allocation); if (UNLIKELY(waited_allocate_size_)) { - VLOG(10) << "Free " << size << " bytes and notify all waited threads, " - "where waited_allocate_size_ = " + VLOG(10) << "Free " << size + << " bytes and notify all waited threads, " + "where waited_allocate_size_ = " << waited_allocate_size_; cv_.notify_all(); } diff --git a/paddle/fluid/memory/allocation/retry_allocator_test.cc b/paddle/fluid/memory/allocation/retry_allocator_test.cc index cb593f5ab74c74fb9b70b3a25a9b39bbc03339d0..e7370036cee36fcfb26f739d0fcd15f3804c26e8 100644 --- a/paddle/fluid/memory/allocation/retry_allocator_test.cc +++ b/paddle/fluid/memory/allocation/retry_allocator_test.cc @@ -15,6 +15,7 @@ #include "paddle/fluid/memory/allocation/retry_allocator.h" #include // NOLINT + #include "gtest/gtest.h" #include "paddle/fluid/memory/allocation/best_fit_allocator.h" #include "paddle/fluid/memory/allocation/cpu_allocator.h" diff --git a/paddle/fluid/memory/allocation/stream_safe_cuda_allocator.cc b/paddle/fluid/memory/allocation/stream_safe_cuda_allocator.cc index 80877cb670ba9cfc78ef872484e0c228313b3c4c..81a87ef07b592146fcde6ea47f4f12a886b1fb52 100644 --- a/paddle/fluid/memory/allocation/stream_safe_cuda_allocator.cc +++ b/paddle/fluid/memory/allocation/stream_safe_cuda_allocator.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/memory/allocation/stream_safe_cuda_allocator.h" + #include "paddle/fluid/platform/profiler/event_tracing.h" #ifdef PADDLE_WITH_CUDA diff --git a/paddle/fluid/memory/allocation/stream_safe_cuda_allocator.h b/paddle/fluid/memory/allocation/stream_safe_cuda_allocator.h index 32d3896e66bbf3ffd0d5ae3695dd8b4298ac6ca3..ac4b7c790c9505572af676e90ab97322cd1cf3b8 100644 --- a/paddle/fluid/memory/allocation/stream_safe_cuda_allocator.h +++ b/paddle/fluid/memory/allocation/stream_safe_cuda_allocator.h @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/fluid/memory/allocation/allocator.h" #include "paddle/fluid/memory/allocation/spin_lock.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/memory/allocation/thread_local_allocator_test.cc b/paddle/fluid/memory/allocation/thread_local_allocator_test.cc index c5378d9f59c3d08ce0393d178c6acb98bb8180e0..74c83149b4cb5d468b2921d76c867c29d4eef499 100644 --- a/paddle/fluid/memory/allocation/thread_local_allocator_test.cc +++ b/paddle/fluid/memory/allocation/thread_local_allocator_test.cc @@ -13,8 +13,10 @@ // limitations under the License. #include "paddle/fluid/memory/allocation/thread_local_allocator.h" + #include // NOLINT #include // NOLINT + #include "gtest/gtest.h" #include "paddle/fluid/memory/malloc.h" diff --git a/paddle/fluid/memory/allocation/virtual_memory_auto_growth_best_fit_allocator.cc b/paddle/fluid/memory/allocation/virtual_memory_auto_growth_best_fit_allocator.cc index c8b4e980566d06b989b22b491d8a12142041db3f..07ad149a3078d69532b5f085da6bd11c802cd89e 100644 --- a/paddle/fluid/memory/allocation/virtual_memory_auto_growth_best_fit_allocator.cc +++ b/paddle/fluid/memory/allocation/virtual_memory_auto_growth_best_fit_allocator.cc @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/memory/allocation/virtual_memory_auto_growth_best_fit_allocator.h" + #include #include "paddle/fluid/memory/allocation/aligned_allocator.h" -#include "paddle/fluid/memory/allocation/virtual_memory_auto_growth_best_fit_allocator.h" namespace paddle { namespace memory { diff --git a/paddle/fluid/memory/buffer.h b/paddle/fluid/memory/buffer.h index 99b25ca289ce18bfcaf914578105783e2ecaccab..f42b5262e3422a74da09269d8db539c72e8fa933 100644 --- a/paddle/fluid/memory/buffer.h +++ b/paddle/fluid/memory/buffer.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/memory/detail/system_allocator.cc b/paddle/fluid/memory/detail/system_allocator.cc index e1077d66c54ecd65cbc4c0c2a4bd8bf93c59fd48..244445d59b829a37f138ea9c3838a3ab07b038a8 100644 --- a/paddle/fluid/memory/detail/system_allocator.cc +++ b/paddle/fluid/memory/detail/system_allocator.cc @@ -168,8 +168,9 @@ void* GPUAllocator::Alloc(size_t* index, size_t size) { } void GPUAllocator::Free(void* p, size_t size, size_t index) { - PADDLE_ENFORCE_EQ(index, 0, platform::errors::InvalidArgument( - "The index should be 0, index is %d", index)); + PADDLE_ENFORCE_EQ(index, 0, + platform::errors::InvalidArgument( + "The index should be 0, index is %d", index)); PADDLE_ENFORCE_GE(gpu_alloc_size_, size, platform::errors::InvalidArgument( "The size of memory (%d) to free exceeds the size of " @@ -223,8 +224,9 @@ void* CUDAPinnedAllocator::Alloc(size_t* index, size_t size) { void CUDAPinnedAllocator::Free(void* p, size_t size, size_t index) { gpuError_t err; - PADDLE_ENFORCE_EQ(index, 1, platform::errors::InvalidArgument( - "The index should be 1, but got %d", index)); + PADDLE_ENFORCE_EQ(index, 1, + platform::errors::InvalidArgument( + "The index should be 1, but got %d", index)); PADDLE_ENFORCE_GE(cuda_pinnd_alloc_size_, size, platform::errors::InvalidArgument( @@ -310,8 +312,9 @@ void* NPUAllocator::Alloc(size_t* index, size_t size) { void NPUAllocator::Free(void* p, size_t size, size_t index) { VLOG(4) << "Free " << p << " size " << size; - PADDLE_ENFORCE_EQ(index, 0, platform::errors::InvalidArgument( - "The index should be 0, index is %d", index)); + PADDLE_ENFORCE_EQ(index, 0, + platform::errors::InvalidArgument( + "The index should be 0, index is %d", index)); PADDLE_ENFORCE_GE(npu_alloc_size_, size, platform::errors::InvalidArgument( "The size of memory (%d) to free exceeds the size of " @@ -355,8 +358,9 @@ void* NPUPinnedAllocator::Alloc(size_t* index, size_t size) { void NPUPinnedAllocator::Free(void* p, size_t size, size_t index) { aclError err; - PADDLE_ENFORCE_EQ(index, 1, platform::errors::InvalidArgument( - "The index should be 1, but got %d", index)); + PADDLE_ENFORCE_EQ(index, 1, + platform::errors::InvalidArgument( + "The index should be 1, but got %d", index)); PADDLE_ENFORCE_GE(npu_pinnd_alloc_size_, size, platform::errors::InvalidArgument( @@ -425,8 +429,9 @@ void* MLUAllocator::Alloc(size_t* index, size_t size) { } void MLUAllocator::Free(void* p, size_t size, size_t index) { - PADDLE_ENFORCE_EQ(index, 0, platform::errors::InvalidArgument( - "The index should be 0, index is %d", index)); + PADDLE_ENFORCE_EQ(index, 0, + platform::errors::InvalidArgument( + "The index should be 0, index is %d", index)); PADDLE_ENFORCE_GE(mlu_alloc_size_, size, platform::errors::InvalidArgument( "The size of memory (%d) to free exceeds the size of " @@ -469,8 +474,9 @@ void* CustomAllocator::Alloc(size_t* index, size_t size) { void CustomAllocator::Free(void* p, size_t size, size_t index) { VLOG(4) << "CustomAllocator::Free " << p << " size " << size; - PADDLE_ENFORCE_EQ(index, 0, platform::errors::InvalidArgument( - "The index should be 0, index is %d", index)); + PADDLE_ENFORCE_EQ(index, 0, + platform::errors::InvalidArgument( + "The index should be 0, index is %d", index)); PADDLE_ENFORCE_GE(plug_alloc_size, size, platform::errors::InvalidArgument( "The size of memory (%d) to free exceeds the size of " diff --git a/paddle/fluid/memory/detail/system_allocator.h b/paddle/fluid/memory/detail/system_allocator.h index f6ff6282a614a3152dee5bd0e45ebe3b733fe14f..18c2e278f99c5355ec01024860be644a0032f785 100644 --- a/paddle/fluid/memory/detail/system_allocator.h +++ b/paddle/fluid/memory/detail/system_allocator.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include // for size_t + #include namespace paddle { diff --git a/paddle/fluid/memory/get_base_ptr_test.cu b/paddle/fluid/memory/get_base_ptr_test.cu index 188d2f5f420cf7de264cd3837f5e6a9bb9d2b3b8..c8928bda0c937d883b2d7ba274831d43562f7337 100644 --- a/paddle/fluid/memory/get_base_ptr_test.cu +++ b/paddle/fluid/memory/get_base_ptr_test.cu @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "gtest/gtest.h" #include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/platform/device/gpu/gpu_info.h" diff --git a/paddle/fluid/memory/malloc.h b/paddle/fluid/memory/malloc.h index 796bdcf0ec2f685288e9acc5a5c0969de10cae1f..a7d0fa9781f773e7d7902ab1cdce236c3f35d079 100644 --- a/paddle/fluid/memory/malloc.h +++ b/paddle/fluid/memory/malloc.h @@ -24,9 +24,9 @@ limitations under the License. */ namespace paddle { namespace memory { -using phi::Allocation; -using allocation::Allocator; using allocation::AllocationPtr; +using allocation::Allocator; +using phi::Allocation; extern std::shared_ptr AllocShared(const platform::Place& place, size_t size); diff --git a/paddle/fluid/memory/memory_stats_test.cc b/paddle/fluid/memory/memory_stats_test.cc index b2fc602e401edcbe8ee8209158a14399758f6018..081f0d3d78c133201892c32d1d9232bde60bccfd 100644 --- a/paddle/fluid/memory/memory_stats_test.cc +++ b/paddle/fluid/memory/memory_stats_test.cc @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/memory/memory.h" #include #include + #include "gtest/gtest.h" +#include "paddle/fluid/memory/memory.h" namespace paddle { namespace memory { diff --git a/paddle/fluid/memory/pinned_memory_test.cu b/paddle/fluid/memory/pinned_memory_test.cu index 837c964e2ad32cb84405365cdd6dc595cf775de6..e5958615d018468be8cb4e6917737c305a92d442 100644 --- a/paddle/fluid/memory/pinned_memory_test.cu +++ b/paddle/fluid/memory/pinned_memory_test.cu @@ -12,12 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include + #include #include "paddle/fluid/memory/detail/memory_block.h" #include "paddle/fluid/memory/memcpy.h" #include "paddle/fluid/memory/memory.h" - #include "paddle/fluid/platform/cpu_info.h" #include "paddle/fluid/platform/device/gpu/gpu_info.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/memory/stats.h b/paddle/fluid/memory/stats.h index bb6a3cca6644c1d47cb0dfc469b5ad734971b8e1..a30ee161e1c08e41e17ccd1b8f2242067daaadd5 100644 --- a/paddle/fluid/memory/stats.h +++ b/paddle/fluid/memory/stats.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/new_executor/workqueue/thread_data_registry.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/errors.h" @@ -149,15 +150,16 @@ void HostMemoryStatUpdate(const std::string& stat_type, int dev_id, #define DEVICE_MEMORY_STAT_UPDATE(item, id, increment) \ DEVICE_MEMORY_STAT_FUNC(item, id, Update, increment) -#define HOST_MEMORY_STAT_FUNC(item, id, func, ...) \ - [&] { \ - PADDLE_ENFORCE_EQ(id, 0, paddle::platform::errors::OutOfRange( \ - "Only support device id 0 for host memory " \ - "stats, not support device id: %d", \ - id)); \ - return paddle::memory::Stat< \ - paddle::memory::HostMemoryStat##item##0>::GetInstance() \ - ->func(__VA_ARGS__); \ +#define HOST_MEMORY_STAT_FUNC(item, id, func, ...) \ + [&] { \ + PADDLE_ENFORCE_EQ(id, 0, \ + paddle::platform::errors::OutOfRange( \ + "Only support device id 0 for host memory " \ + "stats, not support device id: %d", \ + id)); \ + return paddle::memory::Stat< \ + paddle::memory::HostMemoryStat##item##0>::GetInstance() \ + ->func(__VA_ARGS__); \ }() #define HOST_MEMORY_STAT_CURRENT_VALUE(item, id) \ diff --git a/paddle/fluid/memory/stats_test.cc b/paddle/fluid/memory/stats_test.cc index bcaba8e91080f7643b893232d2dee813ef3ffa77..73a6b921ca8a42b44a21b8be434dcd42b2f5b574 100644 --- a/paddle/fluid/memory/stats_test.cc +++ b/paddle/fluid/memory/stats_test.cc @@ -13,11 +13,13 @@ // limitations under the License. #include "paddle/fluid/memory/stats.h" + #include #include #include #include #include + #include "gtest/gtest.h" namespace paddle { diff --git a/paddle/fluid/memory/stream_safe_cuda_alloc_test.cu b/paddle/fluid/memory/stream_safe_cuda_alloc_test.cu index 3bf873bcfc231d1e832358cd353c0fa54a9cb9d3..5b5350c34fb6f7327fd95c8521eba934e33a973d 100644 --- a/paddle/fluid/memory/stream_safe_cuda_alloc_test.cu +++ b/paddle/fluid/memory/stream_safe_cuda_alloc_test.cu @@ -25,6 +25,7 @@ #ifdef PADDLE_WITH_CUDA #include #include + #include "paddle/fluid/platform/cuda_graph_with_memory_pool.h" #endif @@ -47,9 +48,9 @@ __global__ void add_kernel(int *x, int *y, int n) { void CheckMemLeak(const platform::CUDAPlace &place) { uint64_t cuda_malloc_size = platform::RecordedGpuMallocSize(place.GetDeviceId()); - ASSERT_EQ(cuda_malloc_size, 0) << "Found " << cuda_malloc_size - << " bytes memory that not released yet," - << " there may be a memory leak problem"; + ASSERT_EQ(cuda_malloc_size, 0) + << "Found " << cuda_malloc_size << " bytes memory that not released yet," + << " there may be a memory leak problem"; } TEST(StreamSafeCUDAAllocInterfaceTest, AllocInterfaceTest) { diff --git a/paddle/fluid/operators/abs_op.cc b/paddle/fluid/operators/abs_op.cc index b9517e1cc863c1da5a02f798e1cb67e7b400b09c..86b60da341e6391e2b9782fa4742dc8474aab9ee 100644 --- a/paddle/fluid/operators/abs_op.cc +++ b/paddle/fluid/operators/abs_op.cc @@ -16,6 +16,7 @@ #include #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/activation_cudnn_op.cu.cc b/paddle/fluid/operators/activation_cudnn_op.cu.cc index b4a97e24cf29233776b19aa0ea7764a00435f6fc..b9d5e5fbe5ebca04303b44d3114e6d7930c3ebe4 100644 --- a/paddle/fluid/operators/activation_cudnn_op.cu.cc +++ b/paddle/fluid/operators/activation_cudnn_op.cu.cc @@ -20,8 +20,8 @@ namespace paddle { namespace operators { using framework::Tensor; using platform::ActivationDescriptor; -using platform::TensorDescriptor; using platform::CUDADeviceContext; +using platform::TensorDescriptor; #ifdef PADDLE_WITH_HIP #define GPUDNN_ACTIVATION_RELU miopenActivationRELU diff --git a/paddle/fluid/operators/activation_op.cc b/paddle/fluid/operators/activation_op.cc index 6905f3d79546e5dcadf2aeec64f85e9a72937e16..e500992e1b5a52ebb0c530b583c175768ceda776 100644 --- a/paddle/fluid/operators/activation_op.cc +++ b/paddle/fluid/operators/activation_op.cc @@ -1454,18 +1454,19 @@ namespace plat = paddle::platform; REGISTER_OPERATOR(KERNEL_TYPE##_grad, ops::ActivationOpGrad, \ ops::ActivationGradOpInplaceInferer); -#define REGISTER_ACTIVATION_CPU_KERNEL(act_type, op_name, functor, \ - grad_functor) \ - REGISTER_OP_CPU_KERNEL( \ - act_type, ops::ActivationKernel>, \ - ops::ActivationKernel>); \ - REGISTER_OP_CPU_KERNEL( \ - act_type##_grad, \ - ops::ActivationGradKernel>, \ - ops::ActivationGradKernel>, \ + ops::ActivationKernel>); \ + REGISTER_OP_CPU_KERNEL( \ + act_type##_grad, \ + ops::ActivationGradKernel>, \ + ops::ActivationGradKernel>); FOR_EACH_ACTIVATION_OP(REGISTER_ACTIVATION_OP); @@ -1781,21 +1782,18 @@ REGISTER_OP_VERSION(hard_shrink) "((x < -threshold) + (x > threshold)); after checkpoint: out = " "x * (((x < -threshold) + (x > threshold)) > 0)")); -REGISTER_OP_VERSION(softplus) - .AddCheckpoint( - R"ROC(add new attributes [beta] and [threshold], and the formula is changed to " +REGISTER_OP_VERSION(softplus).AddCheckpoint( + R"ROC(add new attributes [beta] and [threshold], and the formula is changed to " " softplus(x) = \\frac{1}{beta} * \\log(1 + e^{beta * x}) \\\\ \\text{For numerical" " stability, the implementation reverts to the linear function when: beta * x > threshold.})ROC", - paddle::framework::compatible::OpVersionDesc() - .NewAttr("beta", "The beta value of the new formula", 1.0f) - .NewAttr("threshold", "The threshold value of the new formula", - 20.0f)); - -REGISTER_OP_VERSION(mish) - .AddCheckpoint( - R"ROC(add new attributes [use_mkldnn], and when computing softplus the formula is changed as the new veriosn of softplus)ROC", - paddle::framework::compatible::OpVersionDesc().NewAttr( - "use_mkldnn", "(bool, default false) Only used in mkldnn kernel", - false)); + paddle::framework::compatible::OpVersionDesc() + .NewAttr("beta", "The beta value of the new formula", 1.0f) + .NewAttr("threshold", "The threshold value of the new formula", 20.0f)); + +REGISTER_OP_VERSION(mish).AddCheckpoint( + R"ROC(add new attributes [use_mkldnn], and when computing softplus the formula is changed as the new veriosn of softplus)ROC", + paddle::framework::compatible::OpVersionDesc().NewAttr( + "use_mkldnn", "(bool, default false) Only used in mkldnn kernel", + false)); /* ========================================================================== */ diff --git a/paddle/fluid/operators/activation_op.h b/paddle/fluid/operators/activation_op.h index 5f3916a65e79274e717ed51a91224c5248f171f8..81f5e24abfed5eddaf704005042a583ee723362b 100644 --- a/paddle/fluid/operators/activation_op.h +++ b/paddle/fluid/operators/activation_op.h @@ -12,19 +12,20 @@ limitations under the License. */ #pragma once #include + #include +#include #include #include #include #include #include - -#include #ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES #endif #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/tensor_util.h" @@ -362,9 +363,8 @@ struct Relu6GradFunctor : public BaseActivationFunctor { typename dX> void operator()(Device d, X x, Out out, dOut dout, dX dx) const { dx.device(d) = - dout * - ((out > static_cast(0)) * (out < static_cast(threshold))) - .template cast(); + dout * ((out > static_cast(0)) * (out < static_cast(threshold))) + .template cast(); } static constexpr ActBwdOpFwdDeps FwdDeps() { diff --git a/paddle/fluid/operators/activation_op_xpu.cc b/paddle/fluid/operators/activation_op_xpu.cc index e950f952c24e603d8ea9eef3b86a0beee4b87e1e..4127e4b1b103b2b22f139851d21325c975ec38f9 100644 --- a/paddle/fluid/operators/activation_op_xpu.cc +++ b/paddle/fluid/operators/activation_op_xpu.cc @@ -253,8 +253,9 @@ struct XPUHardSwishFunctor : public BaseActivationFunctor { PADDLE_ENFORCE_EQ(threshold, 6.0f, platform::errors::External( "Not support threshold [%f] in XPU", threshold)); - PADDLE_ENFORCE_EQ(scale, 6.0f, platform::errors::External( - "Not support scale [%f] in XPU", scale)); + PADDLE_ENFORCE_EQ( + scale, 6.0f, + platform::errors::External("Not support scale [%f] in XPU", scale)); PADDLE_ENFORCE_EQ( offset, 3.0f, platform::errors::External("Not support offset [%f] in XPU", offset)); @@ -273,8 +274,9 @@ struct XPUHardSwishGradFunctor : public BaseActivationFunctor { PADDLE_ENFORCE_EQ(threshold, 6.0f, platform::errors::External( "Not support threshold [%f] in XPU", threshold)); - PADDLE_ENFORCE_EQ(scale, 6.0f, platform::errors::External( - "Not support scale [%f] in XPU", scale)); + PADDLE_ENFORCE_EQ( + scale, 6.0f, + platform::errors::External("Not support scale [%f] in XPU", scale)); PADDLE_ENFORCE_EQ( offset, 3.0f, platform::errors::External("Not support offset [%f] in XPU", offset)); @@ -377,10 +379,12 @@ struct XPUPowGradFunctor : public BaseActivationFunctor { auto x_dims = phi::vectorize(x->dims()); auto dy_dims = phi::vectorize(dOut->dims()); auto dx_dims = phi::vectorize(dX->dims()); - PADDLE_ENFORCE_EQ(x_dims, dy_dims, platform::errors::PreconditionNotMet( - "x_dims should match dy_dims.")); - PADDLE_ENFORCE_EQ(x_dims, dx_dims, platform::errors::PreconditionNotMet( - "x_dims should match dx_dims.")); + PADDLE_ENFORCE_EQ( + x_dims, dy_dims, + platform::errors::PreconditionNotMet("x_dims should match dy_dims.")); + PADDLE_ENFORCE_EQ( + x_dims, dx_dims, + platform::errors::PreconditionNotMet("x_dims should match dx_dims.")); float pow_factor = ctx.Attr("factor"); auto xpu_context = diff --git a/paddle/fluid/operators/add_position_encoding_op.cc b/paddle/fluid/operators/add_position_encoding_op.cc index e5fcd270eb8b8fa58175e11e955161ebfbb2846c..4d2c23e2bb440dd9f7d860e60b7433f3147ce255 100644 --- a/paddle/fluid/operators/add_position_encoding_op.cc +++ b/paddle/fluid/operators/add_position_encoding_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/add_position_encoding_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/addmm_op.cc b/paddle/fluid/operators/addmm_op.cc index 716a2e40179e404c2afcec31fb72cde7172f7e54..d0f0a6ae0c679b85985b825db645c5549f5c21df 100644 --- a/paddle/fluid/operators/addmm_op.cc +++ b/paddle/fluid/operators/addmm_op.cc @@ -16,6 +16,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/affine_channel_op.cc b/paddle/fluid/operators/affine_channel_op.cc index 1b584fc5578493205f8f3e3195388a19e874d419..cd6798be2b2ed5b95c8616bfe9008f053c619806 100644 --- a/paddle/fluid/operators/affine_channel_op.cc +++ b/paddle/fluid/operators/affine_channel_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/data_layout.h" #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/affine_channel_op.cu b/paddle/fluid/operators/affine_channel_op.cu index cf4041f721af2579f34c5978e27612478e300307..87a71130b85bf112081edb54d735a6a1792780f0 100644 --- a/paddle/fluid/operators/affine_channel_op.cu +++ b/paddle/fluid/operators/affine_channel_op.cu @@ -81,13 +81,13 @@ class AffineChannelCUDAKernel : public framework::OpKernel { int max_threads = dev_ctx.GetMaxPhysicalThreadCount(); grid = std::min(std::max(max_threads / block, 1), grid); if (layout == framework::DataLayout::kNCHW) { - KeAffineChannelCUDA<<>>( - x_d, scale_d, bias_d, C, HxW, num, y_d); + KeAffineChannelCUDA + <<>>(x_d, scale_d, bias_d, C, HxW, + num, y_d); } else { - KeAffineChannelCUDA<<>>( - x_d, scale_d, bias_d, C, HxW, num, y_d); + KeAffineChannelCUDA + <<>>(x_d, scale_d, bias_d, C, HxW, + num, y_d); } } }; @@ -169,29 +169,29 @@ class AffineChannelGradCUDAKernel : public framework::OpKernel { if (layout == framework::DataLayout::kNCHW) { if (dscale && dbias) { const T* x_d = x->data(); - AffineChannelScaleBiasGradientCUDAKernel< - T, block, framework::DataLayout::kNCHW><<>>( - dy_d, x_d, N, C, HxW, ds_d, db_d); + AffineChannelScaleBiasGradientCUDAKernel + <<>>(dy_d, x_d, N, C, HxW, ds_d, + db_d); } if (dx) { - KeAffineChannelCUDA<<>>( - dy_d, s_d, nullptr, C, HxW, num, dx_d); + KeAffineChannelCUDA + <<>>(dy_d, s_d, nullptr, C, HxW, + num, dx_d); } } else { if (dscale && dbias) { const T* x_d = x->data(); - AffineChannelScaleBiasGradientCUDAKernel< - T, block, framework::DataLayout::kNHWC><<>>( - dy_d, x_d, N, C, HxW, ds_d, db_d); + AffineChannelScaleBiasGradientCUDAKernel + <<>>(dy_d, x_d, N, C, HxW, ds_d, + db_d); } if (dx) { - KeAffineChannelCUDA<<>>( - dy_d, s_d, nullptr, C, HxW, num, dx_d); + KeAffineChannelCUDA + <<>>(dy_d, s_d, nullptr, C, HxW, + num, dx_d); } } } diff --git a/paddle/fluid/operators/affine_channel_op_xpu.cc b/paddle/fluid/operators/affine_channel_op_xpu.cc index db3eedea7ca67bc9db8964b1da63e77cc3e23681..4de233b184aed161d3835149cbe836ab36b8cf92 100644 --- a/paddle/fluid/operators/affine_channel_op_xpu.cc +++ b/paddle/fluid/operators/affine_channel_op_xpu.cc @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/data_layout.h" #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/affine_grid_cudnn_op.cu.cc b/paddle/fluid/operators/affine_grid_cudnn_op.cu.cc index 31801b14564d3e54d5aa81da36c0b5c011853322..6fca4afabd9ccb784a99b2fbff6a556025820baa 100644 --- a/paddle/fluid/operators/affine_grid_cudnn_op.cu.cc +++ b/paddle/fluid/operators/affine_grid_cudnn_op.cu.cc @@ -65,8 +65,9 @@ class CUDNNAffineGridOpKernel : public framework::OpKernel { PADDLE_ENFORCE_EQ( platform::dynload::cudnnSpatialTfGridGeneratorForward( handle, cudnn_st_desc, theta_data, output_data), - 0, platform::errors::Fatal("Some errors has occurred " - "during forward computation in cudnn.")); + 0, + platform::errors::Fatal("Some errors has occurred " + "during forward computation in cudnn.")); } }; diff --git a/paddle/fluid/operators/affine_grid_op.cc b/paddle/fluid/operators/affine_grid_op.cc index e311d21bb54d3f6b5457c6dcfdc0a82a4ff8c35e..d7a49a965a0ee3bbe5ffd71facb3f96309977d56 100644 --- a/paddle/fluid/operators/affine_grid_op.cc +++ b/paddle/fluid/operators/affine_grid_op.cc @@ -13,9 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/affine_grid_op.h" + #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/platform/device/gpu/gpu_dnn.h" diff --git a/paddle/fluid/operators/affine_grid_op.cu b/paddle/fluid/operators/affine_grid_op.cu index eeb4b3bc8a7601c4fc7f13c3cec1d0c03e627e4e..29a540bdc2ce5ef910508c2d436c15ec8bc3da06 100644 --- a/paddle/fluid/operators/affine_grid_op.cu +++ b/paddle/fluid/operators/affine_grid_op.cu @@ -42,8 +42,8 @@ struct Linspace { auto stream = ctx.cuda_device_context().stream(); int block = 512; int grid = (count + block - 1) / block; - LinspaceKernel<<>>(start, slice, count, - number_data); + LinspaceKernel + <<>>(start, slice, count, number_data); } }; diff --git a/paddle/fluid/operators/affine_grid_op.h b/paddle/fluid/operators/affine_grid_op.h index 21540de2b640e3974017eafe49519431482d1730..cbf70b9135be232210749c119ce253a31d9973e2 100644 --- a/paddle/fluid/operators/affine_grid_op.h +++ b/paddle/fluid/operators/affine_grid_op.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/blas/blas.h" diff --git a/paddle/fluid/operators/amp/alloc_float_status_op_npu.cc b/paddle/fluid/operators/amp/alloc_float_status_op_npu.cc index 68f6e3b2f3bd05d7cdb1dc661cb4565069c258fd..78bacc30161783966b8f607fd68edbd84f821d3f 100644 --- a/paddle/fluid/operators/amp/alloc_float_status_op_npu.cc +++ b/paddle/fluid/operators/amp/alloc_float_status_op_npu.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" diff --git a/paddle/fluid/operators/amp/check_finite_and_unscale_op.cu b/paddle/fluid/operators/amp/check_finite_and_unscale_op.cu index 2f6977b9e2da2ef86830c8cc581b7f0ce0076331..7771902c02b1f0681a36edc220b05f1fb4f0559c 100644 --- a/paddle/fluid/operators/amp/check_finite_and_unscale_op.cu +++ b/paddle/fluid/operators/amp/check_finite_and_unscale_op.cu @@ -143,10 +143,10 @@ class CheckFiniteAndUnscaleGpuKernel : public framework::OpKernel { int blocks_per_grid = (total_num + elements_per_block - 1) / elements_per_block; VLOG(3) << "launch kernel"; - CheckFiniteAndUnscale< - T, MPDType><<>>( - d_xs, inverse_scale_v, xs_size, d_starts, found_inf_data, d_outs); + CheckFiniteAndUnscale + <<>>(d_xs, inverse_scale_v, xs_size, d_starts, + found_inf_data, d_outs); VLOG(3) << "finish kernel"; } }; diff --git a/paddle/fluid/operators/amp/check_finite_and_unscale_op_npu_test.cc b/paddle/fluid/operators/amp/check_finite_and_unscale_op_npu_test.cc index 2862d9230768c5fae323921dcf312810ee38c55d..46572579e081cb7890ae52e628888a3979d10def 100644 --- a/paddle/fluid/operators/amp/check_finite_and_unscale_op_npu_test.cc +++ b/paddle/fluid/operators/amp/check_finite_and_unscale_op_npu_test.cc @@ -20,6 +20,7 @@ limitations under the License. */ #include #include #include + #include "gtest/gtest.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" diff --git a/paddle/fluid/operators/amp/check_finite_and_unscale_op_xpu.cc b/paddle/fluid/operators/amp/check_finite_and_unscale_op_xpu.cc index 30266d3eec0e06331c2a2119205ebcf9946e15a2..1d3e5e5162ca9d3b23d4164b6d994a3ae141d5cb 100644 --- a/paddle/fluid/operators/amp/check_finite_and_unscale_op_xpu.cc +++ b/paddle/fluid/operators/amp/check_finite_and_unscale_op_xpu.cc @@ -65,13 +65,15 @@ class CheckFiniteAndUnscaleXPUKernel : public framework::OpKernel { int r = xpu::isfinite(dev_ctx.x_context(), reinterpret_cast(x->data()), is_finite.data(), x->numel()); - PADDLE_ENFORCE_EQ(r, XPU_SUCCESS, platform::errors::External( - "XPU API(isfinite) return wrong " - "value[%d %s]", - r, XPUAPIErrorMsg[r])); - r = xpu::logical_not(dev_ctx.x_context(), reinterpret_cast( - is_finite.data()), - is_finite.data(), x->numel()); + PADDLE_ENFORCE_EQ( + r, XPU_SUCCESS, + platform::errors::External("XPU API(isfinite) return wrong " + "value[%d %s]", + r, XPUAPIErrorMsg[r])); + r = xpu::logical_not( + dev_ctx.x_context(), + reinterpret_cast(is_finite.data()), + is_finite.data(), x->numel()); PADDLE_ENFORCE_EQ( r, XPU_SUCCESS, platform::errors::External("XPU API(logical_not) return wrong " @@ -79,10 +81,11 @@ class CheckFiniteAndUnscaleXPUKernel : public framework::OpKernel { r, XPUAPIErrorMsg[r])); r = xpu::any(dev_ctx.x_context(), is_finite.data(), found_inf_data, x->numel()); - PADDLE_ENFORCE_EQ(r, XPU_SUCCESS, platform::errors::External( - "XPU API(any) return wrong " - "value[%d %s]", - r, XPUAPIErrorMsg[r])); + PADDLE_ENFORCE_EQ( + r, XPU_SUCCESS, + platform::errors::External("XPU API(any) return wrong " + "value[%d %s]", + r, XPUAPIErrorMsg[r])); if (dev_ctx.x_context()->xpu_stream) { dev_ctx.Wait(); } @@ -106,36 +109,40 @@ class CheckFiniteAndUnscaleXPUKernel : public framework::OpKernel { int r = xpu::cast_v2(dev_ctx.x_context(), reinterpret_cast(x->data()), float_x.data(), x->numel()); - PADDLE_ENFORCE_EQ(r, XPU_SUCCESS, platform::errors::External( - "XPU API(cast_v2) return wrong " - "value[%d %s]", - r, XPUAPIErrorMsg[r])); + PADDLE_ENFORCE_EQ( + r, XPU_SUCCESS, + platform::errors::External("XPU API(cast_v2) return wrong " + "value[%d %s]", + r, XPUAPIErrorMsg[r])); r = xpu::scale(dev_ctx.x_context(), float_x.data(), float_out.data(), x->numel(), false, inverse_scale, 0.0); - PADDLE_ENFORCE_EQ(r, XPU_SUCCESS, platform::errors::External( - "XPU API(scale) return wrong " - "value[%d %s]", - r, XPUAPIErrorMsg[r])); + PADDLE_ENFORCE_EQ( + r, XPU_SUCCESS, + platform::errors::External("XPU API(scale) return wrong " + "value[%d %s]", + r, XPUAPIErrorMsg[r])); r = xpu::cast_v2(dev_ctx.x_context(), float_out.data(), reinterpret_cast(out->data()), out->numel()); - PADDLE_ENFORCE_EQ(r, XPU_SUCCESS, platform::errors::External( - "XPU API(cast_v2) return wrong " - "value[%d %s]", - r, XPUAPIErrorMsg[r])); + PADDLE_ENFORCE_EQ( + r, XPU_SUCCESS, + platform::errors::External("XPU API(cast_v2) return wrong " + "value[%d %s]", + r, XPUAPIErrorMsg[r])); } else { int r = xpu::scale(dev_ctx.x_context(), reinterpret_cast(x->data()), reinterpret_cast(out->data()), x->numel(), false, inverse_scale, 0.0); - PADDLE_ENFORCE_EQ(r, XPU_SUCCESS, platform::errors::External( - "XPU API(scale) return wrong " - "value[%d %s]", - r, XPUAPIErrorMsg[r])); + PADDLE_ENFORCE_EQ( + r, XPU_SUCCESS, + platform::errors::External("XPU API(scale) return wrong " + "value[%d %s]", + r, XPUAPIErrorMsg[r])); } } if (dev_ctx.x_context()->xpu_stream) { diff --git a/paddle/fluid/operators/amp/clear_float_status_op_npu.cc b/paddle/fluid/operators/amp/clear_float_status_op_npu.cc index e5a2d93e32fe23e27f6f5ad4e508ef05ac2b7d75..c102bd2ba47bd99dbd58eec8c2064ea6eaf4d400 100644 --- a/paddle/fluid/operators/amp/clear_float_status_op_npu.cc +++ b/paddle/fluid/operators/amp/clear_float_status_op_npu.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" diff --git a/paddle/fluid/operators/amp/get_float_status_op_npu.cc b/paddle/fluid/operators/amp/get_float_status_op_npu.cc index 8109a1ff43ff2bf0e2f6d0cbd5732e116c1f2a23..0c1187616503bd2a9092094df8384a427f61a601 100644 --- a/paddle/fluid/operators/amp/get_float_status_op_npu.cc +++ b/paddle/fluid/operators/amp/get_float_status_op_npu.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" diff --git a/paddle/fluid/operators/amp/update_loss_scaling_op.cc b/paddle/fluid/operators/amp/update_loss_scaling_op.cc index 8354650df0237e502d79a59aa8e47f8c07febf31..baf742b0b404bfa50b5be3ed0dd75f42e46e3fc3 100644 --- a/paddle/fluid/operators/amp/update_loss_scaling_op.cc +++ b/paddle/fluid/operators/amp/update_loss_scaling_op.cc @@ -13,9 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/amp/update_loss_scaling_op.h" + #include #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/amp/update_loss_scaling_op.cu b/paddle/fluid/operators/amp/update_loss_scaling_op.cu index 43f8f84578c701aa76804201d47b0e1811c6799c..81f986434411cfffb7793a79d086c94923cc4c88 100644 --- a/paddle/fluid/operators/amp/update_loss_scaling_op.cu +++ b/paddle/fluid/operators/amp/update_loss_scaling_op.cu @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/amp/update_loss_scaling_op.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/operators/amp/update_loss_scaling_op.h b/paddle/fluid/operators/amp/update_loss_scaling_op.h index 41eb94247f59374514cfd0b600608f60dd5b521e..f4c6b6f1f7d8dd4669eac8aec564edd587a4f7e2 100644 --- a/paddle/fluid/operators/amp/update_loss_scaling_op.h +++ b/paddle/fluid/operators/amp/update_loss_scaling_op.h @@ -19,6 +19,7 @@ #endif // PADDLE_WITH_CUDA && __NVCC__ #include #include + #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/operators/amp/fp16_type_traits.h" #include "paddle/fluid/platform/device_context.h" diff --git a/paddle/fluid/operators/amp/update_loss_scaling_op_npu.cc b/paddle/fluid/operators/amp/update_loss_scaling_op_npu.cc index f9a93a47ff2be3ec3677dfab71424fcf957d3ab4..da7e23c4620bacf71531eb0f44cd654dfe694490 100644 --- a/paddle/fluid/operators/amp/update_loss_scaling_op_npu.cc +++ b/paddle/fluid/operators/amp/update_loss_scaling_op_npu.cc @@ -12,11 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/amp/update_loss_scaling_op.h" #include #include + #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/op_registry.h" +#include "paddle/fluid/operators/amp/update_loss_scaling_op.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" DECLARE_int32(min_loss_scaling); diff --git a/paddle/fluid/operators/amp/update_loss_scaling_op_xpu.cc b/paddle/fluid/operators/amp/update_loss_scaling_op_xpu.cc index fe03d93f4480fd633d5855081b668e529a6d2895..8f57e00fe1117fbc6dcf82d0729d71c50096e721 100644 --- a/paddle/fluid/operators/amp/update_loss_scaling_op_xpu.cc +++ b/paddle/fluid/operators/amp/update_loss_scaling_op_xpu.cc @@ -13,12 +13,13 @@ See the License for the specific language governing permissions and limitations under the License. */ #ifdef PADDLE_WITH_XPU -#include "paddle/fluid/operators/amp/update_loss_scaling_op.h" #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/amp/fp16_type_traits.h" +#include "paddle/fluid/operators/amp/update_loss_scaling_op.h" #include "paddle/fluid/platform/float16.h" namespace paddle { @@ -59,10 +60,11 @@ class UpdateLossScalingXPUKernel : public framework::OpKernel { r = xpu::constant(dev_ctx.x_context(), reinterpret_cast(out_data), num, XPUTyp(0.0)); - PADDLE_ENFORCE_EQ(r, XPU_SUCCESS, platform::errors::External( - "XPU API(constant) return wrong " - "value[%d %s]", - r, XPUAPIErrorMsg[r])); + PADDLE_ENFORCE_EQ( + r, XPU_SUCCESS, + platform::errors::External("XPU API(constant) return wrong " + "value[%d %s]", + r, XPUAPIErrorMsg[r])); } } const bool stop_update = ctx.Attr("stop_update"); diff --git a/paddle/fluid/operators/angle_op.h b/paddle/fluid/operators/angle_op.h index 116a8053db3edb724d2c68b93d92ce958fbe8e32..ace345465dc2590b2c1fb6d3366e92c111beb7d9 100644 --- a/paddle/fluid/operators/angle_op.h +++ b/paddle/fluid/operators/angle_op.h @@ -17,11 +17,11 @@ #define _USE_MATH_DEFINES #endif #include -#include "paddle/phi/kernels/funcs/complex_functors.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/platform/for_range.h" +#include "paddle/phi/kernels/funcs/complex_functors.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/arg_max_op.cc b/paddle/fluid/operators/arg_max_op.cc index c5e4188ca2d6f749a06127c41da99490a7fb3ffc..63fd27a1edf7ab336d5c99fcf5f871ed702ad362 100644 --- a/paddle/fluid/operators/arg_max_op.cc +++ b/paddle/fluid/operators/arg_max_op.cc @@ -12,10 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/operators/arg_min_max_op_base.h" - -#include "paddle/fluid/framework/infershape_utils.h" #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/infermeta/unary.h" @@ -28,20 +27,18 @@ REGISTER_OPERATOR( paddle::framework::EmptyGradOpMaker, ArgMaxInferShapeFunctor); -REGISTER_OP_VERSION(arg_max) - .AddCheckpoint( - R"ROC( +REGISTER_OP_VERSION(arg_max).AddCheckpoint( + R"ROC( Upgrade argmax add a new attribute [flatten] and modify the attribute of dtype)ROC", - paddle::framework::compatible::OpVersionDesc() - .NewAttr("flatten", - "In order to compute the argmax over the flattened array " - "when the " - "argument `axis` in python API is None.", - false) - .ModifyAttr( - "dtype", - "Change the default value of dtype from -1 to 3" - ", means return the int64 indices directly. The rearse why " - "changing the default value is that the int64 value in " - "VarType is 3 in the frameworke.proto.", - 3)); + paddle::framework::compatible::OpVersionDesc() + .NewAttr("flatten", + "In order to compute the argmax over the flattened array " + "when the " + "argument `axis` in python API is None.", + false) + .ModifyAttr("dtype", + "Change the default value of dtype from -1 to 3" + ", means return the int64 indices directly. The rearse why " + "changing the default value is that the int64 value in " + "VarType is 3 in the frameworke.proto.", + 3)); diff --git a/paddle/fluid/operators/arg_min_max_op_base.h b/paddle/fluid/operators/arg_min_max_op_base.h index 585341beea12c14fbd01a3a47af34ce57def0db5..194a3070bf683709f879c7dd5a179939128ee7f5 100644 --- a/paddle/fluid/operators/arg_min_max_op_base.h +++ b/paddle/fluid/operators/arg_min_max_op_base.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/arg_min_op.cc b/paddle/fluid/operators/arg_min_op.cc index fb3abd01af8c396d764f9f1d247f24c41bd15959..c995d56cf6b09d670ac2aecd072bfec2ff0c1616 100644 --- a/paddle/fluid/operators/arg_min_op.cc +++ b/paddle/fluid/operators/arg_min_op.cc @@ -27,20 +27,18 @@ REGISTER_OPERATOR( paddle::framework::EmptyGradOpMaker, ArgMinInferShapeFunctor); -REGISTER_OP_VERSION(arg_min) - .AddCheckpoint( - R"ROC( +REGISTER_OP_VERSION(arg_min).AddCheckpoint( + R"ROC( Upgrade argmin add a new attribute [flatten] and modify the attribute of dtype)ROC", - paddle::framework::compatible::OpVersionDesc() - .NewAttr("flatten", - "In order to compute the argmin over the flattened array " - "when the " - "argument `axis` in python API is None.", - false) - .ModifyAttr( - "dtype", - "Change the default value of dtype from -1 to 3" - ", means return the int64 indices directly. The rearse why " - "changing the default value is that the int64 value in " - "VarType is 3 in the frameworke.proto.", - 3)); + paddle::framework::compatible::OpVersionDesc() + .NewAttr("flatten", + "In order to compute the argmin over the flattened array " + "when the " + "argument `axis` in python API is None.", + false) + .ModifyAttr("dtype", + "Change the default value of dtype from -1 to 3" + ", means return the int64 indices directly. The rearse why " + "changing the default value is that the int64 value in " + "VarType is 3 in the frameworke.proto.", + 3)); diff --git a/paddle/fluid/operators/array_operator.h b/paddle/fluid/operators/array_operator.h index af44a77c8131dbbeaea5fe7eed92671ee86e6df5..0cc3b695aef93f4a7872da60d9c230be3667d97d 100644 --- a/paddle/fluid/operators/array_operator.h +++ b/paddle/fluid/operators/array_operator.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/lod_tensor_array.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device_context.h" diff --git a/paddle/fluid/operators/array_to_lod_tensor_op.cc b/paddle/fluid/operators/array_to_lod_tensor_op.cc index 1db3592b1cfab9351a782c96bcbf9aefb22db120..f0824695a060f3cc336a79b461d2e0292629c53a 100644 --- a/paddle/fluid/operators/array_to_lod_tensor_op.cc +++ b/paddle/fluid/operators/array_to_lod_tensor_op.cc @@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/phi/core/lod_utils.h" diff --git a/paddle/fluid/operators/ascend_trigger_op.h b/paddle/fluid/operators/ascend_trigger_op.h index eaa79da2ba8ee02e782befb5fddb40920c5ec6ff..d1eaa00c2a3e0c3edd9986883c3ecc3b94c7ece5 100644 --- a/paddle/fluid/operators/ascend_trigger_op.h +++ b/paddle/fluid/operators/ascend_trigger_op.h @@ -15,6 +15,7 @@ #pragma once #include #include + #include "paddle/fluid/framework/op_registry.h" #ifdef PADDLE_WITH_ASCEND #include "paddle/fluid/framework/fleet/ascend_wrapper.h" diff --git a/paddle/fluid/operators/assign_op_xpu.cc b/paddle/fluid/operators/assign_op_xpu.cc index b95be3096f071c86d3c163dce0a440ea6eee0024..7d03982f6ad0353c735eedbc8dd27f8d94ea460f 100644 --- a/paddle/fluid/operators/assign_op_xpu.cc +++ b/paddle/fluid/operators/assign_op_xpu.cc @@ -13,10 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #ifdef PADDLE_WITH_XPU -#include "paddle/fluid/operators/assign_op.h" - #include +#include "paddle/fluid/operators/assign_op.h" + namespace paddle { namespace framework { class OpDesc; diff --git a/paddle/fluid/operators/attention_lstm_op.cc b/paddle/fluid/operators/attention_lstm_op.cc index bf7d609370a8d06064db6a2d621be77dc72c188f..22db7d9e982c272fc088cc4e99787d471ac27014 100644 --- a/paddle/fluid/operators/attention_lstm_op.cc +++ b/paddle/fluid/operators/attention_lstm_op.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/attention_lstm_op.h" + #include + #include "paddle/fluid/platform/cpu_info.h" #include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/cpu_vec.h" @@ -62,8 +64,9 @@ void AttentionLSTMOp::InferShape(framework::InferShapeContext* ctx) const { "LSTMWeight dims should be (%d + %d) * %d.", D, M, 4 * D)); auto b_dims = ctx->GetInputDim("LSTMBias"); - PADDLE_ENFORCE_EQ(b_dims.size(), 2, platform::errors::InvalidArgument( - "Input(LSTMBias)'s rank must be 2.")); + PADDLE_ENFORCE_EQ( + b_dims.size(), 2, + platform::errors::InvalidArgument("Input(LSTMBias)'s rank must be 2.")); PADDLE_ENFORCE_EQ(b_dims[0], 1, platform::errors::InvalidArgument( "LSTMBias dims should be 1 x %d.", 4 * D)); @@ -72,11 +75,13 @@ void AttentionLSTMOp::InferShape(framework::InferShapeContext* ctx) const { "LSTMBias dims should be 1 x %d.", 4 * D)); auto c_dims = ctx->GetInputDim("C0"); - PADDLE_ENFORCE_EQ(c_dims.size(), 2, platform::errors::InvalidArgument( - "Input(C0)'s rank must be 2.")); + PADDLE_ENFORCE_EQ( + c_dims.size(), 2, + platform::errors::InvalidArgument("Input(C0)'s rank must be 2.")); if (ctx->IsRuntime()) { - PADDLE_ENFORCE_EQ(c_dims[1], D, platform::errors::InvalidArgument( - "C0 dims should be N x %d.", D)); + PADDLE_ENFORCE_EQ( + c_dims[1], D, + platform::errors::InvalidArgument("C0 dims should be N x %d.", D)); } if (ctx->HasInput("H0")) { @@ -126,10 +131,12 @@ void AttentionLSTMOp::InferShape(framework::InferShapeContext* ctx) const { PADDLE_ENFORCE_EQ(dims.size(), 2, platform::errors::InvalidArgument( "Input(AttentionScalar)'s rank must be 2.")); - PADDLE_ENFORCE_EQ(dims[0], 1, platform::errors::InvalidArgument( - "AttentionScalar shapes must be 1 * 1.")); - PADDLE_ENFORCE_EQ(dims[1], 1, platform::errors::InvalidArgument( - "AttentionScalar shapes must be 1 * 1.")); + PADDLE_ENFORCE_EQ(dims[0], 1, + platform::errors::InvalidArgument( + "AttentionScalar shapes must be 1 * 1.")); + PADDLE_ENFORCE_EQ(dims[1], 1, + platform::errors::InvalidArgument( + "AttentionScalar shapes must be 1 * 1.")); } if (ctx->HasInput("AttentionScalarBias")) { @@ -332,14 +339,15 @@ class AttentionLSTMKernel : public framework::OpKernel { int len = x_lod[0][i + 1] - x_lod[0][i]; max_seq_len = max_seq_len < len ? len : max_seq_len; } - PADDLE_ENFORCE_EQ(x_lod.size(), 1UL, platform::errors::InvalidArgument( - "Input(X)'s lod size must be 1.")); + PADDLE_ENFORCE_EQ( + x_lod.size(), 1UL, + platform::errors::InvalidArgument("Input(X)'s lod size must be 1.")); PADDLE_ENFORCE_EQ( c0->dims()[0], N, platform::errors::InvalidArgument("C0 dims should be %d x %d.", N, D)); fc_out->Resize({max_seq_len, 1}); - std::function act_gate, act_cell, act_cand; + std::function act_gate, act_cell, act_cand; auto& act_gate_str = ctx.Attr("gate_activation"); auto& act_cell_str = ctx.Attr("cell_activation"); auto& act_cand_str = ctx.Attr("candidate_activation"); diff --git a/paddle/fluid/operators/average_accumulates_op.h b/paddle/fluid/operators/average_accumulates_op.h index 289dda56b19df7db1e3d27bb027e068588614ed9..de6eca3903f88ce917962c5729cac031ca9cb59c 100644 --- a/paddle/fluid/operators/average_accumulates_op.h +++ b/paddle/fluid/operators/average_accumulates_op.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/batch_fc_op.cc b/paddle/fluid/operators/batch_fc_op.cc index 952625bcb6e46e33db4658d5257bf6359b7c1174..2d2deae69a783d4d2876eaaada6bcafba490e52d 100644 --- a/paddle/fluid/operators/batch_fc_op.cc +++ b/paddle/fluid/operators/batch_fc_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/batch_fc_op.h" + #include namespace paddle { @@ -42,8 +43,9 @@ class BatchFCOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ(input_dims.size(), 3, platform::errors::InvalidArgument( "Input of BatchFCOp should have 3D.")); - PADDLE_ENFORCE_EQ(w_dims.size(), 3, platform::errors::InvalidArgument( - "W of BatchFCOp should have 3D.")); + PADDLE_ENFORCE_EQ( + w_dims.size(), 3, + platform::errors::InvalidArgument("W of BatchFCOp should have 3D.")); PADDLE_ENFORCE_EQ( input_dims[0], w_dims[0], platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/batch_fc_op.cu b/paddle/fluid/operators/batch_fc_op.cu index ddedf0172be82161161e79c7ea716a216124fdf9..5843acb4fdd0c8ee816c2ee30d5c63749f96f658 100644 --- a/paddle/fluid/operators/batch_fc_op.cu +++ b/paddle/fluid/operators/batch_fc_op.cu @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/operators/batch_fc_op.h" #include "paddle/fluid/platform/device/gpu/gpu_info.h" diff --git a/paddle/fluid/operators/batch_norm_op.cc b/paddle/fluid/operators/batch_norm_op.cc index 2663a081011573063f671269e6ec1ba17969e9a1..67384338d764ebc01337284c5d78586ad38a29c3 100644 --- a/paddle/fluid/operators/batch_norm_op.cc +++ b/paddle/fluid/operators/batch_norm_op.cc @@ -13,9 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/batch_norm_op.h" + #include #include #include + #include "paddle/fluid/framework/data_layout.h" #ifdef PADDLE_WITH_MKLDNN #include "paddle/fluid/platform/mkldnn_helper.h" @@ -167,10 +169,11 @@ framework::OpKernelType BatchNormOp::GetExpectedKernelType( bn_param_type, framework::TransToProtoVarType(ctx.Input("Mean")->dtype()), platform::errors::InvalidArgument("Mean input should be of float type")); - PADDLE_ENFORCE_EQ(bn_param_type, framework::TransToProtoVarType( - ctx.Input("Variance")->dtype()), - platform::errors::InvalidArgument( - "Variance input should be of float type")); + PADDLE_ENFORCE_EQ( + bn_param_type, + framework::TransToProtoVarType(ctx.Input("Variance")->dtype()), + platform::errors::InvalidArgument( + "Variance input should be of float type")); // TODO(pzelazko-intel): enable MKLDNN layout when it's ready framework::LibraryType library = framework::LibraryType::kPlain; diff --git a/paddle/fluid/operators/batch_norm_op.h b/paddle/fluid/operators/batch_norm_op.h index d274e8d2c006d7cbfe8337eab5c6d9a57a62e5ca..b82b49e5cd58e74c1a0790012855d3409add76c8 100644 --- a/paddle/fluid/operators/batch_norm_op.h +++ b/paddle/fluid/operators/batch_norm_op.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/layout_utils.h" diff --git a/paddle/fluid/operators/batch_norm_op_mlu.cc b/paddle/fluid/operators/batch_norm_op_mlu.cc index 6507890a8b5dcd7a415215caf51bd05c2857db5e..6dff315aa6a214668c80226bfcc0e1f448c39e68 100644 --- a/paddle/fluid/operators/batch_norm_op_mlu.cc +++ b/paddle/fluid/operators/batch_norm_op_mlu.cc @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/batch_norm_op.h" #include "paddle/fluid/operators/amp/fp16_type_traits.h" +#include "paddle/fluid/operators/batch_norm_op.h" #include "paddle/fluid/operators/mlu/mlu_baseop.h" namespace paddle { diff --git a/paddle/fluid/operators/batch_norm_op_npu.cc b/paddle/fluid/operators/batch_norm_op_npu.cc index ae03ecbcb16a0441cdb87e0ec579c07d872bc9a2..725b7f3848f4a790cadaa00c4af702be6754ab93 100644 --- a/paddle/fluid/operators/batch_norm_op_npu.cc +++ b/paddle/fluid/operators/batch_norm_op_npu.cc @@ -113,8 +113,9 @@ class NPUBatchNormOpKernel : public framework::OpKernel { runner_reduce.Run(stream); const auto &runner_update = NpuOpRunner( - "BNTrainingUpdate", {x_tensor, sum, square_sum, *scale, *bias, - *running_mean, *running_var}, + "BNTrainingUpdate", + {x_tensor, sum, square_sum, *scale, *bias, *running_mean, + *running_var}, {y_tesnor, *mean_out, *variance_out, *saved_mean, *saved_variance}, {{"factor", momentum}, {"epsilon", epsilon}}); runner_update.Run(stream); @@ -216,10 +217,11 @@ class NPUBatchNormGradOpKernel : public framework::OpKernel { {dx_tensor}, {{"epsilon", epsilon}}); runner_infer.Run(stream); } else { - const auto &runner_reduce = NpuOpRunner( - "BNTrainingReduceGrad", {dy_tensor, x_tensor, *d_scale, *d_bias, - *scale, *saved_mean, *saved_inv_variance}, - {dx_tensor}, {{"epsilon", epsilon}}); + const auto &runner_reduce = + NpuOpRunner("BNTrainingReduceGrad", + {dy_tensor, x_tensor, *d_scale, *d_bias, *scale, + *saved_mean, *saved_inv_variance}, + {dx_tensor}, {{"epsilon", epsilon}}); runner_reduce.Run(stream); } } diff --git a/paddle/fluid/operators/batch_norm_op_xpu.cc b/paddle/fluid/operators/batch_norm_op_xpu.cc index 0893324c602a88048100b1b05c870986e2542aee..3ade2f36ad89f5eacb5b35406c713d96c91c51d5 100644 --- a/paddle/fluid/operators/batch_norm_op_xpu.cc +++ b/paddle/fluid/operators/batch_norm_op_xpu.cc @@ -13,10 +13,11 @@ limitations under the License. */ #ifdef PADDLE_WITH_XPU -#include "paddle/fluid/operators/batch_norm_op.h" #include #include +#include "paddle/fluid/operators/batch_norm_op.h" + namespace paddle { namespace operators { @@ -128,8 +129,9 @@ static int calculate_inv_BN_Y(xpu::Context *ctx, T *x, const T *scale, const T *bias, const T *mean, const T *variance, const int N, const int C, const int M, const T *y) { - PADDLE_ENFORCE_EQ(x, y, platform::errors::InvalidArgument( - "X and Y should be inplaced in inplace mode")); + PADDLE_ENFORCE_EQ(x, y, + platform::errors::InvalidArgument( + "X and Y should be inplaced in inplace mode")); std::vector tensor_shape_vec({N, C, M}); std::vector array_shape_vec({1, C, 1}); // y - bias @@ -207,8 +209,9 @@ class BatchNormGradXPUKernel : public framework::OpKernel { is_inplace = false; if (d_x) { PADDLE_ENFORCE_NE( - d_x, d_y, platform::errors::InvalidArgument( - "X@GRAD and Y@GRAD inplaced in non-inplace mode")); + d_x, d_y, + platform::errors::InvalidArgument( + "X@GRAD and Y@GRAD inplaced in non-inplace mode")); } } @@ -275,11 +278,12 @@ class BatchNormGradXPUKernel : public framework::OpKernel { int r1 = calculate_inv_var(dev_ctx.x_context(), global_var->data(), epsilon, C, epsilon_data, global_inv_std_data); - PADDLE_ENFORCE_EQ(r1, XPU_SUCCESS, platform::errors::External( - "XPU API(batch_norm_grad " - "calculate_inv_var function) " - "return wrong value[%d %s]", - r1, XPUAPIErrorMsg[r1])); + PADDLE_ENFORCE_EQ( + r1, XPU_SUCCESS, + platform::errors::External("XPU API(batch_norm_grad " + "calculate_inv_var function) " + "return wrong value[%d %s]", + r1, XPUAPIErrorMsg[r1])); } auto px = *x; auto *inv_std_data = @@ -290,11 +294,12 @@ class BatchNormGradXPUKernel : public framework::OpKernel { dev_ctx.x_context(), px.mutable_data(ctx.GetPlace()), scale->data(), bias->data(), mean_data, inv_std_data, N, C, H * W, x->data()); - PADDLE_ENFORCE_EQ(r2, XPU_SUCCESS, platform::errors::External( - "XPU API(batch_norm_grad " - "calculate_inv_BN_Y function) " - "return wrong value[%d %s]", - r2, XPUAPIErrorMsg[r2])); + PADDLE_ENFORCE_EQ( + r2, XPU_SUCCESS, + platform::errors::External("XPU API(batch_norm_grad " + "calculate_inv_BN_Y function) " + "return wrong value[%d %s]", + r2, XPUAPIErrorMsg[r2])); } int r3; @@ -319,10 +324,11 @@ class BatchNormGradXPUKernel : public framework::OpKernel { scale_data, batch_mean->data(), batch_inv_std->data(), d_scale_data, d_bias_data, is_nchw); } - PADDLE_ENFORCE_EQ(r3, XPU_SUCCESS, platform::errors::External( - "XPU API(batch_norm_grad) return " - "wrong value[%d %s]", - r3, XPUAPIErrorMsg[r3])); + PADDLE_ENFORCE_EQ( + r3, XPU_SUCCESS, + platform::errors::External("XPU API(batch_norm_grad) return " + "wrong value[%d %s]", + r3, XPUAPIErrorMsg[r3])); } }; diff --git a/paddle/fluid/operators/batch_size_like.h b/paddle/fluid/operators/batch_size_like.h index facb4cd82542b251695087ff2d129606199bb7a0..1cc6e36467767307a50d66e9700dbfc0cd96d7bd 100644 --- a/paddle/fluid/operators/batch_size_like.h +++ b/paddle/fluid/operators/batch_size_like.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include #include + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/beam_search_decode_op.cc b/paddle/fluid/operators/beam_search_decode_op.cc index 3fae65c50177bb36abf6f75390f59ab2c8ec3580..0e3e32666a83276601a6cffa30d66b095ee7beef 100644 --- a/paddle/fluid/operators/beam_search_decode_op.cc +++ b/paddle/fluid/operators/beam_search_decode_op.cc @@ -12,10 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/operators/beam_search_decode_op.h" + #include #include "paddle/fluid/framework/convert_utils.h" -#include "paddle/fluid/operators/beam_search_decode_op.h" #include "paddle/fluid/platform/device_context.h" namespace paddle { diff --git a/paddle/fluid/operators/beam_search_decode_op_test.cc b/paddle/fluid/operators/beam_search_decode_op_test.cc index cf32e407424419bd5a8a59a935f219b6e4433899..6f70136b2d213dda03d6b1345dc8655ea013a9b6 100644 --- a/paddle/fluid/operators/beam_search_decode_op_test.cc +++ b/paddle/fluid/operators/beam_search_decode_op_test.cc @@ -103,11 +103,9 @@ TEST(BeamSearchDecodeOp, Backtrace) { std::vector{1, 1, 3, 5}, &ids, &scores); paddle::test::GenerateExample( std::vector{0, 2, 4}, - std::vector{0, 0, 0, 2, - 2}, // the branchs of the first source sentence - // are pruned since finished - std::vector{5, 1}, - &ids, &scores); + std::vector{0, 0, 0, 2, 2}, // the branchs of the first source + // sentence are pruned since finished + std::vector{5, 1}, &ids, &scores); ASSERT_EQ(ids.size(), 5UL); ASSERT_EQ(scores.size(), 5UL); diff --git a/paddle/fluid/operators/beam_search_op.cc b/paddle/fluid/operators/beam_search_op.cc index 887d28f5875e366503e67ac21f78f846f6e21a1a..90b6359f447ef0cf320477a8281c95528ebaaa89 100644 --- a/paddle/fluid/operators/beam_search_op.cc +++ b/paddle/fluid/operators/beam_search_op.cc @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/beam_search_op.cu.cc b/paddle/fluid/operators/beam_search_op.cu.cc index 4ef9476eee5d3fac4decd7273da824b2f2349199..15aca070221b057b66733dab6407a9ff575447cd 100644 --- a/paddle/fluid/operators/beam_search_op.cu.cc +++ b/paddle/fluid/operators/beam_search_op.cu.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/beam_search_op.h" + #include "paddle/fluid/framework/op_registry.h" namespace ops = paddle::operators; diff --git a/paddle/fluid/operators/beam_search_op_npu.cc b/paddle/fluid/operators/beam_search_op_npu.cc index cae3d0e55fc5dcdc0a15a10ea6d152c3a93cf1c9..f5fa0ac026d57645e444e0e40b08e91313db72f9 100644 --- a/paddle/fluid/operators/beam_search_op_npu.cc +++ b/paddle/fluid/operators/beam_search_op_npu.cc @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/beam_search_op.h" #include "paddle/fluid/framework/op_registry.h" +#include "paddle/fluid/operators/beam_search_op.h" namespace ops = paddle::operators; REGISTER_OP_NPU_KERNEL( diff --git a/paddle/fluid/operators/benchmark/op_tester.cc b/paddle/fluid/operators/benchmark/op_tester.cc index 4b1593b1f8b40c0c4380007f85f9bb74fea9cd44..fc01eef8058c35c60c238219afdcae9432a3a61a 100644 --- a/paddle/fluid/operators/benchmark/op_tester.cc +++ b/paddle/fluid/operators/benchmark/op_tester.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/benchmark/op_tester.h" + #include + #include "gflags/gflags.h" #include "gtest/gtest.h" #include "paddle/fluid/framework/op_info.h" diff --git a/paddle/fluid/operators/benchmark/op_tester.h b/paddle/fluid/operators/benchmark/op_tester.h index 6acd42c8675cbff6daefaf922a30e7f563a82931..217fbe2653e3d9b414e51b1894cdc93e2d11e8ed 100644 --- a/paddle/fluid/operators/benchmark/op_tester.h +++ b/paddle/fluid/operators/benchmark/op_tester.h @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_desc.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/operators/benchmark/op_tester_config.h" diff --git a/paddle/fluid/operators/benchmark/op_tester_config.cc b/paddle/fluid/operators/benchmark/op_tester_config.cc index e9477798858d13e7a2862081561634011f9156c8..d7a055ede1b73a72447c4e1282060a77fccb31bf 100644 --- a/paddle/fluid/operators/benchmark/op_tester_config.cc +++ b/paddle/fluid/operators/benchmark/op_tester_config.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/benchmark/op_tester_config.h" + #include + #include "paddle/fluid/platform/enforce.h" namespace paddle { diff --git a/paddle/fluid/operators/bilateral_slice_op.cc b/paddle/fluid/operators/bilateral_slice_op.cc index 675566504c2114e1632976273335574b40b0013c..124441093d3a502ce461a6310d35adae57049dee 100644 --- a/paddle/fluid/operators/bilateral_slice_op.cc +++ b/paddle/fluid/operators/bilateral_slice_op.cc @@ -10,9 +10,11 @@ limitations under the License. */ #include "paddle/fluid/operators/bilateral_slice_op.h" + #include #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/bilateral_slice_op.cu b/paddle/fluid/operators/bilateral_slice_op.cu index e7bf6d212dcf1730c32ed794576d569dff96f215..f20debdf0b815117bb47195326c4569588aecef4 100644 --- a/paddle/fluid/operators/bilateral_slice_op.cu +++ b/paddle/fluid/operators/bilateral_slice_op.cu @@ -11,6 +11,7 @@ #include #include + #include "paddle/fluid/operators/bilateral_slice_op.h" #include "paddle/fluid/platform/device/gpu/gpu_launch_config.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" @@ -167,11 +168,11 @@ class BilateralSliceOpCUDAKernel : public framework::OpKernel { platform::GpuLaunchConfig config = platform::GetGpuLaunchConfig1D(ctx.cuda_device_context(), total_count); - BilateralSliceCudaForwardKernel< - T><<>>( - output_data, grid_data, guide_data, input_data, grid_sizes, has_offset, - total_count, output_dims[1]); + BilateralSliceCudaForwardKernel + <<>>( + output_data, grid_data, guide_data, input_data, grid_sizes, + has_offset, total_count, output_dims[1]); } }; @@ -475,29 +476,29 @@ class BilateralSliceGradOpCUDAKernel : public framework::OpKernel { platform::GpuLaunchConfig config = platform::GetGpuLaunchConfig1D(ctx.cuda_device_context(), grid_count); - BilateralSliceCudaGridGradKernel< - T><<>>( - grid_grad_data, output_grad_data, guide_data, input_data, grid_sizes, - has_offset, grid_count, output_chans); + BilateralSliceCudaGridGradKernel + <<>>( + grid_grad_data, output_grad_data, guide_data, input_data, + grid_sizes, has_offset, grid_count, output_chans); config = platform::GetGpuLaunchConfig1D(ctx.cuda_device_context(), guide_count); - BilateralSliceCudaGuideGradKernel< - T><<>>( - guide_grad_data, output_grad_data, grid_data, guide_data, input_data, - grid_sizes, has_offset, guide_count, output_chans); + BilateralSliceCudaGuideGradKernel + <<>>( + guide_grad_data, output_grad_data, grid_data, guide_data, + input_data, grid_sizes, has_offset, guide_count, output_chans); config = platform::GetGpuLaunchConfig1D(ctx.cuda_device_context(), input_count); - BilateralSliceCudaInputGradKernel< - T><<>>( - input_grad_data, output_grad_data, grid_data, guide_data, grid_sizes, - has_offset, input_count, output_chans); + BilateralSliceCudaInputGradKernel + <<>>( + input_grad_data, output_grad_data, grid_data, guide_data, + grid_sizes, has_offset, input_count, output_chans); } }; diff --git a/paddle/fluid/operators/bilateral_slice_op.h b/paddle/fluid/operators/bilateral_slice_op.h index a388f4763ec681a6bdd06e147cdd54be0616e0fa..66783f151ea06a1fa10d904200447b9ed3aaa7b5 100644 --- a/paddle/fluid/operators/bilateral_slice_op.h +++ b/paddle/fluid/operators/bilateral_slice_op.h @@ -12,6 +12,7 @@ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/hostdevice.h" diff --git a/paddle/fluid/operators/bmm_op.cc b/paddle/fluid/operators/bmm_op.cc index 6b5f4755d771e2268126e08491533611e0f46a6d..16066c1a13e41b39131e2161c7d4bca95d68624f 100644 --- a/paddle/fluid/operators/bmm_op.cc +++ b/paddle/fluid/operators/bmm_op.cc @@ -13,6 +13,7 @@ * limitations under the License. */ #include "paddle/fluid/operators/bmm_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/bmm_op.h b/paddle/fluid/operators/bmm_op.h index 3fecb55caaeea8bf10eef3af3532bf0830f68a05..271a74a44442c379b090e0fc4dd2a185dab40fb9 100644 --- a/paddle/fluid/operators/bmm_op.h +++ b/paddle/fluid/operators/bmm_op.h @@ -18,6 +18,7 @@ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/phi/kernels/funcs/blas/blas.h" diff --git a/paddle/fluid/operators/bmm_op_xpu.cc b/paddle/fluid/operators/bmm_op_xpu.cc index cc18558027982b7e496c442333c7e8399b4abbe3..348f25d46b4c5dd417a32dddb7b4ddc461d7b17d 100644 --- a/paddle/fluid/operators/bmm_op_xpu.cc +++ b/paddle/fluid/operators/bmm_op_xpu.cc @@ -16,8 +16,8 @@ #include #include -#include "paddle/fluid/operators/matmul_v2_op.h" +#include "paddle/fluid/operators/matmul_v2_op.h" #include "paddle/fluid/operators/xpu_api_wrapper.h" #include "paddle/fluid/platform/device/device_wrapper.h" diff --git a/paddle/fluid/operators/bpr_loss_op.cc b/paddle/fluid/operators/bpr_loss_op.cc index bbe4bb08adf27d3ea36b8396fd544cf8bbd03e42..afa7aee44504322e6657ee2c041f913f4764f46a 100644 --- a/paddle/fluid/operators/bpr_loss_op.cc +++ b/paddle/fluid/operators/bpr_loss_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/bpr_loss_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/bpr_loss_op.h b/paddle/fluid/operators/bpr_loss_op.h index 993bc0fccf07d8bd4cc52732c423d6fe21b711f3..fd6df2c15947025792c14e6ac65e62188971c62e 100644 --- a/paddle/fluid/operators/bpr_loss_op.h +++ b/paddle/fluid/operators/bpr_loss_op.h @@ -61,8 +61,9 @@ class BprLossOpKernel : public framework::OpKernel { const int64_t* label_data = labels->data(); for (int i = 0; i < step_size; ++i) { int lbl_pos = label_data[i]; - PADDLE_ENFORCE_GE(lbl_pos, 0, platform::errors::InvalidArgument( - "label data %d is illegal.", lbl_pos)); + PADDLE_ENFORCE_GE(lbl_pos, 0, + platform::errors::InvalidArgument( + "label data %d is illegal.", lbl_pos)); PADDLE_ENFORCE_LT(lbl_pos, class_num, platform::errors::InvalidArgument( "label data %d is illegal.", lbl_pos)); diff --git a/paddle/fluid/operators/broadcast_tensors_op.cc b/paddle/fluid/operators/broadcast_tensors_op.cc index 1063a8b7992153dbedcdc0442ac3d8038c5e171b..53146417f2149435d34e4c1c95c34d8efe43c1ea 100644 --- a/paddle/fluid/operators/broadcast_tensors_op.cc +++ b/paddle/fluid/operators/broadcast_tensors_op.cc @@ -20,8 +20,8 @@ limitations under the License. */ namespace paddle { namespace operators { -using framework::Tensor; using framework::DDim; +using framework::Tensor; class BroadcastTensorsOp : public framework::OperatorWithKernel { public: diff --git a/paddle/fluid/operators/cast_op.cc b/paddle/fluid/operators/cast_op.cc index 76e0f23df21680df33d92d361c1043265e505b50..f0146994c1f7e5825a66d1f8de8a1e0cb17fc621 100644 --- a/paddle/fluid/operators/cast_op.cc +++ b/paddle/fluid/operators/cast_op.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/cast_op.h" + #include + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/float16.h" diff --git a/paddle/fluid/operators/cast_op.h b/paddle/fluid/operators/cast_op.h index 034cb47fab189b3c7a712d4d720887de227d8573..2f222d23e7cbae0118c5d152a341d0a87cbda7f3 100644 --- a/paddle/fluid/operators/cast_op.h +++ b/paddle/fluid/operators/cast_op.h @@ -17,7 +17,6 @@ limitations under the License. */ #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/transform.h" - #include "paddle/phi/api/lib/utils/tensor_utils.h" #include "paddle/phi/kernels/cast_kernel.h" diff --git a/paddle/fluid/operators/cast_op_xpu.cc b/paddle/fluid/operators/cast_op_xpu.cc index 64324d9772b47de8dfec256f75f60873ce6aafeb..8551d799cc39b6629483abcdc4f319c65cf05b5e 100644 --- a/paddle/fluid/operators/cast_op_xpu.cc +++ b/paddle/fluid/operators/cast_op_xpu.cc @@ -19,9 +19,8 @@ limitations under the License. */ #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/cast_op.h" #include "paddle/fluid/platform/float16.h" -#include "xpu/refactor/math.h" - #include "paddle/phi/kernels/cast_kernel.h" +#include "xpu/refactor/math.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/center_loss_op.cc b/paddle/fluid/operators/center_loss_op.cc index cd1aa9d9c841af8cb4520d2ce52c747c36c99c0d..add0bf966d9332b767c54d521b52cb9783bf58a1 100644 --- a/paddle/fluid/operators/center_loss_op.cc +++ b/paddle/fluid/operators/center_loss_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/center_loss_op.h" + #include #include diff --git a/paddle/fluid/operators/center_loss_op.cu b/paddle/fluid/operators/center_loss_op.cu index 549bb5ae75affe3694b72e4546a3dce79f3f14d9..b46feeae64bd4873663254f82f1d04c7266aec5e 100644 --- a/paddle/fluid/operators/center_loss_op.cu +++ b/paddle/fluid/operators/center_loss_op.cu @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/operators/center_loss_op.h" #include "paddle/fluid/platform/device/gpu/gpu_info.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" diff --git a/paddle/fluid/operators/center_loss_op.h b/paddle/fluid/operators/center_loss_op.h index ed266e9ac7dc5434f25ecceedc8c5f2068423fa1..18769fed37ba9709b89d02006175162cdfad40be 100644 --- a/paddle/fluid/operators/center_loss_op.h +++ b/paddle/fluid/operators/center_loss_op.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/transform.h" diff --git a/paddle/fluid/operators/chunk_eval_op.cc b/paddle/fluid/operators/chunk_eval_op.cc index dfb0ad96b0be2aecbfd4ed2f0e14e5bc06bc3a08..83bdaa2de7db1c8781abbbccf6c9f949e41a9c90 100644 --- a/paddle/fluid/operators/chunk_eval_op.cc +++ b/paddle/fluid/operators/chunk_eval_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/chunk_eval_op.h" + #include #include @@ -55,11 +56,12 @@ class ChunkEvalOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ( (inference_dim.size() == 3 && inference_dim[2] == 1) || inference_dim.size() == 2, - true, platform::errors::InvalidArgument( - "when Input(SeqLength) is provided, Input(Inference) " - "should be of dim 3 (batch_size, bucket, 1) or dim 2 " - "(batch_size, bucket), but received [%s].", - inference_dim)); + true, + platform::errors::InvalidArgument( + "when Input(SeqLength) is provided, Input(Inference) " + "should be of dim 3 (batch_size, bucket, 1) or dim 2 " + "(batch_size, bucket), but received [%s].", + inference_dim)); auto seq_length_dim = ctx->GetInputDim("SeqLength"); PADDLE_ENFORCE_LE(seq_length_dim.size(), 2, platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/cinn/cinn_instruction_run_op.cc b/paddle/fluid/operators/cinn/cinn_instruction_run_op.cc index 0903c53e5ecac43d4ee37829c3ebec4d4e4bcdc1..be9829dd43b17e222dfaf0796ca1f331524d9b8e 100644 --- a/paddle/fluid/operators/cinn/cinn_instruction_run_op.cc +++ b/paddle/fluid/operators/cinn/cinn_instruction_run_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/cinn/cinn_instruction_run_op.h" + #include "paddle/fluid/framework/paddle2cinn/cinn_compiler.h" #include "paddle/fluid/operators/cinn/cinn_launch_context.h" #include "paddle/fluid/platform/enforce.h" @@ -48,12 +49,12 @@ class CinnInstructionRunOp : public framework::OperatorWithKernel { protected: /* [Why use single type kernel]: - * - * Whether the kernel data type is int, float or other type, - * which has no effect on its execution logic, so directly - * specified a data type here. - * - */ + * + * Whether the kernel data type is int, float or other type, + * which has no effect on its execution logic, so directly + * specified a data type here. + * + */ framework::OpKernelType GetExpectedKernelType( const framework::ExecutionContext& ctx) const override { return framework::OpKernelType(framework::proto::VarType::FP32, diff --git a/paddle/fluid/operators/cinn/cinn_instruction_run_op.cu.cc b/paddle/fluid/operators/cinn/cinn_instruction_run_op.cu.cc index ea72f6c53745ab810803658fc4125ba38878bb1a..afa350ef116c4bf4880d293df2dcdd7d73c199a9 100644 --- a/paddle/fluid/operators/cinn/cinn_instruction_run_op.cu.cc +++ b/paddle/fluid/operators/cinn/cinn_instruction_run_op.cu.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/cinn/cinn_instruction_run_op.h" + #include "paddle/fluid/framework/op_registry.h" namespace ops = paddle::operators; diff --git a/paddle/fluid/operators/cinn/cinn_instruction_run_op.h b/paddle/fluid/operators/cinn/cinn_instruction_run_op.h index 81c2d23d3f149577a0f991977bf7ae5e8dbfab1f..13483d78f49b6015f7eaadcdf6291903cf4d643b 100644 --- a/paddle/fluid/operators/cinn/cinn_instruction_run_op.h +++ b/paddle/fluid/operators/cinn/cinn_instruction_run_op.h @@ -18,6 +18,7 @@ #include #include #include + #include "cinn/hlir/framework/graph_compiler.h" #include "cinn/hlir/framework/instruction.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/cinn/cinn_instruction_run_op_test.cc b/paddle/fluid/operators/cinn/cinn_instruction_run_op_test.cc index 68bc3a0eb5c531628b62dc56b0080fb04ee57105..cbfab3090c0adc4578c668eb38977916df040353 100644 --- a/paddle/fluid/operators/cinn/cinn_instruction_run_op_test.cc +++ b/paddle/fluid/operators/cinn/cinn_instruction_run_op_test.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include + #include "gtest/gtest.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/paddle2cinn/cinn_compiler.h" diff --git a/paddle/fluid/operators/cinn/cinn_launch_context.cc b/paddle/fluid/operators/cinn/cinn_launch_context.cc index a660d59fb4c0fd8763069062308223f565dedb65..6b70efee86f57abfe1f89b2f6e7797e83732b2e3 100644 --- a/paddle/fluid/operators/cinn/cinn_launch_context.cc +++ b/paddle/fluid/operators/cinn/cinn_launch_context.cc @@ -13,10 +13,12 @@ // limitations under the License. #include "paddle/fluid/operators/cinn/cinn_launch_context.h" + #include #include #include #include + #include "cinn/hlir/framework/graph_compiler.h" #include "cinn/hlir/framework/instruction.h" #include "cinn/hlir/framework/scope.h" @@ -43,13 +45,13 @@ namespace paddle { namespace operators::details { -using framework::Scope; using framework::LoDTensor; using framework::ParallelExecutor; +using framework::Scope; using CinnInstruction = ::cinn::hlir::framework::Instruction; using CinnRuntimeProgram = ::cinn::hlir::framework::Program; -using framework::paddle2cinn::Name2VarInfoMap; using framework::paddle2cinn::kMemOptVarInfoFromMainGraph; +using framework::paddle2cinn::Name2VarInfoMap; CinnLaunchContext::CinnLaunchContext(const framework::ir::Graph& graph, const CinnCompiledObject& compiled_obj) diff --git a/paddle/fluid/operators/cinn/cinn_launch_context.h b/paddle/fluid/operators/cinn/cinn_launch_context.h index ed5e4383d83d23322860e3f554160013fd5532c9..0bbbcc8b03177869d3f8bea14f2e0b9182a245f5 100644 --- a/paddle/fluid/operators/cinn/cinn_launch_context.h +++ b/paddle/fluid/operators/cinn/cinn_launch_context.h @@ -20,6 +20,7 @@ #include #include #include + #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/parallel_executor.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/operators/cinn/cinn_launch_context_test.cc b/paddle/fluid/operators/cinn/cinn_launch_context_test.cc index ecbfbf2f92ebfa943d1a2263b3da9b4b6056a9be..cd4465d355f3577a892440ea30dcbfb56d850e21 100644 --- a/paddle/fluid/operators/cinn/cinn_launch_context_test.cc +++ b/paddle/fluid/operators/cinn/cinn_launch_context_test.cc @@ -13,9 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/cinn/cinn_launch_context.h" + #include #include #include + #include "cinn/auto_schedule/auto_tuner.h" #include "cinn/common/target.h" #include "cinn/common/type.h" @@ -38,11 +40,11 @@ USE_OP(cinn_instruction_run); namespace paddle { namespace operators::details { +using framework::LoDTensor; using framework::OpDesc; +using framework::ParallelExecutor; using framework::ProgramDesc; -using framework::LoDTensor; using framework::ir::Graph; -using framework::ParallelExecutor; using framework::paddle2cinn::Name2VarInfoMap; using CinnShape = ::cinn::hlir::framework::Shape; using CinnInstruction = ::cinn::hlir::framework::Instruction; diff --git a/paddle/fluid/operators/cinn/cinn_launch_op.cc b/paddle/fluid/operators/cinn/cinn_launch_op.cc index 0a9b66bc92c154a56853512ee0ee5c28097688a2..3b0198613dbdba1d9681be8bf74244c1bc01af5d 100644 --- a/paddle/fluid/operators/cinn/cinn_launch_op.cc +++ b/paddle/fluid/operators/cinn/cinn_launch_op.cc @@ -13,8 +13,10 @@ // limitations under the License. #include "paddle/fluid/operators/cinn/cinn_launch_op.h" + #include #include + #include "cinn/hlir/framework/graph_compiler.h" #include "cinn/runtime/cinn_runtime.h" #include "cinn/runtime/flags.h" diff --git a/paddle/fluid/operators/cinn/cinn_launch_op.cu.cc b/paddle/fluid/operators/cinn/cinn_launch_op.cu.cc index 9dfd53834e937e201a76d44d4a841f4625c24b19..fb5a48ca3d0b4f19c1d2df7c8bdaff01f47a870d 100644 --- a/paddle/fluid/operators/cinn/cinn_launch_op.cu.cc +++ b/paddle/fluid/operators/cinn/cinn_launch_op.cu.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/cinn/cinn_launch_op.h" + #include "paddle/fluid/framework/operator.h" /* see [Why use single type kernel] */ diff --git a/paddle/fluid/operators/cinn/cinn_launch_op.h b/paddle/fluid/operators/cinn/cinn_launch_op.h index f40b788dfb5b330bce8d191698ab81ecdca48f82..62c79faafec72a30fdc99b8f24f912dc48eddcda 100644 --- a/paddle/fluid/operators/cinn/cinn_launch_op.h +++ b/paddle/fluid/operators/cinn/cinn_launch_op.h @@ -77,16 +77,16 @@ class CinnLaunchOpKernel : public framework::OpKernel { std::map inputs_name2tensor; std::vector input_x_variable_names; std::vector input_no_need_buffer_variable_names; - auto add_name2tensor_fn = [&inputs_name2tensor]( - const std::vector& variable_names, - const std::vector& tensors) { - std::transform( - variable_names.begin(), variable_names.end(), tensors.begin(), - std::inserter(inputs_name2tensor, inputs_name2tensor.end()), - [](const std::string& name, const LoDTensor* tensor) { - return std::make_pair(name, tensor); - }); - }; + auto add_name2tensor_fn = + [&inputs_name2tensor](const std::vector& variable_names, + const std::vector& tensors) { + std::transform( + variable_names.begin(), variable_names.end(), tensors.begin(), + std::inserter(inputs_name2tensor, inputs_name2tensor.end()), + [](const std::string& name, const LoDTensor* tensor) { + return std::make_pair(name, tensor); + }); + }; auto input_x_tensors = ctx.MultiInput(kX); if (!input_x_tensors.empty()) { diff --git a/paddle/fluid/operators/cinn/cinn_launch_op_test.cc b/paddle/fluid/operators/cinn/cinn_launch_op_test.cc index b0bd043f43247159077b6b700256cf373fef4740..9ed9fad36a3d707c6b0b39c8b731c01abdd357b3 100644 --- a/paddle/fluid/operators/cinn/cinn_launch_op_test.cc +++ b/paddle/fluid/operators/cinn/cinn_launch_op_test.cc @@ -13,10 +13,13 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/cinn/cinn_launch_op.h" + #include + #include #include #include + #include "gflags/gflags.h" #include "gtest/gtest.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/cinn/cinn_op_helper.cc b/paddle/fluid/operators/cinn/cinn_op_helper.cc index 3fb9c822c77c4ddb631a31610af0cc950c7533a8..26fee2d9e577c12e99534f249b1455b3ce9eee40 100644 --- a/paddle/fluid/operators/cinn/cinn_op_helper.cc +++ b/paddle/fluid/operators/cinn/cinn_op_helper.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/cinn/cinn_op_helper.h" + #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/platform/device_context.h" diff --git a/paddle/fluid/operators/cinn/cinn_op_helper.h b/paddle/fluid/operators/cinn/cinn_op_helper.h index e542134b94689692e88382b6506a9d87d4708fa2..55ee3789c0a825d62eea42cf3b98f9a56ca76762 100644 --- a/paddle/fluid/operators/cinn/cinn_op_helper.h +++ b/paddle/fluid/operators/cinn/cinn_op_helper.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/framework/operator.h" // We define some common names or utility functions diff --git a/paddle/fluid/operators/cinn/test_helper.h b/paddle/fluid/operators/cinn/test_helper.h index 9720a5309fa6e1ce0316f709d347599fa125f507..4e06882279beefa60b6445d3be784ba768bba31e 100644 --- a/paddle/fluid/operators/cinn/test_helper.h +++ b/paddle/fluid/operators/cinn/test_helper.h @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include + #include "gtest/gtest.h" #include "paddle/fluid/framework/ir/graph.h" #include "paddle/fluid/framework/lod_tensor.h" diff --git a/paddle/fluid/operators/class_center_sample_op.cu b/paddle/fluid/operators/class_center_sample_op.cu index a23cf2815d8fe84ba30d6957c9e31aeb2a3e9040..7192b415c27eccb6b3094dca4ca3d50e9c52016d 100644 --- a/paddle/fluid/operators/class_center_sample_op.cu +++ b/paddle/fluid/operators/class_center_sample_op.cu @@ -15,17 +15,20 @@ #ifdef PADDLE_WITH_HIP #include #include + #include typedef hiprandState curandState; namespace cub = hipcub; #else #include #include + #include #endif #include #include + #include "paddle/fluid/operators/class_center_sample_op.h" #include "paddle/phi/api/include/tensor.h" diff --git a/paddle/fluid/operators/class_center_sample_op.h b/paddle/fluid/operators/class_center_sample_op.h index 24ce9ace3bf113249f4ee64c1e4bf21a6a7d1d7e..8f12e90e18539bfa78061320e8d5dcf9de6fd54c 100644 --- a/paddle/fluid/operators/class_center_sample_op.h +++ b/paddle/fluid/operators/class_center_sample_op.h @@ -16,6 +16,7 @@ #include #include #include + #include "paddle/fluid/framework/generator.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/clip_by_norm_op.h b/paddle/fluid/operators/clip_by_norm_op.h index 8822fffd326e1ee0128d505ffd03195b0b03394f..379cd4c665314243cae9672991542bcd68556f28 100644 --- a/paddle/fluid/operators/clip_by_norm_op.h +++ b/paddle/fluid/operators/clip_by_norm_op.h @@ -114,10 +114,11 @@ class ClipByNormOp : public framework::OperatorWithKernel { "Output(Out) of ClipByNormOp should not be null. " "Please check if it is created correctly.")); auto max_norm = ctx->Attrs().Get("max_norm"); - PADDLE_ENFORCE_GT(max_norm, 0, platform::errors::InvalidArgument( - "max_norm should be greater than 0. " - "Received max_norm is %f.", - max_norm)); + PADDLE_ENFORCE_GT( + max_norm, 0, + platform::errors::InvalidArgument("max_norm should be greater than 0. " + "Received max_norm is %f.", + max_norm)); auto x_dims = ctx->GetInputDim("X"); ctx->SetOutputDim("Out", x_dims); ctx->ShareLoD("X", /*->*/ "Out"); diff --git a/paddle/fluid/operators/clip_by_norm_op_xpu.cc b/paddle/fluid/operators/clip_by_norm_op_xpu.cc index 7c91f06a8d7222c1efcfb17358b31bffcfa03f75..62c2608f11c4cd4cc39c023b64ba886ec5d4605a 100644 --- a/paddle/fluid/operators/clip_by_norm_op_xpu.cc +++ b/paddle/fluid/operators/clip_by_norm_op_xpu.cc @@ -13,9 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #ifdef PADDLE_WITH_XPU -#include "paddle/fluid/operators/clip_by_norm_op.h" #include +#include "paddle/fluid/operators/clip_by_norm_op.h" + namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/clip_op.cc b/paddle/fluid/operators/clip_op.cc index 6e898d31663fac73bc26d13ddb72acdbe4c6473c..46eb9448d9d6b384630068eb6d3032309b84a74e 100644 --- a/paddle/fluid/operators/clip_op.cc +++ b/paddle/fluid/operators/clip_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" @@ -179,14 +180,13 @@ REGISTER_OPERATOR(clip_grad, ops::ClipOpGrad, ops::ClipGradInplaceInferer, ops::ClipDoubleGradOpMaker, ops::ClipDoubleGradOpMaker); -REGISTER_OP_VERSION(clip) - .AddCheckpoint( - R"ROC( +REGISTER_OP_VERSION(clip).AddCheckpoint( + R"ROC( Upgrade clip add a new input [Min])ROC", - paddle::framework::compatible::OpVersionDesc() - .NewInput("Min", - "Pass the mix, min value as input, not attribute. Min is " - "dispensable.") - .NewInput("Max", - "Pass the mix, min value as input, not attribute. Max is " - "dispensable.")); + paddle::framework::compatible::OpVersionDesc() + .NewInput("Min", + "Pass the mix, min value as input, not attribute. Min is " + "dispensable.") + .NewInput("Max", + "Pass the mix, min value as input, not attribute. Max is " + "dispensable.")); diff --git a/paddle/fluid/operators/clip_op_xpu.cc b/paddle/fluid/operators/clip_op_xpu.cc index c551312837274fcc0df50c7150af97923f7008da..a99e5d2506fad96ade0a28659fd806e26352e77d 100644 --- a/paddle/fluid/operators/clip_op_xpu.cc +++ b/paddle/fluid/operators/clip_op_xpu.cc @@ -61,10 +61,11 @@ class ClipXPUKernel : public framework::OpKernel { auto out_data = reinterpret_cast(out->data()); int r = xpu::clip_v2(dev_ctx.x_context(), x_data, out_data, x->numel(), min, max); - PADDLE_ENFORCE_EQ(r, XPU_SUCCESS, platform::errors::External( - "XPU API(clip_v2) return wrong " - "value[%d %s]", - r, XPUAPIErrorMsg[r])); + PADDLE_ENFORCE_EQ( + r, XPU_SUCCESS, + platform::errors::External("XPU API(clip_v2) return wrong " + "value[%d %s]", + r, XPUAPIErrorMsg[r])); } }; diff --git a/paddle/fluid/operators/coalesce_tensor_op.cc b/paddle/fluid/operators/coalesce_tensor_op.cc index aa5a38e4dbf08dffeab1655c7ba8534b504579ed..af15ca2acb7f42629e65534ba96e1aeeeb6cf7d7 100644 --- a/paddle/fluid/operators/coalesce_tensor_op.cc +++ b/paddle/fluid/operators/coalesce_tensor_op.cc @@ -14,6 +14,7 @@ #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/framework/operator.h" @@ -265,11 +266,10 @@ class CoalesceTensorOpKernel : public framework::OpKernel { ->ShareDataWith(fused_tensor->Slice( static_cast(offset), static_cast(offset + len))) .Resize(dim); - len = use_align - ? platform::Alignment(len * size_of_dtype, context.GetPlace(), - align_size) / - size_of_dtype - : len; + len = use_align ? platform::Alignment(len * size_of_dtype, + context.GetPlace(), align_size) / + size_of_dtype + : len; ss << "output(" << out_var_names[i] << ") dim:(" << dim << ")" << " address: " << out_tensors[i]->data() << " len: " << len << ", "; offset += len; @@ -304,12 +304,11 @@ class CoalesceTensorOpKernel : public framework::OpKernel { size, 0, platform::errors::InvalidArgument( "The number of tensor `%s`'s elements is 0.", var_names[i])); - auto len = - use_align - ? platform::Alignment(static_cast(size) * size_of_dtype, - place, align_size) / - size_of_dtype - : static_cast(size); + auto len = use_align ? platform::Alignment( + static_cast(size) * size_of_dtype, + place, align_size) / + size_of_dtype + : static_cast(size); const void *ptr = lod_tensors[i]->IsInitialized() ? lod_tensors[i]->data() : nullptr; VLOG(4) << size << " " << len; diff --git a/paddle/fluid/operators/collective/allreduce_op.cc b/paddle/fluid/operators/collective/allreduce_op.cc index 63b135a74cf4b7b80b8baec462aa920fce370f7e..53843104dc5fd6ed082dce364ab81bb2087806f2 100644 --- a/paddle/fluid/operators/collective/allreduce_op.cc +++ b/paddle/fluid/operators/collective/allreduce_op.cc @@ -12,11 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/operators/collective/allreduce_op.h" + #include // NOLINT #include -#include "paddle/fluid/operators/collective/allreduce_op.h" - namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/collective/barrier_op.h b/paddle/fluid/operators/collective/barrier_op.h index 6df4d24c0edf99a6320b77114bbe0613fd617ed7..88333f36413b88b95fe99ba7498010561a295da2 100644 --- a/paddle/fluid/operators/collective/barrier_op.h +++ b/paddle/fluid/operators/collective/barrier_op.h @@ -25,6 +25,7 @@ limitations under the License. */ #if defined(PADDLE_WITH_GLOO) #include + #include "paddle/fluid/framework/fleet/gloo_wrapper.h" #endif diff --git a/paddle/fluid/operators/collective/broadcast_op.cc b/paddle/fluid/operators/collective/broadcast_op.cc index 61e27887b68c75f3d5c5cc48b4f1fac11d5f4eae..071b0350de6d2f1c3435f227cca9c4514b7fdb36 100644 --- a/paddle/fluid/operators/collective/broadcast_op.cc +++ b/paddle/fluid/operators/collective/broadcast_op.cc @@ -16,6 +16,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/collective/c_allgather_op.cc b/paddle/fluid/operators/collective/c_allgather_op.cc index c4e779698cccafc6d958e823f087a1276b6246c3..f20ec75a970069c355cf0b2fbbdd912e2a0eb694 100644 --- a/paddle/fluid/operators/collective/c_allgather_op.cc +++ b/paddle/fluid/operators/collective/c_allgather_op.cc @@ -26,8 +26,9 @@ class CAllGatherOp : public framework::OperatorWithKernel { OP_INOUT_CHECK(ctx->HasInput("X"), "Input", "X", "AllGather"); OP_INOUT_CHECK(ctx->HasOutput("Out"), "Input", "Out", "AllGather"); int nranks = ctx->Attrs().Get("nranks"); - PADDLE_ENFORCE_GE(nranks, 2, platform::errors::InvalidArgument( - "The value of nranks should be >=2.")); + PADDLE_ENFORCE_GE(nranks, 2, + platform::errors::InvalidArgument( + "The value of nranks should be >=2.")); framework::DDim dim = ctx->GetInputDim("X"); dim[0] = dim[0] * nranks; if (dim[0] < 0) dim[0] = -1; diff --git a/paddle/fluid/operators/collective/c_allgather_op.h b/paddle/fluid/operators/collective/c_allgather_op.h index aa2040a2693b2dfc3eee0447167fa5c9e66f94cd..7f8c7b2f50e7c53092e35ea07c3ec2cad025d1bc 100644 --- a/paddle/fluid/operators/collective/c_allgather_op.h +++ b/paddle/fluid/operators/collective/c_allgather_op.h @@ -25,6 +25,7 @@ limitations under the License. */ #if defined(PADDLE_WITH_GLOO) #include + #include "paddle/fluid/framework/fleet/gloo_wrapper.h" #endif diff --git a/paddle/fluid/operators/collective/c_allgather_op_npu.cc b/paddle/fluid/operators/collective/c_allgather_op_npu.cc index 5339293da0fe22ae65adf904b96ce7b68f82b24f..f9ffdea790807518b37cda2fae23394edb8b27d6 100644 --- a/paddle/fluid/operators/collective/c_allgather_op_npu.cc +++ b/paddle/fluid/operators/collective/c_allgather_op_npu.cc @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/collective/c_allgather_op.h" - #include +#include "paddle/fluid/operators/collective/c_allgather_op.h" + #if defined(PADDLE_WITH_ASCEND_CL) #include "paddle/fluid/platform/collective_helper.h" #include "paddle/fluid/platform/device/npu/hccl_helper.h" diff --git a/paddle/fluid/operators/collective/c_allgather_op_npu_test.cc b/paddle/fluid/operators/collective/c_allgather_op_npu_test.cc index 7206dd01bcaa3e588cc275c2fdf25e70aacc1663..087f6b879c3283e96437fa13bd7151334f082cab 100644 --- a/paddle/fluid/operators/collective/c_allgather_op_npu_test.cc +++ b/paddle/fluid/operators/collective/c_allgather_op_npu_test.cc @@ -17,23 +17,22 @@ limitations under the License. */ #endif #include + #include #include // NOLINT #include #include "gtest/gtest.h" - #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/program_desc.h" -#include "paddle/fluid/string/printf.h" -#include "paddle/phi/kernels/funcs/math_function.h" - #include "paddle/fluid/operators/collective/c_allgather_op.h" #include "paddle/fluid/operators/collective/c_allreduce_op.h" #include "paddle/fluid/operators/collective/c_broadcast_op.h" #include "paddle/fluid/operators/collective/c_reducescatter_op.h" #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" +#include "paddle/fluid/string/printf.h" +#include "paddle/phi/kernels/funcs/math_function.h" #if defined(PADDLE_WITH_ASCEND_CL) #include "paddle/fluid/platform/collective_helper.h" diff --git a/paddle/fluid/operators/collective/c_allreduce_max_op_npu_test.cc b/paddle/fluid/operators/collective/c_allreduce_max_op_npu_test.cc index 0946ad8aca65e28835ea1d139fb94c309ce840a1..5c2d6981bad0351c35cdfb5a1bdaab6e6b9b376c 100644 --- a/paddle/fluid/operators/collective/c_allreduce_max_op_npu_test.cc +++ b/paddle/fluid/operators/collective/c_allreduce_max_op_npu_test.cc @@ -17,23 +17,22 @@ limitations under the License. */ #endif #include + #include #include // NOLINT #include #include "gtest/gtest.h" - #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/program_desc.h" -#include "paddle/fluid/string/printf.h" -#include "paddle/phi/kernels/funcs/math_function.h" - #include "paddle/fluid/operators/collective/c_allgather_op.h" #include "paddle/fluid/operators/collective/c_allreduce_op.h" #include "paddle/fluid/operators/collective/c_broadcast_op.h" #include "paddle/fluid/operators/collective/c_reducescatter_op.h" #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" +#include "paddle/fluid/string/printf.h" +#include "paddle/phi/kernels/funcs/math_function.h" #if defined(PADDLE_WITH_ASCEND_CL) #include "paddle/fluid/platform/collective_helper.h" diff --git a/paddle/fluid/operators/collective/c_allreduce_op.h b/paddle/fluid/operators/collective/c_allreduce_op.h index 404f7c017ac413667e7d2ab01e999a9414fdf68c..61cf4cf5b7f5ff184a85f3b391927c5dfa0d27cd 100644 --- a/paddle/fluid/operators/collective/c_allreduce_op.h +++ b/paddle/fluid/operators/collective/c_allreduce_op.h @@ -41,6 +41,7 @@ limitations under the License. */ #if defined(PADDLE_WITH_GLOO) #include + #include "paddle/fluid/framework/fleet/gloo_wrapper.h" #endif @@ -335,10 +336,11 @@ class CAllReduceOpXPUKernel : public framework::OpKernel { "Invalid reduce type: %d", red_type)); } - PADDLE_ENFORCE_EQ(bkcl_all_reduce(comm->comm(), sendbuff, recvbuff, numel, - dtype, bkcl_red_type, stream), - BKCL_SUCCESS, platform::errors::PreconditionNotMet( - "BKCL all reduce failed")); + PADDLE_ENFORCE_EQ( + bkcl_all_reduce(comm->comm(), sendbuff, recvbuff, numel, dtype, + bkcl_red_type, stream), + BKCL_SUCCESS, + platform::errors::PreconditionNotMet("BKCL all reduce failed")); #else PADDLE_THROW(platform::errors::PreconditionNotMet( "PaddlePaddle should be compiled with XPU.")); diff --git a/paddle/fluid/operators/collective/c_allreduce_sum_op_npu_test.cc b/paddle/fluid/operators/collective/c_allreduce_sum_op_npu_test.cc index 61e5f27903477972ef10465ccfd6f8de8ce8fba6..4c76d094bafa5d993bd0071102f65b401b7e67f2 100644 --- a/paddle/fluid/operators/collective/c_allreduce_sum_op_npu_test.cc +++ b/paddle/fluid/operators/collective/c_allreduce_sum_op_npu_test.cc @@ -17,20 +17,19 @@ limitations under the License. */ #endif #include + #include #include // NOLINT #include #include "gtest/gtest.h" - #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/program_desc.h" -#include "paddle/fluid/string/printf.h" -#include "paddle/phi/kernels/funcs/math_function.h" - #include "paddle/fluid/operators/collective/c_allreduce_op.h" #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" +#include "paddle/fluid/string/printf.h" +#include "paddle/phi/kernels/funcs/math_function.h" #if defined(PADDLE_WITH_ASCEND_CL) #include "paddle/fluid/platform/collective_helper.h" diff --git a/paddle/fluid/operators/collective/c_broadcast_op.h b/paddle/fluid/operators/collective/c_broadcast_op.h index eb4acb9a369fc7bfa8e23b5544f54c955d4a87b6..394ea45efbb7d8cedbf6279033cf1187afc97ecd 100644 --- a/paddle/fluid/operators/collective/c_broadcast_op.h +++ b/paddle/fluid/operators/collective/c_broadcast_op.h @@ -24,6 +24,7 @@ limitations under the License. */ #if defined(PADDLE_WITH_GLOO) #include + #include "paddle/fluid/framework/fleet/gloo_wrapper.h" #endif diff --git a/paddle/fluid/operators/collective/c_broadcast_op_npu_test.cc b/paddle/fluid/operators/collective/c_broadcast_op_npu_test.cc index cf4d6a28744b368212fe8bcb0924001aa53b5a4e..e383e78c5dddc21c435cf561f5d917004edd274d 100644 --- a/paddle/fluid/operators/collective/c_broadcast_op_npu_test.cc +++ b/paddle/fluid/operators/collective/c_broadcast_op_npu_test.cc @@ -17,20 +17,19 @@ limitations under the License. */ #endif #include + #include #include // NOLINT #include #include "gtest/gtest.h" - #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/program_desc.h" -#include "paddle/fluid/string/printf.h" -#include "paddle/phi/kernels/funcs/math_function.h" - #include "paddle/fluid/operators/collective/c_broadcast_op.h" #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" +#include "paddle/fluid/string/printf.h" +#include "paddle/phi/kernels/funcs/math_function.h" #if defined(PADDLE_WITH_ASCEND_CL) #include "paddle/fluid/platform/collective_helper.h" diff --git a/paddle/fluid/operators/collective/c_comm_init_all_op.cc b/paddle/fluid/operators/collective/c_comm_init_all_op.cc index ce2da1f22f1489f702808e3ac2e3bf26742858a6..c9605f4d1b268727250a66448998c82140a36964 100644 --- a/paddle/fluid/operators/collective/c_comm_init_all_op.cc +++ b/paddle/fluid/operators/collective/c_comm_init_all_op.cc @@ -15,7 +15,6 @@ limitations under the License. */ #include "paddle/fluid/framework/op_info.h" #include "paddle/fluid/framework/op_registry.h" - #include "paddle/fluid/framework/threadpool.h" #include "paddle/fluid/platform/collective_helper.h" @@ -53,9 +52,9 @@ class CCommInitAllOp : public framework::OperatorBase { void RunImpl(const framework::Scope& scope, const platform::Place& place) const override { -// PADDLE_ENFORCE_EQ(platform::is_gpu_place(place), true, -// platform::errors::PreconditionNotMet( -// "CCommInitAllOp can run on gpu place only")); + // PADDLE_ENFORCE_EQ(platform::is_gpu_place(place), true, + // platform::errors::PreconditionNotMet( + // "CCommInitAllOp can run on gpu place only")); #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) std::vector devices = Attr>("devices"); diff --git a/paddle/fluid/operators/collective/c_comm_init_multitrainer_op.cc b/paddle/fluid/operators/collective/c_comm_init_multitrainer_op.cc index 86c966378ccb689aae156aa3e725360f77db275f..3ea24f6e654f09c5f9f5e470d3ecd98f27a2f9f2 100644 --- a/paddle/fluid/operators/collective/c_comm_init_multitrainer_op.cc +++ b/paddle/fluid/operators/collective/c_comm_init_multitrainer_op.cc @@ -18,6 +18,7 @@ limitations under the License. */ #include #endif #include + #include #include diff --git a/paddle/fluid/operators/collective/c_comm_init_op.cc b/paddle/fluid/operators/collective/c_comm_init_op.cc index 490747520d67d5adb52ed46b68c9d19670a9464b..a41d4293c90e4b589d4f2b8354511fa56f1fbf0a 100644 --- a/paddle/fluid/operators/collective/c_comm_init_op.cc +++ b/paddle/fluid/operators/collective/c_comm_init_op.cc @@ -71,8 +71,9 @@ class CCommInitOp : public framework::OperatorBase { PADDLE_ENFORCE_EQ( platform::is_gpu_place(place) || platform::is_xpu_place(place) || platform::is_mlu_place(place), - true, platform::errors::PreconditionNotMet( - "CCommInitOp can run on gpu or xpu or mlu place only.")); + true, + platform::errors::PreconditionNotMet( + "CCommInitOp can run on gpu or xpu or mlu place only.")); #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) || \ defined(PADDLE_WITH_XPU_BKCL) || defined(PADDLE_WITH_CNCL) diff --git a/paddle/fluid/operators/collective/c_concat_op.cc b/paddle/fluid/operators/collective/c_concat_op.cc index 551fde21162582fbbb2b356a2aa265247a4af94d..155db23a0391a5a24bbb718a6199d7dc22463a95 100644 --- a/paddle/fluid/operators/collective/c_concat_op.cc +++ b/paddle/fluid/operators/collective/c_concat_op.cc @@ -27,17 +27,19 @@ class CConcatOp : public framework::OperatorWithKernel { int nranks = ctx->Attrs().Get("nranks"); int rank = ctx->Attrs().Get("rank"); int ring_id = ctx->Attrs().Get("ring_id"); - PADDLE_ENFORCE_GE(nranks, 2, platform::errors::InvalidArgument( - "The number of ranks (%d) for c_concat " - "must be greater than 1.", - nranks)); + PADDLE_ENFORCE_GE(nranks, 2, + platform::errors::InvalidArgument( + "The number of ranks (%d) for c_concat " + "must be greater than 1.", + nranks)); PADDLE_ENFORCE_GE( ring_id, 0, platform::errors::InvalidArgument( "The ring_id (%d) for c_concat must be non-negative.", ring_id)); PADDLE_ENFORCE_GE( - rank, 0, platform::errors::InvalidArgument( - "The rank (%d) for c_concat must be non-negative.", rank)); + rank, 0, + platform::errors::InvalidArgument( + "The rank (%d) for c_concat must be non-negative.", rank)); PADDLE_ENFORCE_LT(rank, nranks, platform::errors::InvalidArgument( "The value of rank (%d) for c_concat must " diff --git a/paddle/fluid/operators/collective/c_concat_op.cu.cc b/paddle/fluid/operators/collective/c_concat_op.cu.cc index d3d9db0e5f87ecd6045be4e8fb499b579682adfe..98df6c8688e74b6d46ccca5b524533968cdcf722 100644 --- a/paddle/fluid/operators/collective/c_concat_op.cu.cc +++ b/paddle/fluid/operators/collective/c_concat_op.cu.cc @@ -12,9 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/operators/collective/c_concat_op.h" + #include -#include "paddle/fluid/operators/collective/c_concat_op.h" #include "paddle/fluid/operators/math/concat_and_split.h" #include "paddle/phi/api/include/tensor.h" diff --git a/paddle/fluid/operators/collective/c_gen_bkcl_id_op.cc b/paddle/fluid/operators/collective/c_gen_bkcl_id_op.cc index ec174ad0e56bc938701101fd78a1976354c40b15..3bd7e3ceffa2a0b99557d315d9cebd5de41dd5ed 100644 --- a/paddle/fluid/operators/collective/c_gen_bkcl_id_op.cc +++ b/paddle/fluid/operators/collective/c_gen_bkcl_id_op.cc @@ -21,9 +21,8 @@ limitations under the License. */ #include "paddle/fluid/framework/var_type_traits.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/enforce.h" -#include "paddle/fluid/platform/place.h" - #include "paddle/fluid/platform/gen_comm_id_helper.h" +#include "paddle/fluid/platform/place.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/collective/c_gen_cncl_id_op.cc b/paddle/fluid/operators/collective/c_gen_cncl_id_op.cc index 7e65fba571800b4d48a931dbdaa4bacc5f534e81..d2e85171a4a40803a53a04a67ae1f1fb48b62381 100644 --- a/paddle/fluid/operators/collective/c_gen_cncl_id_op.cc +++ b/paddle/fluid/operators/collective/c_gen_cncl_id_op.cc @@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include + #include #include "paddle/fluid/framework/op_proto_maker.h" @@ -21,9 +22,8 @@ limitations under the License. */ #include "paddle/fluid/framework/var_type_traits.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/enforce.h" -#include "paddle/fluid/platform/place.h" - #include "paddle/fluid/platform/gen_comm_id_helper.h" +#include "paddle/fluid/platform/place.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/collective/c_gen_hccl_id_op.cc b/paddle/fluid/operators/collective/c_gen_hccl_id_op.cc index 6eec385388090e55db709140a8d51ccbd70c0ab6..3f81eab7bc2c46c9091ea064df46461c1f8bbe2f 100644 --- a/paddle/fluid/operators/collective/c_gen_hccl_id_op.cc +++ b/paddle/fluid/operators/collective/c_gen_hccl_id_op.cc @@ -19,12 +19,11 @@ limitations under the License. */ #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/framework/var_type_traits.h" +#include "paddle/fluid/platform/device/npu/dynload/hccl.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/enforce.h" -#include "paddle/fluid/platform/place.h" - -#include "paddle/fluid/platform/device/npu/dynload/hccl.h" #include "paddle/fluid/platform/gen_comm_id_helper.h" +#include "paddle/fluid/platform/place.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/collective/c_gen_nccl_id_op.cc b/paddle/fluid/operators/collective/c_gen_nccl_id_op.cc index d392beb3a48345a8db9251ac8d26c41ec5e1167d..d4f1fe1c18297fe050848e9126aac7b945018fca 100644 --- a/paddle/fluid/operators/collective/c_gen_nccl_id_op.cc +++ b/paddle/fluid/operators/collective/c_gen_nccl_id_op.cc @@ -20,9 +20,8 @@ limitations under the License. */ #include "paddle/fluid/framework/var_type_traits.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/enforce.h" -#include "paddle/fluid/platform/place.h" - #include "paddle/fluid/platform/gen_comm_id_helper.h" +#include "paddle/fluid/platform/place.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/collective/c_reduce_op.h b/paddle/fluid/operators/collective/c_reduce_op.h index 4e9edb53730c220657f3518e910f0786b6592782..5399a4aacbe2cb3808a20ff1d9c5758a1e4285ce 100644 --- a/paddle/fluid/operators/collective/c_reduce_op.h +++ b/paddle/fluid/operators/collective/c_reduce_op.h @@ -40,6 +40,7 @@ limitations under the License. */ #if defined(PADDLE_WITH_GLOO) #include + #include "paddle/fluid/framework/fleet/gloo_wrapper.h" #endif @@ -261,10 +262,11 @@ class CReduceOpXPUKernel : public framework::OpKernel { "Invalid reduce type: %d", red_type)); } - PADDLE_ENFORCE_EQ(bkcl_reduce(comm->comm(), sendbuff, recvbuff, numel, - dtype, bkcl_red_type, root, stream), - BKCL_SUCCESS, platform::errors::PreconditionNotMet( - "BKCL all reduce failed")); + PADDLE_ENFORCE_EQ( + bkcl_reduce(comm->comm(), sendbuff, recvbuff, numel, dtype, + bkcl_red_type, root, stream), + BKCL_SUCCESS, + platform::errors::PreconditionNotMet("BKCL all reduce failed")); #else PADDLE_THROW(platform::errors::PreconditionNotMet( "PaddlePaddle should be compiled with XPU.")); @@ -319,9 +321,10 @@ class CReduceOpCUDAKernel : public framework::OpKernel { break; default: - PADDLE_ENFORCE_EQ(true, false, platform::errors::InvalidArgument( - "red_type must be one of kRedSum, " - "kRedMax, kRedMin, kRedProd.")); + PADDLE_ENFORCE_EQ(true, false, + platform::errors::InvalidArgument( + "red_type must be one of kRedSum, " + "kRedMax, kRedMin, kRedProd.")); } PADDLE_ENFORCE_GPU_SUCCESS(platform::dynload::ncclReduce( diff --git a/paddle/fluid/operators/collective/c_reduce_sum_op_npu_test.cc b/paddle/fluid/operators/collective/c_reduce_sum_op_npu_test.cc index c4e410d04da5fb5e9b6bfe4d7d5c263084889f54..3bd55ea370465a6c4009b457ecefb5fe97b861c8 100644 --- a/paddle/fluid/operators/collective/c_reduce_sum_op_npu_test.cc +++ b/paddle/fluid/operators/collective/c_reduce_sum_op_npu_test.cc @@ -17,20 +17,19 @@ limitations under the License. */ #endif #include + #include #include // NOLINT #include #include "gtest/gtest.h" - #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/program_desc.h" -#include "paddle/fluid/string/printf.h" -#include "paddle/phi/kernels/funcs/math_function.h" - #include "paddle/fluid/operators/collective/c_reduce_op.h" #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" +#include "paddle/fluid/string/printf.h" +#include "paddle/phi/kernels/funcs/math_function.h" #if defined(PADDLE_WITH_ASCEND_CL) #include "paddle/fluid/platform/collective_helper.h" diff --git a/paddle/fluid/operators/collective/c_reducescatter_op_npu_test.cc b/paddle/fluid/operators/collective/c_reducescatter_op_npu_test.cc index 8b498787c69db0f978acaa68ba63883270e11eb4..16437d4769eb0880d6f6c8d3223bd1a902a93ada 100644 --- a/paddle/fluid/operators/collective/c_reducescatter_op_npu_test.cc +++ b/paddle/fluid/operators/collective/c_reducescatter_op_npu_test.cc @@ -17,23 +17,22 @@ limitations under the License. */ #endif #include + #include #include // NOLINT #include #include "gtest/gtest.h" - #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/program_desc.h" -#include "paddle/fluid/string/printf.h" -#include "paddle/phi/kernels/funcs/math_function.h" - #include "paddle/fluid/operators/collective/c_allgather_op.h" #include "paddle/fluid/operators/collective/c_allreduce_op.h" #include "paddle/fluid/operators/collective/c_broadcast_op.h" #include "paddle/fluid/operators/collective/c_reducescatter_op.h" #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" +#include "paddle/fluid/string/printf.h" +#include "paddle/phi/kernels/funcs/math_function.h" #if defined(PADDLE_WITH_ASCEND_CL) #include "paddle/fluid/platform/collective_helper.h" diff --git a/paddle/fluid/operators/collective/c_scatter_op.h b/paddle/fluid/operators/collective/c_scatter_op.h index 71a5f488ebc11a93cece9b85f6af288a4662b2d8..ee07d7663b2ec0fc3d2ff9486bd1df3a97b74acc 100644 --- a/paddle/fluid/operators/collective/c_scatter_op.h +++ b/paddle/fluid/operators/collective/c_scatter_op.h @@ -24,6 +24,7 @@ limitations under the License. */ #if defined(PADDLE_WITH_GLOO) #include + #include "paddle/fluid/framework/fleet/gloo_wrapper.h" #endif diff --git a/paddle/fluid/operators/collective/c_softmax_with_cross_entropy_op.cu b/paddle/fluid/operators/collective/c_softmax_with_cross_entropy_op.cu index 4c9fb14842489d413fb260fd2bcb961dbc698b2d..71216538a4e1283ccd78ade1eb0893f8743fc2a7 100644 --- a/paddle/fluid/operators/collective/c_softmax_with_cross_entropy_op.cu +++ b/paddle/fluid/operators/collective/c_softmax_with_cross_entropy_op.cu @@ -373,15 +373,15 @@ class CSoftmaxWithCrossEntropyGradCUDAKernel : public framework::OpKernel { const int end_index = start_index + D; if (label_type == framework::proto::VarType::INT32) { - MaskLabelByIndexGrad<<>>( - logit_grad_2d.data(), loss_grad->data(), - labels->data(), start_index, end_index, N, D); + MaskLabelByIndexGrad + <<>>( + logit_grad_2d.data(), loss_grad->data(), + labels->data(), start_index, end_index, N, D); } else if (label_type == framework::proto::VarType::INT64) { - MaskLabelByIndexGrad<<>>( - logit_grad_2d.data(), loss_grad->data(), - labels->data(), start_index, end_index, N, D); + MaskLabelByIndexGrad + <<>>( + logit_grad_2d.data(), loss_grad->data(), + labels->data(), start_index, end_index, N, D); } } }; diff --git a/paddle/fluid/operators/collective/c_split_op.cc b/paddle/fluid/operators/collective/c_split_op.cc index 37ec989f3f981227e37deb277c32301926723ed5..32f3ff9eab10d294ea070f5c56467d6ed01adfb9 100644 --- a/paddle/fluid/operators/collective/c_split_op.cc +++ b/paddle/fluid/operators/collective/c_split_op.cc @@ -27,17 +27,19 @@ class CSplitOp : public framework::OperatorWithKernel { int nranks = ctx->Attrs().Get("nranks"); int rank = ctx->Attrs().Get("rank"); int ring_id = ctx->Attrs().Get("ring_id"); - PADDLE_ENFORCE_GE(nranks, 2, platform::errors::InvalidArgument( - "The number of ranks (%d) for c_split " - "must be greater than 1.", - nranks)); + PADDLE_ENFORCE_GE(nranks, 2, + platform::errors::InvalidArgument( + "The number of ranks (%d) for c_split " + "must be greater than 1.", + nranks)); PADDLE_ENFORCE_GE( ring_id, 0, platform::errors::InvalidArgument( "The ring_id (%d) for c_split must be non-negative.", ring_id)); PADDLE_ENFORCE_GE( - rank, 0, platform::errors::InvalidArgument( - "The rank (%d) for c_split must be non-negative.", rank)); + rank, 0, + platform::errors::InvalidArgument( + "The rank (%d) for c_split must be non-negative.", rank)); PADDLE_ENFORCE_LT(rank, nranks, platform::errors::InvalidArgument( "The value of rank (%d) for c_split must " diff --git a/paddle/fluid/operators/collective/c_split_op.cu b/paddle/fluid/operators/collective/c_split_op.cu index a0c4182468f07b5be264ef3db20002c5d0c07660..1dce4ce04b56f85e2b026217db3fff95d9f64300 100644 --- a/paddle/fluid/operators/collective/c_split_op.cu +++ b/paddle/fluid/operators/collective/c_split_op.cu @@ -59,10 +59,11 @@ class CSplitOpCUDAKernel : public framework::OpKernel { int rank = ctx.Attr("rank"); auto place = ctx.GetPlace(); - PADDLE_ENFORCE_GE(rank, 0, platform::errors::PreconditionNotMet( - "The value of rank (%d) for c_split must be " - "greater than or equal to 0.", - rank)); + PADDLE_ENFORCE_GE(rank, 0, + platform::errors::PreconditionNotMet( + "The value of rank (%d) for c_split must be " + "greater than or equal to 0.", + rank)); PADDLE_ENFORCE_GE(nranks, 2, platform::errors::PreconditionNotMet( "The value of nranks (%d) for c_split must be " diff --git a/paddle/fluid/operators/collective/c_sync_comm_stream_op_npu_test.cc b/paddle/fluid/operators/collective/c_sync_comm_stream_op_npu_test.cc index 133085ad3f3b0ffd00dbf4d026687b0311116951..91b89486c6a4bbcd8209360fdb72d3967cf247a2 100644 --- a/paddle/fluid/operators/collective/c_sync_comm_stream_op_npu_test.cc +++ b/paddle/fluid/operators/collective/c_sync_comm_stream_op_npu_test.cc @@ -26,11 +26,10 @@ limitations under the License. */ #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/program_desc.h" -#include "paddle/fluid/string/printf.h" -#include "paddle/phi/kernels/funcs/math_function.h" - #include "paddle/fluid/operators/collective/c_broadcast_op.h" #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" +#include "paddle/fluid/string/printf.h" +#include "paddle/phi/kernels/funcs/math_function.h" #if defined(PADDLE_WITH_ASCEND_CL) #include "paddle/fluid/platform/collective_helper.h" diff --git a/paddle/fluid/operators/collective/checknumeric_npu_test.cc b/paddle/fluid/operators/collective/checknumeric_npu_test.cc index 36c6f4fadd0fcc9b06c61d5c45ce6829f2d3d977..b99ac3816352c1ae911f4aac570805c48f0fa5ae 100644 --- a/paddle/fluid/operators/collective/checknumeric_npu_test.cc +++ b/paddle/fluid/operators/collective/checknumeric_npu_test.cc @@ -17,21 +17,20 @@ limitations under the License. */ #endif #include + #include #include #include // NOLINT #include #include "gtest/gtest.h" - #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/program_desc.h" -#include "paddle/fluid/string/printf.h" -#include "paddle/phi/kernels/funcs/math_function.h" - #include "paddle/fluid/operators/collective/c_allreduce_op.h" #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" +#include "paddle/fluid/string/printf.h" +#include "paddle/phi/kernels/funcs/math_function.h" #if defined(PADDLE_WITH_ASCEND_CL) #include "paddle/fluid/platform/collective_helper.h" diff --git a/paddle/fluid/operators/collective/gen_bkcl_id_op.cc b/paddle/fluid/operators/collective/gen_bkcl_id_op.cc index 1ce8938356895968c5cbf871701946886508ebc7..f60030cec7628cdfc8468e20ea04fe33c58b6374 100644 --- a/paddle/fluid/operators/collective/gen_bkcl_id_op.cc +++ b/paddle/fluid/operators/collective/gen_bkcl_id_op.cc @@ -24,11 +24,10 @@ limitations under the License. */ #include "paddle/fluid/platform/device/xpu/bkcl_helper.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/enforce.h" +#include "paddle/fluid/platform/gen_comm_id_helper.h" #include "paddle/fluid/platform/place.h" #include "paddle/fluid/string/split.h" -#include "paddle/fluid/platform/gen_comm_id_helper.h" - namespace paddle { namespace operators { @@ -69,9 +68,10 @@ class GenBKCLIdOp : public framework::OperatorBase { int trainer_id = Attr("trainer_id"); std::string endpoint = trainers[trainer_id]; - PADDLE_ENFORCE_GE(trainer_id, 0, platform::errors::InvalidArgument( - "trainer_id %d is less than 0. Its " - "valid range is [0, trainer_size)")); + PADDLE_ENFORCE_GE( + trainer_id, 0, + platform::errors::InvalidArgument("trainer_id %d is less than 0. Its " + "valid range is [0, trainer_size)")); PADDLE_ENFORCE_LT( trainer_id, static_cast(trainers.size()), platform::errors::OutOfRange("trainer_id %d is out of range. Its valid " diff --git a/paddle/fluid/operators/collective/gen_hccl_id_op.cc b/paddle/fluid/operators/collective/gen_hccl_id_op.cc index 3d78082f12fc9c47a65f2c4ee5e53cad8369a1da..e0809459be10960b7f376e0ab6ce5019024c8d92 100644 --- a/paddle/fluid/operators/collective/gen_hccl_id_op.cc +++ b/paddle/fluid/operators/collective/gen_hccl_id_op.cc @@ -21,14 +21,13 @@ limitations under the License. */ #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/framework/var_type_traits.h" +#include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" #include "paddle/fluid/platform/device/npu/hccl_helper.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/place.h" #include "paddle/fluid/string/split.h" -#include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" - namespace paddle { namespace operators { @@ -48,9 +47,10 @@ class GenHCCLIdOp : public framework::OperatorBase { int trainer_id = Attr("trainer_id"); std::string endpoint = trainers[trainer_id]; - PADDLE_ENFORCE_GE(trainer_id, 0, platform::errors::InvalidArgument( - "trainer_id %d is less than 0. Its " - "valid range is [0, trainer_size)")); + PADDLE_ENFORCE_GE( + trainer_id, 0, + platform::errors::InvalidArgument("trainer_id %d is less than 0. Its " + "valid range is [0, trainer_size)")); PADDLE_ENFORCE_LT( trainer_id, static_cast(trainers.size()), platform::errors::OutOfRange("trainer_id %d is out of range. Its valid " diff --git a/paddle/fluid/operators/collective/gen_hccl_id_op_helper.cc b/paddle/fluid/operators/collective/gen_hccl_id_op_helper.cc index ad50ac367508b6d78d32668199658d0b8e2ef14d..ba573509bd18a2851ffcb9c0f5a57b17630b98b3 100644 --- a/paddle/fluid/operators/collective/gen_hccl_id_op_helper.cc +++ b/paddle/fluid/operators/collective/gen_hccl_id_op_helper.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" + #include #include #include diff --git a/paddle/fluid/operators/collective/gen_nccl_id_op.cc b/paddle/fluid/operators/collective/gen_nccl_id_op.cc index 7a5b6b5f429b2e2f522ff6764004024fde2e5daf..1e23f38c13ad03fa648ab6bc46906a7517e95909 100644 --- a/paddle/fluid/operators/collective/gen_nccl_id_op.cc +++ b/paddle/fluid/operators/collective/gen_nccl_id_op.cc @@ -70,9 +70,10 @@ class GenNCCLIdOp : public framework::OperatorBase { int trainer_id = Attr("trainer_id"); std::string endpoint = trainers[trainer_id]; - PADDLE_ENFORCE_GE(trainer_id, 0, platform::errors::InvalidArgument( - "trainer_id %d is less than 0. Its " - "valid range is [0, trainer_size)")); + PADDLE_ENFORCE_GE( + trainer_id, 0, + platform::errors::InvalidArgument("trainer_id %d is less than 0. Its " + "valid range is [0, trainer_size)")); PADDLE_ENFORCE_LT( trainer_id, static_cast(trainers.size()), platform::errors::OutOfRange("trainer_id %d is out of range. Its valid " diff --git a/paddle/fluid/operators/collective/partial_allgather_op.cc b/paddle/fluid/operators/collective/partial_allgather_op.cc index bef2ff94d630853487bb5c04798387113e5567ae..6783d2f0b4593115903e79db8969b6506fd472e8 100644 --- a/paddle/fluid/operators/collective/partial_allgather_op.cc +++ b/paddle/fluid/operators/collective/partial_allgather_op.cc @@ -26,8 +26,9 @@ class PartialAllGatherOp : public framework::OperatorWithKernel { int nranks = ctx->Attrs().Get("nranks"); int rank = ctx->Attrs().Get("rank"); - PADDLE_ENFORCE_GE(nranks, 2, platform::errors::InvalidArgument( - "The value of nranks should be >=2.")); + PADDLE_ENFORCE_GE(nranks, 2, + platform::errors::InvalidArgument( + "The value of nranks should be >=2.")); PADDLE_ENFORCE_EQ( (rank >= 0 && rank < nranks), true, platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/collective/partial_allgather_op_npu.cc b/paddle/fluid/operators/collective/partial_allgather_op_npu.cc index 0314bb7d5de1dfb0a81155fcaf24f4ce1efdd320..c727161d10179bda40cd8b6308963893affc6967 100644 --- a/paddle/fluid/operators/collective/partial_allgather_op_npu.cc +++ b/paddle/fluid/operators/collective/partial_allgather_op_npu.cc @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/collective/partial_allgather_op.h" #include +#include "paddle/fluid/operators/collective/partial_allgather_op.h" #include "paddle/fluid/platform/collective_helper.h" #include "paddle/fluid/platform/device/npu/hccl_helper.h" diff --git a/paddle/fluid/operators/collective/partial_recv_op.cc b/paddle/fluid/operators/collective/partial_recv_op.cc index 99b2169180c77c6398a3a1f3bb9ad5fbd007b3f5..df59f49cb3a6025586b5838bc6593a104865bb78 100644 --- a/paddle/fluid/operators/collective/partial_recv_op.cc +++ b/paddle/fluid/operators/collective/partial_recv_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/collective/partial_recv_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/collective/partial_recv_op_npu.cc b/paddle/fluid/operators/collective/partial_recv_op_npu.cc index f14ce5f81f905d31a40abb779057d04082daeb00..4704ab7683cf3ec0daa1dbc28f41fc49c4247111 100644 --- a/paddle/fluid/operators/collective/partial_recv_op_npu.cc +++ b/paddle/fluid/operators/collective/partial_recv_op_npu.cc @@ -13,7 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/collective/partial_recv_op.h" - #include "paddle/fluid/platform/collective_helper.h" #include "paddle/fluid/platform/device/npu/hccl_helper.h" @@ -55,8 +54,9 @@ class PartialRecvOpASCENDKernel : public framework::OpKernel { int nranks = comm->nranks(); int peer = ctx.Attr("peer"); - PADDLE_ENFORCE_EQ(nranks, 2, platform::errors::InvalidArgument( - "The nranks must be 2, but (%d)", nranks)); + PADDLE_ENFORCE_EQ(nranks, 2, + platform::errors::InvalidArgument( + "The nranks must be 2, but (%d)", nranks)); int root = peer; diff --git a/paddle/fluid/operators/collective/partial_send_op_npu.cc b/paddle/fluid/operators/collective/partial_send_op_npu.cc index 31c74fcc196be1f715b50b641ad71bdf92d1b0b9..8f53bd8fc5f6a09218cbe891ffd42afa3decfa71 100644 --- a/paddle/fluid/operators/collective/partial_send_op_npu.cc +++ b/paddle/fluid/operators/collective/partial_send_op_npu.cc @@ -13,7 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/collective/send_v2_op.h" - #include "paddle/fluid/platform/collective_helper.h" #include "paddle/fluid/platform/device/npu/hccl_helper.h" @@ -52,8 +51,9 @@ class PartialSendOpASCENDKernel : public framework::OpKernel { int nranks = comm->nranks(); int rank = comm->rank(); - PADDLE_ENFORCE_EQ(nranks, 2, platform::errors::InvalidArgument( - "The nranks must be 2, but (%d)", nranks)); + PADDLE_ENFORCE_EQ(nranks, 2, + platform::errors::InvalidArgument( + "The nranks must be 2, but (%d)", nranks)); int root = rank; diff --git a/paddle/fluid/operators/collective/recv_v2_op.cc b/paddle/fluid/operators/collective/recv_v2_op.cc index 494665544f0d39ca50546cad51bd50c7af7e8c3e..15da47e713bb917148dfcf87b186b5c907ae56d7 100644 --- a/paddle/fluid/operators/collective/recv_v2_op.cc +++ b/paddle/fluid/operators/collective/recv_v2_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/collective/recv_v2_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/collective/recv_v2_op_npu.cc b/paddle/fluid/operators/collective/recv_v2_op_npu.cc index c31f1210f042264c88c49771bb22d30967be454b..9aa1ab788693d50503369bb8d6af89297f9f3f05 100644 --- a/paddle/fluid/operators/collective/recv_v2_op_npu.cc +++ b/paddle/fluid/operators/collective/recv_v2_op_npu.cc @@ -61,8 +61,9 @@ class CRecvOpASCENDKernel : public framework::OpKernel { int nranks = comm->nranks(); int peer = ctx.Attr("peer"); - PADDLE_ENFORCE_EQ(nranks, 2, platform::errors::InvalidArgument( - "The nranks must be 2, but (%d)", nranks)); + PADDLE_ENFORCE_EQ(nranks, 2, + platform::errors::InvalidArgument( + "The nranks must be 2, but (%d)", nranks)); int root = peer; diff --git a/paddle/fluid/operators/collective/recv_v2_op_npu_test.cc b/paddle/fluid/operators/collective/recv_v2_op_npu_test.cc index 6e02d362156970cdee7257c7d00b70cef0519757..0022b6bf39ddf6cf946d60e38fff8b9d27b289a2 100644 --- a/paddle/fluid/operators/collective/recv_v2_op_npu_test.cc +++ b/paddle/fluid/operators/collective/recv_v2_op_npu_test.cc @@ -17,20 +17,19 @@ limitations under the License. */ #endif #include + #include #include // NOLINT #include #include "gtest/gtest.h" - #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/program_desc.h" -#include "paddle/fluid/string/printf.h" -#include "paddle/phi/kernels/funcs/math_function.h" - #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" #include "paddle/fluid/operators/collective/recv_v2_op.h" +#include "paddle/fluid/string/printf.h" +#include "paddle/phi/kernels/funcs/math_function.h" #if defined(PADDLE_WITH_ASCEND_CL) #include "paddle/fluid/platform/collective_helper.h" diff --git a/paddle/fluid/operators/collective/send_v2_op_npu.cc b/paddle/fluid/operators/collective/send_v2_op_npu.cc index 882630467a012f1c2cef3bf9d9edd33a244fc97f..ee34026cb28b2969dfe9965aaa4244fcb23858a5 100644 --- a/paddle/fluid/operators/collective/send_v2_op_npu.cc +++ b/paddle/fluid/operators/collective/send_v2_op_npu.cc @@ -60,8 +60,9 @@ class CSendOpASCENDKernel : public framework::OpKernel { int nranks = comm->nranks(); int rank = comm->rank(); - PADDLE_ENFORCE_EQ(nranks, 2, platform::errors::InvalidArgument( - "The nranks must be 2, but (%d)", nranks)); + PADDLE_ENFORCE_EQ(nranks, 2, + platform::errors::InvalidArgument( + "The nranks must be 2, but (%d)", nranks)); int root = rank; diff --git a/paddle/fluid/operators/collective/send_v2_op_npu_test.cc b/paddle/fluid/operators/collective/send_v2_op_npu_test.cc index 57e3dd53cc7748fa0fb66e7e934a1c9cd764a15f..9784e6ddc15372314f7e8011be059900f8c2db30 100644 --- a/paddle/fluid/operators/collective/send_v2_op_npu_test.cc +++ b/paddle/fluid/operators/collective/send_v2_op_npu_test.cc @@ -17,19 +17,19 @@ limitations under the License. */ #endif #include + #include #include // NOLINT #include -#include "gtest/gtest.h" +#include "gtest/gtest.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/program_desc.h" -#include "paddle/fluid/string/printf.h" -#include "paddle/phi/kernels/funcs/math_function.h" - #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" #include "paddle/fluid/operators/collective/send_v2_op.h" +#include "paddle/fluid/string/printf.h" +#include "paddle/phi/kernels/funcs/math_function.h" #if defined(PADDLE_WITH_ASCEND_CL) #include "paddle/fluid/platform/collective_helper.h" diff --git a/paddle/fluid/operators/common_infer_shape_functions.cc b/paddle/fluid/operators/common_infer_shape_functions.cc index 1d187451c6858a90afad79f186c5233213a311b7..8bd60c77c46cf31fc459b7455608c099ce6e5697 100644 --- a/paddle/fluid/operators/common_infer_shape_functions.cc +++ b/paddle/fluid/operators/common_infer_shape_functions.cc @@ -61,12 +61,13 @@ inline void GetBroadcastDimsArrays(const framework::DDim &x_dims, PADDLE_ENFORCE_EQ( x_dims_array[i] == y_dims_array[i] || x_dims_array[i] <= 1 || y_dims_array[i] <= 1, - true, platform::errors::InvalidArgument( - "Broadcast dimension mismatch. Operands could " - "not be broadcast together with the shape of X = [%s] and " - "the shape of Y = [%s]. Received [%d] in X is not equal to " - "[%d] in Y at i:%d.", - x_dims, y_dims, x_dims_array[i], y_dims_array[i], i)); + true, + platform::errors::InvalidArgument( + "Broadcast dimension mismatch. Operands could " + "not be broadcast together with the shape of X = [%s] and " + "the shape of Y = [%s]. Received [%d] in X is not equal to " + "[%d] in Y at i:%d.", + x_dims, y_dims, x_dims_array[i], y_dims_array[i], i)); if ((x_dims_array[i] > 1 || y_dims_array[i] > 1) || (x_dims_array[i] == 1 && y_dims_array[i] == 1)) { out_dims_array[i] = std::max(x_dims_array[i], y_dims_array[i]); diff --git a/paddle/fluid/operators/complex_op.cc b/paddle/fluid/operators/complex_op.cc index 7241c92258eeac7031e8bd8eefc9d43e97a0a156..d358f5765f9e87e8158e3c3e56f7a3b3fde2cbe6 100644 --- a/paddle/fluid/operators/complex_op.cc +++ b/paddle/fluid/operators/complex_op.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/fluid/operators/complex_op.h" #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/elementwise/elementwise_op_function.h" diff --git a/paddle/fluid/operators/complex_view_op.cc b/paddle/fluid/operators/complex_view_op.cc index 763f936ec9c48dc78e34e6112d4201c82303b5b7..92b48fe8b06c787be2a3524b6d1eab72cb07956e 100644 --- a/paddle/fluid/operators/complex_view_op.cc +++ b/paddle/fluid/operators/complex_view_op.cc @@ -18,6 +18,7 @@ #include #include #include + #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/operators/complex_view_op.cu b/paddle/fluid/operators/complex_view_op.cu index 261881cb8d256dcfd5afc465a55b6ba642656e38..b62c0470dd6bae5a9f4062e8f33138927cf53415 100644 --- a/paddle/fluid/operators/complex_view_op.cu +++ b/paddle/fluid/operators/complex_view_op.cu @@ -12,9 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/operators/complex_view_op.h" - #include "paddle/fluid/framework/data_type.h" +#include "paddle/fluid/operators/complex_view_op.h" #include "paddle/fluid/platform/enforce.h" namespace ops = paddle::operators; diff --git a/paddle/fluid/operators/concat_op.cc b/paddle/fluid/operators/concat_op.cc index a467f2dbee7c9ba5c896ecda55882ebf61214404..599fbcce39ff3688e01b3a0dc23e790741616609 100644 --- a/paddle/fluid/operators/concat_op.cc +++ b/paddle/fluid/operators/concat_op.cc @@ -15,11 +15,12 @@ limitations under the License. */ #include "paddle/fluid/operators/concat_op.h" #include + #include #include #include -#include "paddle/fluid/framework/infershape_utils.h" +#include "paddle/fluid/framework/infershape_utils.h" #include "paddle/phi/infermeta/multiary.h" #include "paddle/phi/kernels/funcs/concat_funcs.h" diff --git a/paddle/fluid/operators/concat_op.h b/paddle/fluid/operators/concat_op.h index 50aca54c12decfea8703a130317f22cd9cb9d485..746e0e7a056fef4ae24b1c4ce78e6c36032106be 100644 --- a/paddle/fluid/operators/concat_op.h +++ b/paddle/fluid/operators/concat_op.h @@ -17,11 +17,11 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/math/concat_and_split.h" #include "paddle/fluid/operators/strided_memcpy.h" #include "paddle/fluid/operators/utils.h" - #include "paddle/phi/kernels/concat_kernel.h" #include "paddle/phi/kernels/funcs/concat_funcs.h" diff --git a/paddle/fluid/operators/concat_op_mlu.cc b/paddle/fluid/operators/concat_op_mlu.cc index e8f6b2dc86952234a9625810863f8b27b0b641f7..3d927af96e1b79f71f72e9c0f811307bf557234f 100644 --- a/paddle/fluid/operators/concat_op_mlu.cc +++ b/paddle/fluid/operators/concat_op_mlu.cc @@ -99,10 +99,11 @@ class ConcatGradMLUKernel : public framework::OpKernel { axis = ComputeAxis(static_cast(axis), static_cast(ins[0]->dims().size())); - PADDLE_ENFORCE_GE(axis, 0, platform::errors::InvalidArgument( - "concat_grad: axis should be larger than or " - "equal to 0, but received axis is %d.", - axis)); + PADDLE_ENFORCE_GE(axis, 0, + platform::errors::InvalidArgument( + "concat_grad: axis should be larger than or " + "equal to 0, but received axis is %d.", + axis)); PADDLE_ENFORCE_LT( axis, out_grad->dims().size(), platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/concat_op_xpu.cc b/paddle/fluid/operators/concat_op_xpu.cc index ba35098bbac1006686525ede2b25a12825950abc..fcbfc6f7a2b3c71d6cdf48cf3853dd5ecb39ce27 100644 --- a/paddle/fluid/operators/concat_op_xpu.cc +++ b/paddle/fluid/operators/concat_op_xpu.cc @@ -12,12 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifdef PADDLE_WITH_XPU -#include "paddle/fluid/operators/concat_op.h" #include #include #include -#include "paddle/fluid/platform/device/xpu/xpu_header.h" +#include "paddle/fluid/operators/concat_op.h" +#include "paddle/fluid/platform/device/xpu/xpu_header.h" #include "paddle/phi/core/lod_utils.h" namespace paddle { @@ -33,17 +33,19 @@ class ConcatXPUKernel : public framework::OpKernel { auto ins = ctx.MultiInput("X"); framework::LoDTensor* out = ctx.Output("Out"); int axis = ctx.Attr("axis"); - PADDLE_ENFORCE_NE(ins[0], nullptr, platform::errors::InvalidArgument( - "The input should not be null.")); + PADDLE_ENFORCE_NE( + ins[0], nullptr, + platform::errors::InvalidArgument("The input should not be null.")); PADDLE_ENFORCE_NE(ctx.HasInput("AxisTensor"), true, platform::errors::InvalidArgument( "XPU donot surpport AxisTensor for now")); axis = ComputeAxis(static_cast(axis), static_cast(ins[0]->dims().size())); - PADDLE_ENFORCE_GE(axis, 0, platform::errors::InvalidArgument( - "concat: axis should be larger than or " - "equal to 0, but received axis is %d.", - axis)); + PADDLE_ENFORCE_GE(axis, 0, + platform::errors::InvalidArgument( + "concat: axis should be larger than or " + "equal to 0, but received axis is %d.", + axis)); PADDLE_ENFORCE_LT(axis, ins[0]->dims().size(), platform::errors::InvalidArgument( "concat: axis should be less than ins[0]->dims()!" @@ -94,8 +96,9 @@ class ConcatXPUKernel : public framework::OpKernel { } } - PADDLE_ENFORCE_GT(xdims_list.size(), 0, platform::errors::InvalidArgument( - "No tensor need concat")); + PADDLE_ENFORCE_GT( + xdims_list.size(), 0, + platform::errors::InvalidArgument("No tensor need concat")); auto& dev_ctx = ctx.template device_context(); int r = xpu::concat(dev_ctx.x_context(), ptrs, @@ -129,8 +132,9 @@ class ConcatGradXPUKernel : public framework::OpKernel { } } } - PADDLE_ENFORCE_NE(ins[0], nullptr, platform::errors::InvalidArgument( - "The input should not be null.")); + PADDLE_ENFORCE_NE( + ins[0], nullptr, + platform::errors::InvalidArgument("The input should not be null.")); auto axis = ctx.Attr("axis"); if (ctx.HasInput("AxisTensor")) { auto* axis_tensor = ctx.Input("AxisTensor"); @@ -149,10 +153,11 @@ class ConcatGradXPUKernel : public framework::OpKernel { ptrs[j] = nullptr; } } - PADDLE_ENFORCE_GE(axis, 0, platform::errors::InvalidArgument( - "concat_grad: axis should be larger than or " - "equal to 0, but received axis is %d.", - axis)); + PADDLE_ENFORCE_GE(axis, 0, + platform::errors::InvalidArgument( + "concat_grad: axis should be larger than or " + "equal to 0, but received axis is %d.", + axis)); PADDLE_ENFORCE_LT( axis, out_grad->dims().size(), platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/conj_op.cc b/paddle/fluid/operators/conj_op.cc index cbec1182f20b886fb4a77847abf7213aec9990a5..0c294b60482e4fa7d3a675d8f546521ebe4d4f95 100644 --- a/paddle/fluid/operators/conj_op.cc +++ b/paddle/fluid/operators/conj_op.cc @@ -74,8 +74,9 @@ REGISTER_OPERATOR(conj, ops::ConjOp, ops::ConjOpMaker, ConjInferShapeFunctor); REGISTER_OP_CPU_KERNEL( - conj, ops::ConjKernel>, + conj, + ops::ConjKernel>, ops::ConjKernel>, ops::ConjKernel, diff --git a/paddle/fluid/operators/conj_op.cu b/paddle/fluid/operators/conj_op.cu index d04024d70a8ea66128010d39c9eb1233d28caf03..548508636ca26de5d9c92ffda89fe3b95a6b143c 100644 --- a/paddle/fluid/operators/conj_op.cu +++ b/paddle/fluid/operators/conj_op.cu @@ -17,8 +17,9 @@ namespace ops = paddle::operators; REGISTER_OP_CUDA_KERNEL( - conj, ops::ConjKernel>, + conj, + ops::ConjKernel>, ops::ConjKernel>, ops::ConjKernel, diff --git a/paddle/fluid/operators/controlflow/bitwise_op.cc b/paddle/fluid/operators/controlflow/bitwise_op.cc index 4dcbbc8568ff18a1313171f8f66f276d77f019a1..19865f9a9fb7100b2cbc9ac06c02637bd6753e48 100644 --- a/paddle/fluid/operators/controlflow/bitwise_op.cc +++ b/paddle/fluid/operators/controlflow/bitwise_op.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/elementwise/elementwise_op_function.h" diff --git a/paddle/fluid/operators/controlflow/compare_op.cc b/paddle/fluid/operators/controlflow/compare_op.cc index 72d81d8c3fdf2827da9b8362cee80ecbb16e4484..21fc69eb019d32cd796e81ec9ac293dbfd4e33de 100644 --- a/paddle/fluid/operators/controlflow/compare_op.cc +++ b/paddle/fluid/operators/controlflow/compare_op.cc @@ -80,14 +80,12 @@ class CompareOp : public framework::OperatorWithKernel { } // namespace operators } // namespace paddle -#define REGISTER_COMPARE_OP_VERSION(op_type) \ - REGISTER_OP_VERSION(op_type) \ - .AddCheckpoint( \ - R"ROC(Upgrade compare ops, add a new attribute [force_cpu])ROC", \ - paddle::framework::compatible::OpVersionDesc().ModifyAttr( \ - "force_cpu", \ - "In order to force fill output variable to gpu memory.", \ - false)); +#define REGISTER_COMPARE_OP_VERSION(op_type) \ + REGISTER_OP_VERSION(op_type).AddCheckpoint( \ + R"ROC(Upgrade compare ops, add a new attribute [force_cpu])ROC", \ + paddle::framework::compatible::OpVersionDesc().ModifyAttr( \ + "force_cpu", \ + "In order to force fill output variable to gpu memory.", false)); #define REGISTER_COMPARE_OP(op_type, _equation) \ struct _##op_type##Comment { \ diff --git a/paddle/fluid/operators/controlflow/conditional_block_op.h b/paddle/fluid/operators/controlflow/conditional_block_op.h index c024e4a12cd4711b679b986d0bb0918be17c6e1c..c1d13ffdf129591125f1ac7fd050dc8fcaa8acf8 100644 --- a/paddle/fluid/operators/controlflow/conditional_block_op.h +++ b/paddle/fluid/operators/controlflow/conditional_block_op.h @@ -68,10 +68,11 @@ class ConditionalOp : public framework::OperatorBase { PADDLE_ENFORCE_EQ(framework::TransToProtoVarType(ips[0]->dtype()) == framework::proto::VarType::BOOL && ips[0]->numel() == 1, - true, platform::errors::InvalidArgument( - "condition input's data type should be bool, " - "numel should be 1, actual numel is %d", - ips[0]->numel())); + true, + platform::errors::InvalidArgument( + "condition input's data type should be bool, " + "numel should be 1, actual numel is %d", + ips[0]->numel())); bool res = false; if (platform::is_gpu_place(ips[0]->place())) { #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) diff --git a/paddle/fluid/operators/controlflow/fetch_op.cc b/paddle/fluid/operators/controlflow/fetch_op.cc index 111ca9c63c634634d30de11186e5f8b0a4ef7f0b..369a1ffedc419bfc23898abf8cbea28f060a30ae 100644 --- a/paddle/fluid/operators/controlflow/fetch_op.cc +++ b/paddle/fluid/operators/controlflow/fetch_op.cc @@ -35,10 +35,11 @@ static void DataCopy(const framework::LoDTensor &src_item, // as params are not a subject to paddle's data_format VLOG(4) << "innerTransDataLayoutFromMKLDNN"; framework::innerTransDataLayoutFromMKLDNN( - src_item.layout(), fetch_var_name == framework::GradVarName("Filter") - ? framework::DataLayout::kNCHW - : paddle::platform::MKLDNNDeviceContext::tls() - .get_cur_paddle_data_layout(), + src_item.layout(), + fetch_var_name == framework::GradVarName("Filter") + ? framework::DataLayout::kNCHW + : paddle::platform::MKLDNNDeviceContext::tls() + .get_cur_paddle_data_layout(), src_item, &out, platform::CPUPlace()); paddle::framework::TensorCopySync(out, platform::CPUPlace(), dst_item); } else { @@ -92,11 +93,12 @@ class FetchOp : public framework::OperatorBase { int col = Attr("col"); PADDLE_ENFORCE_GE( - col, 0, platform::errors::InvalidArgument( - "Expected the column index (the attribute 'col' of " - "operator 'Fetch') of current fetching variable to be " - "no less than 0. But received column index = %d.", - col)); + col, 0, + platform::errors::InvalidArgument( + "Expected the column index (the attribute 'col' of " + "operator 'Fetch') of current fetching variable to be " + "no less than 0. But received column index = %d.", + col)); VLOG(3) << "Fetch variable " << fetch_var_name << " to variable " << out_name << "'s " << col << " column."; diff --git a/paddle/fluid/operators/controlflow/fetch_v2_op.cc b/paddle/fluid/operators/controlflow/fetch_v2_op.cc index caa67139a9b95aaf1c4f9418d3c72cae0eef8d07..29d6eb1b2d44c771e7076c0a63c6595cf5a52ad2 100644 --- a/paddle/fluid/operators/controlflow/fetch_v2_op.cc +++ b/paddle/fluid/operators/controlflow/fetch_v2_op.cc @@ -42,10 +42,11 @@ static void DeepCopy(const framework::LoDTensor &src_item, // Convert to desired Paddle layout, apart from grads of filter // as params are not a subject to paddle's data_format framework::innerTransDataLayoutFromMKLDNN( - src_item.layout(), fetch_var_name == framework::GradVarName("Filter") - ? framework::DataLayout::kNCHW - : paddle::platform::MKLDNNDeviceContext::tls() - .get_cur_paddle_data_layout(), + src_item.layout(), + fetch_var_name == framework::GradVarName("Filter") + ? framework::DataLayout::kNCHW + : paddle::platform::MKLDNNDeviceContext::tls() + .get_cur_paddle_data_layout(), src_item, &out, platform::CPUPlace()); paddle::framework::TensorCopySync(out, platform::CPUPlace(), dst_item); } else { @@ -123,11 +124,12 @@ class FetchV2Kernel { int col = ctx.Attr("col"); PADDLE_ENFORCE_GE( - col, 0, platform::errors::InvalidArgument( - "Expected the column index (the attribute 'col' of " - "operator 'Fetch') of current fetching variable to be " - "no less than 0. But received column index = %d.", - col)); + col, 0, + platform::errors::InvalidArgument( + "Expected the column index (the attribute 'col' of " + "operator 'Fetch') of current fetching variable to be " + "no less than 0. But received column index = %d.", + col)); auto *fetch_list = out_var->GetMutable(); diff --git a/paddle/fluid/operators/controlflow/get_places_op.cc b/paddle/fluid/operators/controlflow/get_places_op.cc index 55bd4879ab7947159c7cf5053c894c3268b3476e..7f3b004004136ed96c81ef87f2704bd56977515d 100644 --- a/paddle/fluid/operators/controlflow/get_places_op.cc +++ b/paddle/fluid/operators/controlflow/get_places_op.cc @@ -62,9 +62,10 @@ class GetPlacesOp : public framework::OperatorBase { device_count = is_gpu ? CUDADevCount() : std::thread::hardware_concurrency(); } - PADDLE_ENFORCE_NE(device_count, 0UL, platform::errors::InvalidArgument( - "Cannot indicate %s device count", - is_gpu ? "GPU" : "CPU")); + PADDLE_ENFORCE_NE( + device_count, 0UL, + platform::errors::InvalidArgument("Cannot indicate %s device count", + is_gpu ? "GPU" : "CPU")); auto out_var_name = Output("Out"); auto &places = *(GET_DATA_SAFELY(scope.FindVar(out_var_name), "Output", diff --git a/paddle/fluid/operators/controlflow/logical_op.cc b/paddle/fluid/operators/controlflow/logical_op.cc index 4d11cb5ff74e69e991271d2a566dbc9344d35da2..a9c28f48ef7396c54ee667f40d33a8fd0877a908 100644 --- a/paddle/fluid/operators/controlflow/logical_op.cc +++ b/paddle/fluid/operators/controlflow/logical_op.cc @@ -12,6 +12,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/elementwise/elementwise_op_function.h" diff --git a/paddle/fluid/operators/controlflow/op_variant.h b/paddle/fluid/operators/controlflow/op_variant.h index cc1f36a875f774892b38d203e4fd74d8b1626e76..57d44b6793966c45535337a70c65d50c387e0234 100644 --- a/paddle/fluid/operators/controlflow/op_variant.h +++ b/paddle/fluid/operators/controlflow/op_variant.h @@ -50,8 +50,9 @@ class OpVariant { const AttrType &Attr(const std::string &name) const { auto &attrs = Attrs(); auto it = attrs.find(name); - PADDLE_ENFORCE_NE(it, attrs.end(), platform::errors::NotFound( - "Cannot find attribute %s.", name)); + PADDLE_ENFORCE_NE( + it, attrs.end(), + platform::errors::NotFound("Cannot find attribute %s.", name)); return BOOST_GET_CONST(AttrType, it->second); } diff --git a/paddle/fluid/operators/controlflow/recurrent_op_helper.cc b/paddle/fluid/operators/controlflow/recurrent_op_helper.cc index 43913cae6b3c2bf8300075a7b09c906b6d85a9eb..62cd2fc3376d5544f4c33c580ff23d6d3e51c8c8 100644 --- a/paddle/fluid/operators/controlflow/recurrent_op_helper.cc +++ b/paddle/fluid/operators/controlflow/recurrent_op_helper.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/controlflow/recurrent_op_helper.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/controlflow/while_op.cc b/paddle/fluid/operators/controlflow/while_op.cc index d8daa25f31be8d0eac90667daed40367cc037d35..a551bad8eb10e00bdc84d9e3fe3d2fdbcf12619a 100644 --- a/paddle/fluid/operators/controlflow/while_op.cc +++ b/paddle/fluid/operators/controlflow/while_op.cc @@ -45,7 +45,7 @@ static std::string GetSkipEagerDeletionVarsDebugString( } return str; } -} // NOLINT +} // namespace class WhileOp : public framework::OperatorBase { public: @@ -375,10 +375,11 @@ class WhileGradOp : public framework::OperatorBase { PADDLE_ENFORCE_EQ( var->IsType() || var->IsType(), - true, platform::errors::InvalidArgument( - "Currently the type of var only can be LoDTensorArray, " - "or LoDTensor, but the received var[%s] is %s.", - inside_grad_name, framework::ToTypeName(var->Type()))); + true, + platform::errors::InvalidArgument( + "Currently the type of var only can be LoDTensorArray, " + "or LoDTensor, but the received var[%s] is %s.", + inside_grad_name, framework::ToTypeName(var->Type()))); if ((var_iter == outside_og_names.end()) && var->IsType()) { diff --git a/paddle/fluid/operators/controlflow/while_op_helper.cc b/paddle/fluid/operators/controlflow/while_op_helper.cc index 63b273fdbb8bdfe0b97064ec055be3e8217b019a..2b2001be6bfff396aaa1000db25791cc65b66ae4 100644 --- a/paddle/fluid/operators/controlflow/while_op_helper.cc +++ b/paddle/fluid/operators/controlflow/while_op_helper.cc @@ -15,6 +15,7 @@ #include "paddle/fluid/operators/controlflow/while_op_helper.h" #include + #include "paddle/fluid/string/string_helper.h" namespace paddle { diff --git a/paddle/fluid/operators/conv_base_helper.h b/paddle/fluid/operators/conv_base_helper.h index 9e1a323fc9f3d67e3346dfaa255a6f6c09223747..f141c9eb08766f4b553296c324bb31817cf85535 100644 --- a/paddle/fluid/operators/conv_base_helper.h +++ b/paddle/fluid/operators/conv_base_helper.h @@ -19,6 +19,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/conv_search_cache.h" #include "paddle/fluid/operators/conv_cudnn_op_cache.h" #include "paddle/phi/backends/gpu/gpu_context.h" diff --git a/paddle/fluid/operators/conv_cudnn_op_cache.h b/paddle/fluid/operators/conv_cudnn_op_cache.h index af67d857e0eb7c85f7f8ff89e1a9d07640aeb73a..3d704c8be30e4a22406593ab9a6a45a5a94747a1 100644 --- a/paddle/fluid/operators/conv_cudnn_op_cache.h +++ b/paddle/fluid/operators/conv_cudnn_op_cache.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/platform/device/gpu/gpu_dnn.h" diff --git a/paddle/fluid/operators/conv_op.cc b/paddle/fluid/operators/conv_op.cc index f084862b419d5a003298611e064199ceb6c7ca50..28ca2feeec53b4661681805a6f025389d90fe6f8 100644 --- a/paddle/fluid/operators/conv_op.cc +++ b/paddle/fluid/operators/conv_op.cc @@ -19,15 +19,13 @@ limitations under the License. */ #include #include "paddle/fluid/framework/op_version_registry.h" - #include "paddle/fluid/platform/device/gpu/gpu_dnn.h" #ifdef PADDLE_WITH_MKLDNN #include "paddle/fluid/platform/mkldnn_helper.h" #endif -#include "paddle/fluid/platform/cudnn_workspace_helper.h" - #include "paddle/fluid/framework/infershape_utils.h" +#include "paddle/fluid/platform/cudnn_workspace_helper.h" #include "paddle/phi/infermeta/binary.h" namespace paddle { @@ -864,16 +862,15 @@ REGISTER_OPERATOR(conv3d_grad, ops::ConvOpGrad, ops::Conv3DDoubleGradMaker); REGISTER_OPERATOR(conv3d_grad_grad, ops::ConvOpDoubleGrad); -REGISTER_OP_VERSION(conv2d) - .AddCheckpoint( - R"ROC( +REGISTER_OP_VERSION(conv2d).AddCheckpoint( + R"ROC( Upgrade conv2d, add a new attribute [use_addto]. )ROC", - paddle::framework::compatible::OpVersionDesc().NewAttr( - "use_addto", - "In order to support new feature (inplace addto strategy) for " - "gradient accumulation.", - false)); + paddle::framework::compatible::OpVersionDesc().NewAttr( + "use_addto", + "In order to support new feature (inplace addto strategy) for " + "gradient accumulation.", + false)); REGISTER_OP_VERSION(depthwise_conv2d) .AddCheckpoint( @@ -886,13 +883,12 @@ REGISTER_OP_VERSION(depthwise_conv2d) "gradient accumulation.", false)); -REGISTER_OP_VERSION(conv3d) - .AddCheckpoint( - R"ROC( +REGISTER_OP_VERSION(conv3d).AddCheckpoint( + R"ROC( Upgrade conv3d, add a new attribute [use_addto]. )ROC", - paddle::framework::compatible::OpVersionDesc().NewAttr( - "use_addto", - "In order to support new feature (inplace addto strategy) for " - "gradient accumulation.", - false)); + paddle::framework::compatible::OpVersionDesc().NewAttr( + "use_addto", + "In order to support new feature (inplace addto strategy) for " + "gradient accumulation.", + false)); diff --git a/paddle/fluid/operators/conv_op.h b/paddle/fluid/operators/conv_op.h index 58f2eeee256db07c1d0bd35b883217919236fd70..644a827b48821e488883bb76032448c0fcc0f7d2 100644 --- a/paddle/fluid/operators/conv_op.h +++ b/paddle/fluid/operators/conv_op.h @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/layout_utils.h" diff --git a/paddle/fluid/operators/conv_op_npu.cc b/paddle/fluid/operators/conv_op_npu.cc index 3ace825e7b80df6032183505c048a6c0e796aaca..15a5aa737ae7eb8cc9a9fe87be863bc7b8a57bf7 100644 --- a/paddle/fluid/operators/conv_op_npu.cc +++ b/paddle/fluid/operators/conv_op_npu.cc @@ -130,12 +130,12 @@ class DepthwiseConvNPUKernel : public framework::OpKernel { "TransposeD", {*filter}, {transformed_filter}, {{"perm", perm}}); runner_trans.Run(stream); - const auto& runner = - NpuOpRunner("DepthwiseConv2D", {input_tensor, transformed_filter}, - {output_tensor}, {{"strides", strides}, - {"dilations", dilations}, - {"pads", padding}, - {"data_format", data_format}}); + const auto& runner = NpuOpRunner( + "DepthwiseConv2D", {input_tensor, transformed_filter}, {output_tensor}, + {{"strides", strides}, + {"dilations", dilations}, + {"pads", padding}, + {"data_format", data_format}}); runner.Run(stream); } }; @@ -392,14 +392,15 @@ class NPUConvGradOpKernel : public framework::OpKernel { filter_grad_fp32.ShareDataWith(*filter_grad); } - const auto& runner = NpuOpRunner( - "Conv2DBackpropFilterD", {input_tensor, output_grad_tensor}, - {filter_grad_fp32}, {{"filter_size", filter_shape_vec}, - {"strides", strides_vec}, - {"pads", paddings}, - {"dilations", dilations_vec}, - {"groups", groups}, - {"data_format", data_format}}); + const auto& runner = + NpuOpRunner("Conv2DBackpropFilterD", + {input_tensor, output_grad_tensor}, {filter_grad_fp32}, + {{"filter_size", filter_shape_vec}, + {"strides", strides_vec}, + {"pads", paddings}, + {"dilations", dilations_vec}, + {"groups", groups}, + {"data_format", data_format}}); runner.Run(stream); if (framework::TransToProtoVarType(input->dtype()) == @@ -418,12 +419,13 @@ class NPUConvGradOpKernel : public framework::OpKernel { } const auto& runner = NpuOpRunner("Conv2DBackpropInputD", {*filter, output_grad_tensor}, - {input_grad_tensor}, {{"input_size", input_shape_vec}, - {"strides", strides_vec}, - {"pads", paddings}, - {"dilations", dilations_vec}, - {"groups", groups}, - {"data_format", data_format}}); + {input_grad_tensor}, + {{"input_size", input_shape_vec}, + {"strides", strides_vec}, + {"pads", paddings}, + {"dilations", dilations_vec}, + {"groups", groups}, + {"data_format", data_format}}); runner.Run(stream); } } @@ -452,11 +454,12 @@ class NPUConv3dKernel : public framework::OpKernel { "= [%s]", data_format)); - PADDLE_ENFORCE_EQ(groups, 1, platform::errors::Unimplemented( - "the groups must be 1 in " - "the npu kernel of conv3d, but got groups " - "= [%d]", - groups)); + PADDLE_ENFORCE_EQ(groups, 1, + platform::errors::Unimplemented( + "the groups must be 1 in " + "the npu kernel of conv3d, but got groups " + "= [%d]", + groups)); output->mutable_data(ctx.GetPlace()); @@ -537,11 +540,12 @@ class NPUConv3dGradKernel : public framework::OpKernel { "= [%s]", data_format)); - PADDLE_ENFORCE_EQ(groups, 1, platform::errors::Unimplemented( - "the groups must be 1 in " - "the npu kernel of conv3d, but got groups " - "= [%d]", - groups)); + PADDLE_ENFORCE_EQ(groups, 1, + platform::errors::Unimplemented( + "the groups must be 1 in " + "the npu kernel of conv3d, but got groups " + "= [%d]", + groups)); auto& dev_ctx = ctx.template device_context(); auto input_tensor = @@ -593,14 +597,15 @@ class NPUConv3dGradKernel : public framework::OpKernel { filter_grad_tensor.ShareDataWith(*filter_grad); filter_grad_tensor.set_layout(DataLayout::kNCDHW); - const auto& runner = NpuOpRunner( - "Conv3DBackpropFilterD", {input_tensor, output_grad_tensor}, - {filter_grad_tensor}, {{"filter_size", filter_shape_vec}, - {"strides", strides_vec}, - {"pads", paddings}, - {"dilations", dilations_vec}, - {"groups", groups}, - {"data_format", data_format}}); + const auto& runner = + NpuOpRunner("Conv3DBackpropFilterD", + {input_tensor, output_grad_tensor}, {filter_grad_tensor}, + {{"filter_size", filter_shape_vec}, + {"strides", strides_vec}, + {"pads", paddings}, + {"dilations", dilations_vec}, + {"groups", groups}, + {"data_format", data_format}}); runner.Run(stream); } @@ -613,14 +618,15 @@ class NPUConv3dGradKernel : public framework::OpKernel { input_grad_tensor.ShareDataWith(*input_grad); input_grad_tensor.set_layout(DataLayout::kNCDHW); - const auto& runner = NpuOpRunner( - "Conv3DBackpropInputD", {filter_tensor, output_grad_tensor}, - {input_grad_tensor}, {{"input_size", input_shape_vec}, - {"strides", strides_vec}, - {"pads", paddings}, - {"dilations", dilations_vec}, - {"groups", groups}, - {"data_format", data_format}}); + const auto& runner = + NpuOpRunner("Conv3DBackpropInputD", + {filter_tensor, output_grad_tensor}, {input_grad_tensor}, + {{"input_size", input_shape_vec}, + {"strides", strides_vec}, + {"pads", paddings}, + {"dilations", dilations_vec}, + {"groups", groups}, + {"data_format", data_format}}); runner.Run(stream); } } diff --git a/paddle/fluid/operators/conv_op_xpu.cc b/paddle/fluid/operators/conv_op_xpu.cc index cc5c20d392809340002da3362e794436dd4a8001..d66eefc694691f4ef976b808cae4186748eaf24c 100644 --- a/paddle/fluid/operators/conv_op_xpu.cc +++ b/paddle/fluid/operators/conv_op_xpu.cc @@ -8,10 +8,11 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/conv_op.h" #include #include #include + +#include "paddle/fluid/operators/conv_op.h" #include "paddle/fluid/platform/cudnn_workspace_helper.h" #ifdef PADDLE_WITH_XPU namespace paddle { diff --git a/paddle/fluid/operators/conv_shift_op.cc b/paddle/fluid/operators/conv_shift_op.cc index e7af908eba2c5dac72392cde42f9ebae9f18fad8..e996021ed843e4c74924f5d545b2cba5cd2244f3 100644 --- a/paddle/fluid/operators/conv_shift_op.cc +++ b/paddle/fluid/operators/conv_shift_op.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/conv_shift_op.h" + #include + #include "paddle/fluid/framework/eigen.h" namespace paddle { diff --git a/paddle/fluid/operators/conv_transpose_op.cc b/paddle/fluid/operators/conv_transpose_op.cc index fe76fc3aebbc173e4d916d2d2217a8d2922d169e..8b60c67f92e5e0bd96ef566bed79def47e7f51d0 100644 --- a/paddle/fluid/operators/conv_transpose_op.cc +++ b/paddle/fluid/operators/conv_transpose_op.cc @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/data_layout.h" #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/conv_transpose_op_npu.cc b/paddle/fluid/operators/conv_transpose_op_npu.cc index 050ede78f72cfea7c7e20829d530167885181798..c07be5a3fdbf158feed1a698a2e318f56a83a7b1 100644 --- a/paddle/fluid/operators/conv_transpose_op_npu.cc +++ b/paddle/fluid/operators/conv_transpose_op_npu.cc @@ -12,9 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/conv_transpose_op.h" - #include "paddle/fluid/framework/op_registry.h" +#include "paddle/fluid/operators/conv_transpose_op.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" #include "paddle/phi/kernels/cpu/conv_util.h" @@ -90,9 +89,9 @@ class Conv2DTransposeNPUKernel : public framework::OpKernel { auto output_dim_vec = phi::vectorize(output_tensor.dims()); auto stream = ctx.template device_context().stream(); - const auto& runner = - NpuOpRunner("Conv2DTransposeD", {input_tensor, *filter}, - {output_tensor}, {{"input_size", output_dim_vec}, + const auto& runner = NpuOpRunner("Conv2DTransposeD", + {input_tensor, *filter}, {output_tensor}, + {{"input_size", output_dim_vec}, {"strides", strides}, {"dilations", dilations}, {"output_padding", output_padding}, @@ -167,14 +166,15 @@ class Conv2DTransposeGradNPUKernel : public framework::OpKernel { auto stream = ctx.template device_context().stream(); if (filter_grad) { filter_grad->mutable_data(ctx.GetPlace()); - const auto& runner = NpuOpRunner( - "Conv2DBackpropFilterD", {output_grad_tensor, input_tensor}, - {*filter_grad}, {{"filter_size", phi::vectorize(filter_dims)}, - {"strides", strides_vec}, - {"pads", paddings}, - {"dilations", dilations_vec}, - {"groups", groups}, - {"data_format", data_format}}); + const auto& runner = + NpuOpRunner("Conv2DBackpropFilterD", + {output_grad_tensor, input_tensor}, {*filter_grad}, + {{"filter_size", phi::vectorize(filter_dims)}, + {"strides", strides_vec}, + {"pads", paddings}, + {"dilations", dilations_vec}, + {"groups", groups}, + {"data_format", data_format}}); runner.Run(stream); } if (input_grad) { @@ -184,13 +184,13 @@ class Conv2DTransposeGradNPUKernel : public framework::OpKernel { if (channel_last) { input_grad_tensor.set_layout(DataLayout::kNHWC); } - const auto& runner = - NpuOpRunner("Conv2D", {output_grad_tensor, *filter}, - {input_grad_tensor}, {{"strides", strides_vec}, - {"pads", paddings}, - {"dilations", dilations_vec}, - {"groups", groups}, - {"data_format", data_format}}); + const auto& runner = NpuOpRunner("Conv2D", {output_grad_tensor, *filter}, + {input_grad_tensor}, + {{"strides", strides_vec}, + {"pads", paddings}, + {"dilations", dilations_vec}, + {"groups", groups}, + {"data_format", data_format}}); runner.Run(stream); } } diff --git a/paddle/fluid/operators/conv_transpose_op_xpu.cc b/paddle/fluid/operators/conv_transpose_op_xpu.cc index b8bd3c4f006087273e1ae139d42d86891aabad1c..ae25c57784f02135236733c5aa40a72e10c0ff8e 100644 --- a/paddle/fluid/operators/conv_transpose_op_xpu.cc +++ b/paddle/fluid/operators/conv_transpose_op_xpu.cc @@ -9,12 +9,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/conv_transpose_op.h" - #include #include #include + #include "paddle/fluid/framework/op_registry.h" +#include "paddle/fluid/operators/conv_transpose_op.h" #include "paddle/fluid/platform/device/device_wrapper.h" #include "paddle/phi/kernels/cpu/conv_util.h" diff --git a/paddle/fluid/operators/correlation_op.cc b/paddle/fluid/operators/correlation_op.cc index 62e0f311d15d0d9c9d318bd1a510566449b58a86..21258958549ae6556a09dbfeb72a18c455b50113 100644 --- a/paddle/fluid/operators/correlation_op.cc +++ b/paddle/fluid/operators/correlation_op.cc @@ -16,6 +16,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/correlation_op.cu b/paddle/fluid/operators/correlation_op.cu index f488cc12e642b885f66d9b099ff211c9d419cbc6..f9dd9ab98a30842727f46b29bd4a791d793efa39 100644 --- a/paddle/fluid/operators/correlation_op.cu +++ b/paddle/fluid/operators/correlation_op.cu @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" #ifdef __HIPCC__ @@ -227,11 +228,11 @@ class CorrelationCUDAKernel : public framework::OpKernel { dim3 threadsPerBlock(THREADS_PER_BLOCK); dim3 totalBlocksCorr(N, OH, OW); - correlation_forward< - T><<>>( - output->data(), OC, OH, OW, rinput1.data(), C, H, W, - rinput2.data(), pad_size, kernel_size, max_displacement, stride1, - stride2); + correlation_forward + <<>>( + output->data(), OC, OH, OW, rinput1.data(), C, H, W, + rinput2.data(), pad_size, kernel_size, max_displacement, stride1, + stride2); } }; @@ -472,19 +473,19 @@ class CorrelationCUDAGradKernel : public framework::OpKernel { dim3 totalBlocksCorr(H, W, C); for (int n = 0; n < N; n++) { - correlation_backward_input1< - T><<>>( - n, grad_input1->data(), C, H, W, grad_output->data(), GOC, GOH, - GOW, rinput2.data(), pad_size, kernel_size, max_displacement, - stride1, stride2); + correlation_backward_input1 + <<>>( + n, grad_input1->data(), C, H, W, grad_output->data(), GOC, + GOH, GOW, rinput2.data(), pad_size, kernel_size, + max_displacement, stride1, stride2); } for (int n = 0; n < N; n++) { - correlation_backward_input2< - T><<>>( - n, grad_input2->data(), C, H, W, grad_output->data(), GOC, GOH, - GOW, rinput1.data(), pad_size, kernel_size, max_displacement, - stride1, stride2); + correlation_backward_input2 + <<>>( + n, grad_input2->data(), C, H, W, grad_output->data(), GOC, + GOH, GOW, rinput1.data(), pad_size, kernel_size, + max_displacement, stride1, stride2); } } }; diff --git a/paddle/fluid/operators/cos_sim_op.cc b/paddle/fluid/operators/cos_sim_op.cc index d41ceafba1a1b52dde3403d22b669fd81c1b6765..4c0c5596e5d1b494afc9573294658dea82f0908a 100644 --- a/paddle/fluid/operators/cos_sim_op.cc +++ b/paddle/fluid/operators/cos_sim_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/cos_sim_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/crf_decoding_op.cc b/paddle/fluid/operators/crf_decoding_op.cc index 6d3e6e34c3b8e02f2ee3c9e664f6752074e2be02..fa080b7a4b466e185744453cc1357d9e0934f84f 100644 --- a/paddle/fluid/operators/crf_decoding_op.cc +++ b/paddle/fluid/operators/crf_decoding_op.cc @@ -158,11 +158,12 @@ class CRFDecodingOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ( (label_dims.size() == 2UL && label_dims[1] == 1) || label_dims.size() == 1UL, - true, platform::errors::InvalidArgument( - "The Input(Label) should be a 2-D tensor with last " - "dimension fixed to 1 or a 1-D tensor. But received: " - "input rank %u, input shape [%s].", - label_dims.size(), label_dims)); + true, + platform::errors::InvalidArgument( + "The Input(Label) should be a 2-D tensor with last " + "dimension fixed to 1 or a 1-D tensor. But received: " + "input rank %u, input shape [%s].", + label_dims.size(), label_dims)); } if (ctx->IsRuntime() || (emission_dims[0] > 0 && label_dims[0] > 0)) { PADDLE_ENFORCE_EQ( diff --git a/paddle/fluid/operators/crf_decoding_op.h b/paddle/fluid/operators/crf_decoding_op.h index 6b11ff69c3056dea8e1acf89d6cb75dd6c5e2ad1..8b40abf3debe4b18601c92bbb4a8766162ba5966 100644 --- a/paddle/fluid/operators/crf_decoding_op.h +++ b/paddle/fluid/operators/crf_decoding_op.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/jit/kernels.h" @@ -22,8 +23,8 @@ limitations under the License. */ namespace paddle { namespace operators { -using framework::LoDTensor; using framework::LoD; +using framework::LoDTensor; using framework::Tensor; template diff --git a/paddle/fluid/operators/crop_op.cc b/paddle/fluid/operators/crop_op.cc index 9de5bc6ea36368e51f52916f50443a6a732c5b68..2e0a054fa122bed8b411179f970c8274706554c2 100644 --- a/paddle/fluid/operators/crop_op.cc +++ b/paddle/fluid/operators/crop_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/crop_op.h" + #include #include #include diff --git a/paddle/fluid/operators/crop_op.h b/paddle/fluid/operators/crop_op.h index 5ac28fafb09b9e66cf5e940cff005512707407ee..49e1d6ab5842afa45b1841174265066e75fb2f16 100644 --- a/paddle/fluid/operators/crop_op.h +++ b/paddle/fluid/operators/crop_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/eigen/eigen_function.h" @@ -171,17 +172,19 @@ class CropGradKernel : public framework::OpKernel { size_t rank = context.Input(framework::GradVarName("Out"))->dims().size(); PADDLE_ENFORCE_GE( - rank, 1, platform::errors::InvalidArgument( - "The number of dimensions of the input 'Out@GRAD' for " - "CropGrad must be greater than or equal " - "to 1, but the value received is %d.", - rank)); + rank, 1, + platform::errors::InvalidArgument( + "The number of dimensions of the input 'Out@GRAD' for " + "CropGrad must be greater than or equal " + "to 1, but the value received is %d.", + rank)); PADDLE_ENFORCE_LE( - rank, 6, platform::errors::InvalidArgument( - "The number of dimensions of the input 'Out@GRAD' for " - "CropGrad must be less than or equal " - "to 6, but the value received is %d.", - rank)); + rank, 6, + platform::errors::InvalidArgument( + "The number of dimensions of the input 'Out@GRAD' for " + "CropGrad must be less than or equal " + "to 6, but the value received is %d.", + rank)); switch (rank) { case 1: CropGradFunction(context); diff --git a/paddle/fluid/operators/crop_tensor_op.cc b/paddle/fluid/operators/crop_tensor_op.cc index 0e53bbb5d189f39739fdbdac6b641e7e3396440a..a9a94e2c948b96e775881ac4cc65755a7d3948ba 100644 --- a/paddle/fluid/operators/crop_tensor_op.cc +++ b/paddle/fluid/operators/crop_tensor_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/crop_tensor_op.h" + #include #include #include diff --git a/paddle/fluid/operators/crop_tensor_op.h b/paddle/fluid/operators/crop_tensor_op.h index 409458037a2043e13f7c9ce7471c42e0180bd5b7..851d007896d7ecafeb94e4a73703b9e067d5ca43 100644 --- a/paddle/fluid/operators/crop_tensor_op.h +++ b/paddle/fluid/operators/crop_tensor_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/eigen/eigen_function.h" @@ -72,11 +73,12 @@ static framework::DDim ValidateShape(const std::vector shape, "The value (%d) of the %uth element for shape of " "Op(crop_tensor) should not be zero.", shape[i], i)); - PADDLE_ENFORCE_EQ(shape[i], -1, platform::errors::InvalidArgument( - "When the value (%d) of the %uth " - "element for shape of Op(crop_tensor)" - " is negative, only -1 is supported.", - shape[i], i)); + PADDLE_ENFORCE_EQ(shape[i], -1, + platform::errors::InvalidArgument( + "When the value (%d) of the %uth " + "element for shape of Op(crop_tensor)" + " is negative, only -1 is supported.", + shape[i], i)); output_shape[i] = in_dims[i] - offsets[i]; } else { output_shape[i] = static_cast(shape[i]); @@ -226,11 +228,12 @@ class CropTensorKernel : public framework::OpKernel { "value received is %d.", rank)); PADDLE_ENFORCE_LE( - rank, 6, platform::errors::InvalidArgument( - "The number of dimensions of the input 'x' for " - "Op(crop_tensor) must be less than or equal to 6, but the " - "value received is %d.", - rank)); + rank, 6, + platform::errors::InvalidArgument( + "The number of dimensions of the input 'x' for " + "Op(crop_tensor) must be less than or equal to 6, but the " + "value received is %d.", + rank)); switch (rank) { case 1: CropTensorFunction(context); diff --git a/paddle/fluid/operators/cross_entropy_op.cc b/paddle/fluid/operators/cross_entropy_op.cc index 4f5912c81baef2090edf4180cb24e6953b49d12e..a880584f4cfe724967872e4a09aa0ea34dd9e3e7 100644 --- a/paddle/fluid/operators/cross_entropy_op.cc +++ b/paddle/fluid/operators/cross_entropy_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/cross_entropy_op.h" + #include #include #include diff --git a/paddle/fluid/operators/cross_op.cc b/paddle/fluid/operators/cross_op.cc index 674b75625d1983ba97f3d47ee154beff79c42dad..977d84e1e47c885e1174dc16ba32770c9ac3f808 100644 --- a/paddle/fluid/operators/cross_op.cc +++ b/paddle/fluid/operators/cross_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" @@ -21,8 +22,8 @@ namespace paddle { namespace operators { -using framework::Tensor; using framework::DDim; +using framework::Tensor; const int kDefaultDim = framework::DDim::kMaxRank; class CrossOp : public framework::OperatorWithKernel { diff --git a/paddle/fluid/operators/ctc_align_op.cu b/paddle/fluid/operators/ctc_align_op.cu index ba90c677570c503868dff382e9479555c032a8eb..10ec5a6bdd14072776cfdacaa85708ff5239cace 100644 --- a/paddle/fluid/operators/ctc_align_op.cu +++ b/paddle/fluid/operators/ctc_align_op.cu @@ -15,7 +15,9 @@ limitations under the License. */ #include #include #include + #include + #include "paddle/fluid/operators/ctc_align_op.h" namespace paddle { @@ -92,10 +94,10 @@ class CTCAlignOpCUDAKernel : public framework::OpKernel { auto* output_length = ctx.Output("OutputLength"); T* output_length_data = output_length->mutable_data({input_dims[0], 1}, ctx.GetPlace()); - PaddingMergeAndDelCudaKernel< - T><<<32, (input_dims[0] + 32 - 1) / 32, 0, stream>>>( - input_dims[1], tokens, input_length_data, blank, merge_repeated, - padding_value, input_dims[0], output_data, output_length_data); + PaddingMergeAndDelCudaKernel + <<<32, (input_dims[0] + 32 - 1) / 32, 0, stream>>>( + input_dims[1], tokens, input_length_data, blank, merge_repeated, + padding_value, input_dims[0], output_data, output_length_data); } else { const size_t level = 0; auto input_lod = framework::ToAbsOffset(input->lod()); diff --git a/paddle/fluid/operators/ctc_align_op.h b/paddle/fluid/operators/ctc_align_op.h index c561974b0c9766c022794aba5464ad5934384408..9e189a9fb635650d1f174062cbcb39f728966fc4 100644 --- a/paddle/fluid/operators/ctc_align_op.h +++ b/paddle/fluid/operators/ctc_align_op.h @@ -15,7 +15,9 @@ limitations under the License. */ #pragma once #include + #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/cudnn_lstm_cache.h b/paddle/fluid/operators/cudnn_lstm_cache.h index 5451cf815cae331b1cf8082dcbe31c1255527173..da8284b4f2e43316c038bffc293b686a04d0f76a 100644 --- a/paddle/fluid/operators/cudnn_lstm_cache.h +++ b/paddle/fluid/operators/cudnn_lstm_cache.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/platform/device/gpu/gpu_dnn.h" #include "paddle/fluid/platform/dynload/cudnn.h" diff --git a/paddle/fluid/operators/cudnn_lstm_op.cc b/paddle/fluid/operators/cudnn_lstm_op.cc index ccb0062fcc72331b8435dddb26366066667dd8a3..9ff4f796995c08ccb1431c17a4b99ad7b1f3847d 100644 --- a/paddle/fluid/operators/cudnn_lstm_op.cc +++ b/paddle/fluid/operators/cudnn_lstm_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" diff --git a/paddle/fluid/operators/cudnn_rnn_cache.h b/paddle/fluid/operators/cudnn_rnn_cache.h index 6c059257b94e8b6e77e0bcc76de592ea44827779..e2159a09c120c68d01948dea613ae49f63c5c9e9 100644 --- a/paddle/fluid/operators/cudnn_rnn_cache.h +++ b/paddle/fluid/operators/cudnn_rnn_cache.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/platform/device/gpu/gpu_dnn.h" diff --git a/paddle/fluid/operators/cumsum_op.cc b/paddle/fluid/operators/cumsum_op.cc index 11633fb0b870327f14e4454b3f94a43940a9df53..dbb703e7e874d77cadc171b842fb0ea5dac8779a 100644 --- a/paddle/fluid/operators/cumsum_op.cc +++ b/paddle/fluid/operators/cumsum_op.cc @@ -86,13 +86,12 @@ REGISTER_OPERATOR(cumsum, ops::CumOp, ops::CumsumOpMaker, ops::CumsumGradMaker, CumsumInferShapeFunctor); -REGISTER_OP_VERSION(cumsum) - .AddCheckpoint( - R"ROC( +REGISTER_OP_VERSION(cumsum).AddCheckpoint( + R"ROC( Upgrade cumsum add a new attribute [flatten]. )ROC", - paddle::framework::compatible::OpVersionDesc().NewAttr( - "flatten", - "In order to compute the cumsum over the flattened array when the " - "argument `axis` in python API is None.", - false)); + paddle::framework::compatible::OpVersionDesc().NewAttr( + "flatten", + "In order to compute the cumsum over the flattened array when the " + "argument `axis` in python API is None.", + false)); diff --git a/paddle/fluid/operators/cvm_op.cc b/paddle/fluid/operators/cvm_op.cc index e909906da7baa38b339214d19fc5c8ae2314981a..912167cec5af7e0d3302ba917cfce7ceb4f8e3c2 100644 --- a/paddle/fluid/operators/cvm_op.cc +++ b/paddle/fluid/operators/cvm_op.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/cvm_op.h" + #include + #include "paddle/phi/kernels/funcs/math_function.h" namespace paddle { diff --git a/paddle/fluid/operators/data_norm_op.cc b/paddle/fluid/operators/data_norm_op.cc index 137de2d5af985bc30d23979605f29d3a72ef0bdb..8287654949e7076c3fe0dc5fa9ec75ea1b225821 100644 --- a/paddle/fluid/operators/data_norm_op.cc +++ b/paddle/fluid/operators/data_norm_op.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/data_norm_op.h" + #include #include + #include "paddle/fluid/framework/data_layout.h" #ifdef PADDLE_WITH_MKLDNN #include "paddle/fluid/platform/mkldnn_helper.h" @@ -163,10 +165,11 @@ class DataNormOp : public framework::OperatorWithKernel { OperatorWithKernel::IndicateVarDataType(ctx, "BatchSum"), platform::errors::InvalidArgument( "BatchSum input should be of float type")); - PADDLE_ENFORCE_EQ(dn_param_type, OperatorWithKernel::IndicateVarDataType( - ctx, "BatchSquareSum"), - platform::errors::InvalidArgument( - "BatchSquareSum input should be of float type")); + PADDLE_ENFORCE_EQ( + dn_param_type, + OperatorWithKernel::IndicateVarDataType(ctx, "BatchSquareSum"), + platform::errors::InvalidArgument( + "BatchSquareSum input should be of float type")); bool enable_scale_and_shift = ctx.Attr("enable_scale_and_shift"); if (enable_scale_and_shift) { @@ -277,8 +280,9 @@ class DataNormKernel const auto *x = ctx.Input("X"); const auto &x_dims = x->dims(); - PADDLE_ENFORCE_EQ(x_dims.size(), 2, platform::errors::InvalidArgument( - "The Input dim size should be 2")); + PADDLE_ENFORCE_EQ( + x_dims.size(), 2, + platform::errors::InvalidArgument("The Input dim size should be 2")); const int N = x_dims[0]; const int C = (data_layout == DataLayout::kNCHW ? x_dims[1] @@ -515,8 +519,9 @@ class DataNormGradKernel // Get the size for each dimension. // NCHW [batch_size, in_channels, in_height, in_width] const auto &x_dims = x->dims(); - PADDLE_ENFORCE_EQ(x_dims.size(), 2, platform::errors::InvalidArgument( - "The Input dim size should be 2")); + PADDLE_ENFORCE_EQ( + x_dims.size(), 2, + platform::errors::InvalidArgument("The Input dim size should be 2")); const int N = x_dims[0]; const int C = (data_layout == DataLayout::kNCHW ? x_dims[1] @@ -757,10 +762,9 @@ REGISTER_OP_CPU_KERNEL( data_norm_grad, ops::DataNormGradKernel, ops::DataNormGradKernel); -REGISTER_OP_VERSION(data_norm) - .AddCheckpoint( - R"ROC( +REGISTER_OP_VERSION(data_norm).AddCheckpoint( + R"ROC( upgrad data_norm op by adding scale_w to support scale and shift.)ROC", - paddle::framework::compatible::OpVersionDesc().NewInput( - "scale_w", - "scale_w is used to do scale duirng data_norm like batchnorm ")); + paddle::framework::compatible::OpVersionDesc().NewInput( + "scale_w", + "scale_w is used to do scale duirng data_norm like batchnorm ")); diff --git a/paddle/fluid/operators/data_norm_op.cu b/paddle/fluid/operators/data_norm_op.cu index 28a7922120139a0e0ab68bfa8709f873c942503e..21c7d7d4bf49673cbf2e1d3ca9903fc3e6c25c7a 100644 --- a/paddle/fluid/operators/data_norm_op.cu +++ b/paddle/fluid/operators/data_norm_op.cu @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/data_layout.h" #include "paddle/fluid/operators/data_norm_op.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" @@ -100,8 +101,9 @@ class DataNormKernel const auto *x = ctx.Input("X"); const auto &x_dims = x->dims(); // Align with CPU version, but should we add this restriction? - PADDLE_ENFORCE_EQ(x_dims.size(), 2, platform::errors::PreconditionNotMet( - "The Input dim size should be 2")); + PADDLE_ENFORCE_EQ( + x_dims.size(), 2, + platform::errors::PreconditionNotMet("The Input dim size should be 2")); const int N = x_dims[0]; const int C = x_dims[1]; const T *batch_size_in = ctx.Input("BatchSize")->data(); @@ -143,8 +145,9 @@ class DataNormGradKernel const auto &x_dims = x->dims(); // Align with CPU version, but should we add this restriction? - PADDLE_ENFORCE_EQ(x_dims.size(), 2, platform::errors::PreconditionNotMet( - "The Input dim size should be 2")); + PADDLE_ENFORCE_EQ( + x_dims.size(), 2, + platform::errors::PreconditionNotMet("The Input dim size should be 2")); const int N = x_dims[0]; const int C = x_dims[1]; diff --git a/paddle/fluid/operators/decode_jpeg_op.cu b/paddle/fluid/operators/decode_jpeg_op.cu index de6b35bc9cd0ac9cb003a4dcafd8ee13b6f159d1..a257afc50f955c5b69cb5b2da0a0d1c48cb3fbb3 100644 --- a/paddle/fluid/operators/decode_jpeg_op.cu +++ b/paddle/fluid/operators/decode_jpeg_op.cu @@ -15,6 +15,7 @@ #if !defined(WITH_NV_JETSON) && !defined(PADDLE_WITH_HIP) #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/dynload/nvjpeg.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/operators/deformable_conv_op.cc b/paddle/fluid/operators/deformable_conv_op.cc index 1b76aca1e660e84fe61699f15af2ebf67beb2af6..b54c8a81abd641b7350bb1c27b24a9df8ce4c1d5 100644 --- a/paddle/fluid/operators/deformable_conv_op.cc +++ b/paddle/fluid/operators/deformable_conv_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/deformable_conv_op_xpu.cc b/paddle/fluid/operators/deformable_conv_op_xpu.cc index 240e5658956dd5a2f9daafa713054d5683724ec3..d977cfe844a6a6a44c3535f5696664fe9fa07663 100644 --- a/paddle/fluid/operators/deformable_conv_op_xpu.cc +++ b/paddle/fluid/operators/deformable_conv_op_xpu.cc @@ -15,6 +15,7 @@ limitations under the License. */ #ifdef PADDLE_WITH_XPU #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device/xpu/xpu_header.h" @@ -169,28 +170,32 @@ class DeformableConvGradXPUKernel : public framework::OpKernel { const float* offset_ptr = offset.data(); const float* mask_ptr = mask.data(); if (dx_data == nullptr) { - PADDLE_ENFORCE_EQ(xpu_malloc(reinterpret_cast(&dx_data), - input->numel() * sizeof(T)), - XPU_SUCCESS, platform::errors::ResourceExhausted( - "XPU has no enough memory")); + PADDLE_ENFORCE_EQ( + xpu_malloc(reinterpret_cast(&dx_data), + input->numel() * sizeof(T)), + XPU_SUCCESS, + platform::errors::ResourceExhausted("XPU has no enough memory")); } if (dw_data == nullptr) { - PADDLE_ENFORCE_EQ(xpu_malloc(reinterpret_cast(&dw_data), - filter.numel() * sizeof(T)), - XPU_SUCCESS, platform::errors::ResourceExhausted( - "XPU has no enough memory")); + PADDLE_ENFORCE_EQ( + xpu_malloc(reinterpret_cast(&dw_data), + filter.numel() * sizeof(T)), + XPU_SUCCESS, + platform::errors::ResourceExhausted("XPU has no enough memory")); } if (doffset_data == nullptr) { - PADDLE_ENFORCE_EQ(xpu_malloc(reinterpret_cast(&doffset_data), - offset.numel() * sizeof(T)), - XPU_SUCCESS, platform::errors::ResourceExhausted( - "XPU has no enough memory")); + PADDLE_ENFORCE_EQ( + xpu_malloc(reinterpret_cast(&doffset_data), + offset.numel() * sizeof(T)), + XPU_SUCCESS, + platform::errors::ResourceExhausted("XPU has no enough memory")); } if (dmask_data == nullptr) { - PADDLE_ENFORCE_EQ(xpu_malloc(reinterpret_cast(&dmask_data), - mask.numel() * sizeof(T)), - XPU_SUCCESS, platform::errors::ResourceExhausted( - "XPU has no enough memory")); + PADDLE_ENFORCE_EQ( + xpu_malloc(reinterpret_cast(&dmask_data), + mask.numel() * sizeof(T)), + XPU_SUCCESS, + platform::errors::ResourceExhausted("XPU has no enough memory")); } int input_dim = input->numel() / input->dims()[0]; @@ -207,10 +212,11 @@ class DeformableConvGradXPUKernel : public framework::OpKernel { int f = filter.dims()[0]; T* filter_grad_tmp = nullptr; - PADDLE_ENFORCE_EQ(xpu_malloc(reinterpret_cast(&filter_grad_tmp), - filter_grad->numel() * sizeof(T)), - XPU_SUCCESS, platform::errors::ResourceExhausted( - "XPU has no enough memory")); + PADDLE_ENFORCE_EQ( + xpu_malloc(reinterpret_cast(&filter_grad_tmp), + filter_grad->numel() * sizeof(T)), + XPU_SUCCESS, + platform::errors::ResourceExhausted("XPU has no enough memory")); // set zeros for d_table_data const int zero = 0; diff --git a/paddle/fluid/operators/deformable_conv_v1_op.cc b/paddle/fluid/operators/deformable_conv_v1_op.cc index 0ec95cb54bae80e5b06d1b76c89371f84f65d632..2da561c8685165df2d36b7477a73b87e27ec5d93 100644 --- a/paddle/fluid/operators/deformable_conv_v1_op.cc +++ b/paddle/fluid/operators/deformable_conv_v1_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/deformable_psroi_pooling_op.cc b/paddle/fluid/operators/deformable_psroi_pooling_op.cc index 7e7cdbd8d178c1bb1e1aacaef47bf41c0979ba3e..a989e3f9217c034d0222e046333e18a1db02de66 100644 --- a/paddle/fluid/operators/deformable_psroi_pooling_op.cc +++ b/paddle/fluid/operators/deformable_psroi_pooling_op.cc @@ -13,9 +13,11 @@ // limitations under the License. #include "paddle/fluid/operators/deformable_psroi_pooling_op.h" + #include #include #include + #include "paddle/phi/kernels/funcs/blas/blas.h" namespace paddle { @@ -165,11 +167,12 @@ class DeformablePSROIPoolOp : public framework::OperatorWithKernel { auto part_width = part_size[1]; auto sample_per_part = ctx->Attrs().Get("sample_per_part"); auto trans_std = ctx->Attrs().Get("trans_std"); - PADDLE_ENFORCE_GE(trans_std, 0., platform::errors::InvalidArgument( - "Input(trans_std) should not be lower " - "than 0.0, but received trans_std " - "is:%f", - trans_std)); + PADDLE_ENFORCE_GE(trans_std, 0., + platform::errors::InvalidArgument( + "Input(trans_std) should not be lower " + "than 0.0, but received trans_std " + "is:%f", + trans_std)); PADDLE_ENFORCE_GE( input_dims[1], output_channels, platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/deformable_psroi_pooling_op.cu b/paddle/fluid/operators/deformable_psroi_pooling_op.cu index 873950b2d2f65bd982681d5209d4dbff4c586345..174f045c1605c485b3b1ff79abc577b7d913ae27 100644 --- a/paddle/fluid/operators/deformable_psroi_pooling_op.cu +++ b/paddle/fluid/operators/deformable_psroi_pooling_op.cu @@ -23,10 +23,12 @@ #pragma once #include + #include #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/operators/deformable_psroi_pooling_op.h" diff --git a/paddle/fluid/operators/deformable_psroi_pooling_op.h b/paddle/fluid/operators/deformable_psroi_pooling_op.h index 3deabce54ed0bdb00a5901edf667e61a86d5567b..6ff6ab20df2fbd5770a30674277b5841510f8d0d 100644 --- a/paddle/fluid/operators/deformable_psroi_pooling_op.h +++ b/paddle/fluid/operators/deformable_psroi_pooling_op.h @@ -25,6 +25,7 @@ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/dequantize_op.cc b/paddle/fluid/operators/dequantize_op.cc index 876bd1199ad3b11194257731dacffe48419222fa..2bed296efd77a8fb3cd6623513ee220b2a6ddf19 100644 --- a/paddle/fluid/operators/dequantize_op.cc +++ b/paddle/fluid/operators/dequantize_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/dequantize_op.h" + #include "paddle/fluid/framework/op_version_registry.h" #ifdef PADDLE_WITH_MKLDNN #include "paddle/fluid/platform/mkldnn_helper.h" @@ -47,8 +48,8 @@ namespace ops = paddle::operators; REGISTER_OPERATOR(dequantize, ops::DeQuantOp, ops::DeQuantOpMaker); REGISTER_OP_VERSION(dequantize) - .AddCheckpoint( - R"ROC( Add a new attribute [Shift])ROC", - paddle::framework::compatible::OpVersionDesc().NewAttr( - "Shift", "Dequantize data to uint8 if provided non-zero value.", - 0.0f)); + .AddCheckpoint(R"ROC( Add a new attribute [Shift])ROC", + paddle::framework::compatible::OpVersionDesc().NewAttr( + "Shift", + "Dequantize data to uint8 if provided non-zero value.", + 0.0f)); diff --git a/paddle/fluid/operators/dequantize_op.h b/paddle/fluid/operators/dequantize_op.h index 75c27a06c210f2d0e4d7cf52aa16f4c123f8ad8e..ea7a08c8f36841f9a05aee525acb046d46cdab37 100644 --- a/paddle/fluid/operators/dequantize_op.h +++ b/paddle/fluid/operators/dequantize_op.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/dequeue_op.cc b/paddle/fluid/operators/dequeue_op.cc index fb5d53dacf0ed64d1767e603fd5c96687d73d207..1a6286b0a3289f134eab42e7f9db5801c563aaa3 100644 --- a/paddle/fluid/operators/dequeue_op.cc +++ b/paddle/fluid/operators/dequeue_op.cc @@ -14,6 +14,7 @@ #include #include + #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" diff --git a/paddle/fluid/operators/detection/anchor_generator_op.h b/paddle/fluid/operators/detection/anchor_generator_op.h index 0bcb56d7aa8d5c6744b62d2047b2b26bb85d8e67..b3d490ac0b512d8344fae1d29831f4000c4bbdd7 100644 --- a/paddle/fluid/operators/detection/anchor_generator_op.h +++ b/paddle/fluid/operators/detection/anchor_generator_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/transform.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/detection/bbox_util.h b/paddle/fluid/operators/detection/bbox_util.h index 7bbbbe7f40ecc67db6ee2e8be6679e3137982229..b9b9b0b0c0dbfdf59b9c97247ddf1730ff115074 100644 --- a/paddle/fluid/operators/detection/bbox_util.h +++ b/paddle/fluid/operators/detection/bbox_util.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" @@ -122,8 +123,9 @@ void BboxOverlaps(const framework::Tensor& r_boxes, inter_h = std::max(y_max - y_min + 1, zero); inter_area = inter_w * inter_h; overlaps_et(i, j) = - (inter_area == 0.) ? 0 : inter_area / - (r_box_area + c_box_area - inter_area); + (inter_area == 0.) + ? 0 + : inter_area / (r_box_area + c_box_area - inter_area); } } } diff --git a/paddle/fluid/operators/detection/box_clip_op.cc b/paddle/fluid/operators/detection/box_clip_op.cc index 73f0607fdde7fa1be9e8126a0107805acab67304..08d688a149543f32f250f29512c40ac65d09b3f1 100644 --- a/paddle/fluid/operators/detection/box_clip_op.cc +++ b/paddle/fluid/operators/detection/box_clip_op.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/detection/box_clip_op.h" + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/detection/box_clip_op.cu b/paddle/fluid/operators/detection/box_clip_op.cu index 65f2a5590716d42649dbf766575c72571c23eb4d..672b9a5db95d2a692eb6b2ef72cfde6061f0bc17 100644 --- a/paddle/fluid/operators/detection/box_clip_op.cu +++ b/paddle/fluid/operators/detection/box_clip_op.cu @@ -12,6 +12,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/detection/box_clip_op.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" diff --git a/paddle/fluid/operators/detection/box_clip_op.h b/paddle/fluid/operators/detection/box_clip_op.h index 13ba7894d60092c0df62662ebf6e332aa05523b2..4bcc81dbf9865d1ecd4b5fa094e44cc9747c0c5a 100644 --- a/paddle/fluid/operators/detection/box_clip_op.h +++ b/paddle/fluid/operators/detection/box_clip_op.h @@ -11,6 +11,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/detection/bbox_util.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/detection/box_coder_op.cc b/paddle/fluid/operators/detection/box_coder_op.cc index 69d829e0021f3146a01f6541c310b9e850c07db0..461dcb7f39ab599b5ac64fd5ac16226b210bcb9a 100644 --- a/paddle/fluid/operators/detection/box_coder_op.cc +++ b/paddle/fluid/operators/detection/box_coder_op.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/detection/box_coder_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/detection/box_coder_op.cu b/paddle/fluid/operators/detection/box_coder_op.cu index 22dc606df9df5aabdb2377a6081b848c85ea10bc..b7dee412ee31997180a8415d5a163e73b3dca4d1 100644 --- a/paddle/fluid/operators/detection/box_coder_op.cu +++ b/paddle/fluid/operators/detection/box_coder_op.cu @@ -11,6 +11,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/memory/memory.h" #include "paddle/fluid/operators/detection/box_coder_op.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" diff --git a/paddle/fluid/operators/detection/box_coder_op.h b/paddle/fluid/operators/detection/box_coder_op.h index a626f790fac9002508d05ae493bb74039b019987..6ddfd7176539049bca72f21ab48681cca38d51b6 100644 --- a/paddle/fluid/operators/detection/box_coder_op.h +++ b/paddle/fluid/operators/detection/box_coder_op.h @@ -12,6 +12,7 @@ limitations under the License. */ #pragma once #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/detection/box_decoder_and_assign_op.h b/paddle/fluid/operators/detection/box_decoder_and_assign_op.h index d3565f87f33bb4a357fe3ed5bd215d12b4adf633..7eed920fb3d55a3eb78fabeddce4e40bd2b807f8 100644 --- a/paddle/fluid/operators/detection/box_decoder_and_assign_op.h +++ b/paddle/fluid/operators/detection/box_decoder_and_assign_op.h @@ -13,6 +13,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/detection/collect_fpn_proposals_op.cc b/paddle/fluid/operators/detection/collect_fpn_proposals_op.cc index 92c9ab34aa454fc95602fe8c35d8430ddc21f9c8..b1b8c3ba2da84e37e1a2c5aea6baa563d3da341d 100644 --- a/paddle/fluid/operators/detection/collect_fpn_proposals_op.cc +++ b/paddle/fluid/operators/detection/collect_fpn_proposals_op.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License.*/ #include "paddle/fluid/operators/detection/collect_fpn_proposals_op.h" + #include "paddle/fluid/framework/op_version_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/detection/collect_fpn_proposals_op.cu b/paddle/fluid/operators/detection/collect_fpn_proposals_op.cu index 860fdd01794ccc9898332f6f0d0ba4e9c3e296d6..bea6fb1748858488cdb7ccda8f03d570b1e19585 100644 --- a/paddle/fluid/operators/detection/collect_fpn_proposals_op.cu +++ b/paddle/fluid/operators/detection/collect_fpn_proposals_op.cu @@ -18,6 +18,7 @@ namespace cub = hipcub; #endif #include + #include "paddle/fluid/framework/mixed_vector.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/memory/memcpy.h" diff --git a/paddle/fluid/operators/detection/collect_fpn_proposals_op.h b/paddle/fluid/operators/detection/collect_fpn_proposals_op.h index e5ae9a6ccbda5acbdb37d1190314c94ca4007c07..973cbc6ec1658cb434c959891cd8ce6ef2db58d0 100644 --- a/paddle/fluid/operators/detection/collect_fpn_proposals_op.h +++ b/paddle/fluid/operators/detection/collect_fpn_proposals_op.h @@ -20,6 +20,7 @@ limitations under the License.*/ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/detection/density_prior_box_op.h b/paddle/fluid/operators/detection/density_prior_box_op.h index adc2723acbf70c22b9649abdb149fb4955a0bc34..0912ce9016031fad719f6e0c40d2ceca2353af0d 100644 --- a/paddle/fluid/operators/detection/density_prior_box_op.h +++ b/paddle/fluid/operators/detection/density_prior_box_op.h @@ -12,6 +12,7 @@ limitations under the License. */ #pragma once #include #include + #include "paddle/fluid/operators/detection/prior_box_op.h" namespace paddle { diff --git a/paddle/fluid/operators/detection/distribute_fpn_proposals_op.cc b/paddle/fluid/operators/detection/distribute_fpn_proposals_op.cc index 4e514e62f4081edf8a6419da5771c6092d66b1c4..e382586ec666cd9eb86bdd91472cd181845ca02d 100644 --- a/paddle/fluid/operators/detection/distribute_fpn_proposals_op.cc +++ b/paddle/fluid/operators/detection/distribute_fpn_proposals_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/detection/distribute_fpn_proposals_op.h" + #include "paddle/fluid/framework/op_version_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/detection/distribute_fpn_proposals_op.cu b/paddle/fluid/operators/detection/distribute_fpn_proposals_op.cu index 7ad25e003b491294287a62433b8bf494086a87c2..5adf1469ec2f9adcb26d9697b6e6cb1b9bc52d71 100644 --- a/paddle/fluid/operators/detection/distribute_fpn_proposals_op.cu +++ b/paddle/fluid/operators/detection/distribute_fpn_proposals_op.cu @@ -21,6 +21,7 @@ namespace cub = hipcub; #endif #include + #include "paddle/fluid/memory/memcpy.h" #include "paddle/fluid/operators/detection/bbox_util.h" #include "paddle/fluid/operators/detection/distribute_fpn_proposals_op.h" diff --git a/paddle/fluid/operators/detection/distribute_fpn_proposals_op.h b/paddle/fluid/operators/detection/distribute_fpn_proposals_op.h index 5479e08c2a5efa96e64eca45d75af7a6a60a8862..85db2437ee550d36e2207e684c96124ff2ca8511 100644 --- a/paddle/fluid/operators/detection/distribute_fpn_proposals_op.h +++ b/paddle/fluid/operators/detection/distribute_fpn_proposals_op.h @@ -19,6 +19,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/detection/generate_mask_labels_op.cc b/paddle/fluid/operators/detection/generate_mask_labels_op.cc index c9cc4e722071c69f0bf658ad69363dbdd75b63e4..da86502f78c3596cb94eda99eb28baa14a83d3fa 100644 --- a/paddle/fluid/operators/detection/generate_mask_labels_op.cc +++ b/paddle/fluid/operators/detection/generate_mask_labels_op.cc @@ -10,9 +10,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include #include #include + #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/detection/bbox_util.h" diff --git a/paddle/fluid/operators/detection/generate_proposal_labels_op.cc b/paddle/fluid/operators/detection/generate_proposal_labels_op.cc index cbf17048400bfd967e311897bf8d6d6e11d6000b..bc528060355f0b2af60945f60f3d067579ef5063 100644 --- a/paddle/fluid/operators/detection/generate_proposal_labels_op.cc +++ b/paddle/fluid/operators/detection/generate_proposal_labels_op.cc @@ -10,9 +10,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/operators/detection/bbox_util.h" diff --git a/paddle/fluid/operators/detection/generate_proposals_op.cc b/paddle/fluid/operators/detection/generate_proposals_op.cc index d6130823271f05c83e590d28b41c3baf73e054f0..a6d2d8a2a0172c900d4e7dad4f2a49c0d2a49864 100644 --- a/paddle/fluid/operators/detection/generate_proposals_op.cc +++ b/paddle/fluid/operators/detection/generate_proposals_op.cc @@ -16,6 +16,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/operators/detection/bbox_util.h" diff --git a/paddle/fluid/operators/detection/generate_proposals_op.cu b/paddle/fluid/operators/detection/generate_proposals_op.cu index 5fb7973fd89e49f1cc19458059bffe0dadb9aa3e..20efb1fa6ca92f993bff25ab531d51d20d1d4e89 100644 --- a/paddle/fluid/operators/detection/generate_proposals_op.cu +++ b/paddle/fluid/operators/detection/generate_proposals_op.cu @@ -14,8 +14,10 @@ limitations under the License. */ #include #include + #include #include + #include "paddle/fluid/framework/mixed_vector.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/memory/memory.h" diff --git a/paddle/fluid/operators/detection/generate_proposals_v2_op.cc b/paddle/fluid/operators/detection/generate_proposals_v2_op.cc index 1f1802574c5b82281b0a7ecc79d9057df61c37e6..b8b6118058fa2a98caf4e8b5db31ef0a29048a25 100644 --- a/paddle/fluid/operators/detection/generate_proposals_v2_op.cc +++ b/paddle/fluid/operators/detection/generate_proposals_v2_op.cc @@ -16,6 +16,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/operators/detection/bbox_util.h" diff --git a/paddle/fluid/operators/detection/generate_proposals_v2_op.cu b/paddle/fluid/operators/detection/generate_proposals_v2_op.cu index 005309e8ee577119fd295126c40b46a11a762497..deb7f3a41df1f0617dee4ee6b35e1dcb9c52adbc 100644 --- a/paddle/fluid/operators/detection/generate_proposals_v2_op.cu +++ b/paddle/fluid/operators/detection/generate_proposals_v2_op.cu @@ -14,8 +14,10 @@ limitations under the License. */ #include #include + #include #include + #include "paddle/fluid/framework/mixed_vector.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/memory/memory.h" diff --git a/paddle/fluid/operators/detection/gpc.cc b/paddle/fluid/operators/detection/gpc.cc index 6b1b0cd8b3578a344978afae642b66759589ffde..4dea559d8e466899ad49c9a797cd11e3bb6d9915 100644 --- a/paddle/fluid/operators/detection/gpc.cc +++ b/paddle/fluid/operators/detection/gpc.cc @@ -24,6 +24,7 @@ **/ #include "paddle/fluid/operators/detection/gpc.h" + #include "paddle/fluid/platform/enforce.h" namespace gpc { diff --git a/paddle/fluid/operators/detection/locality_aware_nms_op.cc b/paddle/fluid/operators/detection/locality_aware_nms_op.cc index 8cc0ebcab61f7bf46b950900b0198fc07b4e287e..3f8bc8674186d30a82b24be5abba8d5a3fe7f2c6 100644 --- a/paddle/fluid/operators/detection/locality_aware_nms_op.cc +++ b/paddle/fluid/operators/detection/locality_aware_nms_op.cc @@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/detection/nms_util.h" @@ -51,16 +52,17 @@ class LocalityAwareNMSOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ( box_dims[2] == 4 || box_dims[2] == 8 || box_dims[2] == 16 || box_dims[2] == 24 || box_dims[2] == 32, - true, platform::errors::InvalidArgument( - "The last dimension of Input(BBoxes) must be 4 or 8, " - "represents the layout of coordinate " - "[xmin, ymin, xmax, ymax] or " - "4 points: [x1, y1, x2, y2, x3, y3, x4, y4] or " - "8 points: [xi, yi] i= 1,2,...,8 or " - "12 points: [xi, yi] i= 1,2,...,12 or " - "16 points: [xi, yi] i= 1,2,...,16. " - "But received %d.", - box_dims[2])); + true, + platform::errors::InvalidArgument( + "The last dimension of Input(BBoxes) must be 4 or 8, " + "represents the layout of coordinate " + "[xmin, ymin, xmax, ymax] or " + "4 points: [x1, y1, x2, y2, x3, y3, x4, y4] or " + "8 points: [xi, yi] i= 1,2,...,8 or " + "12 points: [xi, yi] i= 1,2,...,12 or " + "16 points: [xi, yi] i= 1,2,...,16. " + "But received %d.", + box_dims[2])); PADDLE_ENFORCE_EQ( box_dims[1], score_dims[2], platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/detection/mask_util.cc b/paddle/fluid/operators/detection/mask_util.cc index e06218cfe569f12ec845126d056963e7b7cf66da..41505ee84286a3fb94a44f34efaa46636ab477b4 100644 --- a/paddle/fluid/operators/detection/mask_util.cc +++ b/paddle/fluid/operators/detection/mask_util.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/detection/mask_util.h" + #include #include + #include "paddle/fluid/memory/memory.h" namespace paddle { diff --git a/paddle/fluid/operators/detection/mask_util.h b/paddle/fluid/operators/detection/mask_util.h index 4e0ea54f6d89ff273382afc1e9a151cfd9773cc6..25b03a11f7db0d6716ef9a6177adc7a31fefd1e3 100644 --- a/paddle/fluid/operators/detection/mask_util.h +++ b/paddle/fluid/operators/detection/mask_util.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include namespace paddle { diff --git a/paddle/fluid/operators/detection/mask_util_test.cc b/paddle/fluid/operators/detection/mask_util_test.cc index de904e947463977229545897b723b98b4d0708d6..68f7a6db6488e3a4c6ff1b7d510d54950bd30a47 100644 --- a/paddle/fluid/operators/detection/mask_util_test.cc +++ b/paddle/fluid/operators/detection/mask_util_test.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/detection/mask_util.h" + #include + #include "paddle/fluid/memory/memory.h" namespace paddle { diff --git a/paddle/fluid/operators/detection/matrix_nms_op.cc b/paddle/fluid/operators/detection/matrix_nms_op.cc index 3353739b01bf674c43fac813f390fc76ab2e87a9..5eee52dfbc704daddc66fc60c94160dd86fd4b24 100644 --- a/paddle/fluid/operators/detection/matrix_nms_op.cc +++ b/paddle/fluid/operators/detection/matrix_nms_op.cc @@ -405,7 +405,6 @@ REGISTER_OPERATOR( REGISTER_OP_CPU_KERNEL(matrix_nms, ops::MatrixNMSKernel, ops::MatrixNMSKernel); REGISTER_OP_VERSION(matrix_nms) - .AddCheckpoint( - R"ROC(Upgrade matrix_nms: add a new output [RoisNum].)ROC", - paddle::framework::compatible::OpVersionDesc().NewOutput( - "RoisNum", "The number of RoIs in each image.")); + .AddCheckpoint(R"ROC(Upgrade matrix_nms: add a new output [RoisNum].)ROC", + paddle::framework::compatible::OpVersionDesc().NewOutput( + "RoisNum", "The number of RoIs in each image.")); diff --git a/paddle/fluid/operators/detection/multiclass_nms_op.cc b/paddle/fluid/operators/detection/multiclass_nms_op.cc index 83cf6e5fd30f6bcad4870d1ebd18a50e21518dfe..f603a501f4b7880df9a20ab6777d597b9ae99115 100644 --- a/paddle/fluid/operators/detection/multiclass_nms_op.cc +++ b/paddle/fluid/operators/detection/multiclass_nms_op.cc @@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/detection/nms_util.h" @@ -55,18 +56,19 @@ class MultiClassNMSOp : public framework::OperatorWithKernel { ". But received rank = %d", box_dims.size())); if (score_size == 3) { - PADDLE_ENFORCE_EQ( - box_dims[2] == 4 || box_dims[2] == 8 || box_dims[2] == 16 || - box_dims[2] == 24 || box_dims[2] == 32, - true, platform::errors::InvalidArgument( - "The last dimension of Input" - "(BBoxes) must be 4 or 8, " - "represents the layout of coordinate " - "[xmin, ymin, xmax, ymax] or " - "4 points: [x1, y1, x2, y2, x3, y3, x4, y4] or " - "8 points: [xi, yi] i= 1,2,...,8 or " - "12 points: [xi, yi] i= 1,2,...,12 or " - "16 points: [xi, yi] i= 1,2,...,16")); + PADDLE_ENFORCE_EQ(box_dims[2] == 4 || box_dims[2] == 8 || + box_dims[2] == 16 || box_dims[2] == 24 || + box_dims[2] == 32, + true, + platform::errors::InvalidArgument( + "The last dimension of Input" + "(BBoxes) must be 4 or 8, " + "represents the layout of coordinate " + "[xmin, ymin, xmax, ymax] or " + "4 points: [x1, y1, x2, y2, x3, y3, x4, y4] or " + "8 points: [xi, yi] i= 1,2,...,8 or " + "12 points: [xi, yi] i= 1,2,...,12 or " + "16 points: [xi, yi] i= 1,2,...,16")); PADDLE_ENFORCE_EQ( box_dims[1], score_dims[2], platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/detection/nms_op.cc b/paddle/fluid/operators/detection/nms_op.cc index f6dc44eb5fc2d969c4b4a379c9c4f95167613730..34a92efa68a63a2a21d3def0b06b2b23bdab92c7 100644 --- a/paddle/fluid/operators/detection/nms_op.cc +++ b/paddle/fluid/operators/detection/nms_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/detection/nms_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/detection/nms_op.cu b/paddle/fluid/operators/detection/nms_op.cu index b6027e67d6ced6f825f5f68383f4baa8ccb4bc9b..4f62c735c265a6c5152f1ec2920d216d1ce85a90 100644 --- a/paddle/fluid/operators/detection/nms_op.cu +++ b/paddle/fluid/operators/detection/nms_op.cu @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/operators/detection/nms_op.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" diff --git a/paddle/fluid/operators/detection/nms_util.h b/paddle/fluid/operators/detection/nms_util.h index 0e448d42fc2ed37b900015d47ded8d9f6387e1cb..7a6565ac760f1b7ec6d76a56dc428c8d2afc40f2 100644 --- a/paddle/fluid/operators/detection/nms_util.h +++ b/paddle/fluid/operators/detection/nms_util.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/operators/detection/poly_util.h" namespace paddle { diff --git a/paddle/fluid/operators/detection/poly_util.cc b/paddle/fluid/operators/detection/poly_util.cc index 1af2c95c6cf526d651b196b54614a21a9cddde8c..6aa81bf1b39f7a24d2b5da0e056dac33ed387336 100644 --- a/paddle/fluid/operators/detection/poly_util.cc +++ b/paddle/fluid/operators/detection/poly_util.cc @@ -16,13 +16,14 @@ limitations under the License. */ #define POLY_UTIL_CC_ #include "paddle/fluid/operators/detection/poly_util.h" + #include "paddle/fluid/framework/op_registry.h" namespace paddle { namespace operators { -using gpc::gpc_polygon_clip; using gpc::gpc_free_polygon; +using gpc::gpc_polygon_clip; template void Array2PointVec(const T*& box, const size_t box_size, diff --git a/paddle/fluid/operators/detection/poly_util.h b/paddle/fluid/operators/detection/poly_util.h index f07baf72d9ff07b8fcb45dcfb2a35741fb1aeed0..cc37f00008d33b5688a7c7719e810b221ba23d30 100644 --- a/paddle/fluid/operators/detection/poly_util.h +++ b/paddle/fluid/operators/detection/poly_util.h @@ -16,6 +16,7 @@ limitations under the License. */ #define POLY_UTIL_H_ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/detection/gpc.h" diff --git a/paddle/fluid/operators/detection/prior_box_op.h b/paddle/fluid/operators/detection/prior_box_op.h index 4000994beb541cc644e2e53f6b0783233ac85878..889bc8354bc4133c0d4e8bcb8e0c7aa567e51083 100644 --- a/paddle/fluid/operators/detection/prior_box_op.h +++ b/paddle/fluid/operators/detection/prior_box_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/transform.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/detection/retinanet_detection_output_op.cc b/paddle/fluid/operators/detection/retinanet_detection_output_op.cc index bc46ec0b656397c66fb5f8e6ebb6c71d923ebee7..4e49a6ed8521e0b8022f2390b6e1eea82f603a2b 100644 --- a/paddle/fluid/operators/detection/retinanet_detection_output_op.cc +++ b/paddle/fluid/operators/detection/retinanet_detection_output_op.cc @@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { @@ -66,23 +67,26 @@ class RetinanetDetectionOutputOp : public framework::OperatorWithKernel { auto im_info_dims = ctx->GetInputDim("ImInfo"); const size_t b_n = bboxes_dims.size(); - PADDLE_ENFORCE_GT(b_n, 0, platform::errors::InvalidArgument( - "The number of Variables in Input(BBoxes) " - "should be greater than 0, " - "but received number is:%d.", - b_n)); + PADDLE_ENFORCE_GT(b_n, 0, + platform::errors::InvalidArgument( + "The number of Variables in Input(BBoxes) " + "should be greater than 0, " + "but received number is:%d.", + b_n)); const size_t s_n = scores_dims.size(); - PADDLE_ENFORCE_GT(s_n, 0, platform::errors::InvalidArgument( - "The number of Variables in Input(Scores) " - "should be greater than 0, " - "but received number is:%d.", - s_n)); + PADDLE_ENFORCE_GT(s_n, 0, + platform::errors::InvalidArgument( + "The number of Variables in Input(Scores) " + "should be greater than 0, " + "but received number is:%d.", + s_n)); const size_t a_n = anchors_dims.size(); - PADDLE_ENFORCE_GT(a_n, 0, platform::errors::InvalidArgument( - "The number of Variables in Input(Anchors) " - "should be greater than 0, " - "but received number is:%d.", - a_n)); + PADDLE_ENFORCE_GT(a_n, 0, + platform::errors::InvalidArgument( + "The number of Variables in Input(Anchors) " + "should be greater than 0, " + "but received number is:%d.", + a_n)); auto bbox_dims = bboxes_dims[0]; auto score_dims = scores_dims[0]; auto anchor_dims = anchors_dims[0]; diff --git a/paddle/fluid/operators/detection/roi_perspective_transform_op.cc b/paddle/fluid/operators/detection/roi_perspective_transform_op.cc index 353d17a6e09f2e5784bc425f43ebe51b7d8c8d69..eb6d6c6db92840670c265df0c2cb10a3f523da4b 100644 --- a/paddle/fluid/operators/detection/roi_perspective_transform_op.cc +++ b/paddle/fluid/operators/detection/roi_perspective_transform_op.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/math_function.h" @@ -40,8 +41,8 @@ bool GT(T a, T b) { } /* -*check if (x, y) is in the boundary of roi -*/ + *check if (x, y) is in the boundary of roi + */ template bool in_quad(T x, T y, T roi_x[], T roi_y[]) { for (int i = 0; i < 4; i++) { @@ -431,10 +432,9 @@ class CPUROIPerspectiveTransformGradOpKernel : public framework::OpKernel { T matrix[9]; get_transform_matrix(transformed_width, transformed_height, roi_x, roi_y, matrix); - const T* out_grad_ptr = out_grad_data + - (roi_idx * channels + c) * - transformed_height * - transformed_width; + const T* out_grad_ptr = out_grad_data + (roi_idx * channels + c) * + transformed_height * + transformed_width; for (int out_h = 0; out_h < transformed_height; ++out_h) { for (int out_w = 0; out_w < transformed_width; ++out_w) { T src_w; diff --git a/paddle/fluid/operators/detection/roi_perspective_transform_op.cu b/paddle/fluid/operators/detection/roi_perspective_transform_op.cu index 515a4bbac59c2cd370e30069bb7e303543b3a75b..1bff79606d44b671c6d04f1ff093b126d6aea49f 100644 --- a/paddle/fluid/operators/detection/roi_perspective_transform_op.cu +++ b/paddle/fluid/operators/detection/roi_perspective_transform_op.cu @@ -13,13 +13,14 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" #include "paddle/fluid/platform/float16.h" #include "paddle/phi/kernels/funcs/math_function.h" -using paddle::platform::PADDLE_CUDA_NUM_THREADS; using paddle::platform::float16; +using paddle::platform::PADDLE_CUDA_NUM_THREADS; namespace paddle { namespace operators { @@ -56,8 +57,8 @@ __device__ T min(T a, T b) { } /* -* check if (x, y) is in the boundary of roi -*/ + * check if (x, y) is in the boundary of roi + */ template __device__ bool in_quad(T x, T y, T roi_x[], T roi_y[]) { for (int i = 0; i < 4; i++) { diff --git a/paddle/fluid/operators/detection/rpn_target_assign_op.cc b/paddle/fluid/operators/detection/rpn_target_assign_op.cc index e96c0bbc272900cecb0be21510fa1e013cce620e..b636decdfbff3c47332b09a3750df704b0037c8a 100644 --- a/paddle/fluid/operators/detection/rpn_target_assign_op.cc +++ b/paddle/fluid/operators/detection/rpn_target_assign_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/detection/bbox_util.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/detection/sigmoid_focal_loss_op.cc b/paddle/fluid/operators/detection/sigmoid_focal_loss_op.cc index 8526f1762cdc9ce88efaa05211a5fe363f2af954..31f3dab81fef67484cc0a013631637e78148391d 100644 --- a/paddle/fluid/operators/detection/sigmoid_focal_loss_op.cc +++ b/paddle/fluid/operators/detection/sigmoid_focal_loss_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/detection/sigmoid_focal_loss_op.h" + #include #include #include diff --git a/paddle/fluid/operators/detection/sigmoid_focal_loss_op.h b/paddle/fluid/operators/detection/sigmoid_focal_loss_op.h index 518295958630c00bc44015ffd80d13a1b1d1f68c..fcb7ec1fbfee0fb4cc8c03168a0e79430af7568b 100644 --- a/paddle/fluid/operators/detection/sigmoid_focal_loss_op.h +++ b/paddle/fluid/operators/detection/sigmoid_focal_loss_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/detection/yolo_box_op.cc b/paddle/fluid/operators/detection/yolo_box_op.cc index 35e389090175f7768244b95b1d388ea0d735c2d5..ae7dfe0dd6685290ce649508fbe3b2f8de427614 100644 --- a/paddle/fluid/operators/detection/yolo_box_op.cc +++ b/paddle/fluid/operators/detection/yolo_box_op.cc @@ -36,10 +36,11 @@ class YoloBoxOp : public framework::OperatorWithKernel { auto iou_aware = ctx->Attrs().Get("iou_aware"); auto iou_aware_factor = ctx->Attrs().Get("iou_aware_factor"); - PADDLE_ENFORCE_EQ(dim_x.size(), 4, platform::errors::InvalidArgument( - "Input(X) should be a 4-D tensor." - "But received X dimension(%s)", - dim_x.size())); + PADDLE_ENFORCE_EQ( + dim_x.size(), 4, + platform::errors::InvalidArgument("Input(X) should be a 4-D tensor." + "But received X dimension(%s)", + dim_x.size())); if (iou_aware) { PADDLE_ENFORCE_EQ( dim_x[1], anchor_num * (6 + class_num), @@ -245,11 +246,10 @@ REGISTER_OPERATOR( paddle::framework::EmptyGradOpMaker, YoloBoxInferShapeFunctor); -REGISTER_OP_VERSION(yolo_box) - .AddCheckpoint( - R"ROC( +REGISTER_OP_VERSION(yolo_box).AddCheckpoint( + R"ROC( Upgrade yolo box to add new attribute [iou_aware, iou_aware_factor]. )ROC", - paddle::framework::compatible::OpVersionDesc() - .NewAttr("iou_aware", "Whether use iou aware", false) - .NewAttr("iou_aware_factor", "iou aware factor", 0.5f)); + paddle::framework::compatible::OpVersionDesc() + .NewAttr("iou_aware", "Whether use iou aware", false) + .NewAttr("iou_aware_factor", "iou aware factor", 0.5f)); diff --git a/paddle/fluid/operators/detection/yolov3_loss_op.cc b/paddle/fluid/operators/detection/yolov3_loss_op.cc index 21044734ca80170dacb501b588098830d75f2af2..2170fd0639fcb84327be04dc7ffc685b2f863183 100644 --- a/paddle/fluid/operators/detection/yolov3_loss_op.cc +++ b/paddle/fluid/operators/detection/yolov3_loss_op.cc @@ -10,6 +10,7 @@ limitations under the License. */ #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/imperative/type_defs.h" diff --git a/paddle/fluid/operators/detection_map_op.cc b/paddle/fluid/operators/detection_map_op.cc index 588967f0832a9208e084d3a1c123ffd980844557..aa4695cc9755656ca525aff7dc838a78ffaf4c96 100644 --- a/paddle/fluid/operators/detection_map_op.cc +++ b/paddle/fluid/operators/detection_map_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/detection_map_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/detection_map_op.h b/paddle/fluid/operators/detection_map_op.h index 4dd41837f060ec180c5df344ff4a9e5a7e0e8596..a034572a0c481af810f393e0b5504f1d4d48f13f 100644 --- a/paddle/fluid/operators/detection_map_op.h +++ b/paddle/fluid/operators/detection_map_op.h @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/determinant_op.cc b/paddle/fluid/operators/determinant_op.cc index 6959b5cf811069cc66321d2129a2b69d4e922f09..ec5a51bbffa59fcb9c02eb0b20fd47363e23a804 100644 --- a/paddle/fluid/operators/determinant_op.cc +++ b/paddle/fluid/operators/determinant_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/determinant_op.h" + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/infermeta/backward.h" diff --git a/paddle/fluid/operators/determinant_op.h b/paddle/fluid/operators/determinant_op.h index 702ff3bfd87b0c439483afeca3761d460a8aa862..d4c05b631e3bb25fa2ef74be5a0f700fef140626 100644 --- a/paddle/fluid/operators/determinant_op.h +++ b/paddle/fluid/operators/determinant_op.h @@ -18,6 +18,7 @@ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/for_range.h" diff --git a/paddle/fluid/operators/dgc_clip_by_norm_op.cc b/paddle/fluid/operators/dgc_clip_by_norm_op.cc index 85a29271b13b5cb8458f3aa020545fa2748d0be0..f60380f0475916233856a3586202ecf9c1331245 100644 --- a/paddle/fluid/operators/dgc_clip_by_norm_op.cc +++ b/paddle/fluid/operators/dgc_clip_by_norm_op.cc @@ -10,10 +10,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include - #include "paddle/fluid/operators/dgc_clip_by_norm_op.h" +#include + namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/dgc_op.cc b/paddle/fluid/operators/dgc_op.cc index 5fe66fa38a83b0f1d79cb792501a1d363f2b744a..95d3f75de9a0235b90883995cc361ea86fb4e2e1 100644 --- a/paddle/fluid/operators/dgc_op.cc +++ b/paddle/fluid/operators/dgc_op.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/dgc_op.h" + #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/dgc_op.h b/paddle/fluid/operators/dgc_op.h index b1bf5e2778167ba9a8e39803c4369be12823259b..91093f67e053627e79dae79e55a1818a852cb46c 100644 --- a/paddle/fluid/operators/dgc_op.h +++ b/paddle/fluid/operators/dgc_op.h @@ -14,8 +14,8 @@ limitations under the License. */ #pragma once #include -#include "dgc/dgc.h" +#include "dgc/dgc.h" #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/operators/elementwise/elementwise_op_function.h" @@ -118,10 +118,12 @@ class DGCOpKernel : public framework::OpKernel { 1 - get_period_sparcity( sparsity, static_cast(*current_step - rampup_begin_step), rampup_step); - PADDLE_ENFORCE_GE(ratio, 0.0, platform::errors::InvalidArgument( - "DGC sparsity ratio must >= 0")); - PADDLE_ENFORCE_LT(ratio, 1.0, platform::errors::InvalidArgument( - "DGC sparsity ratio must < 1")); + PADDLE_ENFORCE_GE( + ratio, 0.0, + platform::errors::InvalidArgument("DGC sparsity ratio must >= 0")); + PADDLE_ENFORCE_LT( + ratio, 1.0, + platform::errors::InvalidArgument("DGC sparsity ratio must < 1")); int k = static_cast(g->numel() * ratio); VLOG(10) << "m:" << m << ", use_nesterov:" << use_nesterov diff --git a/paddle/fluid/operators/diag_embed_op.cu b/paddle/fluid/operators/diag_embed_op.cu index 7e3ab6be664cb92370d50688ab93f9462ec89463..a9d92fdf634a76804f6aa807d4ccdc37975bc373 100644 --- a/paddle/fluid/operators/diag_embed_op.cu +++ b/paddle/fluid/operators/diag_embed_op.cu @@ -14,6 +14,7 @@ #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/diag_embed_op.h" diff --git a/paddle/fluid/operators/diag_embed_op.h b/paddle/fluid/operators/diag_embed_op.h index a5621be3baa27fd2e27d49132cc4afbecf74b785..b07047996d5136939b1b9363fc16a2079d142003 100644 --- a/paddle/fluid/operators/diag_embed_op.h +++ b/paddle/fluid/operators/diag_embed_op.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/platform/for_range.h" diff --git a/paddle/fluid/operators/dirichlet_op.h b/paddle/fluid/operators/dirichlet_op.h index 540acad423aa30a0f2e4e7147a8b11400f47eac8..658688816eb8f9f25aff8426a2767e79bbed0266 100644 --- a/paddle/fluid/operators/dirichlet_op.h +++ b/paddle/fluid/operators/dirichlet_op.h @@ -15,6 +15,7 @@ #pragma once #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/for_range.h" diff --git a/paddle/fluid/operators/dist_op.cc b/paddle/fluid/operators/dist_op.cc index 55b2484941293c8db47ef847bea959ebe82ff3ae..6f897bff75c24e704d56ab8f631940bc42239678 100644 --- a/paddle/fluid/operators/dist_op.cc +++ b/paddle/fluid/operators/dist_op.cc @@ -14,6 +14,7 @@ #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/dlnne/dlnne_engine_op.h b/paddle/fluid/operators/dlnne/dlnne_engine_op.h index 6b2622366fedc22ac0ae32c692cee8cc66fb2c4a..857f295326b94ef9e82049cbf2dbe4f1782a79c6 100644 --- a/paddle/fluid/operators/dlnne/dlnne_engine_op.h +++ b/paddle/fluid/operators/dlnne/dlnne_engine_op.h @@ -13,11 +13,11 @@ // limitations under the License. #pragma once +#include #include // NOTLINT #include // NOTLINT #include // NOTLINT -#include #include #include #include @@ -128,11 +128,13 @@ class DlnneEngineOp : public framework::OperatorBase { << ".onnx"; builder = dl::nne::CreateInferBuilder(); - PADDLE_ENFORCE_NE(builder, nullptr, platform::errors::Unavailable( - "nne create builder failed")); + PADDLE_ENFORCE_NE( + builder, nullptr, + platform::errors::Unavailable("nne create builder failed")); parser = dl::nne::CreateParser(); - PADDLE_ENFORCE_NE(parser, nullptr, platform::errors::Unavailable( - "nne create parser failed")); + PADDLE_ENFORCE_NE( + parser, nullptr, + platform::errors::Unavailable("nne create parser failed")); network = builder->CreateNetwork(); diff --git a/paddle/fluid/operators/dlnne/dlnne_engine_op_test.cc b/paddle/fluid/operators/dlnne/dlnne_engine_op_test.cc index 611366f6c5b8a4c8e9bf1b04a1fb0b866185467e..8e1d7fe5d815a0376165940379618101858d6cf6 100644 --- a/paddle/fluid/operators/dlnne/dlnne_engine_op_test.cc +++ b/paddle/fluid/operators/dlnne/dlnne_engine_op_test.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/operators/dlnne/dlnne_engine_op.h" + #include + #include "paddle/fluid/framework/block_desc.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/op_desc.h" diff --git a/paddle/fluid/operators/dropout_impl.cu.h b/paddle/fluid/operators/dropout_impl.cu.h index 482f88b73e616cd96b61beeb985ceb1785507b93..c40f6c0bbaea024437a0599de492f95bc6d6bcc3 100644 --- a/paddle/fluid/operators/dropout_impl.cu.h +++ b/paddle/fluid/operators/dropout_impl.cu.h @@ -19,11 +19,13 @@ limitations under the License. */ #ifdef PADDLE_WITH_CUDA #include #include + #include "paddle/fluid/platform/dynload/curand.h" #endif #ifdef PADDLE_WITH_HIP #include #include + #include "paddle/fluid/platform/dynload/hiprand.h" #endif diff --git a/paddle/fluid/operators/dropout_op.cc b/paddle/fluid/operators/dropout_op.cc index 8d033ea3194b9bec0b5dbe1f267e3299b0cf367b..9426efa4942088473d5487a7bc5c08930baef002 100644 --- a/paddle/fluid/operators/dropout_op.cc +++ b/paddle/fluid/operators/dropout_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/infermeta/binary.h" diff --git a/paddle/fluid/operators/dropout_op_xpu.cc b/paddle/fluid/operators/dropout_op_xpu.cc index 851f26ee0e717148b807929436749d83deee5a3c..24de99d6d8f856ddd5070931b6e2d7fe30cd0825 100644 --- a/paddle/fluid/operators/dropout_op_xpu.cc +++ b/paddle/fluid/operators/dropout_op_xpu.cc @@ -11,6 +11,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device/device_wrapper.h" namespace paddle { diff --git a/paddle/fluid/operators/edit_distance_op.cc b/paddle/fluid/operators/edit_distance_op.cc index db8a107290eb66d5f51bd85add02ff1158a438f1..8127895569f6f58f18f2f08ca9f7bcade11ffeda 100644 --- a/paddle/fluid/operators/edit_distance_op.cc +++ b/paddle/fluid/operators/edit_distance_op.cc @@ -37,12 +37,13 @@ class EditDistanceOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ( hyp_dims.size() == 2 && ref_dims.size() == 2 && hyp_dims[0] == ref_dims[0], - true, platform::errors::InvalidArgument( - "Input(Hyps) and Input(Refs) must be 2-D Tensors with " - "identical first dimension. But received Input(Hyps): " - "input rank %u, input shape [%s]; received Input(Refs): " - "input rank %u, input shape [%s]", - hyp_dims.size(), hyp_dims, ref_dims.size(), ref_dims)); + true, + platform::errors::InvalidArgument( + "Input(Hyps) and Input(Refs) must be 2-D Tensors with " + "identical first dimension. But received Input(Hyps): " + "input rank %u, input shape [%s]; received Input(Refs): " + "input rank %u, input shape [%s]", + hyp_dims.size(), hyp_dims, ref_dims.size(), ref_dims)); PADDLE_ENFORCE_EQ( hyp_length_dims[0] == ref_length_dims[0] && hyp_length_dims[0] == hyp_dims[0], diff --git a/paddle/fluid/operators/edit_distance_op.cu b/paddle/fluid/operators/edit_distance_op.cu index 49ac7183ff3b0cc84f2013b2145a825105ebb113..eb208c559cef652b3e05bf03aaa505a02303dc4b 100644 --- a/paddle/fluid/operators/edit_distance_op.cu +++ b/paddle/fluid/operators/edit_distance_op.cu @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/mixed_vector.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/edit_distance_op.h" diff --git a/paddle/fluid/operators/edit_distance_op.h b/paddle/fluid/operators/edit_distance_op.h index ef290c2eff2bedecb8f14088dd43a56c43558b44..101e3a90b80d3a0301432e0277940d92a0c094ce 100644 --- a/paddle/fluid/operators/edit_distance_op.h +++ b/paddle/fluid/operators/edit_distance_op.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/mixed_vector.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/eig_op.cc b/paddle/fluid/operators/eig_op.cc index 6f1737dba819ccdddcce3f9a39c6d7de133075b5..5239248d82f1fa498206bdb7bf2bb060a412cd05 100644 --- a/paddle/fluid/operators/eig_op.cc +++ b/paddle/fluid/operators/eig_op.cc @@ -13,8 +13,10 @@ // limitations under the License. #include "paddle/fluid/operators/eig_op.h" + #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { @@ -32,10 +34,11 @@ class EigOp : public framework::OperatorWithKernel { auto x_dims = ctx->GetInputDim("X"); int rank = x_dims.size(); - PADDLE_ENFORCE_GE(rank, 2, platform::errors::InvalidArgument( - "Expects input tensor x to be not less than " - "2 dimentions, but got dimention %d", - rank)); + PADDLE_ENFORCE_GE(rank, 2, + platform::errors::InvalidArgument( + "Expects input tensor x to be not less than " + "2 dimentions, but got dimention %d", + rank)); PADDLE_ENFORCE_EQ(x_dims[rank - 2], x_dims[rank - 1], platform::errors::InvalidArgument( "The input matrix must be a square matrix, " diff --git a/paddle/fluid/operators/eig_op.h b/paddle/fluid/operators/eig_op.h index fe898a6c41c2a57349ff09d2cc23b7aea2b66cb9..0f9afae8267bf561c0c954b5679990439b3b6a5b 100644 --- a/paddle/fluid/operators/eig_op.h +++ b/paddle/fluid/operators/eig_op.h @@ -15,8 +15,10 @@ #pragma once #include + #include #include + #include "paddle/fluid/operators/math/matrix_solve.h" #include "paddle/fluid/operators/transpose_op.h" #include "paddle/fluid/platform/for_range.h" diff --git a/paddle/fluid/operators/eigvals_op.cc b/paddle/fluid/operators/eigvals_op.cc index 2ef591dd26a06fec6fdb65e3005f9560d1b0e393..177dc684662f5409b26f22e5405a510f2c279431 100644 --- a/paddle/fluid/operators/eigvals_op.cc +++ b/paddle/fluid/operators/eigvals_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/eigvals_op.h" + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/eigvals_op.h b/paddle/fluid/operators/eigvals_op.h index 4627acc0d07defcd0f6fc6dd82aaaac8c0f148ca..d75b33e0857bc46a9cd3b9f4ef9b033862c93206 100644 --- a/paddle/fluid/operators/eigvals_op.h +++ b/paddle/fluid/operators/eigvals_op.h @@ -16,6 +16,7 @@ #include #include + #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/memory/allocation/allocator.h" @@ -71,14 +72,16 @@ static void SpiltBatchSquareMatrix(const Tensor& input, } static void CheckLapackEigResult(const int info, const std::string& name) { - PADDLE_ENFORCE_LE(info, 0, platform::errors::PreconditionNotMet( - "The QR algorithm failed to compute all the " - "eigenvalues in function %s.", - name.c_str())); + PADDLE_ENFORCE_LE(info, 0, + platform::errors::PreconditionNotMet( + "The QR algorithm failed to compute all the " + "eigenvalues in function %s.", + name.c_str())); PADDLE_ENFORCE_GE( - info, 0, platform::errors::InvalidArgument( - "The %d-th argument has an illegal value in function %s.", - -info, name.c_str())); + info, 0, + platform::errors::InvalidArgument( + "The %d-th argument has an illegal value in function %s.", -info, + name.c_str())); } template diff --git a/paddle/fluid/operators/einsum_op.cc b/paddle/fluid/operators/einsum_op.cc index 6da0045443cccdbad2965e9c9b320a41c2015d4d..7fc19d6913f83af32bb1fad1fc828043c1ca40e6 100644 --- a/paddle/fluid/operators/einsum_op.cc +++ b/paddle/fluid/operators/einsum_op.cc @@ -14,6 +14,7 @@ #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" diff --git a/paddle/fluid/operators/elementwise/elementwise_add_op_xpu.cc b/paddle/fluid/operators/elementwise/elementwise_add_op_xpu.cc index 22a5de4c6094167ee4e87d5d2ab67d341f897bbe..9c1a84ba8b67f639db427d318248fe63a75b9672 100644 --- a/paddle/fluid/operators/elementwise/elementwise_add_op_xpu.cc +++ b/paddle/fluid/operators/elementwise/elementwise_add_op_xpu.cc @@ -15,8 +15,8 @@ limitations under the License. */ #ifdef PADDLE_WITH_XPU #include #include -#include "paddle/fluid/operators/elementwise/elementwise_op.h" +#include "paddle/fluid/operators/elementwise/elementwise_op.h" #include "paddle/fluid/operators/elementwise/elementwise_xpu.h" #include "paddle/fluid/platform/device/device_wrapper.h" diff --git a/paddle/fluid/operators/elementwise/elementwise_div_op.cc b/paddle/fluid/operators/elementwise/elementwise_div_op.cc index 13fd9b81a8765aea140ad6ca2fc0383151a51dc7..e0523a26ee3ce62e31725417e7397e4fa5fb5558 100644 --- a/paddle/fluid/operators/elementwise/elementwise_div_op.cc +++ b/paddle/fluid/operators/elementwise/elementwise_div_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/elementwise/elementwise_div_op.h" + #include #include diff --git a/paddle/fluid/operators/elementwise/elementwise_div_op.h b/paddle/fluid/operators/elementwise/elementwise_div_op.h index e9adb9abdb528c187817be641b81ffb6f64833b0..b3363862d5f97a47e97d6822d2b1107159a537af 100644 --- a/paddle/fluid/operators/elementwise/elementwise_div_op.h +++ b/paddle/fluid/operators/elementwise/elementwise_div_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/operators/elementwise/elementwise_mul_op.h" namespace paddle { diff --git a/paddle/fluid/operators/elementwise/elementwise_heaviside_op.cc b/paddle/fluid/operators/elementwise/elementwise_heaviside_op.cc index e003a43b5c56b831caeb55988ba7fdc375513bdc..ebdebb2f4852af76b095f94402d6dad224b458c9 100644 --- a/paddle/fluid/operators/elementwise/elementwise_heaviside_op.cc +++ b/paddle/fluid/operators/elementwise/elementwise_heaviside_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/operators/elementwise/elementwise_op.h" namespace paddle { diff --git a/paddle/fluid/operators/elementwise/elementwise_mlu.h b/paddle/fluid/operators/elementwise/elementwise_mlu.h index ff1e12103be9194e971a4ad262fa984d0d7c6ca9..8c230c5f47bf60bd5cb64ef1e8f08701a462e1c3 100644 --- a/paddle/fluid/operators/elementwise/elementwise_mlu.h +++ b/paddle/fluid/operators/elementwise/elementwise_mlu.h @@ -16,6 +16,7 @@ #ifdef PADDLE_WITH_MLU #include + #include "paddle/fluid/operators/elementwise/elementwise_op.h" #include "paddle/fluid/operators/mlu/mlu_baseop.h" diff --git a/paddle/fluid/operators/elementwise/elementwise_mod_op_xpu.cc b/paddle/fluid/operators/elementwise/elementwise_mod_op_xpu.cc index 156589384c0dd2f0013b0c83a8dbf042eb40c978..19d28301ffb830d897793c132fdad0518918fcb5 100644 --- a/paddle/fluid/operators/elementwise/elementwise_mod_op_xpu.cc +++ b/paddle/fluid/operators/elementwise/elementwise_mod_op_xpu.cc @@ -15,11 +15,11 @@ limitations under the License. */ #ifdef PADDLE_WITH_XPU #include #include + #include "paddle/fluid/framework/data_layout.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/operators/common_infer_shape_functions.h" #include "paddle/fluid/operators/elementwise/elementwise_op_function.h" - #include "paddle/fluid/operators/elementwise/elementwise_xpu.h" #include "paddle/fluid/platform/device/device_wrapper.h" diff --git a/paddle/fluid/operators/elementwise/elementwise_mul_op.cc b/paddle/fluid/operators/elementwise/elementwise_mul_op.cc index 45b6f7cb391949043ff4e6725f7e3f0c18eef278..253014a79817aeef10fb318f02c70cd55139c874 100644 --- a/paddle/fluid/operators/elementwise/elementwise_mul_op.cc +++ b/paddle/fluid/operators/elementwise/elementwise_mul_op.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/elementwise/elementwise_mul_op.h" + #include #include + #include "paddle/fluid/operators/elementwise/elementwise_op.h" #include "paddle/fluid/platform/complex.h" diff --git a/paddle/fluid/operators/elementwise/elementwise_mul_op.h b/paddle/fluid/operators/elementwise/elementwise_mul_op.h index e2dd0e36d400afe0d91bdcad74b5f9de2a4c8854..39045bf0d590489db0868625a1948eb223f7c105 100644 --- a/paddle/fluid/operators/elementwise/elementwise_mul_op.h +++ b/paddle/fluid/operators/elementwise/elementwise_mul_op.h @@ -15,9 +15,9 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/operators/elementwise/elementwise_op.h" #include "paddle/fluid/platform/cpu_info.h" - #include "paddle/phi/kernels/elementwise_kernel.h" namespace paddle { diff --git a/paddle/fluid/operators/elementwise/elementwise_op_function.h b/paddle/fluid/operators/elementwise/elementwise_op_function.h index 80b07721f0b4d1feb669bfce91127b0887d79391..476b891bb419d7e4f69a5a7f0a0df04d1decf5e7 100644 --- a/paddle/fluid/operators/elementwise/elementwise_op_function.h +++ b/paddle/fluid/operators/elementwise/elementwise_op_function.h @@ -28,7 +28,6 @@ limitations under the License. */ #include "paddle/fluid/operators/elementwise/elementwise_functor.h" #include "paddle/fluid/platform/device/gpu/gpu_info.h" #include "paddle/fluid/platform/transform.h" - #include "paddle/phi/api/lib/utils/tensor_utils.h" #include "paddle/phi/kernels/cpu/elementwise.h" #include "paddle/phi/kernels/cpu/elementwise_grad.h" @@ -60,14 +59,14 @@ namespace paddle { namespace operators { /* -* Pack input and output tensors into respective vectors with -* consideration of varible X`s class type. -* Input variable X is supported to be whether LoDTensor or -* SelectedRows class type in this package function, once X -* was SelectedRows type, a valid pointer x_for_selectedrows -* is excepted to be passed in from op kernel for acquisition -* of the valid address of LoDTensor created ahead in the function. -*/ + * Pack input and output tensors into respective vectors with + * consideration of varible X`s class type. + * Input variable X is supported to be whether LoDTensor or + * SelectedRows class type in this package function, once X + * was SelectedRows type, a valid pointer x_for_selectedrows + * is excepted to be passed in from op kernel for acquisition + * of the valid address of LoDTensor created ahead in the function. + */ template int PackTensorsIntoVector(const framework::ExecutionContext &ctx, std::vector *ins, @@ -327,10 +326,11 @@ static void FusedElemwiseAndActBroadcast1CUDA(gpuStream_t stream, const T *x, T *intermediate_out) { int block_size = std::min(ELEMWISE_MAX_BLOCK_DIM, w); int gird_size = h; - FusedElemwiseAndActBroadcast1CUDAKernel< - T, CompoundFunctor, BcastY, KeepIntermediateOut, - SameShapeOfIntermediateOutAndOut><<>>( - x, y, h, w, compound_functor, out, intermediate_out); + FusedElemwiseAndActBroadcast1CUDAKernel + <<>>(x, y, h, w, compound_functor, out, + intermediate_out); } template <<>>( - x, y, compound_functor, pre, n, post, out, intermediate_out); + FusedElemwiseAndActBroadcast2CUDAKernel + <<>>(x, y, compound_functor, pre, n, + post, out, intermediate_out); } #endif @@ -544,8 +545,9 @@ void FusedElemwiseAndActGradComputeNoBroadcast( out->data(), dout->data(), dx_op, dy_op, dintermediate_op, dx == nullptr ? nullptr : dx->mutable_data(ctx.GetPlace()), dy == nullptr ? nullptr : dy->mutable_data(ctx.GetPlace()), - dintermediate == nullptr ? nullptr : dintermediate->mutable_data( - ctx.GetPlace())}); + dintermediate == nullptr + ? nullptr + : dintermediate->mutable_data(ctx.GetPlace())}); } template <<>>( - x, y, intermediate_out, out, dout, h, w, dx_op, dy_op, dintermediate_op, - dx, dy, d_intermediate); + FusedElemwiseAndActGradBroadcast1CUDAKernel + <<>>(x, y, intermediate_out, out, dout, h, w, + dx_op, dy_op, dintermediate_op, dx, dy, + d_intermediate); } template <<>>( - x, y, intermediate_out, out, dout, pre, n, post, dx_op, dy_op, - dintermediate_op, dx, dy, dintermediate); + FusedElemwiseAndActGradBroadcast2CUDAKernel + <<>>( + x, y, intermediate_out, out, dout, pre, n, post, dx_op, dy_op, + dintermediate_op, dx, dy, dintermediate); } #endif @@ -995,8 +996,9 @@ void FusedElemwiseAndActGradComputeWithBroadcast( out->data(), dout->data(), h, w, dx_op, dy_op, dintermediate_op, dx == nullptr ? nullptr : dx->mutable_data(ctx.GetPlace()), dy == nullptr ? nullptr : dy->mutable_data(ctx.GetPlace()), - dintermediate == nullptr ? nullptr : dintermediate->mutable_data( - ctx.GetPlace())); + dintermediate == nullptr + ? nullptr + : dintermediate->mutable_data(ctx.GetPlace())); #endif } else { FusedElemwiseAndActGradBroadcast1CPUdata(), dout->data(), h, w, dx_op, dy_op, dintermediate_op, dx == nullptr ? nullptr : dx->mutable_data(ctx.GetPlace()), dy == nullptr ? nullptr : dy->mutable_data(ctx.GetPlace()), - dintermediate == nullptr ? nullptr : dintermediate->mutable_data( - ctx.GetPlace())); + dintermediate == nullptr + ? nullptr + : dintermediate->mutable_data(ctx.GetPlace())); } } else { if (platform::is_gpu_place(ctx.GetPlace())) { @@ -1022,8 +1025,9 @@ void FusedElemwiseAndActGradComputeWithBroadcast( dintermediate_op, dx == nullptr ? nullptr : dx->mutable_data(ctx.GetPlace()), dy == nullptr ? nullptr : dy->mutable_data(ctx.GetPlace()), - dintermediate == nullptr ? nullptr : dintermediate->mutable_data( - ctx.GetPlace())); + dintermediate == nullptr + ? nullptr + : dintermediate->mutable_data(ctx.GetPlace())); #endif } else { FusedElemwiseAndActGradBroadcast2CPUmutable_data(ctx.GetPlace()), dy == nullptr ? nullptr : dy->mutable_data(ctx.GetPlace()), - dintermediate == nullptr ? nullptr : dintermediate->mutable_data( - ctx.GetPlace())); + dintermediate == nullptr + ? nullptr + : dintermediate->mutable_data(ctx.GetPlace())); } } } diff --git a/paddle/fluid/operators/elementwise/elementwise_xpu.h b/paddle/fluid/operators/elementwise/elementwise_xpu.h index db5c94b9d1a6e2ded5410b04cdb6259cb259b58f..3f38450581ec8a098f8b4b9416ae980657f7e877 100644 --- a/paddle/fluid/operators/elementwise/elementwise_xpu.h +++ b/paddle/fluid/operators/elementwise/elementwise_xpu.h @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/platform/place.h" #include "xpu/refactor/math.h" @@ -32,8 +33,9 @@ void XPUElementwise( const std::vector&, const std::vector&)> func) { auto x_var = ctx.InputVar("X"); - PADDLE_ENFORCE_NE(x_var, nullptr, platform::errors::InvalidArgument( - "Cannot get input Variable X")); + PADDLE_ENFORCE_NE( + x_var, nullptr, + platform::errors::InvalidArgument("Cannot get input Variable X")); PADDLE_ENFORCE_EQ( x_var->IsType(), true, platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/elementwise/test_elementwise_div_grad_grad.cc b/paddle/fluid/operators/elementwise/test_elementwise_div_grad_grad.cc index 3cecc52a3c481cf9cb4a1e2eba6ded704a8fa8ee..f647bd91d5f3d1c0ccad62b694c863f7eef0613e 100644 --- a/paddle/fluid/operators/elementwise/test_elementwise_div_grad_grad.cc +++ b/paddle/fluid/operators/elementwise/test_elementwise_div_grad_grad.cc @@ -18,6 +18,7 @@ #include #include #include + #include "gtest/gtest.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/op_registry.h" @@ -72,11 +73,12 @@ class TestElementwiseDivGradGradWithoutDout std::unique_ptr CreateTestOp() override { auto op = framework::OpRegistry::CreateOp( - this->op_type_, {{"Y", {"Y"}}, - {"Out", {"Out"}}, - {"DDX", {"DDX"}}, - {"DDY", {"DDY"}}, - {"DX", {"DX"}}}, + this->op_type_, + {{"Y", {"Y"}}, + {"Out", {"Out"}}, + {"DDX", {"DDX"}}, + {"DDY", {"DDY"}}, + {"DX", {"DX"}}}, {{"Y@GRAD", {"Y@GRAD"}}, {"DDOut", {"DDOut"}}}, {{"use_mkldnn", false}, {"axis", 0}}); return op; diff --git a/paddle/fluid/operators/elementwise/test_elementwise_op_grad_grad.h b/paddle/fluid/operators/elementwise/test_elementwise_op_grad_grad.h index 05f87e5465abea78b0cd573a061c0806f8c1efff..7defe4e5793ab7ab81f8e9c22f1cbdc1164e616f 100644 --- a/paddle/fluid/operators/elementwise/test_elementwise_op_grad_grad.h +++ b/paddle/fluid/operators/elementwise/test_elementwise_op_grad_grad.h @@ -21,6 +21,7 @@ #include #include #include + #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" diff --git a/paddle/fluid/operators/empty_op.cc b/paddle/fluid/operators/empty_op.cc index 9e0e4e7fe1c6d26df7c4347d8bc81a985e6c973b..0f6c308b211bfb0a7ec81ef273cb24f7483dff55 100644 --- a/paddle/fluid/operators/empty_op.cc +++ b/paddle/fluid/operators/empty_op.cc @@ -12,9 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/framework/op_registry.h" - #include "paddle/fluid/framework/infershape_utils.h" +#include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/infermeta/nullary.h" namespace paddle { diff --git a/paddle/fluid/operators/expand_as_op.cc b/paddle/fluid/operators/expand_as_op.cc index 093c4d8f7930e421193ca36188d00ce2338ffd95..cace8b5fdffa78ca33c688da95bd419e1a400c6f 100644 --- a/paddle/fluid/operators/expand_as_op.cc +++ b/paddle/fluid/operators/expand_as_op.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/expand_as_op.h" + #include #include diff --git a/paddle/fluid/operators/expand_as_v2_op.cc b/paddle/fluid/operators/expand_as_v2_op.cc old mode 100755 new mode 100644 index 9361edd43bf15ac0eee4a4de618027af79b78b56..8cdab4c5e1a41dcc5c5472ec6ef0959c8998e4ce --- a/paddle/fluid/operators/expand_as_v2_op.cc +++ b/paddle/fluid/operators/expand_as_v2_op.cc @@ -10,8 +10,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/expand_as_v2_op.h" + #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/phi/infermeta/binary.h" @@ -107,7 +109,6 @@ REGISTER_OPERATOR(expand_as_v2_grad, ops::ExpandAsV2GradOp, ops::ExpandAsV2GradNoNeedBufVarsInferer); REGISTER_OP_VERSION(expand_as_v2) - .AddCheckpoint( - R"ROC(fix expand_as_v2 and add new input [Y])ROC", - paddle::framework::compatible::OpVersionDesc().NewInput( - "Y", "Expand X according to the shape of Y")); + .AddCheckpoint(R"ROC(fix expand_as_v2 and add new input [Y])ROC", + paddle::framework::compatible::OpVersionDesc().NewInput( + "Y", "Expand X according to the shape of Y")); diff --git a/paddle/fluid/operators/expand_as_v2_op_npu.cc b/paddle/fluid/operators/expand_as_v2_op_npu.cc index 67d95e12400229d0b5a9bc915643a9725b591a4e..28fd922d77b81b9605c657ff9d5097b8f44bd109 100644 --- a/paddle/fluid/operators/expand_as_v2_op_npu.cc +++ b/paddle/fluid/operators/expand_as_v2_op_npu.cc @@ -30,10 +30,11 @@ class ExpandAsV2NPUKernel : public framework::OpKernel { "expand_as_v2 op must be greater than or equal to " "the rank (%d) of the input 'x'.", target_rank, rank)); - PADDLE_ENFORCE_GE(rank, 1, platform::errors::InvalidArgument( - "The rank (%d) of the input 'x' for " - "expand_as_v2 op must be positive.", - rank)); + PADDLE_ENFORCE_GE( + rank, 1, + platform::errors::InvalidArgument("The rank (%d) of the input 'x' for " + "expand_as_v2 op must be positive.", + rank)); PADDLE_ENFORCE_LE(target_rank, MAX_RANK_SUPPORTED, platform::errors::InvalidArgument( "The rank (%d) of the input 'target_tensor' for " diff --git a/paddle/fluid/operators/expand_as_v2_op_xpu.cc b/paddle/fluid/operators/expand_as_v2_op_xpu.cc index 0912b280aa6c7682a2d38c08faaf3364278ce878..fc3d77f3cc82cc957333e91c064b18dbfc43f8b5 100644 --- a/paddle/fluid/operators/expand_as_v2_op_xpu.cc +++ b/paddle/fluid/operators/expand_as_v2_op_xpu.cc @@ -33,10 +33,11 @@ class ExpandAsV2XPUKernel : public framework::OpKernel { "expand_as_v2 op must be greater than or equal to " "the rank (%d) of the input 'x'.", target_rank, rank)); - PADDLE_ENFORCE_GE(rank, 1, platform::errors::InvalidArgument( - "The rank (%d) of the input 'x' for " - "expand_as_v2 op must be positive.", - rank)); + PADDLE_ENFORCE_GE( + rank, 1, + platform::errors::InvalidArgument("The rank (%d) of the input 'x' for " + "expand_as_v2 op must be positive.", + rank)); PADDLE_ENFORCE_LE(target_rank, MAX_RANK_SUPPORTED, platform::errors::InvalidArgument( "The rank (%d) of the input 'target_tensor' for " diff --git a/paddle/fluid/operators/expand_op.cc b/paddle/fluid/operators/expand_op.cc index e45761112d4bd8dd317eeeeecd8a6abb921af228..04cdbd5a606151b69b839ee65694cf47dbbae1e2 100644 --- a/paddle/fluid/operators/expand_op.cc +++ b/paddle/fluid/operators/expand_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/expand_op.h" + #include #include #include diff --git a/paddle/fluid/operators/expand_op.h b/paddle/fluid/operators/expand_op.h index 05cd893b057af768c6d7427f01c445f88b1bdff8..880adad743fa3d95172f6da9fa896f8889448df8 100644 --- a/paddle/fluid/operators/expand_op.h +++ b/paddle/fluid/operators/expand_op.h @@ -213,12 +213,13 @@ class ExpandGradKernel : public framework::OpKernel { framework::TensorCopy(*in0, context.GetPlace(), context.device_context(), out0); } else { - PADDLE_ENFORCE_GE(dims, 1, platform::errors::InvalidArgument( - "The number of dimensions of the input " - "'Out@GRAD' for Op(expand_grad)" - " must be greater than or equal to 1, but " - "the value received is %d.", - dims)); + PADDLE_ENFORCE_GE(dims, 1, + platform::errors::InvalidArgument( + "The number of dimensions of the input " + "'Out@GRAD' for Op(expand_grad)" + " must be greater than or equal to 1, but " + "the value received is %d.", + dims)); PADDLE_ENFORCE_LE(dims, MAX_RANK_SUPPORTED, platform::errors::InvalidArgument( "The number of dimensions of the input 'Out@GRAD' " diff --git a/paddle/fluid/operators/expand_v2_op.cc b/paddle/fluid/operators/expand_v2_op.cc index 292f706cb186b09fb4e358fd317b5d4248d5c3a3..6aeea745911aa517fa009aeb0ba1f0ecc66afe2a 100644 --- a/paddle/fluid/operators/expand_v2_op.cc +++ b/paddle/fluid/operators/expand_v2_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/expand_v2_op.h" + #include #include #include diff --git a/paddle/fluid/operators/expand_v2_op_npu.cc b/paddle/fluid/operators/expand_v2_op_npu.cc index c9fe19fd091daa6622a310c601a2d868ad29c086..c64bdabf599648ab8c629ab04276914e4e216e3b 100644 --- a/paddle/fluid/operators/expand_v2_op_npu.cc +++ b/paddle/fluid/operators/expand_v2_op_npu.cc @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/expand_v2_op.h" #include "paddle/fluid/framework/op_registry.h" +#include "paddle/fluid/operators/expand_v2_op.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" namespace paddle { diff --git a/paddle/fluid/operators/expand_v2_op_xpu.cc b/paddle/fluid/operators/expand_v2_op_xpu.cc index cb2165c4e922eb0fd8408f3219db4c01f21ef7ee..3d010c964bcfd645e3afdbb0727eceae594a880b 100644 --- a/paddle/fluid/operators/expand_v2_op_xpu.cc +++ b/paddle/fluid/operators/expand_v2_op_xpu.cc @@ -13,8 +13,8 @@ limitations under the License. */ #ifdef PADDLE_WITH_XPU -#include "paddle/fluid/operators/expand_v2_op.h" #include "paddle/fluid/framework/op_registry.h" +#include "paddle/fluid/operators/expand_v2_op.h" namespace paddle { namespace operators { @@ -110,10 +110,11 @@ class ExpandV2XPUKernel : public framework::OpKernel { r = xpu::broadcast(dev_ctx.x_context(), x_data, out_data, x_shape, out_shape); } - PADDLE_ENFORCE_EQ(r, XPU_SUCCESS, platform::errors::External( - "XPU API(broadcast) return wrong " - "value[%d %s] in ExpandV2XPUKernel.", - r, XPUAPIErrorMsg[r])); + PADDLE_ENFORCE_EQ( + r, XPU_SUCCESS, + platform::errors::External("XPU API(broadcast) return wrong " + "value[%d %s] in ExpandV2XPUKernel.", + r, XPUAPIErrorMsg[r])); } }; diff --git a/paddle/fluid/operators/fake_dequantize_op.cc b/paddle/fluid/operators/fake_dequantize_op.cc index 8172f441e64a4958a2363654ba42bc2cfec31a19..5a3a1cf53deb13df492e40aced582e05ced10da2 100644 --- a/paddle/fluid/operators/fake_dequantize_op.cc +++ b/paddle/fluid/operators/fake_dequantize_op.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fake_dequantize_op.h" + #include #include + #include "paddle/fluid/framework/op_version_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/fake_dequantize_op.cu.h b/paddle/fluid/operators/fake_dequantize_op.cu.h index 9859dd4607c15611bc346eafd31ea857bab7bcca..50f772ec45de82839c04b23383bb8302d1e3ecdc 100644 --- a/paddle/fluid/operators/fake_dequantize_op.cu.h +++ b/paddle/fluid/operators/fake_dequantize_op.cu.h @@ -119,10 +119,10 @@ struct ChannelDequantizeFunctor { quant_stride *= in_dims[i]; } - DequantizeOneScaleQuantAxisN< - T><<>>( - in_data, scale_factor, max_range, num, in_dims[quant_axis], - quant_stride, out_data); + DequantizeOneScaleQuantAxisN + <<>>( + in_data, scale_factor, max_range, num, in_dims[quant_axis], + quant_stride, out_data); } else if (scale_num == 2) { // Not need to consider quant_axis int num = in->numel(); diff --git a/paddle/fluid/operators/fake_dequantize_op.h b/paddle/fluid/operators/fake_dequantize_op.h index aad2c2c7d985a758d2df0921053c3efbeeacdcd0..e623a638922d5c51050e0f24d10e52b1d6607786 100644 --- a/paddle/fluid/operators/fake_dequantize_op.h +++ b/paddle/fluid/operators/fake_dequantize_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/ddim.h" diff --git a/paddle/fluid/operators/fake_quantize_op.cc b/paddle/fluid/operators/fake_quantize_op.cc index ac72f23d46ea84fbff854a2685d7b28b4a16d434..855c78d2998bd054ceb2f0eb74969ad34c9b97be 100644 --- a/paddle/fluid/operators/fake_quantize_op.cc +++ b/paddle/fluid/operators/fake_quantize_op.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fake_quantize_op.h" + #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/platform/transform.h" @@ -832,7 +834,7 @@ REGISTER_OP_VERSION(moving_average_abs_max_scale) "Delete output in order to make the inference model not " "save moving_average_abs_max_scale operator. This will " "make the quantitative model be correctly applied in inference.")) - .AddCheckpoint( - R"ROC(Incompatible upgrade of output [Out])ROC", - paddle::framework::compatible::OpVersionDesc().NewOutput( - "Out", "In order to support dygraph qat, add output again.")); + .AddCheckpoint(R"ROC(Incompatible upgrade of output [Out])ROC", + paddle::framework::compatible::OpVersionDesc().NewOutput( + "Out", + "In order to support dygraph qat, add output again.")); diff --git a/paddle/fluid/operators/fake_quantize_op.cu.h b/paddle/fluid/operators/fake_quantize_op.cu.h index a6130c272d72b28d8606945f2b9ae38c26de1a4d..580521183cbdc1263f998818081208fcbb4b2612 100644 --- a/paddle/fluid/operators/fake_quantize_op.cu.h +++ b/paddle/fluid/operators/fake_quantize_op.cu.h @@ -17,6 +17,7 @@ limitations under the License. */ #endif // PADDLE_FLUID_OPERATORS_FAKE_QUANTIZE_OP_CU_H_ #include + #include "paddle/fluid/memory/memcpy.h" #include "paddle/fluid/operators/fake_quantize_op.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" @@ -80,10 +81,10 @@ struct FindAbsMaxFunctor { framework::Tensor max; T* max_data = max.mutable_data(phi::make_ddim({grid}), ctx.GetPlace()); - FindAbsMaxKernel<<>>( - in, num, max_data); - FindAbsMaxKernel<<<1, block, 1024 * sizeof(T), ctx.stream()>>>( - max_data, grid, out); + FindAbsMaxKernel + <<>>(in, num, max_data); + FindAbsMaxKernel + <<<1, block, 1024 * sizeof(T), ctx.stream()>>>(max_data, grid, out); } }; @@ -176,9 +177,9 @@ struct FindChannelAbsMaxFunctor { int cout = in_dims[0]; int grid = cout; int block = 1024; - FindChannelAbsMaxKernelQuantAxis0< - T><<>>( - in_data, num, cout, out_abs_max); + FindChannelAbsMaxKernelQuantAxis0 + <<>>(in_data, num, cout, + out_abs_max); } else if (quant_axis == 1) { int cin = in_dims[0]; int cout = in_dims[1]; @@ -193,17 +194,17 @@ struct FindChannelAbsMaxFunctor { for (int i = 0; i < cin / max_threads; i++) { int block = max_threads; - FindChannelAbsMaxKernelQuantAxis1< - T><<>>( - in_data, num, cin, cout, out_abs_max); + FindChannelAbsMaxKernelQuantAxis1 + <<>>( + in_data, num, cin, cout, out_abs_max); in_data += num / cin; } int block = cin % max_threads; if (block > 0) { - FindChannelAbsMaxKernelQuantAxis1< - T><<>>( - in_data, num, in_dims[0], in_dims[1], out_abs_max); + FindChannelAbsMaxKernelQuantAxis1 + <<>>( + in_data, num, in_dims[0], in_dims[1], out_abs_max); } } } @@ -549,16 +550,16 @@ struct ChannelClipFakeQuantDequantFunctor { if (quant_axis == 0) { int grid = in_dims[0]; int block = 1024; - ChannelClipAndQuantDequantKernelQuantAxis0< - T><<>>(in_data, scale_data, bin_cnt, - num, in_dims[0], out_data); + ChannelClipAndQuantDequantKernelQuantAxis0 + <<>>(in_data, scale_data, bin_cnt, num, + in_dims[0], out_data); } else if (quant_axis == 1) { int grid = in_dims[0] * in_dims[1]; int block = 1024; - ChannelClipAndQuantDequantKernelQuantAxis1< - T><<>>( - in_data, scale_data, bin_cnt, num, in_dims[0], in_dims[1], out_data); + ChannelClipAndQuantDequantKernelQuantAxis1 + <<>>(in_data, scale_data, bin_cnt, num, + in_dims[0], in_dims[1], out_data); } } }; diff --git a/paddle/fluid/operators/fake_quantize_op.h b/paddle/fluid/operators/fake_quantize_op.h index dc3f081cc9eabe164b902a3a6117b0749d521884..182db11ed847d9ca369a04955307daff3f35a67c 100644 --- a/paddle/fluid/operators/fake_quantize_op.h +++ b/paddle/fluid/operators/fake_quantize_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/tensor_util.h" diff --git a/paddle/fluid/operators/fc_op.cc b/paddle/fluid/operators/fc_op.cc index 6e646f0d4bf264b3b4aebdb56dceaef063a404c3..68ef8f3c2be11e4fe47240ffbe4194ee47fa3f60 100644 --- a/paddle/fluid/operators/fc_op.cc +++ b/paddle/fluid/operators/fc_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fc_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/fc_op.h b/paddle/fluid/operators/fc_op.h index 47c7128603587d4d786b13f1ca5764bca188f09d..1c76c2c36b84ecd3df2b9b48d5b41dbd902b85d6 100644 --- a/paddle/fluid/operators/fc_op.h +++ b/paddle/fluid/operators/fc_op.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/fc_functor.h" diff --git a/paddle/fluid/operators/fill_any_like_op_xpu.cc b/paddle/fluid/operators/fill_any_like_op_xpu.cc index ec4ba6e926c41bab8d7ceda20486db39f2d4dabe..a07fbe5a7a5502435e6921383d419ee374129ca9 100644 --- a/paddle/fluid/operators/fill_any_like_op_xpu.cc +++ b/paddle/fluid/operators/fill_any_like_op_xpu.cc @@ -15,7 +15,6 @@ limitations under the License. */ #ifdef PADDLE_WITH_XPU #include "paddle/fluid/framework/op_registry.h" - #include "paddle/phi/kernels/full_kernel.h" namespace paddle { diff --git a/paddle/fluid/operators/fill_constant_op.cc b/paddle/fluid/operators/fill_constant_op.cc index 07593a70f05b7c46cf7da92942c02e815fbd1cc0..d6726b99813e62c5e9496b247ee778e2296e913f 100644 --- a/paddle/fluid/operators/fill_constant_op.cc +++ b/paddle/fluid/operators/fill_constant_op.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fill_constant_op.h" + #include + #include "paddle/fluid/framework/op_version_registry.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/fill_constant_op_npu.cc b/paddle/fluid/operators/fill_constant_op_npu.cc index edd8613ba525d0dfb5f62b08f0a06294a651b605..a121eb8cc841b18d3e471c9359dc7fd24ba58357 100644 --- a/paddle/fluid/operators/fill_constant_op_npu.cc +++ b/paddle/fluid/operators/fill_constant_op_npu.cc @@ -84,9 +84,10 @@ class FillConstantNPUKernel : public framework::OpKernel { const auto &dev_ctx = ctx.template device_context(); auto op_func = [&shape, &value]( - const std::vector &inputs, const std::vector &outputs, - const NPUAttributeMap &attrs, - const platform::NPUDeviceContext &dev_ctx) { + const std::vector &inputs, + const std::vector &outputs, + const NPUAttributeMap &attrs, + const platform::NPUDeviceContext &dev_ctx) { Tensor tensor_value; tensor_value.mutable_data({1}, dev_ctx.GetPlace()); FillNpuTensorWithConstant(&tensor_value, diff --git a/paddle/fluid/operators/fill_diagonal_tensor_op.h b/paddle/fluid/operators/fill_diagonal_tensor_op.h index ebb980b66af85d3a3508f233b749bf5188560e3b..5bee72f526815957de194f58f001c560260f5a9c 100644 --- a/paddle/fluid/operators/fill_diagonal_tensor_op.h +++ b/paddle/fluid/operators/fill_diagonal_tensor_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/fill_op.cc b/paddle/fluid/operators/fill_op.cc index 521ddd4ec12b33d832aa9896844fe917172e2d13..e934b794f8ba72016e39fcd12b6aff9e24fe28a5 100644 --- a/paddle/fluid/operators/fill_op.cc +++ b/paddle/fluid/operators/fill_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fill_op.h" + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/fill_op.h b/paddle/fluid/operators/fill_op.h index c5cbffbf5c695ffe9d16a530b4c84db094a72df2..7f7e0f2b31aa0b03fa34196186a92cf629f922d9 100644 --- a/paddle/fluid/operators/fill_op.h +++ b/paddle/fluid/operators/fill_op.h @@ -14,9 +14,9 @@ limitations under the License. */ #pragma once +#include #include -#include #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/fill_zeros_like_op.cc b/paddle/fluid/operators/fill_zeros_like_op.cc index 2d340829332c810ecff2936d24dffe4f5fb9bf3f..518d8414c50927f6262383cdfcd24c4ccfb5ad6d 100644 --- a/paddle/fluid/operators/fill_zeros_like_op.cc +++ b/paddle/fluid/operators/fill_zeros_like_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fill_zeros_like_op.h" + #include "paddle/fluid/platform/complex.h" namespace paddle { diff --git a/paddle/fluid/operators/fill_zeros_like_op.cu.cc b/paddle/fluid/operators/fill_zeros_like_op.cu.cc index 4cb0887c1f326cdb1dc9a7d40318eb5560316b98..91809b8cd11bd0014b70d72eb76cae2c2668e5df 100644 --- a/paddle/fluid/operators/fill_zeros_like_op.cu.cc +++ b/paddle/fluid/operators/fill_zeros_like_op.cu.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fill_zeros_like_op.h" + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/complex.h" #include "paddle/fluid/platform/float16.h" diff --git a/paddle/fluid/operators/filter_by_instag_op.cc b/paddle/fluid/operators/filter_by_instag_op.cc index 02ea2d59ae30777c65ed6fb4488cdbc9ba15a796..cb1e3083320b42e6a2a8ce6f81346e510b90dc95 100644 --- a/paddle/fluid/operators/filter_by_instag_op.cc +++ b/paddle/fluid/operators/filter_by_instag_op.cc @@ -15,6 +15,7 @@ #include "paddle/fluid/operators/filter_by_instag_op.h" #include + #include "paddle/fluid/framework/no_need_buffer_vars_inference.h" #include "paddle/fluid/framework/var_type_inference.h" diff --git a/paddle/fluid/operators/filter_by_instag_op.cu b/paddle/fluid/operators/filter_by_instag_op.cu index 7870efba4e7a1a285bbd4b28b04c2b15f263c347..75680a61b30eb08ab2e71560a907440574027968 100644 --- a/paddle/fluid/operators/filter_by_instag_op.cu +++ b/paddle/fluid/operators/filter_by_instag_op.cu @@ -20,6 +20,7 @@ #include #include + #include #include #include @@ -30,11 +31,10 @@ #include "paddle/fluid/framework/mixed_vector.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/memory/memcpy.h" +#include "paddle/fluid/operators/filter_by_instag_op.h" #include "paddle/fluid/platform/device/gpu/gpu_info.h" #include "paddle/fluid/platform/enforce.h" -#include "paddle/fluid/operators/filter_by_instag_op.h" - #if defined(PADDLE_WITH_CUDA) namespace cg = cooperative_groups; #endif @@ -277,7 +277,7 @@ __global__ void filter_copy_fuse_kernel( T* dst = out_data + output_start_idx * x1_embed_size; const T* src_start = x1_data + x1_lods_data[p] * x1_embed_size; const T* src_end = x1_data + x1_lods_data[p + 1] * x1_embed_size; - for (const T *j = src_start; j != src_end; dst++, j++) { + for (const T* j = src_start; j != src_end; dst++, j++) { *dst = *j; } } @@ -306,7 +306,7 @@ __global__ void copy_grad_kernel(const size_t N, const int ins_per_thread, const T* src_end = out_grad_data + (map_data[p * 3] + map_data[p * 3 + 2]) * x1_embed_size; - for (const T *j = src_start; j != src_end; dst++, j++) { + for (const T* j = src_start; j != src_end; dst++, j++) { *dst = *j; } } diff --git a/paddle/fluid/operators/filter_by_instag_op.h b/paddle/fluid/operators/filter_by_instag_op.h index 3abc980ceaafc3719c13cad51c346282be2c694f..6172fef9b4bba738220a1497a5a738fba4995c53 100644 --- a/paddle/fluid/operators/filter_by_instag_op.h +++ b/paddle/fluid/operators/filter_by_instag_op.h @@ -20,6 +20,7 @@ #include #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/mixed_vector.h" diff --git a/paddle/fluid/operators/flatten_op.cc b/paddle/fluid/operators/flatten_op.cc index d1ac573b84461b9a29bbc04c1a27d05f80147e26..2e767c3705188331dcf6afc535326b4f4d341e34 100644 --- a/paddle/fluid/operators/flatten_op.cc +++ b/paddle/fluid/operators/flatten_op.cc @@ -13,10 +13,12 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/flatten_op.h" + #include #include #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/flatten_op.h b/paddle/fluid/operators/flatten_op.h index cacd30cad8a949cce1be0a375f5fe0f8d90312ef..6a91cd8b9414a7da17fa8fa3631a539f9781ce2e 100644 --- a/paddle/fluid/operators/flatten_op.h +++ b/paddle/fluid/operators/flatten_op.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/phi_utils.h" #include "paddle/fluid/platform/device_context.h" diff --git a/paddle/fluid/operators/flip_op.cc b/paddle/fluid/operators/flip_op.cc index e1ee1a86a2f9691d5b2850cdd1aad5a040f45e29..b00cbf5c4fc26f2e5048daeb857ca23cdc752a97 100644 --- a/paddle/fluid/operators/flip_op.cc +++ b/paddle/fluid/operators/flip_op.cc @@ -93,10 +93,9 @@ REGISTER_OPERATOR(flip, ops::FlipOp, ops::FlipOpMaker, ops::FlipOpInferVarType, FlipInferShapeFunctor); /* ========================== register checkpoint ===========================*/ -REGISTER_OP_VERSION(flip) - .AddCheckpoint( - R"ROC(Upgrade flip, add new attr [axis] and delete attr [dims].)ROC", - paddle::framework::compatible::OpVersionDesc() - .NewAttr("axis", "The added attr 'axis' doesn't set default value.", - paddle::none) - .DeleteAttr("dims", "The attr 'dims' is deleted.")); +REGISTER_OP_VERSION(flip).AddCheckpoint( + R"ROC(Upgrade flip, add new attr [axis] and delete attr [dims].)ROC", + paddle::framework::compatible::OpVersionDesc() + .NewAttr("axis", "The added attr 'axis' doesn't set default value.", + paddle::none) + .DeleteAttr("dims", "The attr 'dims' is deleted.")); diff --git a/paddle/fluid/operators/fold_op.h b/paddle/fluid/operators/fold_op.h index c0aa47a0b4fccd5615e1254713874c024068f799..fd1a7558b7127ae2885466ba976262723e530633 100644 --- a/paddle/fluid/operators/fold_op.h +++ b/paddle/fluid/operators/fold_op.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/math/im2col.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/frame_op.cc b/paddle/fluid/operators/frame_op.cc index 2ff9beb36f284b04e27123316467ce626682a502..00c98cae10e1c94aa193a5c8dce267ccf8b3d1a6 100644 --- a/paddle/fluid/operators/frame_op.cc +++ b/paddle/fluid/operators/frame_op.cc @@ -33,10 +33,11 @@ class FrameOp : public framework::OperatorWithKernel { const int x_rank = x_dims.size(); PADDLE_ENFORCE_GE( - x_rank, 1, platform::errors::InvalidArgument( - "Input(X) of FrameOp should be a tensor which contains " - "at least 1 dimension, but got rank %s.", - x_rank)); + x_rank, 1, + platform::errors::InvalidArgument( + "Input(X) of FrameOp should be a tensor which contains " + "at least 1 dimension, but got rank %s.", + x_rank)); PADDLE_ENFORCE_GT(hop_length, 0, platform::errors::InvalidArgument( "Attribute(hop_length) of FrameOp should be greater " diff --git a/paddle/fluid/operators/fsp_op.cc b/paddle/fluid/operators/fsp_op.cc index f00ec6a1e140c1bf34a1dc8a7ac491db1c89ae9c..16ce2b43bf4e1521f4dc7ae96a0738ca1e3d7e4d 100644 --- a/paddle/fluid/operators/fsp_op.cc +++ b/paddle/fluid/operators/fsp_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fsp_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/fused/attention_layer_norm.h b/paddle/fluid/operators/fused/attention_layer_norm.h index 43491a9faf18cffb342168cdb37d5d58ee7a3aa4..b960b83597973d3d33ae46421cdec1761de3bce7 100644 --- a/paddle/fluid/operators/fused/attention_layer_norm.h +++ b/paddle/fluid/operators/fused/attention_layer_norm.h @@ -38,11 +38,10 @@ class AttnLayerNorm { auto stream = dev_ctx_.stream(); switch (GetDesiredBlockDim(feature_size_)) { - FIXED_BLOCK_DIM_CASE( - LayerNormForward, - kBlockDim><<>>( - x_data, scale_data, bias_data, y_data, mean_data, var_data, - epsilon_, feature_size_)); + FIXED_BLOCK_DIM_CASE(LayerNormForward, kBlockDim> + <<>>( + x_data, scale_data, bias_data, y_data, mean_data, + var_data, epsilon_, feature_size_)); default: PADDLE_THROW(platform::errors::InvalidArgument( "Feature_size must be larger than 1")); diff --git a/paddle/fluid/operators/fused/attn_bias_add.cu.h b/paddle/fluid/operators/fused/attn_bias_add.cu.h index b059223eaf6e7a0907f8344c4ee44087002d005d..feac0f795302757fb5f55c4c3728ea830290bb63 100644 --- a/paddle/fluid/operators/fused/attn_bias_add.cu.h +++ b/paddle/fluid/operators/fused/attn_bias_add.cu.h @@ -120,24 +120,24 @@ void LaunchBiasAddFwKernel(const platform::CUDADeviceContext& ctx, int m, int n, auto stream = ctx.stream(); switch (vec_size) { case 4: { - BroadcastKernelBinary<<>>( - in0, in1, out, use_broadcast, numel, configlists, main_tid, tail_tid, - func); + BroadcastKernelBinary + <<>>(in0, in1, out, use_broadcast, numel, + configlists, main_tid, tail_tid, + func); break; } case 2: { - BroadcastKernelBinary<<>>( - in0, in1, out, use_broadcast, numel, configlists, main_tid, tail_tid, - func); + BroadcastKernelBinary + <<>>(in0, in1, out, use_broadcast, numel, + configlists, main_tid, tail_tid, + func); break; } case 1: { - BroadcastKernelBinary<<>>( - in0, in1, out, use_broadcast, numel, configlists, main_tid, tail_tid, - func); + BroadcastKernelBinary + <<>>(in0, in1, out, use_broadcast, numel, + configlists, main_tid, tail_tid, + func); break; } default: { @@ -176,8 +176,8 @@ void Launch1DColumnReduce(gpuStream_t stream, const int max_threads, const int block = 256; const int max_blocks = std::max(max_threads / block, 1); const int grid = std::min(left_num, max_blocks); - Compute1DColumnReduceKernel<<>>( - reduce_num, left_num, d_out, d_bias); + Compute1DColumnReduceKernel + <<>>(reduce_num, left_num, d_out, d_bias); } void SetConfigForColumnReduce(const int max_threads, const int reduce_num, @@ -273,8 +273,8 @@ void Launch2DColumnReduce(const platform::CUDADeviceContext& dev_ctx, const auto& stream = dev_ctx.stream(); if (!should_reduce_again) { - BiasAddBwSinglePassKernel<<>>(d_out, reduce_num, - left_num, d_bias); + BiasAddBwSinglePassKernel + <<>>(d_out, reduce_num, left_num, d_bias); } else { framework::Tensor tmp_sum; tmp_sum.Resize({grid.y, left_num}); diff --git a/paddle/fluid/operators/fused/attn_gemm.h b/paddle/fluid/operators/fused/attn_gemm.h index 304aad16ad0c66ddccbdb525ae5a81d796350bce..a85b2f99bb157403426773912c35b03c70022368 100644 --- a/paddle/fluid/operators/fused/attn_gemm.h +++ b/paddle/fluid/operators/fused/attn_gemm.h @@ -14,12 +14,10 @@ limitations under the License. */ #pragma once -#include "paddle/fluid/platform/float16.h" -#include "paddle/phi/kernels/funcs/blas/blas.h" -#include "paddle/phi/kernels/funcs/elementwise_functor.h" - #include "paddle/fluid/operators/kernel_primitives/kernel_primitives.h" #include "paddle/fluid/operators/reduce_ops/reduce_op.cu.h" +#include "paddle/fluid/platform/float16.h" +#include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/broadcast_function.h" #include "paddle/phi/kernels/funcs/elementwise_functor.h" diff --git a/paddle/fluid/operators/fused/conv_fusion_op.cc b/paddle/fluid/operators/fused/conv_fusion_op.cc index 671e94061cb5c2e31820a8045c598b7298b54d4d..490d92880c9a8f45993ce0c8d28cd5384d7dccd7 100644 --- a/paddle/fluid/operators/fused/conv_fusion_op.cc +++ b/paddle/fluid/operators/fused/conv_fusion_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/operators/conv_op.h" #include "paddle/fluid/platform/device/gpu/gpu_dnn.h" diff --git a/paddle/fluid/operators/fused/conv_fusion_op.cu b/paddle/fluid/operators/fused/conv_fusion_op.cu index 8191c85f2a1205fe01cbeba72360ff13b26834eb..9ca9f8aaf743f95c36e15403e933dee7cac621bb 100644 --- a/paddle/fluid/operators/fused/conv_fusion_op.cu +++ b/paddle/fluid/operators/fused/conv_fusion_op.cu @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/conv_search_cache.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/conv_cudnn_op_cache.h" diff --git a/paddle/fluid/operators/fused/cudnn_bn_add_relu_test.cc b/paddle/fluid/operators/fused/cudnn_bn_add_relu_test.cc index 516b10fa021c115a5461056d6843d07b9df8d4d4..09fa3a247e64b947c456c1f88ad28e692e5246af 100644 --- a/paddle/fluid/operators/fused/cudnn_bn_add_relu_test.cc +++ b/paddle/fluid/operators/fused/cudnn_bn_add_relu_test.cc @@ -182,19 +182,20 @@ void ComputeBatchNormForward(const platform::CUDADeviceContext &ctx, std::string data_layout = "NHWC"; attrs.insert({"data_layout", data_layout}); - auto op = framework::OpRegistry::CreateOp( - "batch_norm", {{"X", {"X"}}, - {"Scale", {"Scale"}}, - {"Bias", {"Bias"}}, - {"Mean", {"Mean"}}, - {"Variance", {"Variance"}}}, - {{"Y", {"Y"}}, - {"MeanOut", {"Mean"}}, - {"VarianceOut", {"Variance"}}, - {"SavedMean", {"SavedMean"}}, - {"SavedVariance", {"SavedVariance"}}, - {"ReserveSpace", {"ReserveSpace"}}}, - attrs); + auto op = + framework::OpRegistry::CreateOp("batch_norm", + {{"X", {"X"}}, + {"Scale", {"Scale"}}, + {"Bias", {"Bias"}}, + {"Mean", {"Mean"}}, + {"Variance", {"Variance"}}}, + {{"Y", {"Y"}}, + {"MeanOut", {"Mean"}}, + {"VarianceOut", {"Variance"}}, + {"SavedMean", {"SavedMean"}}, + {"SavedVariance", {"SavedVariance"}}, + {"ReserveSpace", {"ReserveSpace"}}}, + attrs); op->Run(scope, ctx.GetPlace()); paddle::framework::TensorCopySync(*y, platform::CPUPlace(), cpu_y); @@ -314,8 +315,9 @@ void ComputeFusedBNAddReluBackward( attrs.insert({"epsilon", epsilon}); attrs.insert({"act_type", act_type}); - auto op = framework::OpRegistry::CreateOp( - "fused_bn_add_activation_grad", {{"X", {"X"}}, + auto op = + framework::OpRegistry::CreateOp("fused_bn_add_activation_grad", + {{"X", {"X"}}, {"Y", {"Y"}}, {"Y@GRAD", {"Y@GRAD"}}, {"Scale", {"Scale"}}, @@ -323,11 +325,11 @@ void ComputeFusedBNAddReluBackward( {"SavedMean", {"SavedMean"}}, {"SavedVariance", {"SavedVariance"}}, {"ReserveSpace", {"ReserveSpace"}}}, - {{"X@GRAD", {"X@GRAD"}}, - {"Z@GRAD", {"Z@GRAD"}}, - {"Scale@GRAD", {"Scale@GRAD"}}, - {"Bias@GRAD", {"Bias@GRAD"}}}, - attrs); + {{"X@GRAD", {"X@GRAD"}}, + {"Z@GRAD", {"Z@GRAD"}}, + {"Scale@GRAD", {"Scale@GRAD"}}, + {"Bias@GRAD", {"Bias@GRAD"}}}, + attrs); op->Run(scope, ctx.GetPlace()); paddle::framework::TensorCopySync(*dx, platform::CPUPlace(), cpu_dx); diff --git a/paddle/fluid/operators/fused/cudnn_fusion_helper.h b/paddle/fluid/operators/fused/cudnn_fusion_helper.h index 13fad0b7cbb3d2b87e1403bc63fca0b8486c72c6..a8f700c21199f9155668837c9a5d9d2a17b741cb 100644 --- a/paddle/fluid/operators/fused/cudnn_fusion_helper.h +++ b/paddle/fluid/operators/fused/cudnn_fusion_helper.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/operator_kernel_configs.h" #include "paddle/fluid/platform/dynload/cudnn.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/operators/fused/cudnn_norm_conv_test.cc b/paddle/fluid/operators/fused/cudnn_norm_conv_test.cc index 5881322007add3b9e1f29a93b27fa20905ccc655..f4443bba3fdb235f822bfa81496da4b5b6934a1e 100644 --- a/paddle/fluid/operators/fused/cudnn_norm_conv_test.cc +++ b/paddle/fluid/operators/fused/cudnn_norm_conv_test.cc @@ -167,9 +167,10 @@ void ComputeConv2DBackward(const platform::CUDADeviceContext &ctx, attrs.insert({"workspace_size_MB", 512}); auto op = framework::OpRegistry::CreateOp( - "conv2d_grad", {{"Input", {"Input"}}, - {"Filter", {"Filter"}}, - {"Output@GRAD", {"Output@GRAD"}}}, + "conv2d_grad", + {{"Input", {"Input"}}, + {"Filter", {"Filter"}}, + {"Output@GRAD", {"Output@GRAD"}}}, {{"Input@GRAD", {"Input@GRAD"}}, {"Filter@GRAD", {"Filter@GRAD"}}}, attrs); op->Run(scope, ctx.GetPlace()); diff --git a/paddle/fluid/operators/fused/fmha_ref.h b/paddle/fluid/operators/fused/fmha_ref.h index 38f9aff226ea9f74f83c19eb8e3163de6e502cfb..ce95b0a320c66382f4ad441ae57337c90a757210 100644 --- a/paddle/fluid/operators/fused/fmha_ref.h +++ b/paddle/fluid/operators/fused/fmha_ref.h @@ -186,8 +186,9 @@ class FMHARef { if (dropout_param_.dropout_prob_) { DropoutFwGPUKernelDriver( static_cast(dev_ctx_), - dropout_param_.is_test_, static_cast( - dropout_param_.dropout_implementation_), + dropout_param_.is_test_, + static_cast( + dropout_param_.dropout_implementation_), dropout_param_.dropout_prob_, dropout_param_.is_upscale_in_train_, dropout_param_.is_fix_seed_, dropout_param_.seed_val_, static_cast(*softmax_out_tensor), dropout_param_.seed_, diff --git a/paddle/fluid/operators/fused/fused_attention_op.cc b/paddle/fluid/operators/fused/fused_attention_op.cc index a1adec9641a6e7fdd6ccecfbb58c460aacba911b..06ede8e2c7bdde943c60a2ced76611a005282399 100644 --- a/paddle/fluid/operators/fused/fused_attention_op.cc +++ b/paddle/fluid/operators/fused/fused_attention_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { @@ -88,12 +89,13 @@ class FusedAttentionOp : public framework::OperatorWithKernel { // y: qkv's weight: [3, num_head, dim_head, dim_embed] auto x_dim = ctx->GetInputDim("X"); auto y_dim = ctx->GetInputDim("QKVW"); - PADDLE_ENFORCE_EQ(x_dim.size(), 3, platform::errors::InvalidArgument( - "The dimensions of x must be 3" - "(batch_size, seq_len, dim_embed)," - "but received dimensions of" - "Input is [%d]", - x_dim.size())); + PADDLE_ENFORCE_EQ( + x_dim.size(), 3, + platform::errors::InvalidArgument("The dimensions of x must be 3" + "(batch_size, seq_len, dim_embed)," + "but received dimensions of" + "Input is [%d]", + x_dim.size())); PADDLE_ENFORCE_EQ(y_dim.size(), 4, platform::errors::InvalidArgument( "The dimensions of qkv_weight must be 4" diff --git a/paddle/fluid/operators/fused/fused_attention_op.cu b/paddle/fluid/operators/fused/fused_attention_op.cu index f25bd53992894d2a94bdf074ba04dcc68bb17baf..73fdd29fd62c313424be1a5bc7bc1e265450f2f1 100644 --- a/paddle/fluid/operators/fused/fused_attention_op.cu +++ b/paddle/fluid/operators/fused/fused_attention_op.cu @@ -13,21 +13,21 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" +#include "paddle/fluid/operators/fused/attention_layer_norm.h" +#include "paddle/fluid/operators/fused/attn_gemm.h" +#include "paddle/fluid/operators/fused/fmha_ref.h" +#include "paddle/fluid/operators/fused/fused_dropout_helper.h" #include "paddle/fluid/platform/device/gpu/gpu_device_function.h" #include "paddle/fluid/platform/device/gpu/gpu_dnn.h" - #include "paddle/phi/kernels/funcs/broadcast_function.h" #include "paddle/phi/kernels/funcs/elementwise_functor.h" #include "paddle/phi/kernels/funcs/math_function.h" -#include "paddle/fluid/operators/fused/attention_layer_norm.h" -#include "paddle/fluid/operators/fused/attn_gemm.h" -#include "paddle/fluid/operators/fused/fmha_ref.h" -#include "paddle/fluid/operators/fused/fused_dropout_helper.h" - #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) #include "paddle/fluid/platform/collective_helper.h" #include "paddle/fluid/platform/device/gpu/nccl_helper.h" @@ -463,11 +463,13 @@ class FusedAttentionGradKernel : public framework::OpKernel { auto *bias_dropout_residual_out_data = bias_dropout_residual_out->data(); auto *d_ln_2_scale_data = - (d_ln_2_scale == nullptr ? nullptr : d_ln_2_scale->mutable_data( - ctx.GetPlace())); + (d_ln_2_scale == nullptr + ? nullptr + : d_ln_2_scale->mutable_data(ctx.GetPlace())); auto *d_ln_2_bias_data = - (d_ln_2_bias == nullptr ? nullptr : d_ln_2_bias->mutable_data( - ctx.GetPlace())); + (d_ln_2_bias == nullptr + ? nullptr + : d_ln_2_bias->mutable_data(ctx.GetPlace())); auto *d_bias_dropout_residual_out_data = d_bias_dropout_residual_out->mutable_data(ctx.GetPlace()); diff --git a/paddle/fluid/operators/fused/fused_bias_dropout_residual_layer_norm_op.cc b/paddle/fluid/operators/fused/fused_bias_dropout_residual_layer_norm_op.cc index 781f51d70ec6604a8b01ae7e284f46a0d58110e4..56f9afdbe90905a775d8a1699f65f9e3d3ef61ff 100644 --- a/paddle/fluid/operators/fused/fused_bias_dropout_residual_layer_norm_op.cc +++ b/paddle/fluid/operators/fused/fused_bias_dropout_residual_layer_norm_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/fused/fused_bias_dropout_residual_layer_norm_op.cu b/paddle/fluid/operators/fused/fused_bias_dropout_residual_layer_norm_op.cu index 71a2c9728cc6b0455b963448c7b840b16990ce58..35a48611a74f1147e7df6eec7db4b37f771bb65d 100644 --- a/paddle/fluid/operators/fused/fused_bias_dropout_residual_layer_norm_op.cu +++ b/paddle/fluid/operators/fused/fused_bias_dropout_residual_layer_norm_op.cu @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/operators/fused/fused_dropout_helper.h" diff --git a/paddle/fluid/operators/fused/fused_bn_activation_op.cc b/paddle/fluid/operators/fused/fused_bn_activation_op.cc index 1b3521f14962a1a31ae59ba52cfe882b10db8281..464856003f03f5e5194d63e4e0704043c6157af8 100644 --- a/paddle/fluid/operators/fused/fused_bn_activation_op.cc +++ b/paddle/fluid/operators/fused/fused_bn_activation_op.cc @@ -13,9 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fused/fused_bn_activation_op.h" + #include #include #include + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/op_registry.h" @@ -70,20 +72,22 @@ void FusedBatchNormActOp::InferShape(framework::InferShapeContext *ctx) const { const auto x_dims = ctx->GetInputDim("X"); - PADDLE_ENFORCE_GE(x_dims.size(), 2, platform::errors::PreconditionNotMet( - "ShapeError: the dimension of input " - "X must greater than or equal to 2." - "But received: the shape of input X " - "= [%s], the dimension of input X =" - "[%d]", - x_dims, x_dims.size())); - PADDLE_ENFORCE_LE(x_dims.size(), 5, platform::errors::PreconditionNotMet( - "ShapeError: the dimension of input " - "X must smaller than or equal to 5." - "But received: the shape of input X " - "= [%s], the dimension of input X =" - "[%d]", - x_dims, x_dims.size())); + PADDLE_ENFORCE_GE( + x_dims.size(), 2, + platform::errors::PreconditionNotMet("ShapeError: the dimension of input " + "X must greater than or equal to 2." + "But received: the shape of input X " + "= [%s], the dimension of input X =" + "[%d]", + x_dims, x_dims.size())); + PADDLE_ENFORCE_LE( + x_dims.size(), 5, + platform::errors::PreconditionNotMet("ShapeError: the dimension of input " + "X must smaller than or equal to 5." + "But received: the shape of input X " + "= [%s], the dimension of input X =" + "[%d]", + x_dims, x_dims.size())); const int64_t C = x_dims[x_dims.size() - 1]; @@ -140,22 +144,26 @@ framework::OpKernelType FusedBatchNormActOp::GetExpectedKernelType( if (input_data_type == framework::proto::VarType::FP64) { bn_param_type = framework::proto::VarType::FP64; } - PADDLE_ENFORCE_EQ(bn_param_type, framework::TransToProtoVarType( - ctx.Input("Scale")->dtype()), - platform::errors::PreconditionNotMet( - "Scale input should be of float type")); - PADDLE_ENFORCE_EQ(bn_param_type, framework::TransToProtoVarType( - ctx.Input("Bias")->dtype()), - platform::errors::PreconditionNotMet( - "Bias input should be of float type")); - PADDLE_ENFORCE_EQ(bn_param_type, framework::TransToProtoVarType( - ctx.Input("Mean")->dtype()), - platform::errors::PreconditionNotMet( - "Mean input should be of float type")); - PADDLE_ENFORCE_EQ(bn_param_type, framework::TransToProtoVarType( - ctx.Input("Variance")->dtype()), - platform::errors::PreconditionNotMet( - "Variance input should be of float type")); + PADDLE_ENFORCE_EQ( + bn_param_type, + framework::TransToProtoVarType(ctx.Input("Scale")->dtype()), + platform::errors::PreconditionNotMet( + "Scale input should be of float type")); + PADDLE_ENFORCE_EQ( + bn_param_type, + framework::TransToProtoVarType(ctx.Input("Bias")->dtype()), + platform::errors::PreconditionNotMet( + "Bias input should be of float type")); + PADDLE_ENFORCE_EQ( + bn_param_type, + framework::TransToProtoVarType(ctx.Input("Mean")->dtype()), + platform::errors::PreconditionNotMet( + "Mean input should be of float type")); + PADDLE_ENFORCE_EQ( + bn_param_type, + framework::TransToProtoVarType(ctx.Input("Variance")->dtype()), + platform::errors::PreconditionNotMet( + "Variance input should be of float type")); framework::LibraryType library = framework::LibraryType::kPlain; framework::DataLayout layout = framework::DataLayout::kAnyLayout; diff --git a/paddle/fluid/operators/fused/fused_bn_activation_op.cu b/paddle/fluid/operators/fused/fused_bn_activation_op.cu index 9e709c9a01a1c4ef21d41f60ed016f89ff16add6..0ebe21dfc60598d7b2b617dd1aba1c5826b2608b 100644 --- a/paddle/fluid/operators/fused/fused_bn_activation_op.cu +++ b/paddle/fluid/operators/fused/fused_bn_activation_op.cu @@ -16,6 +16,7 @@ #include #include #include + #include "cub/cub.cuh" #include "paddle/fluid/framework/data_layout.h" #include "paddle/fluid/operators/activation_op.h" @@ -181,8 +182,9 @@ class FusedBatchNormActKernel ctx.GetPlace()), variance_out->template mutable_data>( ctx.GetPlace()), - epsilon, saved_mean->template mutable_data>( - ctx.GetPlace()), + epsilon, + saved_mean->template mutable_data>( + ctx.GetPlace()), saved_variance->template mutable_data>( ctx.GetPlace()), activation_desc_, workspace_ptr, workspace_size, reserve_space_ptr, @@ -343,10 +345,12 @@ class FusedBatchNormActGradKernel /*dBnScaleBiasDesc=*/bn_param_desc_, /*bnScaleData=*/scale->template data>(), /*bnBiasData=*/bias->template data>(), - /*dBnScaleData=*/d_scale - ->template mutable_data>(ctx.GetPlace()), - /*dBnBiasData=*/d_bias - ->template mutable_data>(ctx.GetPlace()), + /*dBnScaleData=*/ + d_scale->template mutable_data>( + ctx.GetPlace()), + /*dBnBiasData=*/ + d_bias->template mutable_data>( + ctx.GetPlace()), /*epsilon=*/epsilon, /*savedMean=*/saved_mean_data, /*savedInvVariance=*/saved_var_data, diff --git a/paddle/fluid/operators/fused/fused_bn_activation_op.h b/paddle/fluid/operators/fused/fused_bn_activation_op.h index b8404e4c6553fd0c25e269263b7aa7d71d2f3932..da9bca4fc22f7235ae37277f9cbbdd66549b60fc 100644 --- a/paddle/fluid/operators/fused/fused_bn_activation_op.h +++ b/paddle/fluid/operators/fused/fused_bn_activation_op.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/grad_op_desc_maker.h" #include "paddle/fluid/framework/op_proto_maker.h" #include "paddle/fluid/framework/operator.h" diff --git a/paddle/fluid/operators/fused/fused_bn_add_activation_op.cc b/paddle/fluid/operators/fused/fused_bn_add_activation_op.cc index d667fafb83594a070994fe0dab8aeb21f2615390..5d06ac19f9e1c55923eb1f946f11712a21fa43fc 100644 --- a/paddle/fluid/operators/fused/fused_bn_add_activation_op.cc +++ b/paddle/fluid/operators/fused/fused_bn_add_activation_op.cc @@ -13,9 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fused/fused_bn_add_activation_op.h" + #include #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { @@ -52,20 +54,22 @@ void FusedBatchNormAddActOp::InferShape( "of input X = [%s], and the shape of " "input Y = [%s]", x_dims, z_dims)); - PADDLE_ENFORCE_GE(x_dims.size(), 2, platform::errors::InvalidArgument( - "ShapeError: the dimensions of input " - "must greater than or equal to 2." - "But received: the shape of input " - "= [%s], the dimension of input = " - "[%d]", - x_dims, x_dims.size())); - PADDLE_ENFORCE_LE(x_dims.size(), 5, platform::errors::InvalidArgument( - "ShapeError: the dimensions of input " - "must smaller than or equal to 5." - "But received: the shape of input " - "= [%s], the dimension of input = " - "[%d]", - x_dims, x_dims.size())); + PADDLE_ENFORCE_GE( + x_dims.size(), 2, + platform::errors::InvalidArgument("ShapeError: the dimensions of input " + "must greater than or equal to 2." + "But received: the shape of input " + "= [%s], the dimension of input = " + "[%d]", + x_dims, x_dims.size())); + PADDLE_ENFORCE_LE( + x_dims.size(), 5, + platform::errors::InvalidArgument("ShapeError: the dimensions of input " + "must smaller than or equal to 5." + "But received: the shape of input " + "= [%s], the dimension of input = " + "[%d]", + x_dims, x_dims.size())); const int64_t C = x_dims[x_dims.size() - 1]; diff --git a/paddle/fluid/operators/fused/fused_bn_add_activation_op.cu b/paddle/fluid/operators/fused/fused_bn_add_activation_op.cu index 421c1bacb663340f322d979270e96d677d47afae..2f7fc6160122d500ac618e16bb713fecb7cddb77 100644 --- a/paddle/fluid/operators/fused/fused_bn_add_activation_op.cu +++ b/paddle/fluid/operators/fused/fused_bn_add_activation_op.cu @@ -16,6 +16,7 @@ #include #include #include + #include "paddle/fluid/framework/data_layout.h" #include "paddle/fluid/operators/activation_op.h" #include "paddle/fluid/operators/fused/fused_bn_add_activation_op.h" @@ -160,8 +161,9 @@ class FusedBatchNormAddActKernel ctx.GetPlace()), variance_out->template mutable_data>( ctx.GetPlace()), - epsilon, saved_mean->template mutable_data>( - ctx.GetPlace()), + epsilon, + saved_mean->template mutable_data>( + ctx.GetPlace()), saved_variance->template mutable_data>( ctx.GetPlace()), activation_desc_, workspace_ptr, workspace_size, reserve_space_ptr, diff --git a/paddle/fluid/operators/fused/fused_bn_add_activation_op.h b/paddle/fluid/operators/fused/fused_bn_add_activation_op.h index d5e5ae9bda642cb126c5ca9f0ab85877750c067a..07d2e4564b692f9e814f29bff0a6baca16c98962 100644 --- a/paddle/fluid/operators/fused/fused_bn_add_activation_op.h +++ b/paddle/fluid/operators/fused/fused_bn_add_activation_op.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/grad_op_desc_maker.h" #include "paddle/fluid/framework/op_proto_maker.h" #include "paddle/fluid/framework/operator.h" diff --git a/paddle/fluid/operators/fused/fused_dropout_act_bias.h b/paddle/fluid/operators/fused/fused_dropout_act_bias.h old mode 100755 new mode 100644 index 9f5a1bad047b44b715e11e74d92fdca1982c96f8..f7af7deff53760d3d4e7c8552c8dd3aa84b307e5 --- a/paddle/fluid/operators/fused/fused_dropout_act_bias.h +++ b/paddle/fluid/operators/fused/fused_dropout_act_bias.h @@ -109,15 +109,15 @@ void LaunchDropoutActBias(Functor act_functor, const uint64_t seed, const int real_vec_size = cols % VecSize == 0 ? VecSize : 1; const auto config = Get1DBlocksAnd2DGrids(ctx, rows, cols, real_vec_size); if (cols % VecSize == 0) { - FusedDropoutActBias<<< - config.block_per_grid, config.thread_per_block, 0, ctx.stream()>>>( - act_functor, seed, rows, cols, increment, dropout_prob, - is_upscale_in_train, is_test, src, bias, dst, mask_data); + FusedDropoutActBias + <<>>( + act_functor, seed, rows, cols, increment, dropout_prob, + is_upscale_in_train, is_test, src, bias, dst, mask_data); } else { - FusedDropoutActBias<<< - config.block_per_grid, config.thread_per_block, 0, ctx.stream()>>>( - act_functor, seed, rows, cols, increment, dropout_prob, - is_upscale_in_train, is_test, src, bias, dst, mask_data); + FusedDropoutActBias + <<>>( + act_functor, seed, rows, cols, increment, dropout_prob, + is_upscale_in_train, is_test, src, bias, dst, mask_data); } } @@ -231,28 +231,28 @@ void LaunchDropoutActBiasGrad(Functor act_functor, const T *dout, dim3 block_dim(threads, 128, 1); dim3 grid_dim(blocks, 1, 1); if (cols % VecSize == 0) { - FusedDropoutActBiasGrad< - T, MaskType, 8, 128, VecSize, - Functor><<>>( - act_functor, dout, mask, src, bias, factor, rows, cols, dx, dbias); + FusedDropoutActBiasGrad + <<>>(act_functor, dout, mask, + src, bias, factor, rows, + cols, dx, dbias); } else { - FusedDropoutActBiasGrad< - T, MaskType, 8, 128, 1, - Functor><<>>( - act_functor, dout, mask, src, bias, factor, rows, cols, dx, dbias); + FusedDropoutActBiasGrad + <<>>(act_functor, dout, mask, + src, bias, factor, rows, + cols, dx, dbias); } } else { const uint64_t n = rows * cols; platform::GpuLaunchConfig config = platform::GetGpuLaunchConfig1D(ctx, n / real_vec_size); if (n % VecSize == 0) { - FusedDropoutActGrad<<< - config.block_per_grid, config.thread_per_block, 0, ctx.stream()>>>( - act_functor, dout, mask, src, factor, n, dx); + FusedDropoutActGrad + <<>>( + act_functor, dout, mask, src, factor, n, dx); } else { - FusedDropoutActGrad<<< - config.block_per_grid, config.thread_per_block, 0, ctx.stream()>>>( - act_functor, dout, mask, src, factor, n, dx); + FusedDropoutActGrad + <<>>( + act_functor, dout, mask, src, factor, n, dx); } } } diff --git a/paddle/fluid/operators/fused/fused_dropout_helper.h b/paddle/fluid/operators/fused/fused_dropout_helper.h index c352f08ec2ba7d8ca5b0ce072f7396f17b0e09c9..6dc1c446bd7d57c2710271a3616c9004c76a18ac 100644 --- a/paddle/fluid/operators/fused/fused_dropout_helper.h +++ b/paddle/fluid/operators/fused/fused_dropout_helper.h @@ -30,7 +30,7 @@ namespace operators { * The DropoutParam will be used in the fused_dropout_act_bias, * fused_residual_dropout_bias(pre_layer_norm=ture) or * fused_layernorm_residual_dropout_bias(pre_layer_norm=false). -*/ + */ struct DropoutParam { uint64_t seed; float dropout_prob; @@ -232,8 +232,8 @@ class FusedDropoutLayerNormHelper : public FusedDropoutHelper { using U = LayerNormParamType; switch (GetDesiredBlockDim(this->cols_)) { FIXED_BLOCK_DIM_CASE( - LayerNormForward< - T, U, kBlockDim><<rows_, kBlockDim, 0, ctx.stream()>>>( + LayerNormForward + <<rows_, kBlockDim, 0, ctx.stream()>>>( src, gamma, beta, out, mean, variance, epsilon_, this->cols_)); } } diff --git a/paddle/fluid/operators/fused/fused_elemwise_activation_op.cc b/paddle/fluid/operators/fused/fused_elemwise_activation_op.cc index 3e69bf0806756cd67a364fd69a2f106a6cab06f3..a43562b29722887c691878d9024f85650375ee67 100644 --- a/paddle/fluid/operators/fused/fused_elemwise_activation_op.cc +++ b/paddle/fluid/operators/fused/fused_elemwise_activation_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fused/fused_elemwise_activation_op.h" + #include #include diff --git a/paddle/fluid/operators/fused/fused_elemwise_activation_op.h b/paddle/fluid/operators/fused/fused_elemwise_activation_op.h index 5404cdeab01e007d9278306c4a83093666a778a2..3ce54968355a5239bfb7aad7483b75b96da6693f 100644 --- a/paddle/fluid/operators/fused/fused_elemwise_activation_op.h +++ b/paddle/fluid/operators/fused/fused_elemwise_activation_op.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_desc.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/elementwise/elementwise_op_function.h" @@ -412,8 +413,9 @@ class FusedElemwiseActivationGradKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext &ctx) const override { auto in_y = ctx.Input("Y"); - PADDLE_ENFORCE_NE(in_y, nullptr, platform::errors::InvalidArgument( - "Input(Y) should not be nullptr.")); + PADDLE_ENFORCE_NE( + in_y, nullptr, + platform::errors::InvalidArgument("Input(Y) should not be nullptr.")); auto in_out = ctx.Input("Out"); PADDLE_ENFORCE_NE( in_out, nullptr, @@ -449,15 +451,17 @@ class FusedElemwiseActivationGradKernel : public framework::OpKernel { " so the number of 'Out' should be two.")); } else { if (!InputXCanBeAbsent(functor_list)) { - PADDLE_ENFORCE_NE(in_x, nullptr, platform::errors::InvalidArgument( - "Input(X) should not be null.")); + PADDLE_ENFORCE_NE( + in_x, nullptr, + platform::errors::InvalidArgument("Input(X) should not be null.")); } } // Get in_x if (ctx.HasInput("X")) { - PADDLE_ENFORCE_NE(in_x, nullptr, platform::errors::InvalidArgument( - "Input(X) should not be null.")); + PADDLE_ENFORCE_NE( + in_x, nullptr, + platform::errors::InvalidArgument("Input(X) should not be null.")); } else { // If functor_list contains elementwise_add, the backward doesn't use // in_x, in_y and in_out. diff --git a/paddle/fluid/operators/fused/fused_embedding_eltwise_layernorm_op.cc b/paddle/fluid/operators/fused/fused_embedding_eltwise_layernorm_op.cc index 6746b3b8e8489d3177784092b63d00f3faca9e22..951189269c748a1fa1d81d308f091bd85c64f6d1 100644 --- a/paddle/fluid/operators/fused/fused_embedding_eltwise_layernorm_op.cc +++ b/paddle/fluid/operators/fused/fused_embedding_eltwise_layernorm_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/errors.h" diff --git a/paddle/fluid/operators/fused/fused_embedding_eltwise_layernorm_op.cu b/paddle/fluid/operators/fused/fused_embedding_eltwise_layernorm_op.cu index 13f1c6808aef2e0873c5ce6493514c47710dcf16..f0cb2edb670ecf427e99373ba567ca8bf35acde5 100644 --- a/paddle/fluid/operators/fused/fused_embedding_eltwise_layernorm_op.cu +++ b/paddle/fluid/operators/fused/fused_embedding_eltwise_layernorm_op.cu @@ -13,7 +13,9 @@ // limitations under the License. #include + #include + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/memory/malloc.h" diff --git a/paddle/fluid/operators/fused/fused_embedding_fc_lstm_op.cc b/paddle/fluid/operators/fused/fused_embedding_fc_lstm_op.cc index 7308f30779248e64f55e10b0661d2c98d263416c..625bfe36e386425bace7aefc7f9908cd31b7963d 100644 --- a/paddle/fluid/operators/fused/fused_embedding_fc_lstm_op.cc +++ b/paddle/fluid/operators/fused/fused_embedding_fc_lstm_op.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fused/fused_embedding_fc_lstm_op.h" + #include + #include "paddle/fluid/platform/cpu_info.h" #include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/cpu_vec.h" @@ -100,10 +102,11 @@ void FusedEmbeddingFCLSTMOp::InferShape( platform::errors::InvalidArgument( "The rank of Input(Bias) should be 2, but received value is:%d.", b_dims.size())); - PADDLE_ENFORCE_EQ(b_dims[0], 1, platform::errors::InvalidArgument( - "The first dimension of Input(Bias) " - "should be 1, but received value is:%d.", - b_dims[0])); + PADDLE_ENFORCE_EQ(b_dims[0], 1, + platform::errors::InvalidArgument( + "The first dimension of Input(Bias) " + "should be 1, but received value is:%d.", + b_dims[0])); PADDLE_ENFORCE_EQ( b_dims[1], (ctx->Attrs().Get("use_peepholes") ? 7 : 4) * frame_size, platform::errors::InvalidArgument( @@ -237,21 +240,21 @@ This operator fuse the X into LSTM, more details can refer to LSTM op. template class FusedEmbeddingFCLSTMKernel : public framework::OpKernel { public: -#define INIT_VEC_FUNC \ - std::function act_gate, act_cell, act_cand; \ - auto& act_gate_str = ctx.Attr("gate_activation"); \ - auto& act_cell_str = ctx.Attr("cell_activation"); \ - auto& act_cand_str = ctx.Attr("candidate_activation"); \ - if (platform::MayIUse(platform::avx)) { \ - phi::funcs::VecActivations act_functor; \ - act_gate = act_functor(act_gate_str); \ - act_cell = act_functor(act_cell_str); \ - act_cand = act_functor(act_cand_str); \ - } else { \ - phi::funcs::VecActivations act_functor; \ - act_gate = act_functor(act_gate_str); \ - act_cell = act_functor(act_cell_str); \ - act_cand = act_functor(act_cand_str); \ +#define INIT_VEC_FUNC \ + std::function act_gate, act_cell, act_cand; \ + auto& act_gate_str = ctx.Attr("gate_activation"); \ + auto& act_cell_str = ctx.Attr("cell_activation"); \ + auto& act_cand_str = ctx.Attr("candidate_activation"); \ + if (platform::MayIUse(platform::avx)) { \ + phi::funcs::VecActivations act_functor; \ + act_gate = act_functor(act_gate_str); \ + act_cell = act_functor(act_cell_str); \ + act_cand = act_functor(act_cand_str); \ + } else { \ + phi::funcs::VecActivations act_functor; \ + act_gate = act_functor(act_gate_str); \ + act_cell = act_functor(act_cell_str); \ + act_cand = act_functor(act_cand_str); \ } #define INIT_BASE_INPUT_OUTPUT \ diff --git a/paddle/fluid/operators/fused/fused_embedding_seq_pool_op.cc b/paddle/fluid/operators/fused/fused_embedding_seq_pool_op.cc index ec3a76e316ecd30a67b1b96b32406335d591e852..cb3bf5857750fd6b4e6634ad95df22a6bfd4b395 100644 --- a/paddle/fluid/operators/fused/fused_embedding_seq_pool_op.cc +++ b/paddle/fluid/operators/fused/fused_embedding_seq_pool_op.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fused/fused_embedding_seq_pool_op.h" + #include + #include "paddle/fluid/framework/var_type_inference.h" namespace paddle { diff --git a/paddle/fluid/operators/fused/fused_fc_elementwise_layernorm_op.cu b/paddle/fluid/operators/fused/fused_fc_elementwise_layernorm_op.cu index 04d3730a77d4d324a1f80fe863d56e8c59f8702e..2c0184fea463e821f2f4836b38b32fff01499507 100644 --- a/paddle/fluid/operators/fused/fused_fc_elementwise_layernorm_op.cu +++ b/paddle/fluid/operators/fused/fused_fc_elementwise_layernorm_op.cu @@ -179,22 +179,20 @@ class FusedFCElementwiseLayerNormOpKernel : public framework::OpKernel { if (with_relu) { switch (platform::RoundToPowerOfTwo(N)) { CUDA_LAUNCH_KERNEL_HELPER( - InplaceAddReluAddLayerNormKernel< - T, true, - kPowerOfTwoDim><<>>( - y_data, bias_0_data, bias_1_data, scale_data, out_data, - mean_data, variance_data, M, N, epsilon)); + InplaceAddReluAddLayerNormKernel + <<>>(y_data, bias_0_data, bias_1_data, scale_data, + out_data, mean_data, variance_data, M, N, + epsilon)); } } else { switch (platform::RoundToPowerOfTwo(N)) { CUDA_LAUNCH_KERNEL_HELPER( - InplaceAddReluAddLayerNormKernel< - T, false, - kPowerOfTwoDim><<>>( - y_data, bias_0_data, bias_1_data, scale_data, out_data, - mean_data, variance_data, M, N, epsilon)); + InplaceAddReluAddLayerNormKernel + <<>>(y_data, bias_0_data, bias_1_data, scale_data, + out_data, mean_data, variance_data, M, N, + epsilon)); } } } diff --git a/paddle/fluid/operators/fused/fused_feedforward_op.cc b/paddle/fluid/operators/fused/fused_feedforward_op.cc index 8e15232acda90ea0f021b01b45d8caef06d1caf7..d3cc1b9127670e5f432f44231fb06da5d1b5d724 100644 --- a/paddle/fluid/operators/fused/fused_feedforward_op.cc +++ b/paddle/fluid/operators/fused/fused_feedforward_op.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/operators/matmul_v2_op.h" diff --git a/paddle/fluid/operators/fused/fused_feedforward_op.cu b/paddle/fluid/operators/fused/fused_feedforward_op.cu index 2eb9885286dab8702cd96519a76b4bb69ed6aff6..675ec29da67c8cdeb4166b63460fd670048fc8ba 100644 --- a/paddle/fluid/operators/fused/fused_feedforward_op.cu +++ b/paddle/fluid/operators/fused/fused_feedforward_op.cu @@ -14,11 +14,10 @@ limitations under the License. */ #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" -#include "paddle/fluid/operators/matmul_v2_op.h" -#include "paddle/phi/kernels/funcs/blas/blas.h" - #include "paddle/fluid/operators/fused/fused_dropout_helper.h" #include "paddle/fluid/operators/layer_norm_kernel.cu.h" +#include "paddle/fluid/operators/matmul_v2_op.h" +#include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/broadcast_function.h" #include "paddle/phi/kernels/funcs/elementwise_functor.h" @@ -387,20 +386,19 @@ class FusedFeedForwardGradKernel : public framework::OpKernel { !pre_layer_norm ? context.Input("Ln2Bias") : nullptr; auto* d_x = context.Output(framework::GradVarName("X")); - auto* d_ln1_scale = pre_layer_norm - ? context.Output( - framework::GradVarName("Ln1Scale")) - : nullptr; - auto* d_ln1_bias = pre_layer_norm - ? context.Output( - framework::GradVarName("Ln1Bias")) - : nullptr; - auto* d_ln2_scale = - pre_layer_norm ? nullptr : context.Output( - framework::GradVarName("Ln2Scale")); - auto* d_ln2_bias = - pre_layer_norm ? nullptr : context.Output( - framework::GradVarName("Ln2Bias")); + auto* d_ln1_scale = pre_layer_norm ? context.Output( + framework::GradVarName("Ln1Scale")) + : nullptr; + auto* d_ln1_bias = pre_layer_norm ? context.Output( + framework::GradVarName("Ln1Bias")) + : nullptr; + auto* d_ln2_scale = pre_layer_norm + ? nullptr + : context.Output( + framework::GradVarName("Ln2Scale")); + auto* d_ln2_bias = pre_layer_norm ? nullptr + : context.Output( + framework::GradVarName("Ln2Bias")); auto* d_linear1_weight = context.Output( framework::GradVarName("Linear1Weight")); auto* d_linear1_bias = context.Output( diff --git a/paddle/fluid/operators/fused/fused_gate_attention_op.cc b/paddle/fluid/operators/fused/fused_gate_attention_op.cc index ba9dbd82e3dcc4f3f94d5309b035eb9177607851..0bbeabd5fc9cb965241becfc6593dfc8a313f1a7 100644 --- a/paddle/fluid/operators/fused/fused_gate_attention_op.cc +++ b/paddle/fluid/operators/fused/fused_gate_attention_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/fused/fused_gate_attention_op.cu b/paddle/fluid/operators/fused/fused_gate_attention_op.cu index b1badf72557ae4d1657cbe6a5d315f0dfa1a4625..8f375a22cc0234c8d9aaec9e272e65f27de65215 100644 --- a/paddle/fluid/operators/fused/fused_gate_attention_op.cu +++ b/paddle/fluid/operators/fused/fused_gate_attention_op.cu @@ -374,9 +374,9 @@ class FusedGateAttentionOpKernel : public framework::OpKernel { v_transpose_out, qkv_transpose_out, softmax_out, fmha_out, &config); // 3. Gating Linear - Tensor *fmha_or_gate_out = - !has_gating ? fmha_out : ComputeGatingLinearForward(ctx, config, - query, fmha_out); + Tensor *fmha_or_gate_out = !has_gating ? fmha_out + : ComputeGatingLinearForward( + ctx, config, query, fmha_out); // 4. Output Linear ComputeOutputLinearForward(ctx, config, fmha_or_gate_out); diff --git a/paddle/fluid/operators/fused/fused_gemm_epilogue_op.cc b/paddle/fluid/operators/fused/fused_gemm_epilogue_op.cc index 7cb6777e5a79ac55d15bf369cd00957904541b01..978daa3be85e9bbc9ab4fc77df90814bfd1470ab 100644 --- a/paddle/fluid/operators/fused/fused_gemm_epilogue_op.cc +++ b/paddle/fluid/operators/fused/fused_gemm_epilogue_op.cc @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fused/fused_gemm_epilogue_op.h" + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" @@ -369,8 +370,9 @@ class FusedGemmEpilogueOpGradMaker : public framework::SingleGradOpMaker { protected: void Apply(GradOpPtr op) const override { const auto& act_type = this->template Attr("activation"); - PADDLE_ENFORCE_EQ(act_type, "none", phi::errors::InvalidArgument( - "The activation should be none.")); + PADDLE_ENFORCE_EQ( + act_type, "none", + phi::errors::InvalidArgument("The activation should be none.")); op->SetType(this->ForwardOpType() + "_grad"); op->SetInput("X", this->Input("X")); diff --git a/paddle/fluid/operators/fused/fused_gemm_epilogue_op.h b/paddle/fluid/operators/fused/fused_gemm_epilogue_op.h index 8ff41b2c9616bbda80bf9be7fd3e8d9556560c86..b00bdfe5660a9db78d15a1965715f763302b8d08 100644 --- a/paddle/fluid/operators/fused/fused_gemm_epilogue_op.h +++ b/paddle/fluid/operators/fused/fused_gemm_epilogue_op.h @@ -16,9 +16,11 @@ limitations under the License. */ #pragma once #include + #include #include #include + #include "gflags/gflags.h" #include "paddle/fluid/platform/dynload/cublasLt.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/operators/fused/fused_layernorm_residual_dropout_bias.h b/paddle/fluid/operators/fused/fused_layernorm_residual_dropout_bias.h index 9d7d34ebdc9e657c09fe9c23336ae7cb1d38acb2..f72f73438c0a22800cf6d8e49f4fd7e8ebb287df 100644 --- a/paddle/fluid/operators/fused/fused_layernorm_residual_dropout_bias.h +++ b/paddle/fluid/operators/fused/fused_layernorm_residual_dropout_bias.h @@ -441,11 +441,10 @@ void LaunchLayernormResidualDropoutBias( // call layernorm forward switch (GetDesiredBlockDim(cols)) { FIXED_BLOCK_DIM_CASE( - LayerNormForward< - T, U, kBlockDim, - ScaleBiasWithSameTypeX><<>>( - dst, scale, layernorm_bias, layernorm_dst, mean, var, epsilon, - cols)); + LayerNormForward + <<>>(dst, scale, layernorm_bias, + layernorm_dst, mean, var, + epsilon, cols)); default: PADDLE_THROW(platform::errors::InvalidArgument( "Product from begin_norm_axis to end must be larger than 1")); @@ -468,11 +467,11 @@ void LaunchLayernormResidualDropoutBias( static_cast(std::ceil(rows / static_cast(ROWS_PER_CTA))); \ fused_fast_ln_fwd_kernel< \ T, U, LayerNormScaleBiasT, uint8_t, \ - VecSize, WARPS_M, WARPS_N, BYTES_PER_LDG, \ - cols><<>>( \ - rows, cols, seed, dropout_prob, is_upscale_in_train, is_test, \ - increment, epsilon, src, residual, bias, scale, layernorm_bias, \ - mask_data, mean, var, dst, layernorm_dst); \ + VecSize, WARPS_M, WARPS_N, BYTES_PER_LDG, cols> \ + <<>>( \ + rows, cols, seed, dropout_prob, is_upscale_in_train, is_test, \ + increment, epsilon, src, residual, bias, scale, layernorm_bias, \ + mask_data, mean, var, dst, layernorm_dst); \ } break #define LAUNCH_FUSED_FAST_LN_KERNEL \ @@ -494,12 +493,11 @@ void LaunchLayernormResidualDropoutBias( const int VecSize = MAX_CACHE_BYTES / sizeof(T); if (cols % VecSize != 0) { int blockDim = GetDesiredBlockDim(cols); - FusedLayernormResidualDropoutBias< - T, uint8_t, 1, U, - ScaleBiasWithSameTypeX><<>>( - rows, cols, seed, dropout_prob, is_upscale_in_train, is_test, increment, - epsilon, src, residual, bias, scale, layernorm_bias, mask_data, dst, - layernorm_dst, mean, var); + FusedLayernormResidualDropoutBias + <<>>( + rows, cols, seed, dropout_prob, is_upscale_in_train, is_test, + increment, epsilon, src, residual, bias, scale, layernorm_bias, + mask_data, dst, layernorm_dst, mean, var); } else { if (can_call_fast_ln_kernel) { switch (cols) { @@ -512,12 +510,12 @@ void LaunchLayernormResidualDropoutBias( } } else { int blockDim = GetDesiredBlockDim(cols / VecSize); - FusedLayernormResidualDropoutBias< - T, uint8_t, VecSize, U, - ScaleBiasWithSameTypeX><<>>( - rows, cols, seed, dropout_prob, is_upscale_in_train, is_test, - increment, epsilon, src, residual, bias, scale, layernorm_bias, - mask_data, dst, layernorm_dst, mean, var); + FusedLayernormResidualDropoutBias + <<>>( + rows, cols, seed, dropout_prob, is_upscale_in_train, is_test, + increment, epsilon, src, residual, bias, scale, layernorm_bias, + mask_data, dst, layernorm_dst, mean, var); } } } diff --git a/paddle/fluid/operators/fused/fused_multi_transformer_op.cc b/paddle/fluid/operators/fused/fused_multi_transformer_op.cc index 98602e4edd0a2399faba2e3ec212bcf5d62d545d..63627db49d6fa357f74ce2caff2c5f461c83d48f 100644 --- a/paddle/fluid/operators/fused/fused_multi_transformer_op.cc +++ b/paddle/fluid/operators/fused/fused_multi_transformer_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { @@ -62,12 +63,13 @@ class FusedMultiTransformerOp : public framework::OperatorWithKernel { // y: qkv's weight: [3, num_head, dim_head, dim_embed] auto x_dim = ctx->GetInputDim("X"); auto y_dim = ctx->GetInputsDim("QKVW")[0]; - PADDLE_ENFORCE_EQ(x_dim.size(), 3, platform::errors::InvalidArgument( - "The dimensions of x must be 3" - "(batch_size, seq_len, dim_embed)," - "but received dimensions of" - "Input is [%d]", - x_dim.size())); + PADDLE_ENFORCE_EQ( + x_dim.size(), 3, + platform::errors::InvalidArgument("The dimensions of x must be 3" + "(batch_size, seq_len, dim_embed)," + "but received dimensions of" + "Input is [%d]", + x_dim.size())); PADDLE_ENFORCE_EQ(y_dim.size(), 4, platform::errors::InvalidArgument( "The dimensions of qkv_weight must be 4" diff --git a/paddle/fluid/operators/fused/fused_multi_transformer_op.cu b/paddle/fluid/operators/fused/fused_multi_transformer_op.cu index c13c287f4af648612e4d7b73fcd8fd1e39adc30e..01c5b79fff11569f7b43b7024ca95f8da1739b84 100644 --- a/paddle/fluid/operators/fused/fused_multi_transformer_op.cu +++ b/paddle/fluid/operators/fused/fused_multi_transformer_op.cu @@ -18,18 +18,18 @@ limitations under the License. */ #include #include + #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" -#include "paddle/fluid/platform/device/gpu/gpu_device_function.h" -#include "paddle/fluid/platform/device/gpu/gpu_dnn.h" - -#include "paddle/phi/kernels/funcs/math_function.h" - #include "paddle/fluid/operators/fused/attention_layer_norm.h" #include "paddle/fluid/operators/fused/attn_gemm.h" #include "paddle/fluid/operators/fused/fmha_ref.h" #include "paddle/fluid/operators/fused/fused_dropout_helper.h" +#include "paddle/fluid/platform/device/gpu/gpu_device_function.h" +#include "paddle/fluid/platform/device/gpu/gpu_dnn.h" +#include "paddle/phi/kernels/funcs/math_function.h" #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) #include "paddle/fluid/platform/collective_helper.h" @@ -861,10 +861,9 @@ inline size_t smem_size_in_bytes( size_t smem_sz = smem_size_in_bytes(params, Dh, THDS_PER_VALUE, \ THDS_PER_BLOCK, pad_active_groups); \ dim3 grid(params.num_head, params.batch_size); \ - masked_multihead_attention_kernel< \ - T, Dh, Dh_MAX, THDS_PER_KEY, THDS_PER_VALUE, \ - THDS_PER_BLOCK><<>>( \ - params, pad_active_groups) + masked_multihead_attention_kernel \ + <<>>(params, pad_active_groups) template void fmha_launch_kernel(const Masked_multihead_attention_params ¶ms, diff --git a/paddle/fluid/operators/fused/fused_residual_dropout_bias.h b/paddle/fluid/operators/fused/fused_residual_dropout_bias.h index 1d3085a013f81ee9dca21468476df8f621bb26c2..0cc31e6fc3255873c8d0e53b4f85da77c25a044c 100644 --- a/paddle/fluid/operators/fused/fused_residual_dropout_bias.h +++ b/paddle/fluid/operators/fused/fused_residual_dropout_bias.h @@ -153,16 +153,15 @@ void LaunchResidualDropoutBias(const uint32_t rows, const uint32_t cols, const int real_vec_size = cols % VecSize == 0 ? VecSize : 1; auto config = Get1DBlocksAnd2DGrids(ctx, rows, cols, real_vec_size); if (cols % VecSize == 0) { - FusedResidualDropoutBias<<< - config.block_per_grid, config.thread_per_block, 0, ctx.stream()>>>( - rows, cols, seed, dropout_prob, is_upscale_in_train, src, residual, - bias, mask_data, dst, increment, is_test); + FusedResidualDropoutBias + <<>>( + rows, cols, seed, dropout_prob, is_upscale_in_train, src, residual, + bias, mask_data, dst, increment, is_test); } else { - FusedResidualDropoutBias< - T, uint8_t, - 1><<>>( - rows, cols, seed, dropout_prob, is_upscale_in_train, src, residual, - bias, mask_data, dst, increment, is_test); + FusedResidualDropoutBias + <<>>( + rows, cols, seed, dropout_prob, is_upscale_in_train, src, residual, + bias, mask_data, dst, increment, is_test); } } @@ -263,27 +262,26 @@ void LaunchResidualDropoutBiasGrad(const T *dout, const MaskType *mask, dim3 block_dim(threads, 128, 1); dim3 grid_dim(blocks, 1, 1); if (cols % VecSize == 0) { - FusedResidualDropoutBiasGrad< - T, MaskType, 8, 128, - VecSize><<>>( - dout, mask, factor, rows, cols, dx, dbias); + FusedResidualDropoutBiasGrad + <<>>(dout, mask, factor, rows, + cols, dx, dbias); } else { - FusedResidualDropoutBiasGrad<<>>( - dout, mask, factor, rows, cols, dx, dbias); + FusedResidualDropoutBiasGrad + <<>>(dout, mask, factor, rows, + cols, dx, dbias); } } else { const uint64_t n = rows * cols; platform::GpuLaunchConfig config = platform::GetGpuLaunchConfig1D(ctx, n / real_vec_size); if (n % VecSize == 0) { - FusedResidualDropoutGrad<<< - config.block_per_grid, config.thread_per_block, 0, ctx.stream()>>>( - dout, mask, factor, n, dx); + FusedResidualDropoutGrad + <<>>( + dout, mask, factor, n, dx); } else { - FusedResidualDropoutGrad<<< - config.block_per_grid, config.thread_per_block, 0, ctx.stream()>>>( - dout, mask, factor, n, dx); + FusedResidualDropoutGrad + <<>>( + dout, mask, factor, n, dx); } } } diff --git a/paddle/fluid/operators/fused/fused_seqpool_cvm_op.cc b/paddle/fluid/operators/fused/fused_seqpool_cvm_op.cc index 23b82ac5d966f4602f2df8a5bd685dad331ad05c..e316f58b3f759a38957870af246a491dad3cfa35 100644 --- a/paddle/fluid/operators/fused/fused_seqpool_cvm_op.cc +++ b/paddle/fluid/operators/fused/fused_seqpool_cvm_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fused/fused_seqpool_cvm_op.h" + #include namespace paddle { namespace operators { @@ -34,9 +35,10 @@ class FusedSeqpoolCVMOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ( cvm_dims.size(), 2UL, platform::errors::InvalidArgument("Input(CVM)'s rank should be 2.")); - PADDLE_ENFORCE_EQ(cvm_dims[1], 2UL, platform::errors::InvalidArgument( - "The 2nd dimension of " - "Input(CVM) should be 2.")); + PADDLE_ENFORCE_EQ( + cvm_dims[1], 2UL, + platform::errors::InvalidArgument("The 2nd dimension of " + "Input(CVM) should be 2.")); auto ins_dims = ctx->GetInputsDim("X"); const int cvm_offset = ctx->Attrs().Get("cvm_offset"); diff --git a/paddle/fluid/operators/fused/fused_seqpool_cvm_op.cu b/paddle/fluid/operators/fused/fused_seqpool_cvm_op.cu index 3770a536a8fcff141e6963da22ef7b053779d76d..2b6b7d49345395e62c1945cdfee7f96350dc3dcf 100644 --- a/paddle/fluid/operators/fused/fused_seqpool_cvm_op.cu +++ b/paddle/fluid/operators/fused/fused_seqpool_cvm_op.cu @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/framework/mixed_vector.h" #include "paddle/fluid/operators/fused/fused_seqpool_cvm_op.h" #include "paddle/fluid/platform/device/gpu/gpu_info.h" diff --git a/paddle/fluid/operators/fused/fused_seqpool_cvm_op.h b/paddle/fluid/operators/fused/fused_seqpool_cvm_op.h index 6042772adb054ec5233a26ff84b7a3c3fc5c0002..e3bc424f25910f3f70f642b3ee18a7693ef9b529 100644 --- a/paddle/fluid/operators/fused/fused_seqpool_cvm_op.h +++ b/paddle/fluid/operators/fused/fused_seqpool_cvm_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include #include + #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/tensor.h" diff --git a/paddle/fluid/operators/fused/fused_softmax_mask.cu.h b/paddle/fluid/operators/fused/fused_softmax_mask.cu.h index 11f1011dec3a26bfa94e0190b30c986cd027d89f..4c00f778ced3f86fd3e66e4691191d4068b5bb32 100644 --- a/paddle/fluid/operators/fused/fused_softmax_mask.cu.h +++ b/paddle/fluid/operators/fused/fused_softmax_mask.cu.h @@ -114,10 +114,9 @@ __global__ void FusedSoftmaxMaskVecKernel(T* dst, const T* src, const T* mask, } } -#define SOFTMAX_MASK_KERNEL(VEC_SIZE, ELEMENTS) \ - FusedSoftmaxMaskVecKernel<<>>( \ - dst, src, mask, seq_len) +#define SOFTMAX_MASK_KERNEL(VEC_SIZE, ELEMENTS) \ + FusedSoftmaxMaskVecKernel \ + <<>>(dst, src, mask, seq_len) // FIXME(wangxi): It is found that the performance of VEC_SIZE=2 is better // than that of =4 and =8. Further analysis of the kernel is needed later. diff --git a/paddle/fluid/operators/fused/fused_transformer_op.cc b/paddle/fluid/operators/fused/fused_transformer_op.cc index 9e5fc42fc76dd1c0aa8a9e44fe522be548140288..d11171eb2d086eabce89896275f5e91826bb07f7 100644 --- a/paddle/fluid/operators/fused/fused_transformer_op.cc +++ b/paddle/fluid/operators/fused/fused_transformer_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fused/fused_transformer_op.h" + #include namespace paddle { @@ -157,5 +158,5 @@ void FusedMHA::ComputeForward(T* output, T* softmax_mask) {} template void FusedMHA::ComputeBackward(const T* grad_output, T* softmax_mask, T* grad_x) {} -} -} \ No newline at end of file +} // namespace operators +} // namespace paddle diff --git a/paddle/fluid/operators/fused/fused_transformer_op.h b/paddle/fluid/operators/fused/fused_transformer_op.h index 2d2d390d243e5aeee6219f755dde53ba08c76e75..a2d5862abf06addf0600b92da8f616dfdb3d725e 100644 --- a/paddle/fluid/operators/fused/fused_transformer_op.h +++ b/paddle/fluid/operators/fused/fused_transformer_op.h @@ -151,5 +151,5 @@ class FusedTransformerEncoderLayer { std::string act_method; }; -} -} +} // namespace operators +} // namespace paddle diff --git a/paddle/fluid/operators/fused/fusion_conv_inception_op.cc b/paddle/fluid/operators/fused/fusion_conv_inception_op.cc index eeeb004003c9c405ad5b11889228caf85b2114a6..802cd18e1db24dc4d6bef14278154d02afff5cf5 100644 --- a/paddle/fluid/operators/fused/fusion_conv_inception_op.cc +++ b/paddle/fluid/operators/fused/fusion_conv_inception_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" #ifdef PADDLE_WITH_CUDA #include "paddle/fluid/platform/device/gpu/gpu_dnn.h" @@ -35,8 +36,9 @@ class ConvInceptionFusionOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ( in_dims.size(), 4, platform::errors::InvalidArgument("Conv intput should be 4-D tensor.")); - PADDLE_ENFORCE_EQ(w_dims.size(), 4, platform::errors::InvalidArgument( - "There should be 4 filters.")); + PADDLE_ENFORCE_EQ( + w_dims.size(), 4, + platform::errors::InvalidArgument("There should be 4 filters.")); PADDLE_ENFORCE_EQ(w_dims[0][1], in_dims[1], platform::errors::InvalidArgument( "Invalid fileter channel number %d, which should be " diff --git a/paddle/fluid/operators/fused/fusion_group_op.cu.cc b/paddle/fluid/operators/fused/fusion_group_op.cu.cc index 94949f563311638d866a7c4bbef23a5e5d2a4dff..c592bbe7d3e9aecb2abd22ff6af81f39d9a50334 100644 --- a/paddle/fluid/operators/fused/fusion_group_op.cu.cc +++ b/paddle/fluid/operators/fused/fusion_group_op.cu.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fused/fusion_group_op.h" + #include "paddle/fluid/platform/float16.h" namespace ops = paddle::operators; diff --git a/paddle/fluid/operators/fused/fusion_group_op.h b/paddle/fluid/operators/fused/fusion_group_op.h index 5e5f2c60ffbd48d801aa4cff1b074170c44ed88a..f71355b85d96af26f38af05f34973c4ba3d9277d 100644 --- a/paddle/fluid/operators/fused/fusion_group_op.h +++ b/paddle/fluid/operators/fused/fusion_group_op.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device_code.h" diff --git a/paddle/fluid/operators/fused/fusion_gru_op.cc b/paddle/fluid/operators/fused/fusion_gru_op.cc index afbd5380a8301e408ae338cddda5edf3f4916bc8..fd05155bc2cefc64dcea930a006666d055a71c9d 100644 --- a/paddle/fluid/operators/fused/fusion_gru_op.cc +++ b/paddle/fluid/operators/fused/fusion_gru_op.cc @@ -13,9 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fused/fusion_gru_op.h" + #include // for memcpy #include #include + #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/operators/jit/kernels.h" #include "paddle/phi/kernels/funcs/blas/blas.h" diff --git a/paddle/fluid/operators/fused/fusion_lstm_op.cc b/paddle/fluid/operators/fused/fusion_lstm_op.cc index 3dada660aeffe38d9b4c64d00cc2eaf89653d084..f2e6f099b4b58405b03a3d8c012d28c879160167 100644 --- a/paddle/fluid/operators/fused/fusion_lstm_op.cc +++ b/paddle/fluid/operators/fused/fusion_lstm_op.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fused/fusion_lstm_op.h" + #include + #include "paddle/fluid/operators/jit/kernels.h" #include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/fc_functor.h" diff --git a/paddle/fluid/operators/fused/fusion_repeated_fc_relu_op.cc b/paddle/fluid/operators/fused/fusion_repeated_fc_relu_op.cc index bed5125b99583eb6a7139fd1a2aa02fa8adfc8d3..c9d6d42efac248b9e6c89d90ec297657dafaac29 100644 --- a/paddle/fluid/operators/fused/fusion_repeated_fc_relu_op.cc +++ b/paddle/fluid/operators/fused/fusion_repeated_fc_relu_op.cc @@ -13,8 +13,10 @@ * limitations under the License. */ #include "paddle/fluid/operators/fused/fusion_repeated_fc_relu_op.h" + #include #include + #include "paddle/fluid/operators/jit/kernels.h" namespace paddle { @@ -24,10 +26,11 @@ void FusionRepeatedFCReluOp::InferShape( framework::InferShapeContext* ctx) const { OP_INOUT_CHECK(ctx->HasInput("X"), "Input", "X", "FusionRepeatedFCRelu"); auto sz = ctx->Inputs("W").size(); - PADDLE_ENFORCE_GT(sz, 1UL, platform::errors::InvalidArgument( - "Inputs(W) of FusionRepeatedFCReluOp should " - "be greater than 1, but received value is %d.", - sz)); + PADDLE_ENFORCE_GT(sz, 1UL, + platform::errors::InvalidArgument( + "Inputs(W) of FusionRepeatedFCReluOp should " + "be greater than 1, but received value is %d.", + sz)); PADDLE_ENFORCE_EQ( ctx->Inputs("Bias").size(), sz, platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/fused/fusion_seqconv_eltadd_relu_op.cc b/paddle/fluid/operators/fused/fusion_seqconv_eltadd_relu_op.cc index ee28a5480565303bd993b7da02f45b400c70477f..b99b53de9c4d675e5ba2452a2614a43dd826a202 100644 --- a/paddle/fluid/operators/fused/fusion_seqconv_eltadd_relu_op.cc +++ b/paddle/fluid/operators/fused/fusion_seqconv_eltadd_relu_op.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fused/fusion_seqconv_eltadd_relu_op.h" + #include // for min, max #include + #include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/fc_functor.h" diff --git a/paddle/fluid/operators/fused/fusion_seqexpand_concat_fc_op.cc b/paddle/fluid/operators/fused/fusion_seqexpand_concat_fc_op.cc index 58613173ad212e31035657d9518a7eaeb6aa7573..7341d1f864d931b13f316d59d549c90873727596 100644 --- a/paddle/fluid/operators/fused/fusion_seqexpand_concat_fc_op.cc +++ b/paddle/fluid/operators/fused/fusion_seqexpand_concat_fc_op.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fused/fusion_seqexpand_concat_fc_op.h" + #include + #include "paddle/fluid/platform/cpu_info.h" #include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/cpu_vec.h" @@ -48,8 +50,9 @@ void FusionSeqExpandConcatFCOp::InferShape( for (size_t i = 1; i < ins_dims.size(); ++i) { sum += ins_dims[i][1]; } - PADDLE_ENFORCE_EQ(sum, w_dims[0], platform::errors::InvalidArgument( - "FC height should be sum of all inputs " + PADDLE_ENFORCE_EQ( + sum, w_dims[0], + platform::errors::InvalidArgument("FC height should be sum of all inputs " "width, but received FC height is: %d, " "sum of all inputs width is: %d.", w_dims[0], sum)); diff --git a/paddle/fluid/operators/fused/fusion_seqpool_concat_op.cc b/paddle/fluid/operators/fused/fusion_seqpool_concat_op.cc index e574d67e3982c90a46dba7ebccd19177ee2c481b..1d487ef3dabc162bdb905f221161416568f4823f 100644 --- a/paddle/fluid/operators/fused/fusion_seqpool_concat_op.cc +++ b/paddle/fluid/operators/fused/fusion_seqpool_concat_op.cc @@ -13,8 +13,10 @@ * limitations under the License. */ #include "paddle/fluid/operators/fused/fusion_seqpool_concat_op.h" + #include #include + #include "paddle/fluid/operators/jit/kernels.h" namespace paddle { @@ -29,17 +31,19 @@ void FusionSeqPoolConcatOp::InferShape( ctx->Inputs("X").size())); OP_INOUT_CHECK(ctx->HasOutput("Out"), "Output", "Out", "FusionSeqPoolConcat"); int axis = ctx->Attrs().Get("axis"); - PADDLE_ENFORCE_EQ(axis, 1, platform::errors::InvalidArgument( - "FusionSeqPoolConcatOp only supports concat " - "axis=1 yet, but received axis value is %d", - axis)); + PADDLE_ENFORCE_EQ(axis, 1, + platform::errors::InvalidArgument( + "FusionSeqPoolConcatOp only supports concat " + "axis=1 yet, but received axis value is %d", + axis)); auto ins_dims = ctx->GetInputsDim("X"); const size_t n = ins_dims.size(); - PADDLE_ENFORCE_GT(n, 0UL, platform::errors::InvalidArgument( - "Input tensors count should be greater than 0, " - "but received value is %d.", - n)); + PADDLE_ENFORCE_GT(n, 0UL, + platform::errors::InvalidArgument( + "Input tensors count should be greater than 0, " + "but received value is %d.", + n)); if (n == 1) { LOG(WARNING) << "Only have one input, may waste memory"; } diff --git a/paddle/fluid/operators/fused/fusion_seqpool_cvm_concat_op.cc b/paddle/fluid/operators/fused/fusion_seqpool_cvm_concat_op.cc index c74cc504840d3af17eb49c4936fa97b07b00fedd..d29bc00b5459ed8cfd398507e42f402da2ed3b61 100644 --- a/paddle/fluid/operators/fused/fusion_seqpool_cvm_concat_op.cc +++ b/paddle/fluid/operators/fused/fusion_seqpool_cvm_concat_op.cc @@ -13,8 +13,10 @@ * limitations under the License. */ #include "paddle/fluid/operators/fused/fusion_seqpool_cvm_concat_op.h" + #include #include + #include "paddle/fluid/operators/jit/kernels.h" namespace paddle { @@ -31,20 +33,23 @@ void FusionSeqPoolCVMConcatOp::InferShape( paddle::platform::errors::InvalidArgument( "Output(Out) of FusionSeqPoolCVMConcatOp should not be null.")); int axis = ctx->Attrs().Get("axis"); - PADDLE_ENFORCE_EQ(axis, 1, paddle::platform::errors::InvalidArgument( - "FusionSeqPoolCVMConcatOp only supports " - "concat axis=1 yet, but received %d.", - axis)); + PADDLE_ENFORCE_EQ(axis, 1, + paddle::platform::errors::InvalidArgument( + "FusionSeqPoolCVMConcatOp only supports " + "concat axis=1 yet, but received %d.", + axis)); bool use_cvm = ctx->Attrs().Get("use_cvm"); - PADDLE_ENFORCE_EQ(use_cvm, true, paddle::platform::errors::InvalidArgument( - "FusionSeqPoolCVMConcatOp only supports " - "use_cvm is true yet, but received %d.", - use_cvm)); + PADDLE_ENFORCE_EQ(use_cvm, true, + paddle::platform::errors::InvalidArgument( + "FusionSeqPoolCVMConcatOp only supports " + "use_cvm is true yet, but received %d.", + use_cvm)); auto ins_dims = ctx->GetInputsDim("X"); const size_t n = ins_dims.size(); - PADDLE_ENFORCE_GT(n, 0UL, paddle::platform::errors::InvalidArgument( - "Input tensors count should > 0.")); + PADDLE_ENFORCE_GT(n, 0UL, + paddle::platform::errors::InvalidArgument( + "Input tensors count should > 0.")); if (n == 1) { LOG(WARNING) << "Only have one input, may waste memory"; } diff --git a/paddle/fluid/operators/fused/fusion_squared_mat_sub_op.cc b/paddle/fluid/operators/fused/fusion_squared_mat_sub_op.cc index 870f72b8c7f0d68daf8c86099cdf234fe48ef585..047fefc1eeb07a71312db151c436f32d2597423b 100644 --- a/paddle/fluid/operators/fused/fusion_squared_mat_sub_op.cc +++ b/paddle/fluid/operators/fused/fusion_squared_mat_sub_op.cc @@ -13,8 +13,10 @@ * limitations under the License. */ #include "paddle/fluid/operators/fused/fusion_squared_mat_sub_op.h" + #include #include + #include "paddle/fluid/operators/jit/kernels.h" namespace paddle { diff --git a/paddle/fluid/operators/fused/fusion_transpose_flatten_concat_op.cc b/paddle/fluid/operators/fused/fusion_transpose_flatten_concat_op.cc index 954cd7cc7a40b06b1ec9acc4bc4536abeff21585..bf8e9818e545f1e583a55b6c1f971904c7476f04 100644 --- a/paddle/fluid/operators/fused/fusion_transpose_flatten_concat_op.cc +++ b/paddle/fluid/operators/fused/fusion_transpose_flatten_concat_op.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fused/fusion_transpose_flatten_concat_op.h" + #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/fused/fusion_transpose_flatten_concat_op.cu.cc b/paddle/fluid/operators/fused/fusion_transpose_flatten_concat_op.cu.cc index 786f5b4e07798d46517367eeb839f6e4b7b80587..eb29859d8d15b9ef14153fbcb5f3481e885fadec 100644 --- a/paddle/fluid/operators/fused/fusion_transpose_flatten_concat_op.cu.cc +++ b/paddle/fluid/operators/fused/fusion_transpose_flatten_concat_op.cu.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fused/fusion_transpose_flatten_concat_op.h" + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device/gpu/gpu_dnn.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/operators/fused/fusion_transpose_flatten_concat_op.h b/paddle/fluid/operators/fused/fusion_transpose_flatten_concat_op.h index 66e6c00da2db847dd01c849a83977ef84575402c..52140c0ca46ee66a30a9e49ba612696ef50de9c8 100644 --- a/paddle/fluid/operators/fused/fusion_transpose_flatten_concat_op.h +++ b/paddle/fluid/operators/fused/fusion_transpose_flatten_concat_op.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/phi/core/ddim.h" namespace paddle { diff --git a/paddle/fluid/operators/fused/mkldnn/multi_gru_mkldnn_op.cc b/paddle/fluid/operators/fused/mkldnn/multi_gru_mkldnn_op.cc index 0ffc4c91b851c12a5329ae5b27bd3300753896a9..c9956dcdd2010615d13a27ec576951350b350399 100644 --- a/paddle/fluid/operators/fused/mkldnn/multi_gru_mkldnn_op.cc +++ b/paddle/fluid/operators/fused/mkldnn/multi_gru_mkldnn_op.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include #include #include + #include "dnnl.hpp" #include "paddle/fluid/framework/mixed_vector.h" #include "paddle/fluid/framework/operator.h" @@ -31,8 +32,8 @@ using paddle::platform::CPUDeviceContext; using paddle::platform::CreateKey; using paddle::platform::MKLDNNGetDataType; using paddle::platform::MKLDNNMemDesc; -using platform::to_void_cast; using phi::vectorize; +using platform::to_void_cast; using Direction = dnnl::rnn_direction; namespace { diff --git a/paddle/fluid/operators/fused/multi_gru_op.cc b/paddle/fluid/operators/fused/multi_gru_op.cc index e7d697767fcace462b02c133beb2e74ecf84bcb0..ad0cc0bd1cf86f62ff544894aaece9fdefe71ad7 100644 --- a/paddle/fluid/operators/fused/multi_gru_op.cc +++ b/paddle/fluid/operators/fused/multi_gru_op.cc @@ -17,6 +17,7 @@ limitations under the License. */ #include // for memcpy #include #include + #include "paddle/fluid/operators/jit/kernels.h" #include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/fc_functor.h" diff --git a/paddle/fluid/operators/fused/multi_gru_op.h b/paddle/fluid/operators/fused/multi_gru_op.h index ebd3faf44a84b74194191df8d3e73a4d12a00436..8b064c8754f5e5e657e3582b531a565b97811e4f 100644 --- a/paddle/fluid/operators/fused/multi_gru_op.h +++ b/paddle/fluid/operators/fused/multi_gru_op.h @@ -19,9 +19,9 @@ limitations under the License. */ namespace paddle { namespace operators { +using framework::ExecutionContext; using framework::LoDTensor; using framework::Tensor; -using framework::ExecutionContext; class MultiGRUOp : public framework::OperatorWithKernel { public: diff --git a/paddle/fluid/operators/fused/multihead_matmul_op.cc b/paddle/fluid/operators/fused/multihead_matmul_op.cc index 8f2c04d5afe12ef0525dc5fcc39cb9e663a0db05..79b886c37297ce57be917f9675a5b549fe584577 100644 --- a/paddle/fluid/operators/fused/multihead_matmul_op.cc +++ b/paddle/fluid/operators/fused/multihead_matmul_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/errors.h" diff --git a/paddle/fluid/operators/fused/multihead_matmul_op.cu b/paddle/fluid/operators/fused/multihead_matmul_op.cu index f0e05659c9294d5a8e59409b95ae92bc10500944..301553467165abdf1e714fea630f103de0efe9ac 100644 --- a/paddle/fluid/operators/fused/multihead_matmul_op.cu +++ b/paddle/fluid/operators/fused/multihead_matmul_op.cu @@ -13,7 +13,9 @@ // limitations under the License. #include + #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/operators/math/bert_encoder_functor.h" @@ -105,8 +107,8 @@ void TransQKVWithBias(const int batch, const int seq_len, const int head_size, platform::errors::InvalidArgument( "head_num (%d) * head_size (%d) should <= %d", head_num, head_size, 1024 * 4)); - TransposeQkvKernel<<>>(h, input4, bias4, - output4); + TransposeQkvKernel + <<>>(h, input4, bias4, output4); } else if (head_size % 2 == 0 && scratch_size % 2 == 0) { const int h = head_size / 2; const float2 *input2 = reinterpret_cast(input); @@ -118,8 +120,8 @@ void TransQKVWithBias(const int batch, const int seq_len, const int head_size, platform::errors::InvalidArgument( "head_num (%d) * head_size (%d) should <= %d", head_num, head_size, 1024 * 2)); - TransposeQkvKernel<<>>(h, input2, bias2, - output2); + TransposeQkvKernel + <<>>(h, input2, bias2, output2); } else { const dim3 block(head_size, head_num, 1); // limit head_size * head_num to max block size(1024). @@ -127,8 +129,8 @@ void TransQKVWithBias(const int batch, const int seq_len, const int head_size, platform::errors::InvalidArgument( "head_num (%d) * head_size (%d) should <= %d", head_num, head_size, 1024)); - TransposeQkvKernel<<>>(head_size, input, - bias, output); + TransposeQkvKernel + <<>>(head_size, input, bias, output); } } diff --git a/paddle/fluid/operators/fused/resnet_unit_op.cc b/paddle/fluid/operators/fused/resnet_unit_op.cc index 6f4246aadd9032c5c7e24a8460d3224e6bb85451..d5860fe9cf12ba68a808f18aa2f5d43c239cd4b9 100644 --- a/paddle/fluid/operators/fused/resnet_unit_op.cc +++ b/paddle/fluid/operators/fused/resnet_unit_op.cc @@ -115,13 +115,14 @@ class ResNetUnitOp : public framework::OperatorWithKernel { bn_param_shape = {1, 1, 1, bn_param_shape[0]}; } framework::DDim bn_param_dims = phi::make_ddim(bn_param_shape); - PADDLE_ENFORCE_EQ(x_dims.size(), 4, platform::errors::InvalidArgument( - "The dimensions of input " - "must equal to 4." - "But received: the shape of input " - "= [%s], the dimension of input = " - "[%d]", - x_dims, x_dims.size())); + PADDLE_ENFORCE_EQ( + x_dims.size(), 4, + platform::errors::InvalidArgument("The dimensions of input " + "must equal to 4." + "But received: the shape of input " + "= [%s], the dimension of input = " + "[%d]", + x_dims, x_dims.size())); PADDLE_ENFORCE_EQ(w_dims.size(), 4, platform::errors::InvalidArgument( "The dimensions of filter " @@ -180,14 +181,16 @@ class ResNetUnitOp : public framework::OperatorWithKernel { // and var tensors should be float when input tensor's dtype is float16. auto bn_param_type = framework::proto::VarType::FP32; - PADDLE_ENFORCE_EQ(bn_param_type, framework::TransToProtoVarType( - ctx.Input("ScaleX")->dtype()), - platform::errors::InvalidArgument( - "Scale input should be of float type")); - PADDLE_ENFORCE_EQ(bn_param_type, framework::TransToProtoVarType( - ctx.Input("BiasX")->dtype()), - platform::errors::InvalidArgument( - "Bias input should be of float type")); + PADDLE_ENFORCE_EQ( + bn_param_type, + framework::TransToProtoVarType(ctx.Input("ScaleX")->dtype()), + platform::errors::InvalidArgument( + "Scale input should be of float type")); + PADDLE_ENFORCE_EQ( + bn_param_type, + framework::TransToProtoVarType(ctx.Input("BiasX")->dtype()), + platform::errors::InvalidArgument( + "Bias input should be of float type")); framework::LibraryType library = framework::LibraryType::kPlain; framework::DataLayout layout = framework::DataLayout::kAnyLayout; return framework::OpKernelType(input_data_type, ctx.GetPlace(), layout, diff --git a/paddle/fluid/operators/fused/skip_layernorm_op.cc b/paddle/fluid/operators/fused/skip_layernorm_op.cc index 442f359c0dac59a5d6ee6d071d1d1b63838b4963..6ac6f51e4ce47b80cd1f0b1546c61267d6b0b7cf 100644 --- a/paddle/fluid/operators/fused/skip_layernorm_op.cc +++ b/paddle/fluid/operators/fused/skip_layernorm_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/errors.h" diff --git a/paddle/fluid/operators/fused/skip_layernorm_op.cu b/paddle/fluid/operators/fused/skip_layernorm_op.cu index e755ea33755ca7c4a4019152c8de90d3bea5695e..66a164ff31bea76ed977424fdab6133461911999 100644 --- a/paddle/fluid/operators/fused/skip_layernorm_op.cu +++ b/paddle/fluid/operators/fused/skip_layernorm_op.cu @@ -13,7 +13,9 @@ // limitations under the License. #include + #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/operators/math/bert_encoder_functor.h" diff --git a/paddle/fluid/operators/fused_softmax_mask_op.cc b/paddle/fluid/operators/fused_softmax_mask_op.cc index a41380028338a12449fe3ba4b1b7425fabab82be..a33070d94b919fa88b4554313089c90237aacea4 100644 --- a/paddle/fluid/operators/fused_softmax_mask_op.cc +++ b/paddle/fluid/operators/fused_softmax_mask_op.cc @@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fused_softmax_mask_op.h" + #include "paddle/fluid/framework/generator.h" #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/fused_softmax_mask_op.cu b/paddle/fluid/operators/fused_softmax_mask_op.cu index c4ab4de8a64cbe0af4abbc129cec998d522f4d08..b68a6907d7a65771afc696c1075cb6c85d492bca 100644 --- a/paddle/fluid/operators/fused_softmax_mask_op.cu +++ b/paddle/fluid/operators/fused_softmax_mask_op.cu @@ -40,6 +40,7 @@ limitations under the License. */ #include #include #include + #include #include diff --git a/paddle/fluid/operators/fused_softmax_mask_upper_triangle_op.cc b/paddle/fluid/operators/fused_softmax_mask_upper_triangle_op.cc index c737ba361e0f2573d46def53d1b566774a4bd90f..eefca7b6ab5644bc3218d177037425864a2f7354 100644 --- a/paddle/fluid/operators/fused_softmax_mask_upper_triangle_op.cc +++ b/paddle/fluid/operators/fused_softmax_mask_upper_triangle_op.cc @@ -11,6 +11,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/fused_softmax_mask_upper_triangle_op.h" + #include "paddle/fluid/framework/generator.h" #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/fused_softmax_mask_upper_triangle_op.cu b/paddle/fluid/operators/fused_softmax_mask_upper_triangle_op.cu index d4c5b8877056f2cee47ef75b8273d680457d3f5e..4ee90eb318496f6d177d7b0c4d0c1c1b162ef8f7 100644 --- a/paddle/fluid/operators/fused_softmax_mask_upper_triangle_op.cu +++ b/paddle/fluid/operators/fused_softmax_mask_upper_triangle_op.cu @@ -39,6 +39,7 @@ limitations under the License. */ #include #include #include + #include #include @@ -395,49 +396,49 @@ class SoftmaxMaskFuseUpperTriangleKernel : public framework::OpKernel { switch (pow2_index) { case 5: // 32 - SoftmaxMaskFuseUpperTriangleGPUKernel< - T, 5><<>>(x_data, y_data, batch_count, - key_seq_len); + SoftmaxMaskFuseUpperTriangleGPUKernel + <<>>(x_data, y_data, batch_count, + key_seq_len); break; case 6: // 64 - SoftmaxMaskFuseUpperTriangleGPUKernel< - T, 6><<>>(x_data, y_data, batch_count, - key_seq_len); + SoftmaxMaskFuseUpperTriangleGPUKernel + <<>>(x_data, y_data, batch_count, + key_seq_len); break; case 7: // 128 - SoftmaxMaskFuseUpperTriangleGPUKernel< - T, 7><<>>(x_data, y_data, batch_count, - key_seq_len); + SoftmaxMaskFuseUpperTriangleGPUKernel + <<>>(x_data, y_data, batch_count, + key_seq_len); break; case 8: // 256 - SoftmaxMaskFuseUpperTriangleGPUKernel< - T, 8><<>>(x_data, y_data, batch_count, - key_seq_len); + SoftmaxMaskFuseUpperTriangleGPUKernel + <<>>(x_data, y_data, batch_count, + key_seq_len); break; case 9: // 512 - SoftmaxMaskFuseUpperTriangleGPUKernel< - T, 9><<>>(x_data, y_data, batch_count, - key_seq_len); + SoftmaxMaskFuseUpperTriangleGPUKernel + <<>>(x_data, y_data, batch_count, + key_seq_len); break; case 10: // 1024 - SoftmaxMaskFuseUpperTriangleGPUKernel< - T, 10><<>>(x_data, y_data, batch_count, - key_seq_len); + SoftmaxMaskFuseUpperTriangleGPUKernel + <<>>(x_data, y_data, batch_count, + key_seq_len); break; case 11: // 2048 - SoftmaxMaskFuseUpperTriangleGPUKernel< - T, 11><<>>(x_data, y_data, batch_count, - key_seq_len); + SoftmaxMaskFuseUpperTriangleGPUKernel + <<>>(x_data, y_data, batch_count, + key_seq_len); break; case 12: // 4096 - SoftmaxMaskFuseUpperTriangleGPUKernel< - T, 12><<>>(x_data, y_data, batch_count, - key_seq_len); + SoftmaxMaskFuseUpperTriangleGPUKernel + <<>>(x_data, y_data, batch_count, + key_seq_len); break; case 13: // 8192 - SoftmaxMaskFuseUpperTriangleGPUKernel< - T, 13><<>>(x_data, y_data, batch_count, - key_seq_len); + SoftmaxMaskFuseUpperTriangleGPUKernel + <<>>(x_data, y_data, batch_count, + key_seq_len); break; default: break; @@ -483,58 +484,58 @@ class SoftmaxMaskFuseUpperTriangleGradKernel : public framework::OpKernel { switch (pow2_index) { case 5: // 32 - SoftmaxMaskFuseUpperTriangleGradGPUKernel< - T, 5><<>>(grad_y_data, grad_x_data, - softmax_rst_data, batch_count, - key_seq_len); + SoftmaxMaskFuseUpperTriangleGradGPUKernel + <<>>(grad_y_data, grad_x_data, + softmax_rst_data, batch_count, + key_seq_len); break; case 6: // 64 - SoftmaxMaskFuseUpperTriangleGradGPUKernel< - T, 6><<>>(grad_y_data, grad_x_data, - softmax_rst_data, batch_count, - key_seq_len); + SoftmaxMaskFuseUpperTriangleGradGPUKernel + <<>>(grad_y_data, grad_x_data, + softmax_rst_data, batch_count, + key_seq_len); break; case 7: // 128 - SoftmaxMaskFuseUpperTriangleGradGPUKernel< - T, 7><<>>(grad_y_data, grad_x_data, - softmax_rst_data, batch_count, - key_seq_len); + SoftmaxMaskFuseUpperTriangleGradGPUKernel + <<>>(grad_y_data, grad_x_data, + softmax_rst_data, batch_count, + key_seq_len); break; case 8: // 256 - SoftmaxMaskFuseUpperTriangleGradGPUKernel< - T, 8><<>>(grad_y_data, grad_x_data, - softmax_rst_data, batch_count, - key_seq_len); + SoftmaxMaskFuseUpperTriangleGradGPUKernel + <<>>(grad_y_data, grad_x_data, + softmax_rst_data, batch_count, + key_seq_len); break; case 9: // 512 - SoftmaxMaskFuseUpperTriangleGradGPUKernel< - T, 9><<>>(grad_y_data, grad_x_data, - softmax_rst_data, batch_count, - key_seq_len); + SoftmaxMaskFuseUpperTriangleGradGPUKernel + <<>>(grad_y_data, grad_x_data, + softmax_rst_data, batch_count, + key_seq_len); break; case 10: // 1024 - SoftmaxMaskFuseUpperTriangleGradGPUKernel< - T, 10><<>>(grad_y_data, grad_x_data, - softmax_rst_data, - batch_count, key_seq_len); + SoftmaxMaskFuseUpperTriangleGradGPUKernel + <<>>(grad_y_data, grad_x_data, + softmax_rst_data, batch_count, + key_seq_len); break; case 11: // 2048 - SoftmaxMaskFuseUpperTriangleGradGPUKernel< - T, 11><<>>(grad_y_data, grad_x_data, - softmax_rst_data, - batch_count, key_seq_len); + SoftmaxMaskFuseUpperTriangleGradGPUKernel + <<>>(grad_y_data, grad_x_data, + softmax_rst_data, batch_count, + key_seq_len); break; case 12: // 4096 - SoftmaxMaskFuseUpperTriangleGradGPUKernel< - T, 12><<>>(grad_y_data, grad_x_data, - softmax_rst_data, - batch_count, key_seq_len); + SoftmaxMaskFuseUpperTriangleGradGPUKernel + <<>>(grad_y_data, grad_x_data, + softmax_rst_data, batch_count, + key_seq_len); break; case 13: // 8192 - SoftmaxMaskFuseUpperTriangleGradGPUKernel< - T, 13><<>>(grad_y_data, grad_x_data, - softmax_rst_data, - batch_count, key_seq_len); + SoftmaxMaskFuseUpperTriangleGradGPUKernel + <<>>(grad_y_data, grad_x_data, + softmax_rst_data, batch_count, + key_seq_len); break; default: break; diff --git a/paddle/fluid/operators/gather_op.cc b/paddle/fluid/operators/gather_op.cc index 9f2b48a24b44700dc93e9eba09ea2dd2a900bdfa..d44dd324d6ccb82ce7fea6c60b96c9813cfd31e0 100644 --- a/paddle/fluid/operators/gather_op.cc +++ b/paddle/fluid/operators/gather_op.cc @@ -153,7 +153,7 @@ REGISTER_OPERATOR(gather_grad, ops::GatherGradOp, ops::GatherGradNoNeedBufferVarInferer, GatherGradInferShapeFunctor); -REGISTER_OP_VERSION(gather) - .AddCheckpoint(R"ROC(upgrad gather, add a new input [Axis])ROC", - paddle::framework::compatible::OpVersionDesc().NewInput( - "Axis", "Specify the axis of gather operation.")); +REGISTER_OP_VERSION(gather).AddCheckpoint( + R"ROC(upgrad gather, add a new input [Axis])ROC", + paddle::framework::compatible::OpVersionDesc().NewInput( + "Axis", "Specify the axis of gather operation.")); diff --git a/paddle/fluid/operators/gather_op_xpu.cc b/paddle/fluid/operators/gather_op_xpu.cc index 9dd8f58d2424c680732a75d3bac289461c859d80..327eec2a6ca74d31f3bda6defc32ab7d0b361f9a 100644 --- a/paddle/fluid/operators/gather_op_xpu.cc +++ b/paddle/fluid/operators/gather_op_xpu.cc @@ -168,10 +168,11 @@ class GatherGradOpXPUKernel : public framework::OpKernel { r = xpu::cast_v2(dev_ctx.x_context(), index->data(), index_int_ptr_l3, index->numel()); - PADDLE_ENFORCE_EQ(r, XPU_SUCCESS, platform::errors::External( - "XPU API(cast_v2) return wrong " - "value[%d %s]", - r, XPUAPIErrorMsg[r])); + PADDLE_ENFORCE_EQ( + r, XPU_SUCCESS, + platform::errors::External("XPU API(cast_v2) return wrong " + "value[%d %s]", + r, XPUAPIErrorMsg[r])); r = xpu::gather_grad( dev_ctx.x_context(), diff --git a/paddle/fluid/operators/gather_scatter_kernel.cu b/paddle/fluid/operators/gather_scatter_kernel.cu index f97eb3d5e9d9a348e3ad151cc234f0989c937985..6c4a7a01f3fbbc9750f5018ee975270ccdccec38 100644 --- a/paddle/fluid/operators/gather_scatter_kernel.cu +++ b/paddle/fluid/operators/gather_scatter_kernel.cu @@ -132,10 +132,11 @@ struct gpu_gather_scatter_functor { int64_t grid = (n + block - 1) / block; auto stream = reinterpret_cast(ctx).stream(); - GatherScatterGPUKernel<<>>( - self_data, dim, index_data, src_data, inner_dim_size, select_dim_size, - replaced_select_dim_size, outer_dim_size, index_size, reduce_op); + GatherScatterGPUKernel + <<>>(self_data, dim, index_data, src_data, + inner_dim_size, select_dim_size, + replaced_select_dim_size, outer_dim_size, + index_size, reduce_op); } }; // struct gpu_gather_scatter_functor diff --git a/paddle/fluid/operators/gather_test.cc b/paddle/fluid/operators/gather_test.cc index c962dd065234f37fe98481c9866f7d2f405db69c..676143bf01145c546ccb0ef8a24ab75e7f2c2ac7 100644 --- a/paddle/fluid/operators/gather_test.cc +++ b/paddle/fluid/operators/gather_test.cc @@ -12,11 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/phi/kernels/funcs/gather.h" + #include #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/platform/place.h" -#include "paddle/phi/kernels/funcs/gather.h" TEST(Gather, GatherData) { paddle::framework::Tensor* src = new paddle::framework::Tensor(); diff --git a/paddle/fluid/operators/gaussian_random_op.cu b/paddle/fluid/operators/gaussian_random_op.cu index deac932d59b800594cf6915bd67cb0aef2ffaca1..1e89091b202dee4fdf7a99dea1637517cc64aba0 100644 --- a/paddle/fluid/operators/gaussian_random_op.cu +++ b/paddle/fluid/operators/gaussian_random_op.cu @@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/generator.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" diff --git a/paddle/fluid/operators/gaussian_random_op_xpu.cc b/paddle/fluid/operators/gaussian_random_op_xpu.cc index 5a1ac46f615d254bef7517e4653dccb58d424583..2ffc90fbd8c20f10a9d2c06d6f51a8d8e68db3ca 100644 --- a/paddle/fluid/operators/gaussian_random_op_xpu.cc +++ b/paddle/fluid/operators/gaussian_random_op_xpu.cc @@ -15,6 +15,7 @@ limitations under the License. */ #ifdef PADDLE_WITH_XPU #include + #include "paddle/fluid/framework/generator.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/gelu_op.cc b/paddle/fluid/operators/gelu_op.cc index 3be2606bfc93984f918adf595b522fe6bfca72be..080ceaa45e34332cb29f0450713fef18f2cc370d 100644 --- a/paddle/fluid/operators/gelu_op.cc +++ b/paddle/fluid/operators/gelu_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" diff --git a/paddle/fluid/operators/gelu_op_xpu.cc b/paddle/fluid/operators/gelu_op_xpu.cc index 559d2448ad94525d623e24fc8fb6c5e3881b58e3..408638f7d2cfc16ea76049afeb66088c349a35be 100644 --- a/paddle/fluid/operators/gelu_op_xpu.cc +++ b/paddle/fluid/operators/gelu_op_xpu.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/tensor.h" diff --git a/paddle/fluid/operators/graph_khop_sampler_op.cc b/paddle/fluid/operators/graph_khop_sampler_op.cc index c83ee2584060585707aa7733f3cf26f6b4aae908..edf7d20c6d5c8274c82c6d25c4b2e8221c61635e 100644 --- a/paddle/fluid/operators/graph_khop_sampler_op.cc +++ b/paddle/fluid/operators/graph_khop_sampler_op.cc @@ -19,10 +19,11 @@ namespace operators { void InputShapeCheck(const framework::DDim& dims, std::string tensor_name) { if (dims.size() == 2) { - PADDLE_ENFORCE_EQ(dims[1], 1, platform::errors::InvalidArgument( - "The last dim of %s should be 1 when it " - "is 2D, but we get %d", - tensor_name, dims[1])); + PADDLE_ENFORCE_EQ(dims[1], 1, + platform::errors::InvalidArgument( + "The last dim of %s should be 1 when it " + "is 2D, but we get %d", + tensor_name, dims[1])); } else { PADDLE_ENFORCE_EQ( dims.size(), 1, diff --git a/paddle/fluid/operators/graph_khop_sampler_op.cu b/paddle/fluid/operators/graph_khop_sampler_op.cu index df977b43512a007c6acb6808fb8d81851dc4f5e4..a63fdc89e24b2c015c69f6b8addd068168b9439c 100644 --- a/paddle/fluid/operators/graph_khop_sampler_op.cu +++ b/paddle/fluid/operators/graph_khop_sampler_op.cu @@ -26,6 +26,7 @@ limitations under the License. */ #include #include #include + #include #ifdef PADDLE_WITH_HIP @@ -217,15 +218,16 @@ void SampleNeighbors(const framework::ExecutionContext& ctx, const T* src, constexpr int TILE_SIZE = BLOCK_WARPS * 16; const dim3 block(WARP_SIZE, BLOCK_WARPS); const dim3 grid((bs + TILE_SIZE - 1) / TILE_SIZE); - GraphSampleNeighborsCUDAKernel<<< - grid, block, 0, - reinterpret_cast(ctx.device_context()) - .stream()>>>( - 0, k, bs, thrust::raw_pointer_cast(inputs->data()), src, dst_count, - src_eids, thrust::raw_pointer_cast(outputs->data()), - thrust::raw_pointer_cast(outputs_eids->data()), - thrust::raw_pointer_cast(output_ptr.data()), - thrust::raw_pointer_cast(output_idxs.data()), return_eids); + GraphSampleNeighborsCUDAKernel + <<( + ctx.device_context()) + .stream()>>>( + 0, k, bs, thrust::raw_pointer_cast(inputs->data()), src, dst_count, + src_eids, thrust::raw_pointer_cast(outputs->data()), + thrust::raw_pointer_cast(outputs_eids->data()), + thrust::raw_pointer_cast(output_ptr.data()), + thrust::raw_pointer_cast(output_idxs.data()), return_eids); // 5. Get inputs = outputs - inputs: if (!is_last_layer) { @@ -264,19 +266,19 @@ void FillHashTable(const framework::ExecutionContext& ctx, const T* input, int grid_tmp = (num_input + block - 1) / block; int grid = grid_tmp < max_grid_dimx ? grid_tmp : max_grid_dimx; // 1. Insert data into keys and values. - BuildHashTable< - T><<( - ctx.device_context()) - .stream()>>>( + BuildHashTable<<( + ctx.device_context()) + .stream()>>>( input, num_input, len_hashtable, thrust::raw_pointer_cast(keys->data()), thrust::raw_pointer_cast(key_index->data())); // 2. Get item index count. thrust::device_vector item_count(num_input + 1, 0); - GetItemIndexCount< - T><<( - ctx.device_context()) - .stream()>>>( + GetItemIndexCount<<( + ctx.device_context()) + .stream()>>>( input, thrust::raw_pointer_cast(item_count.data()), num_input, len_hashtable, thrust::raw_pointer_cast(keys->data()), thrust::raw_pointer_cast(key_index->data())); @@ -287,16 +289,16 @@ void FillHashTable(const framework::ExecutionContext& ctx, const T* input, unique_items->resize(total_unique_items); // 3. Get unique items. - FillUniqueItems< - T><<( - ctx.device_context()) - .stream()>>>( - input, num_input, len_hashtable, - thrust::raw_pointer_cast(unique_items->data()), - thrust::raw_pointer_cast(item_count.data()), - thrust::raw_pointer_cast(keys->data()), - thrust::raw_pointer_cast(values->data()), - thrust::raw_pointer_cast(key_index->data())); + FillUniqueItems + <<( + ctx.device_context()) + .stream()>>>(input, num_input, len_hashtable, + thrust::raw_pointer_cast(unique_items->data()), + thrust::raw_pointer_cast(item_count.data()), + thrust::raw_pointer_cast(keys->data()), + thrust::raw_pointer_cast(values->data()), + thrust::raw_pointer_cast(key_index->data())); } template @@ -337,23 +339,23 @@ void ReindexFunc(const framework::ExecutionContext& ctx, int64_t max_grid_dimx = dev_ctx.GetCUDAMaxGridDimSize()[0]; int64_t grid_tmp = (outputs->size() + block - 1) / block; int64_t grid = grid_tmp < max_grid_dimx ? grid_tmp : max_grid_dimx; - ReindexSrcOutput< - T><<( - ctx.device_context()) - .stream()>>>( + ReindexSrcOutput<<( + ctx.device_context()) + .stream()>>>( thrust::raw_pointer_cast(outputs->data()), outputs->size(), size, thrust::raw_pointer_cast(keys.data()), thrust::raw_pointer_cast(values.data())); int grid_ = (bs + block - 1) / block; - ReindexInputNodes<<( - ctx.device_context()) - .stream()>>>( - thrust::raw_pointer_cast(orig_nodes->data()), bs, - thrust::raw_pointer_cast(reindex_nodes->data()), size, - thrust::raw_pointer_cast(keys.data()), - thrust::raw_pointer_cast(values.data())); + ReindexInputNodes + <<( + ctx.device_context()) + .stream()>>>(thrust::raw_pointer_cast(orig_nodes->data()), bs, + thrust::raw_pointer_cast(reindex_nodes->data()), size, + thrust::raw_pointer_cast(keys.data()), + thrust::raw_pointer_cast(values.data())); } template @@ -532,15 +534,16 @@ class GraphKhopSamplerOpCUDAKernel : public framework::OpKernel { const dim3 block(WARP_SIZE, BLOCK_WARPS); const dim3 grid((unique_dst_size + TILE_SIZE - 1) / TILE_SIZE); - GetDstEdgeCUDAKernel<<< - grid, block, 0, reinterpret_cast( - ctx.device_context()) - .stream()>>>( - unique_dst_size, - thrust::raw_pointer_cast(unique_dst_merge_reindex.data()), - thrust::raw_pointer_cast(dst_sample_counts_merge.data()), - thrust::raw_pointer_cast(dst_ptr.data()), - thrust::raw_pointer_cast(dst_merge.data())); + GetDstEdgeCUDAKernel + <<( + ctx.device_context()) + .stream()>>>( + unique_dst_size, + thrust::raw_pointer_cast(unique_dst_merge_reindex.data()), + thrust::raw_pointer_cast(dst_sample_counts_merge.data()), + thrust::raw_pointer_cast(dst_ptr.data()), + thrust::raw_pointer_cast(dst_merge.data())); // 8. Give operator's outputs. auto* out_src = ctx.Output("Out_Src"); diff --git a/paddle/fluid/operators/graph_khop_sampler_op.h b/paddle/fluid/operators/graph_khop_sampler_op.h index d7121cb549370482085ee690200a57f3ada57e97..1005a6ab11cc030e4305c4a14882a3baea898dc9 100644 --- a/paddle/fluid/operators/graph_khop_sampler_op.h +++ b/paddle/fluid/operators/graph_khop_sampler_op.h @@ -15,10 +15,12 @@ limitations under the License. */ #pragma once #include + #include #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/operators/group_norm_op.cc b/paddle/fluid/operators/group_norm_op.cc index f6a1e20a1a11066a365a44a818a5bf878980df34..4d989ed1f2ec0d1f9508cbce07080d44d810f826 100644 --- a/paddle/fluid/operators/group_norm_op.cc +++ b/paddle/fluid/operators/group_norm_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/group_norm_op.h" + #include #include #include diff --git a/paddle/fluid/operators/group_norm_op.cu b/paddle/fluid/operators/group_norm_op.cu index bb8031b0cc4e6cd97afe5f5584d64d58197d6f9d..84eb2fbc7d31f7af66d5e2e45d1332e1c600a4f7 100644 --- a/paddle/fluid/operators/group_norm_op.cu +++ b/paddle/fluid/operators/group_norm_op.cu @@ -322,9 +322,9 @@ class GroupNormKernel ScalarGetMeanAndVarNCHW<<>>( x_data, mean_data, temp_var_data, size); } else { - VectorizedGetMeanAndVarNCHW< - T, AccT, vec_size><<>>( - x_data, mean_data, temp_var_data, size); + VectorizedGetMeanAndVarNCHW + <<>>(x_data, mean_data, + temp_var_data, size); } } else { set_zero(dev_ctx, mean, static_cast(0)); @@ -613,16 +613,16 @@ class GroupNormGradKernel } block_size_nchw = std::max(block_size_nchw, kps::details::kWarpSize); dim3 blocks(block_size_nchw); - ScalarGetDsDbCUDAKernel< - T><<>>( - imsize, x_data, dy_data, ds_data, db_data); + ScalarGetDsDbCUDAKernel + <<>>( + imsize, x_data, dy_data, ds_data, db_data); if (d_scale || d_bias) { const int block = 256; - GetScaleBiasGradientCUDAKernel< - T><<<(C + block - 1) / block, block, 0, dev_ctx.stream()>>>( - x_dims[0], C, groups, epsilon, mean_data, var_data, ds_data, - db_data, d_scale_data, d_bias_data); + GetScaleBiasGradientCUDAKernel + <<<(C + block - 1) / block, block, 0, dev_ctx.stream()>>>( + x_dims[0], C, groups, epsilon, mean_data, var_data, ds_data, + db_data, d_scale_data, d_bias_data); } if (d_x_data != nullptr) { @@ -639,10 +639,10 @@ class GroupNormGradKernel T* p2_data = p2.data(); T* p3_data = p3.data(); - GetBackwardParamsCUDAKernel<<< - dim3(x_dims[0], groups), block_dims, 0, dev_ctx.stream()>>>( - imsize, groups, group_size, epsilon, mean_data, var_data, - scale_data, ds_data, db_data, p1_data, p2_data, p3_data); + GetBackwardParamsCUDAKernel + <<>>( + imsize, groups, group_size, epsilon, mean_data, var_data, + scale_data, ds_data, db_data, p1_data, p2_data, p3_data); GetXGradientCUDAKernel<<>>( imsize, C, group_size, groups, p1_data, p2_data, p3_data, x_data, dy_data, d_x_data); diff --git a/paddle/fluid/operators/group_norm_op.h b/paddle/fluid/operators/group_norm_op.h index 2d80ab89471fc51895930aec819d93ef8a8a76a7..28a3ad2a8e1eee8b84163cc79d90b9776c3300ca 100644 --- a/paddle/fluid/operators/group_norm_op.h +++ b/paddle/fluid/operators/group_norm_op.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/data_layout.h" #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/group_norm_op_npu.cc b/paddle/fluid/operators/group_norm_op_npu.cc index 8de8647186ed37ee49d8257a835d79891334f020..dfc509941bc2ddaf6d248a03af0c1af8b397a74a 100644 --- a/paddle/fluid/operators/group_norm_op_npu.cc +++ b/paddle/fluid/operators/group_norm_op_npu.cc @@ -12,8 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/group_norm_op.h" #include + +#include "paddle/fluid/operators/group_norm_op.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" namespace paddle { diff --git a/paddle/fluid/operators/gru_op.cc b/paddle/fluid/operators/gru_op.cc index 58cbdfda34799dfa92348e06b45e3bce90a46d1f..21ad5914c5d4d93f0bdbae3829b3768f7d98e994 100644 --- a/paddle/fluid/operators/gru_op.cc +++ b/paddle/fluid/operators/gru_op.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/gru_op.h" + #include #include + #include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/detail/gru_cpu_kernel.h" #include "paddle/phi/kernels/funcs/detail/gru_kernel.h" diff --git a/paddle/fluid/operators/gru_op.h b/paddle/fluid/operators/gru_op.h index 852655034c8c277f7e7bf1fb562951c26223c101..4cc6c65983fe9f16df1a740c396898437c12ba3d 100644 --- a/paddle/fluid/operators/gru_op.h +++ b/paddle/fluid/operators/gru_op.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/detail/activation_functions.h" diff --git a/paddle/fluid/operators/gru_unit_op.cc b/paddle/fluid/operators/gru_unit_op.cc index 8998c51f0df62e81540125bbac365d0b364e8bff..b6d9ef50f83e8a7c8e8f8b90dbddce4bd14997b3 100644 --- a/paddle/fluid/operators/gru_unit_op.cc +++ b/paddle/fluid/operators/gru_unit_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/gru_unit_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/gru_unit_op.h b/paddle/fluid/operators/gru_unit_op.h index 291f5f4ad26732ce845bc59240964a069edf3438..2dd1515919b3b7dfbcd68b2e5da9eaf19251dd7f 100644 --- a/paddle/fluid/operators/gru_unit_op.h +++ b/paddle/fluid/operators/gru_unit_op.h @@ -77,9 +77,9 @@ class GRUUnitKernel : public framework::OpKernel { // calculate unactivated gate outputs if (bias) { auto b = framework::EigenMatrix::From(*bias); - g.device(place) = x + - b.reshape(Eigen::array({{1, frame_size * 3}})) - .broadcast(Eigen::array({{batch_size, 1}})); + g.device(place) = + x + b.reshape(Eigen::array({{1, frame_size * 3}})) + .broadcast(Eigen::array({{batch_size, 1}})); } else { g.device(place) = x; } diff --git a/paddle/fluid/operators/hinge_loss_op.cc b/paddle/fluid/operators/hinge_loss_op.cc index cce80518354d75b9caa61462a2d3cefb3fa47627..f72fe9282abb60d3db4afd9d34f48474d6eef953 100644 --- a/paddle/fluid/operators/hinge_loss_op.cc +++ b/paddle/fluid/operators/hinge_loss_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/hinge_loss_op.h" + #include #include #include diff --git a/paddle/fluid/operators/huber_loss_op_xpu.cc b/paddle/fluid/operators/huber_loss_op_xpu.cc index ccddec2779515f26db10440633ab9d9894537182..2fafd18621528023dad13ddcf3c959d16c551aae 100644 --- a/paddle/fluid/operators/huber_loss_op_xpu.cc +++ b/paddle/fluid/operators/huber_loss_op_xpu.cc @@ -39,10 +39,11 @@ class HuberLossXPUKernel : public framework::OpKernel { ctx.template device_context(); int r = xpu::huber_loss(dev_ctx.x_context(), in0_data, in1_data, residual_data, out_data, in0->numel(), 1, delta); - PADDLE_ENFORCE_EQ(r, XPU_SUCCESS, platform::errors::External( - "XPU API(huber_loss) return wrong " - "value[%d %s]", - r, XPUAPIErrorMsg[r])); + PADDLE_ENFORCE_EQ( + r, XPU_SUCCESS, + platform::errors::External("XPU API(huber_loss) return wrong " + "value[%d %s]", + r, XPUAPIErrorMsg[r])); } }; diff --git a/paddle/fluid/operators/im2sequence_op.cc b/paddle/fluid/operators/im2sequence_op.cc index d248857b8f42fb9e8a6c8a0ac60546a390597714..107384742bbddf268ff9f1a6f7ad795c3efe6bd0 100644 --- a/paddle/fluid/operators/im2sequence_op.cc +++ b/paddle/fluid/operators/im2sequence_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/im2sequence_op.h" + #include #include #include diff --git a/paddle/fluid/operators/im2sequence_op.h b/paddle/fluid/operators/im2sequence_op.h index b0c4b9b4a99a5e4f59405b3d78025471c519a7d9..218161fd00aaa5d292c3e2b19e90df61ead1e7d4 100644 --- a/paddle/fluid/operators/im2sequence_op.h +++ b/paddle/fluid/operators/im2sequence_op.h @@ -15,6 +15,7 @@ #pragma once #include #include + #include "paddle/fluid/framework/data_layout.h" #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/index_impl.cu.h b/paddle/fluid/operators/index_impl.cu.h index bb26e2f445e7034b8f982594216eacfd3007a24f..d8417e42e1bf7b25aa0676dd3fc907ff054a9289 100644 --- a/paddle/fluid/operators/index_impl.cu.h +++ b/paddle/fluid/operators/index_impl.cu.h @@ -15,6 +15,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/generator.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" @@ -73,16 +74,16 @@ void IndexKernel(const KPDevice &dev_ctx, Tensor *out, Functor func) { size_t main_offset = (numel / (vec_size * block)) * vec_size * block; switch (vec_size) { case 4: - VectorizedIndexKernel<<>>( - out_data, numel, main_offset, func); + VectorizedIndexKernel + <<>>(out_data, numel, main_offset, func); break; case 2: - VectorizedIndexKernel<<>>( - out_data, numel, main_offset, func); + VectorizedIndexKernel + <<>>(out_data, numel, main_offset, func); break; case 1: - VectorizedIndexKernel<<>>( - out_data, numel, main_offset, func); + VectorizedIndexKernel + <<>>(out_data, numel, main_offset, func); break; default: { PADDLE_THROW(paddle::platform::errors::Unimplemented( diff --git a/paddle/fluid/operators/index_sample_op.cc b/paddle/fluid/operators/index_sample_op.cc index d17c6368c7537b93ceb6f1d75b6d73467bd207ac..15fc0f6d14fe4ed81a33d5346f50aed35e867039 100644 --- a/paddle/fluid/operators/index_sample_op.cc +++ b/paddle/fluid/operators/index_sample_op.cc @@ -13,11 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include -#include "paddle/fluid/framework/no_need_buffer_vars_inference.h" -#include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/framework/infershape_utils.h" +#include "paddle/fluid/framework/no_need_buffer_vars_inference.h" #include "paddle/fluid/framework/op_registry.h" +#include "paddle/fluid/platform/enforce.h" #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/infermeta/binary.h" namespace paddle { diff --git a/paddle/fluid/operators/index_select_op.h b/paddle/fluid/operators/index_select_op.h index 684829be2697cdc1676e8b80e15b2d600d922f3b..c82aaab0fe1c2845d5cae052ea826bf7ac4423ed 100644 --- a/paddle/fluid/operators/index_select_op.h +++ b/paddle/fluid/operators/index_select_op.h @@ -14,6 +14,7 @@ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/inplace_abn_op.cc b/paddle/fluid/operators/inplace_abn_op.cc index d420d0319bfe46d9501ef06dccfdf32b38ae7a0e..6cb8d664d80222c9ae511aee055c21b21e483e8e 100644 --- a/paddle/fluid/operators/inplace_abn_op.cc +++ b/paddle/fluid/operators/inplace_abn_op.cc @@ -13,9 +13,11 @@ // limitations under the License. #include "paddle/fluid/operators/inplace_abn_op.h" + #include #include #include + #include "paddle/fluid/operators/batch_norm_op.h" #include "paddle/phi/kernels/batch_norm_grad_kernel.h" #include "paddle/phi/kernels/batch_norm_kernel.h" @@ -38,18 +40,21 @@ class InplaceABNOp : public paddle::operators::BatchNormOp { if (input_data_type == framework::proto::VarType::FP64) { bn_param_type = framework::proto::VarType::FP64; } - PADDLE_ENFORCE_EQ(bn_param_type, framework::TransToProtoVarType( - ctx.Input("Scale")->dtype()), - platform::errors::InvalidArgument( - "Scale input should be of float type")); - PADDLE_ENFORCE_EQ(bn_param_type, framework::TransToProtoVarType( - ctx.Input("Bias")->dtype()), - platform::errors::InvalidArgument( - "Bias input should be of float type")); - PADDLE_ENFORCE_EQ(bn_param_type, framework::TransToProtoVarType( - ctx.Input("Mean")->dtype()), - platform::errors::InvalidArgument( - "Mean input should be of float type")); + PADDLE_ENFORCE_EQ( + bn_param_type, + framework::TransToProtoVarType(ctx.Input("Scale")->dtype()), + platform::errors::InvalidArgument( + "Scale input should be of float type")); + PADDLE_ENFORCE_EQ( + bn_param_type, + framework::TransToProtoVarType(ctx.Input("Bias")->dtype()), + platform::errors::InvalidArgument( + "Bias input should be of float type")); + PADDLE_ENFORCE_EQ( + bn_param_type, + framework::TransToProtoVarType(ctx.Input("Mean")->dtype()), + platform::errors::InvalidArgument( + "Mean input should be of float type")); PADDLE_ENFORCE_EQ( bn_param_type, framework::TransToProtoVarType(ctx.Input("Variance")->dtype()), @@ -209,8 +214,9 @@ class InplaceABNKernel : public framework::OpKernel { void Compute(const framework::ExecutionContext& ctx) const override { auto* x = ctx.Input("X"); auto* y = ctx.Output("Y"); - PADDLE_ENFORCE_EQ(x, y, platform::errors::InvalidArgument( - "X and Y not inplaced in inplace mode")); + PADDLE_ENFORCE_EQ(x, y, + platform::errors::InvalidArgument( + "X and Y not inplaced in inplace mode")); auto activation = GetInplaceABNActivationType(ctx.Attr("activation")); auto& place = *ctx.template device_context().eigen_device(); diff --git a/paddle/fluid/operators/inplace_abn_op.cu b/paddle/fluid/operators/inplace_abn_op.cu index 6476023fcd20eac115179e60c40aefe21c83a75c..7245629e565e92db3e457eada38572b5e582afcd 100644 --- a/paddle/fluid/operators/inplace_abn_op.cu +++ b/paddle/fluid/operators/inplace_abn_op.cu @@ -28,8 +28,9 @@ class InplaceABNKernel void Compute(const framework::ExecutionContext& ctx) const override { auto* y = ctx.Output("Y"); auto* x = ctx.Input("X"); - PADDLE_ENFORCE_EQ(x, y, platform::errors::InvalidArgument( - "X and Y not inplaced in inplace mode")); + PADDLE_ENFORCE_EQ(x, y, + platform::errors::InvalidArgument( + "X and Y not inplaced in inplace mode")); auto activation = GetInplaceABNActivationType(ctx.Attr("activation")); auto& place = *ctx.template device_context().eigen_device(); diff --git a/paddle/fluid/operators/inplace_abn_op.h b/paddle/fluid/operators/inplace_abn_op.h index 942404978584d35f056b70f7e1bf31cc90ea8635..275209911d18e641bf35ab47e86bedd39dbe8989 100644 --- a/paddle/fluid/operators/inplace_abn_op.h +++ b/paddle/fluid/operators/inplace_abn_op.h @@ -14,6 +14,7 @@ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/activation_op.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/instance_norm_op.cc b/paddle/fluid/operators/instance_norm_op.cc index de92de453a354110dcaedae9b4bc1e53ab46a554..21ccf777051c29e9d3816d33b454ebc4c53ff549 100644 --- a/paddle/fluid/operators/instance_norm_op.cc +++ b/paddle/fluid/operators/instance_norm_op.cc @@ -13,9 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/instance_norm_op.h" + #include #include #include + #include "paddle/fluid/framework/data_layout.h" #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_version_registry.h" @@ -38,16 +40,18 @@ framework::OpKernelType InstanceNormOp::GetExpectedKernelType( in_param_type = framework::proto::VarType::FP64; } if (ctx.HasInput("Scale")) { - PADDLE_ENFORCE_EQ(in_param_type, framework::TransToProtoVarType( - ctx.Input("Scale")->dtype()), - platform::errors::InvalidArgument( - "Scale input should be of float type")); + PADDLE_ENFORCE_EQ( + in_param_type, + framework::TransToProtoVarType(ctx.Input("Scale")->dtype()), + platform::errors::InvalidArgument( + "Scale input should be of float type")); } if (ctx.HasInput("Bias")) { - PADDLE_ENFORCE_EQ(in_param_type, framework::TransToProtoVarType( - ctx.Input("Bias")->dtype()), - platform::errors::InvalidArgument( - "Bias input should be of float type")); + PADDLE_ENFORCE_EQ( + in_param_type, + framework::TransToProtoVarType(ctx.Input("Bias")->dtype()), + platform::errors::InvalidArgument( + "Bias input should be of float type")); } return framework::OpKernelType(input_data_type, ctx.GetPlace()); diff --git a/paddle/fluid/operators/instance_norm_op.h b/paddle/fluid/operators/instance_norm_op.h index 265e4acef0d7a28345d429f4ced4a7de588ea2e2..3f99cdf10c64b4d89126af7cd72a28a109117d11 100644 --- a/paddle/fluid/operators/instance_norm_op.h +++ b/paddle/fluid/operators/instance_norm_op.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/interpolate_op.cc b/paddle/fluid/operators/interpolate_op.cc index fda168c94e1e064c65e3b5fcf56b606772345b9d..3c746d7c08a1a04ff7f361bab1e9249b789d5041 100644 --- a/paddle/fluid/operators/interpolate_op.cc +++ b/paddle/fluid/operators/interpolate_op.cc @@ -10,9 +10,11 @@ limitations under the License. */ #include "paddle/fluid/operators/interpolate_op.h" + #include #include #include + #include "paddle/fluid/framework/op_registry.h" #ifdef PADDLE_WITH_MKLDNN #include "paddle/fluid/platform/mkldnn_helper.h" @@ -112,11 +114,12 @@ static void Interpolate2DInferShapeCheck(framework::InferShapeContext* ctx) { PADDLE_ENFORCE_EQ("bilinear" == interp_method || "nearest" == interp_method || "bicubic" == interp_method, - true, platform::errors::InvalidArgument( - "Interpolation method can only be \"bilinear\" " - "or \"nearest\" or \"bicubic\" when " - "Input(X) dimension is 4, but got method is %s.", - interp_method)); + true, + platform::errors::InvalidArgument( + "Interpolation method can only be \"bilinear\" " + "or \"nearest\" or \"bicubic\" when " + "Input(X) dimension is 4, but got method is %s.", + interp_method)); const DataLayout data_layout = framework::StringToDataLayout( ctx->Attrs().Get("data_layout")); diff --git a/paddle/fluid/operators/interpolate_op.cu b/paddle/fluid/operators/interpolate_op.cu index 8a63c9a394638f00c2793433da864f43f1c8d323..729eba43d726484a331d2241d40dc635e2c86f98 100644 --- a/paddle/fluid/operators/interpolate_op.cu +++ b/paddle/fluid/operators/interpolate_op.cu @@ -11,6 +11,7 @@ #include #include + #include "paddle/fluid/operators/interpolate_op.h" #include "paddle/fluid/platform/device/gpu/gpu_launch_config.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" @@ -860,9 +861,10 @@ static void Interpolate1DCUDAFwd(const framework::ExecutionContext& ctx, out_w = size_data[0]; } } - PADDLE_ENFORCE_GT(out_w, 0, platform::errors::InvalidArgument( - "out_w in Attr(out_shape) of Op(interpolate) " - "should be greater than 0.")); + PADDLE_ENFORCE_GT(out_w, 0, + platform::errors::InvalidArgument( + "out_w in Attr(out_shape) of Op(interpolate) " + "should be greater than 0.")); framework::DDim dim_out; if (data_layout == DataLayout::kNCHW) { dim_out = {n, c, out_w}; @@ -942,12 +944,14 @@ static void Interpolate2DCUDAFwd(const framework::ExecutionContext& ctx, out_w = size_data[1]; } } - PADDLE_ENFORCE_GT(out_h, 0, platform::errors::InvalidArgument( - "out_h in Attr(out_shape) of Op(interpolate) " - "should be greater than 0.")); - PADDLE_ENFORCE_GT(out_w, 0, platform::errors::InvalidArgument( - "out_w in Attr(out_shape) of Op(interpolate) " - "should be greater than 0.")); + PADDLE_ENFORCE_GT(out_h, 0, + platform::errors::InvalidArgument( + "out_h in Attr(out_shape) of Op(interpolate) " + "should be greater than 0.")); + PADDLE_ENFORCE_GT(out_w, 0, + platform::errors::InvalidArgument( + "out_w in Attr(out_shape) of Op(interpolate) " + "should be greater than 0.")); framework::DDim dim_out; if (data_layout == DataLayout::kNCHW) { @@ -984,21 +988,21 @@ static void Interpolate2DCUDAFwd(const framework::ExecutionContext& ctx, platform::GetGpuLaunchConfig1D(ctx.cuda_device_context(), pixelNum); if ("nearest" == interp_method) { - KeNearestNeighborInterpFw< - T><<>>( - input_data, in_h, in_w, n, in_chw, output_data, out_h, out_w, n, - out_chw, c, ratio_h, ratio_w, align_corners, data_layout); + KeNearestNeighborInterpFw + <<>>( + input_data, in_h, in_w, n, in_chw, output_data, out_h, out_w, n, + out_chw, c, ratio_h, ratio_w, align_corners, data_layout); } else if ("bilinear" == interp_method) { KeBilinearInterpFw<<>>( input_data, in_h, in_w, n, in_chw, output_data, out_h, out_w, n, out_chw, c, ratio_h, ratio_w, align_corners, align_mode, data_layout); } else if ("bicubic" == interp_method) { - KeBicubicInterpFw<<>>( - input_data, in_h, in_w, n, in_chw, output_data, out_h, out_w, n, - out_chw, c, ratio_h, ratio_w, align_corners, data_layout); + KeBicubicInterpFw + <<>>( + input_data, in_h, in_w, n, in_chw, output_data, out_h, out_w, n, + out_chw, c, ratio_h, ratio_w, align_corners, data_layout); } } @@ -1051,15 +1055,18 @@ static void Interpolate3DCUDAFwd(const framework::ExecutionContext& ctx, out_w = size_data[2]; } } - PADDLE_ENFORCE_GT(out_d, 0, platform::errors::InvalidArgument( - "out_d in Attr(out_shape) of Op(interpolate) " - "should be greater than 0.")); - PADDLE_ENFORCE_GT(out_h, 0, platform::errors::InvalidArgument( - "out_h in Attr(out_shape) of Op(interpolate) " - "should be greater than 0.")); - PADDLE_ENFORCE_GT(out_w, 0, platform::errors::InvalidArgument( - "out_w in Attr(out_shape) of Op(interpolate) " - "should be greater than 0.")); + PADDLE_ENFORCE_GT(out_d, 0, + platform::errors::InvalidArgument( + "out_d in Attr(out_shape) of Op(interpolate) " + "should be greater than 0.")); + PADDLE_ENFORCE_GT(out_h, 0, + platform::errors::InvalidArgument( + "out_h in Attr(out_shape) of Op(interpolate) " + "should be greater than 0.")); + PADDLE_ENFORCE_GT(out_w, 0, + platform::errors::InvalidArgument( + "out_w in Attr(out_shape) of Op(interpolate) " + "should be greater than 0.")); framework::DDim dim_out; if (data_layout == DataLayout::kNCHW) { @@ -1271,11 +1278,11 @@ static void Interpolate2DCUDABwd(const framework::ExecutionContext& ctx, platform::GetGpuLaunchConfig1D(ctx.cuda_device_context(), pixelNum); if ("nearest" == interp_method) { - KeNearestNeighborInterpBw< - T><<>>( - input_grad_data, in_h, in_w, n, in_chw, output_grad_data, out_h, out_w, - n, out_chw, c, ratio_h, ratio_w, align_corners, data_layout); + KeNearestNeighborInterpBw + <<>>( + input_grad_data, in_h, in_w, n, in_chw, output_grad_data, out_h, + out_w, n, out_chw, c, ratio_h, ratio_w, align_corners, data_layout); } else if ("bilinear" == interp_method) { KeBilinearInterpBw<<>>( @@ -1283,10 +1290,10 @@ static void Interpolate2DCUDABwd(const framework::ExecutionContext& ctx, n, out_chw, c, ratio_h, ratio_w, align_corners, align_mode, data_layout); } else if ("bicubic" == interp_method) { - KeBicubicInterpBw<<>>( - input_grad_data, in_h, in_w, n, in_chw, output_grad_data, out_h, out_w, - n, out_chw, c, ratio_h, ratio_w, align_corners, data_layout); + KeBicubicInterpBw + <<>>( + input_grad_data, in_h, in_w, n, in_chw, output_grad_data, out_h, + out_w, n, out_chw, c, ratio_h, ratio_w, align_corners, data_layout); } } diff --git a/paddle/fluid/operators/interpolate_op.h b/paddle/fluid/operators/interpolate_op.h index 57b5eb553cc4c7a0b2318753ef0ba3b6d2f63880..18caed22b4855e68e7b0a0831b5b902a69aca25e 100644 --- a/paddle/fluid/operators/interpolate_op.h +++ b/paddle/fluid/operators/interpolate_op.h @@ -13,6 +13,7 @@ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/hostdevice.h" #include "paddle/phi/kernels/funcs/math_function.h" @@ -808,9 +809,10 @@ static void Interpolate1DCPUFwd(const framework::ExecutionContext& ctx, out_w = out_size_data[0]; } } - PADDLE_ENFORCE_GT(out_w, 0, platform::errors::InvalidArgument( - "out_w in Attr(out_shape) of Op(interpolate) " - "should be greater than 0.")); + PADDLE_ENFORCE_GT(out_w, 0, + platform::errors::InvalidArgument( + "out_w in Attr(out_shape) of Op(interpolate) " + "should be greater than 0.")); framework::DDim dim_out; if (data_layout == DataLayout::kNCHW) { dim_out = {n, c, out_w}; @@ -876,12 +878,14 @@ static void Interpolate2DCPUFwd(const framework::ExecutionContext& ctx, out_w = out_size_data[1]; } } - PADDLE_ENFORCE_GT(out_h, 0, platform::errors::InvalidArgument( - "out_h in Attr(out_shape) of Op(interpolate) " - "should be greater than 0.")); - PADDLE_ENFORCE_GT(out_w, 0, platform::errors::InvalidArgument( - "out_w in Attr(out_shape) of Op(interpolate) " - "should be greater than 0.")); + PADDLE_ENFORCE_GT(out_h, 0, + platform::errors::InvalidArgument( + "out_h in Attr(out_shape) of Op(interpolate) " + "should be greater than 0.")); + PADDLE_ENFORCE_GT(out_w, 0, + platform::errors::InvalidArgument( + "out_w in Attr(out_shape) of Op(interpolate) " + "should be greater than 0.")); framework::DDim dim_out; if (data_layout == DataLayout::kNCHW) { dim_out = {n, c, out_h, out_w}; @@ -964,15 +968,18 @@ static void Interpolate3DCPUFwd(const framework::ExecutionContext& ctx, out_w = out_size_data[2]; } } - PADDLE_ENFORCE_GT(out_d, 0, platform::errors::InvalidArgument( - "out_d in Attr(out_shape) of Op(interpolate) " - "should be greater than 0.")); - PADDLE_ENFORCE_GT(out_h, 0, platform::errors::InvalidArgument( - "out_h in Attr(out_shape) of Op(interpolate) " - "should be greater than 0.")); - PADDLE_ENFORCE_GT(out_w, 0, platform::errors::InvalidArgument( - "out_w in Attr(out_shape) of Op(interpolate) " - "should be greater than 0.")); + PADDLE_ENFORCE_GT(out_d, 0, + platform::errors::InvalidArgument( + "out_d in Attr(out_shape) of Op(interpolate) " + "should be greater than 0.")); + PADDLE_ENFORCE_GT(out_h, 0, + platform::errors::InvalidArgument( + "out_h in Attr(out_shape) of Op(interpolate) " + "should be greater than 0.")); + PADDLE_ENFORCE_GT(out_w, 0, + platform::errors::InvalidArgument( + "out_w in Attr(out_shape) of Op(interpolate) " + "should be greater than 0.")); framework::DDim dim_out; if (data_layout == DataLayout::kNCHW) { diff --git a/paddle/fluid/operators/interpolate_op_npu.cc b/paddle/fluid/operators/interpolate_op_npu.cc old mode 100755 new mode 100644 index f83f149b87c31463dccba9d4113c83a3cea1456d..0cbac393af504c3c8c3921e9dfbd2d059d48945f --- a/paddle/fluid/operators/interpolate_op_npu.cc +++ b/paddle/fluid/operators/interpolate_op_npu.cc @@ -12,9 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/interpolate_op.h" #include #include + +#include "paddle/fluid/operators/interpolate_op.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" namespace paddle { diff --git a/paddle/fluid/operators/interpolate_op_xpu.cc b/paddle/fluid/operators/interpolate_op_xpu.cc index 9576dc8452463d8df059782392d13582a030ff21..09780505ac2ce6caea63f56ee949dff7c32e9cbe 100644 --- a/paddle/fluid/operators/interpolate_op_xpu.cc +++ b/paddle/fluid/operators/interpolate_op_xpu.cc @@ -111,14 +111,16 @@ class InterpolateXPUKernel : public framework::OpKernel { out_w = out_size_data[1]; } } - PADDLE_ENFORCE_GT(out_h, 0, platform::errors::InvalidArgument( - "out_h in Attr(out_shape) of " - "Op(interpolate) " - "should be greater than 0.")); - PADDLE_ENFORCE_GT(out_w, 0, platform::errors::InvalidArgument( - "out_w in Attr(out_shape) of " - "Op(interpolate) " - "should be greater than 0.")); + PADDLE_ENFORCE_GT( + out_h, 0, + platform::errors::InvalidArgument("out_h in Attr(out_shape) of " + "Op(interpolate) " + "should be greater than 0.")); + PADDLE_ENFORCE_GT( + out_w, 0, + platform::errors::InvalidArgument("out_w in Attr(out_shape) of " + "Op(interpolate) " + "should be greater than 0.")); framework::DDim dim_out; if (data_layout == DataLayout::kNCHW) { dim_out = {n, c, out_h, out_w}; diff --git a/paddle/fluid/operators/interpolate_v2_op.cc b/paddle/fluid/operators/interpolate_v2_op.cc index d0d7b7694fc3a01fd8527c4e6a438f944ac0d6ff..6bac35ee1d45501b3d729d320c60842e8cc0c730 100644 --- a/paddle/fluid/operators/interpolate_v2_op.cc +++ b/paddle/fluid/operators/interpolate_v2_op.cc @@ -40,10 +40,11 @@ static void Interpolate1DInferShapeCheck(framework::InferShapeContext* ctx) { const DataLayout data_layout = framework::StringToDataLayout( ctx->Attrs().Get("data_layout")); for (int i = 0; i < dim_x.size(); ++i) { - PADDLE_ENFORCE_NE(dim_x[i], 0, platform::errors::InvalidArgument( - "The shape of input(x) should be larged " - "than 0, bug received shape[%d] is %d ", - i, dim_x[i])); + PADDLE_ENFORCE_NE(dim_x[i], 0, + platform::errors::InvalidArgument( + "The shape of input(x) should be larged " + "than 0, bug received shape[%d] is %d ", + i, dim_x[i])); } if (ctx->HasInputs("SizeTensor")) { // top prority size @@ -144,10 +145,11 @@ static void Interpolate2DInferShapeCheck(framework::InferShapeContext* ctx) { ctx->Attrs().Get("data_layout")); for (int i = 0; i < dim_x.size(); ++i) { - PADDLE_ENFORCE_NE(dim_x[i], 0, platform::errors::InvalidArgument( - "The shape of input(x) should be larged " - "than 0, bug received shape[%d] is %d ", - i, dim_x[i])); + PADDLE_ENFORCE_NE(dim_x[i], 0, + platform::errors::InvalidArgument( + "The shape of input(x) should be larged " + "than 0, bug received shape[%d] is %d ", + i, dim_x[i])); } if (ctx->HasInputs("SizeTensor")) { @@ -263,10 +265,11 @@ static void Interpolate3DInferShapeCheck(framework::InferShapeContext* ctx) { ctx->Attrs().Get("data_layout")); for (int i = 0; i < dim_x.size(); ++i) { - PADDLE_ENFORCE_NE(dim_x[i], 0, platform::errors::InvalidArgument( - "The shape of input(x) should be larged " - "than 0, bug received shape[%d] is %d ", - i, dim_x[i])); + PADDLE_ENFORCE_NE(dim_x[i], 0, + platform::errors::InvalidArgument( + "The shape of input(x) should be larged " + "than 0, bug received shape[%d] is %d ", + i, dim_x[i])); } if (ctx->HasInputs("SizeTensor")) { diff --git a/paddle/fluid/operators/interpolate_v2_op_npu.cc b/paddle/fluid/operators/interpolate_v2_op_npu.cc index 615b5ea142b583936c1a7f783f42779f2216d7a0..97f39aa49026411f3c3f25e3d931d1192954aa1b 100644 --- a/paddle/fluid/operators/interpolate_v2_op_npu.cc +++ b/paddle/fluid/operators/interpolate_v2_op_npu.cc @@ -12,9 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/platform/device/npu/npu_op_runner.h" - #include "paddle/fluid/framework/op_registry.h" +#include "paddle/fluid/platform/device/npu/npu_op_runner.h" #include "paddle/phi/kernels/funcs/interpolate_function.h" namespace paddle { diff --git a/paddle/fluid/operators/interpolate_v2_op_xpu.cc b/paddle/fluid/operators/interpolate_v2_op_xpu.cc index 9cbfc95158348371301abb1ed23189920ffc77e9..9d52c9a865ea75bc71da12368f297e9cf69fa9a7 100644 --- a/paddle/fluid/operators/interpolate_v2_op_xpu.cc +++ b/paddle/fluid/operators/interpolate_v2_op_xpu.cc @@ -114,14 +114,16 @@ class InterpolateV2XPUKernel : public framework::OpKernel { out_w = out_size_data[1]; } } - PADDLE_ENFORCE_GT(out_h, 0, platform::errors::InvalidArgument( - "out_h in Attr(out_shape) of " - "Op(interpolate) " - "should be greater than 0.")); - PADDLE_ENFORCE_GT(out_w, 0, platform::errors::InvalidArgument( - "out_w in Attr(out_shape) of " - "Op(interpolate) " - "should be greater than 0.")); + PADDLE_ENFORCE_GT( + out_h, 0, + platform::errors::InvalidArgument("out_h in Attr(out_shape) of " + "Op(interpolate) " + "should be greater than 0.")); + PADDLE_ENFORCE_GT( + out_w, 0, + platform::errors::InvalidArgument("out_w in Attr(out_shape) of " + "Op(interpolate) " + "should be greater than 0.")); framework::DDim dim_out; if (data_layout == DataLayout::kNCHW) { dim_out = {n, c, out_h, out_w}; diff --git a/paddle/fluid/operators/inverse_op.cc b/paddle/fluid/operators/inverse_op.cc index f5b817a0e11faa85ef4b1288d639b9f3b45d7638..c4f3fbb2ca77226614bf48971794086d57f2ba41 100644 --- a/paddle/fluid/operators/inverse_op.cc +++ b/paddle/fluid/operators/inverse_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/inverse_op.h" + #include #include diff --git a/paddle/fluid/operators/isfinite_op.cc b/paddle/fluid/operators/isfinite_op.cc index 2e770f98525697ef8625cd065dc14fd22ebe51d1..456c1c2d44f3e4e945dbe7a76b648168c6b1030c 100644 --- a/paddle/fluid/operators/isfinite_op.cc +++ b/paddle/fluid/operators/isfinite_op.cc @@ -120,15 +120,16 @@ namespace ops = paddle::operators; paddle::framework::EmptyGradOpMaker, \ paddle::framework::EmptyGradOpMaker) -#define REGISTER_OVERFLOW_CPU_KERNEL(op_type, functor) \ - REGISTER_OP_CPU_KERNEL( \ - op_type, ops::OverflowKernel, \ - ops::OverflowKernel, \ - ops::OverflowKernel, \ - ops::OverflowKernel, \ + ops::OverflowKernel, \ + ops::OverflowKernel, \ + ops::OverflowKernel); REGISTER_OP_MAKER(isinf, "isinf(X)"); diff --git a/paddle/fluid/operators/isfinite_op.cu b/paddle/fluid/operators/isfinite_op.cu index e233e3713649050e857be9918ef7816d18e1b6ed..d1437d5b44d6fa6a7b772239cca6f698436d2bca 100644 --- a/paddle/fluid/operators/isfinite_op.cu +++ b/paddle/fluid/operators/isfinite_op.cu @@ -18,8 +18,9 @@ namespace ops = paddle::operators; namespace plat = paddle::platform; REGISTER_OP_CUDA_KERNEL( - isinf, ops::OverflowKernel, + isinf, + ops::OverflowKernel, ops::OverflowKernel, ops::OverflowKernel); REGISTER_OP_CUDA_KERNEL( - isfinite, ops::OverflowKernel, + isfinite, + ops::OverflowKernel, ops::OverflowKernel, ops::OverflowKernel(upper - lower), (n - 1))); PADDLE_ENFORCE_GT( - n, 0, paddle::platform::errors::InvalidArgument( - "The Sgd size should be larger than 0. But the n is %d.", n)); + n, 0, + paddle::platform::errors::InvalidArgument( + "The Sgd size should be larger than 0. But the n is %d.", n)); std::vector all, out; for (int i = 0; i < n; ++i) { all.push_back(i); diff --git a/paddle/fluid/operators/jit/gen/act.cc b/paddle/fluid/operators/jit/gen/act.cc index 677e9979399c5e46fa0e9e1abe805429fe68d6af..5a73e3c56d5117849b9d929527e93cf79b6d2f2e 100644 --- a/paddle/fluid/operators/jit/gen/act.cc +++ b/paddle/fluid/operators/jit/gen/act.cc @@ -122,9 +122,8 @@ bool VTanhCreator::CanBeUsed(const int& d) const { } size_t VReluCreator::CodeSize(const int& d) const { - return 96 /* init size */ + - (d / YMM_FLOAT_BLOCK + 3) * 4 /* instructions */ * - 8 /* average bytes for each instruction */; + return 96 /* init size */ + (d / YMM_FLOAT_BLOCK + 3) * 4 /* instructions */ * + 8 /* average bytes for each instruction */; } size_t VSquareCreator::CodeSize(const int& d) const { diff --git a/paddle/fluid/operators/jit/gen/jitcode.h b/paddle/fluid/operators/jit/gen/jitcode.h index bd84368a573881e0eaba02d6d19d239985a42940..24434c5993bbb7797da0460cb0b1cebbdc512f40 100644 --- a/paddle/fluid/operators/jit/gen/jitcode.h +++ b/paddle/fluid/operators/jit/gen/jitcode.h @@ -16,6 +16,7 @@ #include #include + #include "paddle/fluid/operators/jit/gen_base.h" #include "paddle/fluid/platform/cpu_info.h" diff --git a/paddle/fluid/operators/jit/gen/matmul.cc b/paddle/fluid/operators/jit/gen/matmul.cc index 3b2139c9ed025745b2500512a27b653d3a2bfa67..9c859229c5a88077af5403fdf728a15cb766fc01 100644 --- a/paddle/fluid/operators/jit/gen/matmul.cc +++ b/paddle/fluid/operators/jit/gen/matmul.cc @@ -122,20 +122,23 @@ class MatMulCreator : public JitCodeCreator { std::unique_ptr CreateJitCode( const matmul_attr_t& attr) const override { PADDLE_ENFORCE_GT( - attr.m, 0, platform::errors::InvalidArgument( - "The attribute m (first matrix's row) of MatMul should " - "be larger than 0. But it is %d.", - attr.m)); + attr.m, 0, + platform::errors::InvalidArgument( + "The attribute m (first matrix's row) of MatMul should " + "be larger than 0. But it is %d.", + attr.m)); PADDLE_ENFORCE_GT( - attr.n, 0, platform::errors::InvalidArgument( - "The attribute n (first matrix's col) of MatMul should " - "be larger than 0. But it is %d.", - attr.n)); + attr.n, 0, + platform::errors::InvalidArgument( + "The attribute n (first matrix's col) of MatMul should " + "be larger than 0. But it is %d.", + attr.n)); PADDLE_ENFORCE_GT( - attr.k, 0, platform::errors::InvalidArgument( - "The attribute k (second matrix's col) of MatMul should " - "be larger than 0. But it is %d.", - attr.k)); + attr.k, 0, + platform::errors::InvalidArgument( + "The attribute k (second matrix's col) of MatMul should " + "be larger than 0. But it is %d.", + attr.k)); return make_unique(attr, CodeSize(attr)); } }; diff --git a/paddle/fluid/operators/jit/gen/matmul.h b/paddle/fluid/operators/jit/gen/matmul.h index eb7328d7e069cf05a22ec1ecee70f36280e6d231..af626326340248fcfd442d0c43e6a3f94ad63689 100644 --- a/paddle/fluid/operators/jit/gen/matmul.h +++ b/paddle/fluid/operators/jit/gen/matmul.h @@ -15,6 +15,7 @@ #pragma once #include // for malloc and free + #include #include @@ -33,10 +34,11 @@ class MatMulJitCode : public JitCode { size_t code_size = 256 * 1024, void* code_ptr = nullptr) : JitCode(code_size, code_ptr), m_(attr.m), n_(attr.n), k_(attr.k) { - PADDLE_ENFORCE_EQ(m_, 1, platform::errors::Unimplemented( - "Jitcode of matmul only support m==1 (first " - "matrix's row) now. But m is %d.", - m_)); + PADDLE_ENFORCE_EQ(m_, 1, + platform::errors::Unimplemented( + "Jitcode of matmul only support m==1 (first " + "matrix's row) now. But m is %d.", + m_)); this->genCode(); } diff --git a/paddle/fluid/operators/jit/gen/seqpool.cc b/paddle/fluid/operators/jit/gen/seqpool.cc index 52fdf04f3f6771a4a54d187ab2574619c1e333bd..4788050a14cd7fbdde627773d5c10dd52545d6c5 100644 --- a/paddle/fluid/operators/jit/gen/seqpool.cc +++ b/paddle/fluid/operators/jit/gen/seqpool.cc @@ -62,22 +62,23 @@ class SeqPoolCreator : public JitCodeCreator { return platform::MayIUse(platform::avx); } size_t CodeSize(const seq_pool_attr_t& attr) const override { - return 96 + - ((attr.w / YMM_FLOAT_BLOCK + 4 /* for rest */) * - 4 /* load, mul and save */ + - 256) * - 16; + return 96 + ((attr.w / YMM_FLOAT_BLOCK + 4 /* for rest */) * + 4 /* load, mul and save */ + + 256) * + 16; } std::unique_ptr CreateJitCode( const seq_pool_attr_t& attr) const override { - PADDLE_ENFORCE_GT(attr.w, 0, platform::errors::InvalidArgument( - "The attribute width of SeqPool should " - "be larger than 0. But it is %d.", - attr.w)); - PADDLE_ENFORCE_GT(attr.h, 0, platform::errors::InvalidArgument( - "The attribute height of SeqPool should " - "be larger than 0. But it is %d.", - attr.h)); + PADDLE_ENFORCE_GT(attr.w, 0, + platform::errors::InvalidArgument( + "The attribute width of SeqPool should " + "be larger than 0. But it is %d.", + attr.w)); + PADDLE_ENFORCE_GT(attr.h, 0, + platform::errors::InvalidArgument( + "The attribute height of SeqPool should " + "be larger than 0. But it is %d.", + attr.h)); return make_unique(attr, CodeSize(attr)); } }; diff --git a/paddle/fluid/operators/jit/gen_base.cc b/paddle/fluid/operators/jit/gen_base.cc index 5baafa11cfea08f02eb70f4e236df701cc869165..2a3c347c16a25b09a92ceff581ba5ca44192854b 100644 --- a/paddle/fluid/operators/jit/gen_base.cc +++ b/paddle/fluid/operators/jit/gen_base.cc @@ -15,6 +15,7 @@ #include "paddle/fluid/operators/jit/gen_base.h" #include + #include "paddle/fluid/memory/allocation/cpu_allocator.h" // for posix_memalign #include "paddle/fluid/platform/cpu_info.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/operators/jit/gen_base.h b/paddle/fluid/operators/jit/gen_base.h index c22a7f3ec9292cd9ea9f27b4304771d66f466190..761c52b7d7c7952efde2dd0f1f237e6b7433df86 100644 --- a/paddle/fluid/operators/jit/gen_base.h +++ b/paddle/fluid/operators/jit/gen_base.h @@ -17,8 +17,8 @@ #include // for unique_ptr #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/operators/jit/kernel_base.h" DECLARE_bool(dump_jitcode); diff --git a/paddle/fluid/operators/jit/helper.cc b/paddle/fluid/operators/jit/helper.cc index 46da6fba2e98a29a6453c970c056c2ed9c3e1be3..07d69658632a6d050061685d1bbbd20673609c54 100644 --- a/paddle/fluid/operators/jit/helper.cc +++ b/paddle/fluid/operators/jit/helper.cc @@ -13,7 +13,9 @@ * limitations under the License. */ #include "paddle/fluid/operators/jit/helper.h" + #include + #include "paddle/fluid/platform/enforce.h" namespace paddle { @@ -112,10 +114,11 @@ void pack_weights(const float* src, float* dst, int n, int k) { int block, rest; const auto groups = packed_groups(n, k, &block, &rest); std::for_each(groups.begin(), groups.end(), [&](int i) { - PADDLE_ENFORCE_GT(i, 0, platform::errors::InvalidArgument( - "Each element of groups should be larger than " - "0. However the element: %d doesn't satify.", - i)); + PADDLE_ENFORCE_GT(i, 0, + platform::errors::InvalidArgument( + "Each element of groups should be larger than " + "0. However the element: %d doesn't satify.", + i)); }); int sum = std::accumulate(groups.begin(), groups.end(), 0); std::memset(dst, 0, k * sum * block * sizeof(float)); diff --git a/paddle/fluid/operators/jit/kernel_base.h b/paddle/fluid/operators/jit/kernel_base.h index 9a48d9c3c8d6c9c0b294d7a8fa8523642b8497f7..0389828b49537bf76683681e63cc2229be63522d 100644 --- a/paddle/fluid/operators/jit/kernel_base.h +++ b/paddle/fluid/operators/jit/kernel_base.h @@ -14,6 +14,7 @@ #pragma once #include + #include "paddle/fluid/operators/jit/macro.h" #include "paddle/fluid/platform/macros.h" diff --git a/paddle/fluid/operators/jit/kernel_key.cc b/paddle/fluid/operators/jit/kernel_key.cc index 4f652002bc7455180b8eef6d4a5e111b3aa72dfb..528aec9ace1d396aeb35e99ce3717181304bb4e6 100644 --- a/paddle/fluid/operators/jit/kernel_key.cc +++ b/paddle/fluid/operators/jit/kernel_key.cc @@ -13,6 +13,7 @@ * limitations under the License. */ #include "paddle/fluid/operators/jit/kernel_key.h" + #include // XXH64: 13.8 GB/s namespace paddle { diff --git a/paddle/fluid/operators/jit/more/intrinsic/crf_decoding.cc b/paddle/fluid/operators/jit/more/intrinsic/crf_decoding.cc index 7e1f7ab8bf8b0950a15fd55a03b0d61a509591da..f11a690523bf82299e59db574e9224906a56d261 100644 --- a/paddle/fluid/operators/jit/more/intrinsic/crf_decoding.cc +++ b/paddle/fluid/operators/jit/more/intrinsic/crf_decoding.cc @@ -13,7 +13,9 @@ * limitations under the License. */ #include "paddle/fluid/operators/jit/more/intrinsic/crf_decoding.h" + #include + #include "paddle/fluid/operators/jit/registry.h" #include "paddle/fluid/platform/cpu_info.h" diff --git a/paddle/fluid/operators/jit/more/intrinsic/layer_norm.cc b/paddle/fluid/operators/jit/more/intrinsic/layer_norm.cc index 61d8c50c56825577eb7d085557ea0d63c634a166..ef8fe6963c0451797cb229ffc217ea17cc2352d9 100644 --- a/paddle/fluid/operators/jit/more/intrinsic/layer_norm.cc +++ b/paddle/fluid/operators/jit/more/intrinsic/layer_norm.cc @@ -13,7 +13,9 @@ * limitations under the License. */ #include "paddle/fluid/operators/jit/more/intrinsic/layer_norm.h" + #include + #include "paddle/fluid/operators/jit/registry.h" #include "paddle/fluid/platform/cpu_info.h" diff --git a/paddle/fluid/operators/jit/more/mix/mix.cc b/paddle/fluid/operators/jit/more/mix/mix.cc index a4459cee5b8a3402eaf29dd1dbf9124c8f229d6a..f0008d4152f53c4b154c9d597124adaf4596807c 100644 --- a/paddle/fluid/operators/jit/more/mix/mix.cc +++ b/paddle/fluid/operators/jit/more/mix/mix.cc @@ -13,6 +13,7 @@ * limitations under the License. */ #include "paddle/fluid/operators/jit/more/mix/mix.h" + #include "paddle/fluid/operators/jit/kernels.h" #include "paddle/fluid/operators/jit/registry.h" diff --git a/paddle/fluid/operators/jit/more/mkl/mkl.cc b/paddle/fluid/operators/jit/more/mkl/mkl.cc index 75ebddb125989b121b62d42b50e896eccd392a71..16bf045aa6671d385be589305a694377b411342e 100644 --- a/paddle/fluid/operators/jit/more/mkl/mkl.cc +++ b/paddle/fluid/operators/jit/more/mkl/mkl.cc @@ -13,6 +13,7 @@ * limitations under the License. */ #include "paddle/fluid/operators/jit/more/mkl/mkl.h" + #include "paddle/fluid/operators/jit/refer/refer.h" #include "paddle/fluid/operators/jit/registry.h" #include "paddle/fluid/platform/cpu_info.h" diff --git a/paddle/fluid/operators/jit/more/mkl/mkl.h b/paddle/fluid/operators/jit/more/mkl/mkl.h index 5f3c29ad5efb848f1fa12236ffe36a9f654864a3..ad04b4618cb4146786c73fb41daa55bcae6b85c5 100644 --- a/paddle/fluid/operators/jit/more/mkl/mkl.h +++ b/paddle/fluid/operators/jit/more/mkl/mkl.h @@ -117,10 +117,11 @@ void EmbSeqPool(const T* table, const int64_t* idx, T* out, "The idx shoud be lower than the attribute table_height of " "EmbSeqPool. But %dth of idx is %d and table_height is %d.", i, idx[i], attr->table_height)); - PADDLE_ENFORCE_GE(idx[i], 0, platform::errors::InvalidArgument( - "The idx shoud be equal to or larger than " - "the 0. But %dth of idx is %d.", - i, idx[i])); + PADDLE_ENFORCE_GE(idx[i], 0, + platform::errors::InvalidArgument( + "The idx shoud be equal to or larger than " + "the 0. But %dth of idx is %d.", + i, idx[i])); }; for (int64_t w = 0; w != attr->index_width; ++w) { @@ -204,11 +205,12 @@ void Sgd(const T* lr, const T* param, const T* grad, const int64_t* rows, "less than the attribute. But %dth of rows " "is %d and grad_width is %d.", i, h_idx, attr->param_height)); - PADDLE_ENFORCE_GE(h_idx, 0, platform::errors::InvalidArgument( - "The rows of Sgd should be " - "larger than 0. But %dth of rows " - "is %d.", - i, h_idx)); + PADDLE_ENFORCE_GE( + h_idx, 0, + platform::errors::InvalidArgument("The rows of Sgd should be " + "larger than 0. But %dth of rows " + "is %d.", + i, h_idx)); VAXPY(scalar, grad + i * width, out + h_idx * width, width); } } else { @@ -220,11 +222,12 @@ void Sgd(const T* lr, const T* param, const T* grad, const int64_t* rows, "less than the attribute. But %dth of rows " "is %d and grad_width is %d.", i, h_idx, attr->param_height)); - PADDLE_ENFORCE_GE(h_idx, 0, platform::errors::InvalidArgument( - "The rows of Sgd should be " - "larger than 0. But %dth of rows " - "is %d.", - i, h_idx)); + PADDLE_ENFORCE_GE( + h_idx, 0, + platform::errors::InvalidArgument("The rows of Sgd should be " + "larger than 0. But %dth of rows " + "is %d.", + i, h_idx)); VScal(&scalar, grad + i * width, out + h_idx * width, width); VAdd(param + h_idx * width, out + h_idx * width, out + h_idx * width, width); diff --git a/paddle/fluid/operators/jit/refer/refer.cc b/paddle/fluid/operators/jit/refer/refer.cc index 779d4c172b83c0422ab3ae5f4fa5c8a3b3cf2d9f..9919f2d46dd8b356978076495eff6c048325e37d 100644 --- a/paddle/fluid/operators/jit/refer/refer.cc +++ b/paddle/fluid/operators/jit/refer/refer.cc @@ -13,6 +13,7 @@ * limitations under the License. */ #include "paddle/fluid/operators/jit/refer/refer.h" + #include "paddle/fluid/operators/jit/registry.h" namespace refer = paddle::operators::jit::refer; diff --git a/paddle/fluid/operators/jit/refer/refer.h b/paddle/fluid/operators/jit/refer/refer.h index 79b2e174efc16024c96dcfb8dac33c0985d201dc..3f1e5b3235b25a7b4d7cea8451dc4c04fdcea186 100644 --- a/paddle/fluid/operators/jit/refer/refer.h +++ b/paddle/fluid/operators/jit/refer/refer.h @@ -481,10 +481,11 @@ void EmbSeqPool(const T* table, const int64_t* idx, T* out, "The idx shoud be lower than the attribute table_height of " "EmbSeqPool. But %dth of idx is %d and table_height is %d.", i, idx[i], attr->table_height)); - PADDLE_ENFORCE_GE(idx[i], 0, platform::errors::InvalidArgument( - "The idx shoud be equal to or larger than " - "the 0. But %dth of idx is %d.", - i, idx[i])); + PADDLE_ENFORCE_GE(idx[i], 0, + platform::errors::InvalidArgument( + "The idx shoud be equal to or larger than " + "the 0. But %dth of idx is %d.", + i, idx[i])); }; for (int64_t w = 0; w != attr->index_width; ++w) { @@ -539,11 +540,12 @@ void Sgd(const T* lr, const T* param, const T* grad, const int64_t* rows, "less than the attribute. But %dth of rows " "is %d and grad_width is %d.", i, h_idx, attr->param_height)); - PADDLE_ENFORCE_GE(h_idx, 0, platform::errors::InvalidArgument( - "The rows of Sgd should be " - "larger than 0. But %dth of rows " - "is %d.", - i, h_idx)); + PADDLE_ENFORCE_GE( + h_idx, 0, + platform::errors::InvalidArgument("The rows of Sgd should be " + "larger than 0. But %dth of rows " + "is %d.", + i, h_idx)); for (int64_t j = 0; j < attr->grad_width; ++j) { out[h_idx * attr->grad_width + j] = param[h_idx * attr->grad_width + j] - diff --git a/paddle/fluid/operators/jit/registry.h b/paddle/fluid/operators/jit/registry.h index 567a903236979ff4ac6095033f53d2a473f4eb2c..15d5e605b01bb7f181fbdfd956bb1fee87aff4c1 100644 --- a/paddle/fluid/operators/jit/registry.h +++ b/paddle/fluid/operators/jit/registry.h @@ -18,6 +18,7 @@ #include #include #include // for std::move + #include "paddle/fluid/operators/jit/kernel_base.h" #include "paddle/fluid/operators/jit/kernel_pool.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/operators/jit/test.cc b/paddle/fluid/operators/jit/test.cc index 74f2d62c64da947c9bf77832c5df48d54aa863a8..27e816248ab38e8a656c70bf0d037cd0f53ff063 100644 --- a/paddle/fluid/operators/jit/test.cc +++ b/paddle/fluid/operators/jit/test.cc @@ -286,48 +286,48 @@ void TestKernelLSTM() { ref(&step, &attr); VLOG(10) << attr; - auto verifier = []( - const typename KernelTuple::func_type tgt, - const std::vector& xsrc, const std::vector& wp, - const std::vector& ct_1, const std::vector& ct_ref, - const std::vector& ht_ref, - const typename KernelTuple::attr_type& attr) { - EXPECT_TRUE(tgt != nullptr); - EXPECT_EQ(ct_ref.size(), ht_ref.size()); - EXPECT_EQ(ct_1.size(), ht_ref.size()); - EXPECT_EQ(xsrc.size(), 4 * ht_ref.size()); - EXPECT_EQ(wp.size(), 3 * ht_ref.size()); - - // x could be changed after compute, so copy to save src - int d = ht_ref.size(); - std::vector x(xsrc.size()), ct(ct_ref.size()), - ht(ht_ref.size()); - std::vector checked(2 * d); - std::copy(xsrc.begin(), xsrc.end(), x.begin()); - - const T* ct_1_data = ct_1.data(); - const T* wp_data = wp.data(); - const T* ct_ref_data = ct_ref.data(); - const T* ht_ref_data = ht_ref.data(); - T* x_data = x.data(); - T* ct_data = ct.data(); - T* ht_data = ht.data(); - T* checked_data = checked.data(); - - jit::lstm_t step; - step.gates = x_data; - step.ct_1 = ct_1_data; - step.ct = ct_data; - step.ht = ht_data; - if (attr.use_peephole) { - step.wp = wp_data; - step.checked = checked_data; - } - - tgt(&step, &attr); - ExpectEQ(ct_data, ct_ref_data, d); - ExpectEQ(ht_data, ht_ref_data, d); - }; + auto verifier = + [](const typename KernelTuple::func_type tgt, + const std::vector& xsrc, const std::vector& wp, + const std::vector& ct_1, const std::vector& ct_ref, + const std::vector& ht_ref, + const typename KernelTuple::attr_type& attr) { + EXPECT_TRUE(tgt != nullptr); + EXPECT_EQ(ct_ref.size(), ht_ref.size()); + EXPECT_EQ(ct_1.size(), ht_ref.size()); + EXPECT_EQ(xsrc.size(), 4 * ht_ref.size()); + EXPECT_EQ(wp.size(), 3 * ht_ref.size()); + + // x could be changed after compute, so copy to save src + int d = ht_ref.size(); + std::vector x(xsrc.size()), ct(ct_ref.size()), + ht(ht_ref.size()); + std::vector checked(2 * d); + std::copy(xsrc.begin(), xsrc.end(), x.begin()); + + const T* ct_1_data = ct_1.data(); + const T* wp_data = wp.data(); + const T* ct_ref_data = ct_ref.data(); + const T* ht_ref_data = ht_ref.data(); + T* x_data = x.data(); + T* ct_data = ct.data(); + T* ht_data = ht.data(); + T* checked_data = checked.data(); + + jit::lstm_t step; + step.gates = x_data; + step.ct_1 = ct_1_data; + step.ct = ct_data; + step.ht = ht_data; + if (attr.use_peephole) { + step.wp = wp_data; + step.checked = checked_data; + } + + tgt(&step, &attr); + ExpectEQ(ct_data, ct_ref_data, d); + ExpectEQ(ht_data, ht_ref_data, d); + }; TestAllImpls(attr, verifier, xsrc, wp, ct_1, ct_ref, ht_ref, attr); } @@ -484,41 +484,42 @@ void TestKernelLayerNorm() { ref(x_data, outref_data, mean_data, var_data, scale_data, bias_data, left, epsilon, right); - auto verifier = []( - const typename KernelTuple::func_type tgt, const std::vector& x_, - const std::vector& outref_, const std::vector& mean_, - const std::vector& var_, const std::vector& scale, - const std::vector& bias, const int& left, const float& epsilon, - const typename KernelTuple::attr_type& right) { - EXPECT_TRUE(tgt != nullptr); - std::vector outtgt(outref_.size()); - std::vector x(x_.size()); - std::vector mean(mean_.size()); - std::vector var(var_.size()); - std::vector outref(outref_.size()); - std::copy(x_.begin(), x_.end(), x.begin()); - std::copy(mean_.begin(), mean_.end(), mean.begin()); - std::copy(var_.begin(), var_.end(), var.begin()); - std::copy(outref_.begin(), outref_.end(), outref.begin()); - - EXPECT_EQ(x.size(), static_cast(left * right)); - EXPECT_EQ(outref.size(), static_cast(left * right)); - EXPECT_EQ(mean.size(), static_cast(left)); - EXPECT_EQ(var.size(), static_cast(left)); - EXPECT_EQ(scale.size(), static_cast(right)); - EXPECT_EQ(bias.size(), static_cast(right)); - - const T* scale_data = scale.data(); - const T* bias_data = bias.data(); - T* x_data = x.data(); - T* mean_data = mean.data(); - T* var_data = var.data(); - T* outref_data = outref.data(); - T* outtgt_data = outtgt.data(); - tgt(x_data, outtgt_data, mean_data, var_data, scale_data, bias_data, - left, epsilon, right); - ExpectEQ(outtgt_data, outref_data, left * right); - }; + auto verifier = + [](const typename KernelTuple::func_type tgt, + const std::vector& x_, const std::vector& outref_, + const std::vector& mean_, const std::vector& var_, + const std::vector& scale, const std::vector& bias, + const int& left, const float& epsilon, + const typename KernelTuple::attr_type& right) { + EXPECT_TRUE(tgt != nullptr); + std::vector outtgt(outref_.size()); + std::vector x(x_.size()); + std::vector mean(mean_.size()); + std::vector var(var_.size()); + std::vector outref(outref_.size()); + std::copy(x_.begin(), x_.end(), x.begin()); + std::copy(mean_.begin(), mean_.end(), mean.begin()); + std::copy(var_.begin(), var_.end(), var.begin()); + std::copy(outref_.begin(), outref_.end(), outref.begin()); + + EXPECT_EQ(x.size(), static_cast(left * right)); + EXPECT_EQ(outref.size(), static_cast(left * right)); + EXPECT_EQ(mean.size(), static_cast(left)); + EXPECT_EQ(var.size(), static_cast(left)); + EXPECT_EQ(scale.size(), static_cast(right)); + EXPECT_EQ(bias.size(), static_cast(right)); + + const T* scale_data = scale.data(); + const T* bias_data = bias.data(); + T* x_data = x.data(); + T* mean_data = mean.data(); + T* var_data = var.data(); + T* outref_data = outref.data(); + T* outtgt_data = outtgt.data(); + tgt(x_data, outtgt_data, mean_data, var_data, scale_data, + bias_data, left, epsilon, right); + ExpectEQ(outtgt_data, outref_data, left * right); + }; TestAllImpls(right, verifier, x, outref, mean, var, scale, bias, left, epsilon, right); @@ -548,11 +549,12 @@ void TestKernelCRFDecoding() { ref(seq_len, (const T*)x.data(), (const T*)w.data(), alpharef.data(), trackref.data(), tag_num); - auto verifier = []( - const typename KernelTuple::func_type tgt, const int& seq_len, - const std::vector& x, const std::vector& w, - const std::vector& alpharef, const std::vector& trackref, - const typename KernelTuple::attr_type& tag_num) { + auto verifier = [](const typename KernelTuple::func_type tgt, + const int& seq_len, const std::vector& x, + const std::vector& w, + const std::vector& alpharef, + const std::vector& trackref, + const typename KernelTuple::attr_type& tag_num) { constexpr int state_trans_base_idx = 2; EXPECT_TRUE(tgt != nullptr); EXPECT_EQ(x.size(), static_cast(seq_len * tag_num)); @@ -878,12 +880,13 @@ void TestKernelAdam() { mom2.data(), param.data(), mom1_out.data(), mom2_out.data(), param_out.data()); - auto verifier = []( - const typename KernelTuple::func_type tgt, T beta1, T beta2, T lr, T eps, - int64_t numel, const std::vector& grad, const std::vector& mom1, - const std::vector& mom2, const std::vector& param, - const std::vector& ref_mom1_out, const std::vector& ref_mom2_out, - const std::vector& ref_param_out) { + auto verifier = [](const typename KernelTuple::func_type tgt, T beta1, + T beta2, T lr, T eps, int64_t numel, + const std::vector& grad, const std::vector& mom1, + const std::vector& mom2, const std::vector& param, + const std::vector& ref_mom1_out, + const std::vector& ref_mom2_out, + const std::vector& ref_param_out) { EXPECT_TRUE(tgt != nullptr); EXPECT_EQ(param.size(), static_cast(numel)); EXPECT_EQ(grad.size(), static_cast(numel)); @@ -944,30 +947,31 @@ void TestKernelAdamW() { grad.data(), mom1.data(), mom2.data(), param.data(), mom1_out.data(), mom2_out.data(), param_out.data()); - auto verifier = []( - const typename KernelTuple::func_type tgt, T beta1, T beta2, T lr, T eps, - T old_lr, T lr_ratio, T coeff, int64_t numel, const std::vector& grad, - const std::vector& mom1, const std::vector& mom2, - const std::vector& param, const std::vector& ref_mom1_out, - const std::vector& ref_mom2_out, const std::vector& ref_param_out) { - EXPECT_TRUE(tgt != nullptr); - EXPECT_EQ(param.size(), static_cast(numel)); - EXPECT_EQ(grad.size(), static_cast(numel)); - EXPECT_EQ(mom1.size(), static_cast(numel)); - EXPECT_EQ(mom2.size(), static_cast(numel)); - - std::vector jit_mom1_out(ref_mom1_out.size()); - std::vector jit_mom2_out(ref_mom2_out.size()); - std::vector jit_param_out(ref_param_out.size()); - - tgt(beta1, beta2, -lr, eps, old_lr, lr_ratio, coeff, numel, grad.data(), - mom1.data(), mom2.data(), param.data(), jit_mom1_out.data(), - jit_mom2_out.data(), jit_param_out.data()); - - ExpectEQ(ref_mom1_out.data(), jit_mom1_out.data(), numel); - ExpectEQ(ref_mom2_out.data(), jit_mom2_out.data(), numel); - ExpectEQ(ref_param_out.data(), jit_param_out.data(), numel); - }; + auto verifier = + [](const typename KernelTuple::func_type tgt, T beta1, T beta2, T lr, + T eps, T old_lr, T lr_ratio, T coeff, int64_t numel, + const std::vector& grad, const std::vector& mom1, + const std::vector& mom2, const std::vector& param, + const std::vector& ref_mom1_out, const std::vector& ref_mom2_out, + const std::vector& ref_param_out) { + EXPECT_TRUE(tgt != nullptr); + EXPECT_EQ(param.size(), static_cast(numel)); + EXPECT_EQ(grad.size(), static_cast(numel)); + EXPECT_EQ(mom1.size(), static_cast(numel)); + EXPECT_EQ(mom2.size(), static_cast(numel)); + + std::vector jit_mom1_out(ref_mom1_out.size()); + std::vector jit_mom2_out(ref_mom2_out.size()); + std::vector jit_param_out(ref_param_out.size()); + + tgt(beta1, beta2, -lr, eps, old_lr, lr_ratio, coeff, numel, grad.data(), + mom1.data(), mom2.data(), param.data(), jit_mom1_out.data(), + jit_mom2_out.data(), jit_param_out.data()); + + ExpectEQ(ref_mom1_out.data(), jit_mom1_out.data(), numel); + ExpectEQ(ref_mom2_out.data(), jit_mom2_out.data(), numel); + ExpectEQ(ref_param_out.data(), jit_param_out.data(), numel); + }; TestAllImpls( 1, verifier, beta1, beta2, learning_rate, eps, old_lr, lr_ratio, coeff, @@ -988,8 +992,9 @@ void TestKernelSgd() { "and n-1 is %d.", static_cast(upper - lower), n - 1)); PADDLE_ENFORCE_GT( - n, 0, paddle::platform::errors::InvalidArgument( - "The Sgd size should be larger than 0. But the n is %d.", n)); + n, 0, + paddle::platform::errors::InvalidArgument( + "The Sgd size should be larger than 0. But the n is %d.", n)); std::vector all, out; for (int i = 0; i < n; ++i) { all.push_back(i); @@ -1031,11 +1036,12 @@ void TestKernelSgd() { grad_w); } - auto verifier = []( - const typename KernelTuple::func_type tgt, const T lr, - const std::vector& param, const std::vector& grad, - const std::vector& rows, const std::vector& oref, - const typename KernelTuple::attr_type& attr) { + auto verifier = [](const typename KernelTuple::func_type tgt, + const T lr, const std::vector& param, + const std::vector& grad, + const std::vector& rows, + const std::vector& oref, + const typename KernelTuple::attr_type& attr) { EXPECT_TRUE(tgt != nullptr); EXPECT_EQ(param.size(), static_cast(attr.param_height * attr.param_width)); diff --git a/paddle/fluid/operators/kernel_primitives/kernel_primitives.h b/paddle/fluid/operators/kernel_primitives/kernel_primitives.h index 169befc88f28d0697018d4f36d0230a53676f037..82de4c82d1121b817ead8d70576c0a1df6dd1f4f 100644 --- a/paddle/fluid/operators/kernel_primitives/kernel_primitives.h +++ b/paddle/fluid/operators/kernel_primitives/kernel_primitives.h @@ -19,4 +19,4 @@ namespace paddle { namespace operators { namespace kernel_primitives = phi::kps; } -} +} // namespace paddle diff --git a/paddle/fluid/operators/kldiv_loss_op.cc b/paddle/fluid/operators/kldiv_loss_op.cc index 67c1942ea0b41e480c524f9c188b2a82649ba44e..8597c21b3ec97255f3b1675141e680aefe283d02 100644 --- a/paddle/fluid/operators/kldiv_loss_op.cc +++ b/paddle/fluid/operators/kldiv_loss_op.cc @@ -11,6 +11,7 @@ #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/infermeta/binary.h" diff --git a/paddle/fluid/operators/kldiv_loss_op_npu.cc b/paddle/fluid/operators/kldiv_loss_op_npu.cc index eac181489aa9d09f4661c898b13e77570ad928a8..41499f3f7bf8bc79d84af8063ec3bc3013674014 100644 --- a/paddle/fluid/operators/kldiv_loss_op_npu.cc +++ b/paddle/fluid/operators/kldiv_loss_op_npu.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the Licnse. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" diff --git a/paddle/fluid/operators/kthvalue_op.cc b/paddle/fluid/operators/kthvalue_op.cc index 4c679d30263863c70176bebb686556af056068d0..1ff9ab796e9d91223be32de64e0182175fe503a5 100644 --- a/paddle/fluid/operators/kthvalue_op.cc +++ b/paddle/fluid/operators/kthvalue_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/generator.h" #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/l1_norm_op.cc b/paddle/fluid/operators/l1_norm_op.cc index ddd0554add5105b0e682c6cb2e42ac4ec936c448..7a6a28a33c13c397901e60a94c67600f9bc457ad 100644 --- a/paddle/fluid/operators/l1_norm_op.cc +++ b/paddle/fluid/operators/l1_norm_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/l1_norm_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/label_smooth_op.cc b/paddle/fluid/operators/label_smooth_op.cc index 7e07610db2875d45aa250ab084e0eaf493dc7034..e14e61006478e142d5323d36611ead74ff5aa075 100644 --- a/paddle/fluid/operators/label_smooth_op.cc +++ b/paddle/fluid/operators/label_smooth_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/layer_norm_kernel.cu.h b/paddle/fluid/operators/layer_norm_kernel.cu.h index 0c5946b4ae411ce076556521f8d7aabcf6e65f6c..ac20a5962f394e7f016c2b9db190a660c1ee430f 100644 --- a/paddle/fluid/operators/layer_norm_kernel.cu.h +++ b/paddle/fluid/operators/layer_norm_kernel.cu.h @@ -661,7 +661,7 @@ __global__ __launch_bounds__(THREADS_PER_CTA) void fused_ln_bwd_1024_kernel( * output is [1, 1024]. * #blocks: 32 * #threads: 512 -*/ + */ // todo(@limin29): to think if there are better impl strategies template < typename U, typename ScaleT = U, int VecSize = 1, int WARPS_M = 16, @@ -783,16 +783,16 @@ __global__ __launch_bounds__(THREADS_PER_CTA) void ln_bwd_1024_final_kernel( } /* This function support two kinds of computations (only for float and fp16 -* type): -* -* Case-1: compute layer_norm_grad for layernorm op by setting mask_ptr and -* d_dropout_src_ptr to nullptr. Here, d_x_ptr returns the grad of layernorm -* input. -* -* Case-2: compute layer_norm_grad + residual_grad + dropout_grad for -* fused_dropout_residual_layernorm op. Here, dx_ptr returns residual_grad. -* -*/ + * type): + * + * Case-1: compute layer_norm_grad for layernorm op by setting mask_ptr and + * d_dropout_src_ptr to nullptr. Here, d_x_ptr returns the grad of layernorm + * input. + * + * Case-2: compute layer_norm_grad + residual_grad + dropout_grad for + * fused_dropout_residual_layernorm op. Here, dx_ptr returns residual_grad. + * + */ template void ln_bwd_1024_kernel_driver(const phi::GPUContext &dev_ctx, const int rows, @@ -839,19 +839,19 @@ void ln_bwd_1024_kernel_driver(const phi::GPUContext &dev_ctx, const int rows, "To compute fused_dropout_residual_ln grad, d_dropout_src_ptr " "can't be null")); } - fused_ln_bwd_1024_kernel< - true, T, U, ScaleT, MaskType, VecSize, WARPS_M, WARPS_N, - BYTES_PER_LDG><<>>( - rows, epsilon, x_ptr, scale_ptr, mean_ptr, var_ptr, dout_ptr, - dscale_temp_ptr, dbias_temp_ptr, dx_ptr, mask_ptr, factor, - d_dropout_src_ptr); + fused_ln_bwd_1024_kernel + <<>>( + rows, epsilon, x_ptr, scale_ptr, mean_ptr, var_ptr, dout_ptr, + dscale_temp_ptr, dbias_temp_ptr, dx_ptr, mask_ptr, factor, + d_dropout_src_ptr); } else { - fused_ln_bwd_1024_kernel< - false, T, U, ScaleT, MaskType, VecSize, WARPS_M, WARPS_N, - BYTES_PER_LDG><<>>( - rows, epsilon, x_ptr, scale_ptr, mean_ptr, var_ptr, dout_ptr, - dscale_temp_ptr, dbias_temp_ptr, dx_ptr); + fused_ln_bwd_1024_kernel + <<>>( + rows, epsilon, x_ptr, scale_ptr, mean_ptr, var_ptr, dout_ptr, + dscale_temp_ptr, dbias_temp_ptr, dx_ptr); } const int WARPS_M_2 = 16; const int WARPS_N_2 = 1; @@ -873,10 +873,10 @@ void ln_bwd_1024_kernel_driver(const phi::GPUContext &dev_ctx, const int rows, PADDLE_THROW(platform::errors::InvalidArgument( "Only support float and fp16 type")); } else { - ln_bwd_1024_final_kernel< - U, ScaleT, VecSize_2, WARPS_M_2, WARPS_N_2, - BYTES_PER_LDG_2><<>>( - gridx, dscale_temp_ptr, dbias_temp_ptr, dscale_ptr, dbias_ptr); + ln_bwd_1024_final_kernel + <<>>( + gridx, dscale_temp_ptr, dbias_temp_ptr, dscale_ptr, dbias_ptr); } } else { PADDLE_THROW(platform::errors::InvalidArgument( @@ -1387,16 +1387,17 @@ static void LayerNormBackward( if (gradient_flag == 0) return; if (batch_size == 1) { - LayerNormBackwardWhenBatchSizeIsOne<<< - (feature_size + kMaxBlockDim - 1) / kMaxBlockDim, kMaxBlockDim, 0, - stream>>>(x, d_y, d_x, d_scale, d_bias, mean, var, scale, epsilon, - feature_size); + LayerNormBackwardWhenBatchSizeIsOne + <<<(feature_size + kMaxBlockDim - 1) / kMaxBlockDim, kMaxBlockDim, 0, + stream>>>(x, d_y, d_x, d_scale, d_bias, mean, var, scale, epsilon, + feature_size); if (d_x != nullptr) { switch (GetDesiredBlockDim(feature_size)) { - FIXED_BLOCK_DIM_CASE(LayerNormBackwardPostProcessToCalculateDX< - T, U, kBlockDim><<<1, kBlockDim, 0, stream>>>( - x, d_x, mean, var, epsilon, feature_size)); + FIXED_BLOCK_DIM_CASE( + LayerNormBackwardPostProcessToCalculateDX + <<<1, kBlockDim, 0, stream>>>(x, d_x, mean, var, epsilon, + feature_size)); } } return; @@ -1408,9 +1409,9 @@ static void LayerNormBackward( switch (block_dim) { FIXED_BLOCK_DIM_FIXED_BLOCK_NUM_CASE( feature_size, kMaxBlockNum, - LayerNormBackwardGradientScaleOrBias< - T, U, kBlockDim, false, false, - ScaleBiasWithSameTypeX><<>>( + LayerNormBackwardGradientScaleOrBias + <<>>( x, d_y, d_scale, d_bias, d_x, mean, var, scale, epsilon, batch_size, feature_size, col_offset)); } @@ -1419,9 +1420,9 @@ static void LayerNormBackward( switch (block_dim) { FIXED_BLOCK_DIM_FIXED_BLOCK_NUM_CASE( feature_size, kMaxBlockNum, - LayerNormBackwardGradientScaleOrBias< - T, U, kBlockDim, false, true, - ScaleBiasWithSameTypeX><<>>( + LayerNormBackwardGradientScaleOrBias + <<>>( x, d_y, d_scale, d_bias, d_x, mean, var, scale, epsilon, batch_size, feature_size, col_offset)); } @@ -1430,9 +1431,9 @@ static void LayerNormBackward( switch (block_dim) { FIXED_BLOCK_DIM_FIXED_BLOCK_NUM_CASE( feature_size, kMaxBlockNum, - LayerNormBackwardGradientAll< - T, U, kBlockDim, false, - ScaleBiasWithSameTypeX><<>>( + LayerNormBackwardGradientAll + <<>>( x, d_y, d_scale, d_bias, d_x, mean, var, scale, epsilon, batch_size, feature_size, col_offset)); } @@ -1440,9 +1441,9 @@ static void LayerNormBackward( case 4: // d_x != nullptr, d_scale == nullptr, d_bias == nullptr switch (GetDesiredBlockDim(feature_size)) { FIXED_BLOCK_DIM_CASE( - LayerNormBackwardGradientOnlyDX< - T, U, kBlockDim, - ScaleBiasWithSameTypeX><<>>( + LayerNormBackwardGradientOnlyDX + <<>>( x, d_y, d_x, mean, var, scale, epsilon, feature_size)); } break; @@ -1450,34 +1451,34 @@ static void LayerNormBackward( switch (block_dim) { FIXED_BLOCK_DIM_FIXED_BLOCK_NUM_CASE( feature_size, kMaxBlockNum, - LayerNormBackwardGradientScaleOrBias< - T, U, kBlockDim, true, false, - ScaleBiasWithSameTypeX><<>>( + LayerNormBackwardGradientScaleOrBias + <<>>( x, d_y, d_scale, d_bias, d_x, mean, var, scale, epsilon, batch_size, feature_size, col_offset)); } switch (GetDesiredBlockDim(feature_size)) { FIXED_BLOCK_DIM_CASE( - LayerNormBackwardPostProcessToCalculateDX< - T, U, kBlockDim><<>>( - x, d_x, mean, var, epsilon, feature_size)); + LayerNormBackwardPostProcessToCalculateDX + <<>>(x, d_x, mean, var, epsilon, + feature_size)); } break; case 6: // d_x != nullptr, d_scale != nullptr, d_bias == nullptr switch (block_dim) { FIXED_BLOCK_DIM_FIXED_BLOCK_NUM_CASE( feature_size, kMaxBlockNum, - LayerNormBackwardGradientScaleOrBias< - T, U, kBlockDim, true, true, - ScaleBiasWithSameTypeX><<>>( + LayerNormBackwardGradientScaleOrBias + <<>>( x, d_y, d_scale, d_bias, d_x, mean, var, scale, epsilon, batch_size, feature_size, col_offset)); } switch (GetDesiredBlockDim(feature_size)) { FIXED_BLOCK_DIM_CASE( - LayerNormBackwardPostProcessToCalculateDX< - T, U, kBlockDim><<>>( - x, d_x, mean, var, epsilon, feature_size)); + LayerNormBackwardPostProcessToCalculateDX + <<>>(x, d_x, mean, var, epsilon, + feature_size)); } break; case 7: // d_x != nullptr, d_scale != nullptr, d_bias != nullptr @@ -1511,29 +1512,30 @@ static void LayerNormBackward( U *part_grad_gamma = reinterpret_cast(part_grad_gamma_ptr->ptr()); U *part_grad_beta = reinterpret_cast(part_grad_beta_ptr->ptr()); - LayerNormBackwardPartGradGammaBeta< - T, U, BDIMX2, BDIMY2, VPT><<>>( - d_y, x, batch_size, feature_size, mean, var, epsilon, - part_grad_gamma, - part_grad_beta); // compute part_grad_gamma, beta + LayerNormBackwardPartGradGammaBeta + <<>>( + d_y, x, batch_size, feature_size, mean, var, epsilon, + part_grad_gamma, + part_grad_beta); // compute part_grad_gamma, beta constexpr int BDIMX3 = 32; constexpr int BDIMY3 = 8; dim3 threads3(BDIMX3, BDIMY3, 1); const dim3 blocks3((feature_size + BDIMX2 - 1) / BDIMX2, 1, 1); - LayerNormBackwardSumGradGammaBeta< - T, U, BDIMX3, BDIMY3, - ScaleBiasWithSameTypeX><<>>( - part_grad_gamma, part_grad_beta, part_size, batch_size, - feature_size, d_scale, d_bias); + LayerNormBackwardSumGradGammaBeta + <<>>(part_grad_gamma, part_grad_beta, + part_size, batch_size, + feature_size, d_scale, d_bias); constexpr int BDIMX1 = 32; constexpr int BDIMY1 = 4; dim3 threads1(BDIMX1, BDIMY1, 1); - LayerNormBackwardComputeGradInput< - T, U, BDIMX1, BDIMY1, - ScaleBiasWithSameTypeX><<>>( - d_y, x, batch_size, feature_size, mean, var, epsilon, scale, d_x); + LayerNormBackwardComputeGradInput + <<>>(d_y, x, batch_size, + feature_size, mean, var, + epsilon, scale, d_x); #ifdef PADDLE_WITH_CUDA } #endif diff --git a/paddle/fluid/operators/layer_norm_op.cc b/paddle/fluid/operators/layer_norm_op.cc index 224ab748dab6cdf8be246c4b400b4e55b6faf675..3d1e563ef1aca2c91c81c8bcc3862eba31e6054f 100644 --- a/paddle/fluid/operators/layer_norm_op.cc +++ b/paddle/fluid/operators/layer_norm_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" #ifdef PADDLE_WITH_MKLDNN diff --git a/paddle/fluid/operators/layer_norm_op_xpu.cc b/paddle/fluid/operators/layer_norm_op_xpu.cc index 3b21a55f8df0dbb532729cf5cbca4c7362223b9c..a27952c57f7fae4dacfcd049ea2402417b3f0278 100644 --- a/paddle/fluid/operators/layer_norm_op_xpu.cc +++ b/paddle/fluid/operators/layer_norm_op_xpu.cc @@ -88,8 +88,9 @@ class LayerNormGradXPUKernel : public framework::OpKernel { auto* dscale_data = (dscale == nullptr ? nullptr : dscale->mutable_data(ctx.GetPlace())); - auto* dbias_data = (dbias == nullptr ? nullptr : dbias->mutable_data( - ctx.GetPlace())); + auto* dbias_data = + (dbias == nullptr ? nullptr + : dbias->mutable_data(ctx.GetPlace())); auto* dx_data = (dx == nullptr ? nullptr : dx->mutable_data(ctx.GetPlace())); auto& dev_ctx = ctx.template device_context(); diff --git a/paddle/fluid/operators/layout_utils.h b/paddle/fluid/operators/layout_utils.h index e304f33d0455ad5d7f9fbef067a84965f9e71aac..f058afdb4adc3820bd662167fe906a863910df80 100644 --- a/paddle/fluid/operators/layout_utils.h +++ b/paddle/fluid/operators/layout_utils.h @@ -18,6 +18,7 @@ #include #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/linear_chain_crf_op.h b/paddle/fluid/operators/linear_chain_crf_op.h index 7308363b9fe0ddb299a287052f5b47afe63e5a01..a6ef87d43e2d4b15631c0eb422b62ccb9d706324 100644 --- a/paddle/fluid/operators/linear_chain_crf_op.h +++ b/paddle/fluid/operators/linear_chain_crf_op.h @@ -28,9 +28,10 @@ static inline T NormalizeL1(T* x, size_t len) { // Right now, we just bet that sum won't be zero. If this really happens, we // will figure out what should be done then. PADDLE_ENFORCE_GT( - sum, 0., platform::errors::InvalidArgument( - "The unnormalized probabilities of all possible unfinished " - "sequences must be greater than 0.")); + sum, 0., + platform::errors::InvalidArgument( + "The unnormalized probabilities of all possible unfinished " + "sequences must be greater than 0.")); T s = 1. / sum; for (size_t i = 0; i < len; ++i) x[i] *= s; return sum; @@ -44,8 +45,8 @@ struct ScalarMul { T scalar; }; -using framework::LoDTensor; using framework::LoD; +using framework::LoDTensor; using framework::Tensor; template diff --git a/paddle/fluid/operators/linspace_op.cc b/paddle/fluid/operators/linspace_op.cc index e9375be1706eb462f4bbc12fafc034e9e5cdd68b..5e451d99dbc85318f62f684c51af0fc73640c6c4 100644 --- a/paddle/fluid/operators/linspace_op.cc +++ b/paddle/fluid/operators/linspace_op.cc @@ -77,10 +77,9 @@ REGISTER_OPERATOR( paddle::framework::EmptyGradOpMaker, LinspaceInferShapeFunctor); -REGISTER_OP_VERSION(linspace) - .AddCheckpoint( - R"ROC( +REGISTER_OP_VERSION(linspace).AddCheckpoint( + R"ROC( Upgrade linspace to add a new attribute [dtype]. )ROC", - paddle::framework::compatible::OpVersionDesc().NewAttr( - "dtype", "In order to change output data type ", 5)); + paddle::framework::compatible::OpVersionDesc().NewAttr( + "dtype", "In order to change output data type ", 5)); diff --git a/paddle/fluid/operators/lite/lite_engine_op.cc b/paddle/fluid/operators/lite/lite_engine_op.cc index 7a879c1e21642df8f7ddac6b3627a6cb999bfad9..0ec1c55f7abeeef2644954981d1f6a71ecd498db 100644 --- a/paddle/fluid/operators/lite/lite_engine_op.cc +++ b/paddle/fluid/operators/lite/lite_engine_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/lite/lite_engine_op.h" + #include #include diff --git a/paddle/fluid/operators/lite/lite_engine_op.h b/paddle/fluid/operators/lite/lite_engine_op.h index 5d2a1683d381b40f9344a379618a61afc3e728d3..240f6b06325f4b8d5ccb0a74621b56ba2601111f 100644 --- a/paddle/fluid/operators/lite/lite_engine_op.h +++ b/paddle/fluid/operators/lite/lite_engine_op.h @@ -26,11 +26,10 @@ limitations under the License. */ #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/inference/analysis/helper.h" -#include "paddle/fluid/platform/device/gpu/gpu_info.h" - #include "paddle/fluid/inference/lite/engine.h" #include "paddle/fluid/inference/lite/tensor_utils.h" #include "paddle/fluid/inference/utils/singleton.h" +#include "paddle/fluid/platform/device/gpu/gpu_info.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/lite/lite_engine_op_test.cc b/paddle/fluid/operators/lite/lite_engine_op_test.cc index 01583cea3122267de9294bfd7f68c063cbb29cf1..c38386365f3dcf14bdf0ba555f85fde6a601e488 100644 --- a/paddle/fluid/operators/lite/lite_engine_op_test.cc +++ b/paddle/fluid/operators/lite/lite_engine_op_test.cc @@ -12,6 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include "paddle/fluid/operators/lite/lite_engine_op.h" + #include #include "paddle/fluid/framework/block_desc.h" @@ -19,13 +21,12 @@ #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/scope.h" #include "paddle/fluid/inference/utils/singleton.h" -#include "paddle/fluid/operators/lite/lite_engine_op.h" #include "paddle/fluid/operators/lite/ut_helper.h" USE_NO_KERNEL_OP(lite_engine) -using paddle::inference::lite::AddTensorToBlockDesc; using paddle::inference::lite::AddFetchListToBlockDesc; +using paddle::inference::lite::AddTensorToBlockDesc; using paddle::inference::lite::CreateTensor; using paddle::inference::lite::serialize_params; namespace paddle { diff --git a/paddle/fluid/operators/load_combine_op.cc b/paddle/fluid/operators/load_combine_op.cc index 374bfa73f21870ae630043983466601920b53f6f..94797b08ade807f909dde6b1300b123f4bc7a5c5 100644 --- a/paddle/fluid/operators/load_combine_op.cc +++ b/paddle/fluid/operators/load_combine_op.cc @@ -12,11 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/operators/load_combine_op.h" + #include #include -#include "paddle/fluid/operators/load_combine_op.h" - namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/load_op.cc b/paddle/fluid/operators/load_op.cc index ba19aee9b8d7621703cfe0ac7da24d5bde2b5339..196792707ebbdbadf5e5e4bb49012fb1964d43f7 100644 --- a/paddle/fluid/operators/load_op.cc +++ b/paddle/fluid/operators/load_op.cc @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include - #include "paddle/fluid/operators/load_op.h" +#include + namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/lod_reset_op.cc b/paddle/fluid/operators/lod_reset_op.cc index 5616309683365c30fea9907268ed87a6f2cd4a8d..616aad2b976911468680ff82c8fe75933909366f 100644 --- a/paddle/fluid/operators/lod_reset_op.cc +++ b/paddle/fluid/operators/lod_reset_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/lod_reset_op.h" + #include #include diff --git a/paddle/fluid/operators/lod_reset_op.h b/paddle/fluid/operators/lod_reset_op.h index 642c8bcd9ae496d78f1894d2e80ffac9f5581f4b..f6f7155f37c3a2172193e9cdba0bf6be7c815cd3 100644 --- a/paddle/fluid/operators/lod_reset_op.h +++ b/paddle/fluid/operators/lod_reset_op.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/log_loss_op.cc b/paddle/fluid/operators/log_loss_op.cc index 883e3597d8a31138a6ff1e4cfcb05a165eafc4a6..11edbc84a19d96639ccf9c249b1b556ac2f5b5a7 100644 --- a/paddle/fluid/operators/log_loss_op.cc +++ b/paddle/fluid/operators/log_loss_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/log_loss_op_npu.cc b/paddle/fluid/operators/log_loss_op_npu.cc index f103a69707a214400bbe2734409df4d9de3902e8..99ccad1ca76a5c1db4b6ef3b5908d821ee0e6515 100644 --- a/paddle/fluid/operators/log_loss_op_npu.cc +++ b/paddle/fluid/operators/log_loss_op_npu.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" diff --git a/paddle/fluid/operators/log_loss_op_xpu.cc b/paddle/fluid/operators/log_loss_op_xpu.cc index fee1f56ebdcf2c6f2ea831376cd638f2adc2238c..1ba0a0f3b3d7e0fa88117e246ecce5531960a4e2 100644 --- a/paddle/fluid/operators/log_loss_op_xpu.cc +++ b/paddle/fluid/operators/log_loss_op_xpu.cc @@ -11,6 +11,7 @@ limitations under the License. */ #ifdef PADDLE_WITH_XPU #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device/device_wrapper.h" namespace paddle { diff --git a/paddle/fluid/operators/log_softmax_op.cc b/paddle/fluid/operators/log_softmax_op.cc index da38f906b9bd34ba6c3251059ee12902e62eadaf..95ebeedaf797ed342a6fc7bfe579865aaf91537c 100644 --- a/paddle/fluid/operators/log_softmax_op.cc +++ b/paddle/fluid/operators/log_softmax_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/common_infer_shape_functions.h" diff --git a/paddle/fluid/operators/lookup_table_op.cu b/paddle/fluid/operators/lookup_table_op.cu index 29079b8b1385dee3a28c42a178a046fab77e6200..c519e0845f7507924d566b53d4b8b41def355b24 100644 --- a/paddle/fluid/operators/lookup_table_op.cu +++ b/paddle/fluid/operators/lookup_table_op.cu @@ -113,26 +113,22 @@ class LookupTableCUDAKernel : public framework::OpKernel { dim3 grids(8, 1); #ifdef PADDLE_WITH_HIP if (padding_idx == -1) - LookupTable< - T, 64, 4, 8, - false><<>>( - output, table, ids, N, K, D, padding_idx); + LookupTable + <<>>( + output, table, ids, N, K, D, padding_idx); else - LookupTable< - T, 64, 4, 8, - true><<>>( - output, table, ids, N, K, D, padding_idx); + LookupTable + <<>>( + output, table, ids, N, K, D, padding_idx); #else if (padding_idx == -1) - LookupTable< - T, 128, 8, 8, - false><<>>( - output, table, ids, N, K, D, padding_idx); + LookupTable + <<>>( + output, table, ids, N, K, D, padding_idx); else - LookupTable< - T, 128, 8, 8, - true><<>>( - output, table, ids, N, K, D, padding_idx); + LookupTable + <<>>( + output, table, ids, N, K, D, padding_idx); #endif // PADDLE_WITH_HIP } }; diff --git a/paddle/fluid/operators/lookup_table_v2_op.cc b/paddle/fluid/operators/lookup_table_v2_op.cc index 48ae080783d112c7e11daebe984de70925f5bbe2..65aeca1e49928562925f9c194e61ad18ee004508 100644 --- a/paddle/fluid/operators/lookup_table_v2_op.cc +++ b/paddle/fluid/operators/lookup_table_v2_op.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/fluid/operators/lookup_table_v2_op.h" #include + #include "paddle/fluid/framework/no_need_buffer_vars_inference.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/framework/var_type_inference.h" diff --git a/paddle/fluid/operators/lookup_table_v2_op_npu.cc b/paddle/fluid/operators/lookup_table_v2_op_npu.cc index c2df6dff5b53c344bbc41744d329f7194286c163..c47ea64e24c42c80bb67872327a56b8037d56fe3 100644 --- a/paddle/fluid/operators/lookup_table_v2_op_npu.cc +++ b/paddle/fluid/operators/lookup_table_v2_op_npu.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" diff --git a/paddle/fluid/operators/lookup_table_v2_op_xpu.cc b/paddle/fluid/operators/lookup_table_v2_op_xpu.cc index 521d3ab571efde89857bfba9dbcdd4148884477c..223bf2cc8678b869afc173bff198e5012572f07e 100644 --- a/paddle/fluid/operators/lookup_table_v2_op_xpu.cc +++ b/paddle/fluid/operators/lookup_table_v2_op_xpu.cc @@ -12,11 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/lookup_table_v2_op.h" #include + #include "paddle/fluid/framework/no_need_buffer_vars_inference.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/framework/var_type_inference.h" +#include "paddle/fluid/operators/lookup_table_v2_op.h" #include "paddle/fluid/platform/device/device_wrapper.h" #ifdef PADDLE_WITH_XPU namespace paddle { diff --git a/paddle/fluid/operators/lrn_op.cc b/paddle/fluid/operators/lrn_op.cc index 88d70d9bb7dae50f9ca0d82ce53896632b8b00ed..17c5f08c66c943eb67c4a1ae20c4b8de686cbb24 100644 --- a/paddle/fluid/operators/lrn_op.cc +++ b/paddle/fluid/operators/lrn_op.cc @@ -13,9 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/lrn_op.h" + #include #include #include + #include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/math_function.h" #ifdef PADDLE_WITH_MKLDNN @@ -174,20 +176,23 @@ class LRNOp : public framework::OperatorWithKernel { OP_INOUT_CHECK(ctx->HasOutput("MidOut"), "Output", "MidOut", "LRN"); auto x_dim = ctx->GetInputDim("X"); - PADDLE_ENFORCE_EQ(x_dim.size(), 4, platform::errors::InvalidArgument( - "Input(input) rank should be 4, " - "but received input rank (%d) != 4", - x_dim.size())); + PADDLE_ENFORCE_EQ( + x_dim.size(), 4, + platform::errors::InvalidArgument("Input(input) rank should be 4, " + "but received input rank (%d) != 4", + x_dim.size())); int n = ctx->Attrs().Get("n"); - PADDLE_ENFORCE_GT(n, 0UL, platform::errors::InvalidArgument( - "Argument(n) should be positive, " - "but received n(%d) not greater than 0", - n)); - PADDLE_ENFORCE_EQ(n % 2, 1UL, platform::errors::InvalidArgument( - "Argument(n) should be odd value, " - "but received n(%d) is not an odd value", - n)); + PADDLE_ENFORCE_GT(n, 0UL, + platform::errors::InvalidArgument( + "Argument(n) should be positive, " + "but received n(%d) not greater than 0", + n)); + PADDLE_ENFORCE_EQ(n % 2, 1UL, + platform::errors::InvalidArgument( + "Argument(n) should be odd value, " + "but received n(%d) is not an odd value", + n)); ctx->SetOutputDim("Out", x_dim); ctx->ShareLoD("X", /*->*/ "Out"); diff --git a/paddle/fluid/operators/lrn_op.h b/paddle/fluid/operators/lrn_op.h index f2d72d07405730c51303f5eb64cbc116192966b9..671055caa16f14d79ad176a1329bf38df672c8a8 100644 --- a/paddle/fluid/operators/lrn_op.h +++ b/paddle/fluid/operators/lrn_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/data_layout.h" #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" @@ -68,18 +69,21 @@ class LRNKernel : public framework::OpKernel { T beta = ctx.Attr("beta"); T k = ctx.Attr("k"); - PADDLE_ENFORCE_GE(alpha, 0UL, platform::errors::InvalidArgument( - "Argument(alpha) should >= 0.0, " - "but received alpha(%d) less than 0", - alpha)); - PADDLE_ENFORCE_GE(beta, 0UL, platform::errors::InvalidArgument( - "Argument(beta) should >= 0.0, " - "but received beta(%d) less than 0", - beta)); - PADDLE_ENFORCE_GE(k, 0UL, platform::errors::InvalidArgument( - "Argument(k) should >= 0.0, " - "but received k(%d) less than 0", - k)); + PADDLE_ENFORCE_GE( + alpha, 0UL, + platform::errors::InvalidArgument("Argument(alpha) should >= 0.0, " + "but received alpha(%d) less than 0", + alpha)); + PADDLE_ENFORCE_GE( + beta, 0UL, + platform::errors::InvalidArgument("Argument(beta) should >= 0.0, " + "but received beta(%d) less than 0", + beta)); + PADDLE_ENFORCE_GE( + k, 0UL, + platform::errors::InvalidArgument("Argument(k) should >= 0.0, " + "but received k(%d) less than 0", + k)); LRNFunctor f; f(ctx, x, out, mid, N, C, H, W, n, k, alpha, beta, data_layout); diff --git a/paddle/fluid/operators/lstm_op.cc b/paddle/fluid/operators/lstm_op.cc index 2ec9de3e3bbfc35992f75c0a4f4426ba52b45fd0..21a0fce2893488c66cfc607e87a5a7d12df176f7 100644 --- a/paddle/fluid/operators/lstm_op.cc +++ b/paddle/fluid/operators/lstm_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/lstm_op.h" + #include #include diff --git a/paddle/fluid/operators/lstm_op.h b/paddle/fluid/operators/lstm_op.h index 4ec3072a96d445805f482060585a888a2a165413..1e1aaf3ea5328e0612b6811f85ee6a607d513f74 100644 --- a/paddle/fluid/operators/lstm_op.h +++ b/paddle/fluid/operators/lstm_op.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/detail/activation_functions.h" @@ -272,9 +273,10 @@ class LSTMGradKernel : public framework::OpKernel { phi::funcs::LoDTensor2BatchFunctor to_batch; - auto ToBatch = [&batch_gate, &to_batch]( - const DeviceContext& ctx, const framework::LoDTensor& src, - const framework::DDim& dims, framework::LoDTensor& dst) { + auto ToBatch = [&batch_gate, &to_batch](const DeviceContext& ctx, + const framework::LoDTensor& src, + const framework::DDim& dims, + framework::LoDTensor& dst) { dst.mutable_data(dims, ctx.GetPlace()); dst.set_lod(batch_gate->lod()); to_batch(ctx, src, &dst, false); diff --git a/paddle/fluid/operators/lstm_unit_op.cc b/paddle/fluid/operators/lstm_unit_op.cc index 917482589fcf37255cc149ac998fa06cb34f987f..235a4bd689b23e55ab77a899b20a7775a231af36 100644 --- a/paddle/fluid/operators/lstm_unit_op.cc +++ b/paddle/fluid/operators/lstm_unit_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/lstm_unit_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/lstmp_op.cc b/paddle/fluid/operators/lstmp_op.cc index 562f7755591fd859fe36df50f0ac335808283613..7ecf294433ead7653fb226392b330adb4f8f6bb7 100644 --- a/paddle/fluid/operators/lstmp_op.cc +++ b/paddle/fluid/operators/lstmp_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/lstmp_op.h" + #include #include diff --git a/paddle/fluid/operators/lstmp_op.h b/paddle/fluid/operators/lstmp_op.h index 5d24c0b70d3477224e89ca47924816e14abc5c56..5e68259852c28570addb0c83822e4b182618e0ed 100644 --- a/paddle/fluid/operators/lstmp_op.h +++ b/paddle/fluid/operators/lstmp_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/activation_op.h" @@ -371,9 +372,10 @@ class LSTMPGradKernel : public framework::OpKernel { phi::funcs::LoDTensor2BatchFunctor to_batch; - auto ToBatch = [&batch_gate, &to_batch]( - const DeviceContext& ctx, const framework::LoDTensor& src, - const framework::DDim& dims, framework::LoDTensor& dst) { + auto ToBatch = [&batch_gate, &to_batch](const DeviceContext& ctx, + const framework::LoDTensor& src, + const framework::DDim& dims, + framework::LoDTensor& dst) { dst.mutable_data(dims, ctx.GetPlace()); dst.set_lod(batch_gate->lod()); to_batch(ctx, src, &dst, false); diff --git a/paddle/fluid/operators/lstsq_op.cc b/paddle/fluid/operators/lstsq_op.cc index f060125620f5a59673f22a0cb332e260b22275c3..e093e4d8c01a6e9ff256f3d2c79842ae1f29b78f 100644 --- a/paddle/fluid/operators/lstsq_op.cc +++ b/paddle/fluid/operators/lstsq_op.cc @@ -13,8 +13,10 @@ // limitations under the License. #include "paddle/fluid/operators/lstsq_op.h" + #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { @@ -139,4 +141,4 @@ REGISTER_OPERATOR(lstsq, ops::LstsqOp, ops::LstsqOpMaker) REGISTER_OP_CPU_KERNEL( lstsq, ops::LstsqCPUKernel, - ops::LstsqCPUKernel); \ No newline at end of file + ops::LstsqCPUKernel); diff --git a/paddle/fluid/operators/lstsq_op.cu b/paddle/fluid/operators/lstsq_op.cu index 10e2867bf2953f5c6fbc3d50bd8156fa3b0266e9..53c78fef7b5d4bd38ab3a1e0238766f10047b4a5 100644 --- a/paddle/fluid/operators/lstsq_op.cu +++ b/paddle/fluid/operators/lstsq_op.cu @@ -17,6 +17,7 @@ #include #include + #include "paddle/fluid/framework/phi_utils.h" #include "paddle/fluid/operators/lstsq_op.h" #include "paddle/fluid/operators/qr_op.h" diff --git a/paddle/fluid/operators/lstsq_op.h b/paddle/fluid/operators/lstsq_op.h index 520722dafcbea3ce8c545389317516cc22f7689f..7955b3b7df9a329fcb902524bc2678a64410c7c0 100644 --- a/paddle/fluid/operators/lstsq_op.h +++ b/paddle/fluid/operators/lstsq_op.h @@ -15,8 +15,10 @@ #pragma once #include + #include #include + #include "paddle/fluid/operators/eig_op.h" #include "paddle/fluid/operators/math/eigen_values_vectors.h" #include "paddle/fluid/operators/math/matrix_solve.h" diff --git a/paddle/fluid/operators/lu_op.cc b/paddle/fluid/operators/lu_op.cc index fc8673181c467eb1fd4ab0a56b41e72287aea4bc..0894323015e684b108b96b0facb9251f149f3043 100644 --- a/paddle/fluid/operators/lu_op.cc +++ b/paddle/fluid/operators/lu_op.cc @@ -45,8 +45,9 @@ class LUOp : public framework::OperatorWithKernel { bool pivots = context->Attrs().Get("pivots"); auto x_dims = context->GetInputDim("X"); int x_rank = x_dims.size(); - PADDLE_ENFORCE_GE(x_rank, 2, platform::errors::InvalidArgument( - "the rank of input must greater than 2")); + PADDLE_ENFORCE_GE(x_rank, 2, + platform::errors::InvalidArgument( + "the rank of input must greater than 2")); context->SetOutputDim("Out", x_dims); int m = x_dims[x_rank - 1]; int n = x_dims[x_rank - 2]; diff --git a/paddle/fluid/operators/lu_unpack_op.cc b/paddle/fluid/operators/lu_unpack_op.cc index e38a4703f64ee7c61029cc69b57dd9c375a3c23c..e3b4263b4ff68050422605af1e8b6273486435b2 100644 --- a/paddle/fluid/operators/lu_unpack_op.cc +++ b/paddle/fluid/operators/lu_unpack_op.cc @@ -53,8 +53,9 @@ class LU_UnpackOp : public framework::OperatorWithKernel { auto x_dims = context->GetInputDim("X"); int x_rank = x_dims.size(); - PADDLE_ENFORCE_GE(x_rank, 2, platform::errors::InvalidArgument( - "the rank of input must greater than 2")); + PADDLE_ENFORCE_GE(x_rank, 2, + platform::errors::InvalidArgument( + "the rank of input must greater than 2")); // context->SetOutputDim("Out", x_dims); int m = x_dims[x_rank - 1]; diff --git a/paddle/fluid/operators/margin_cross_entropy_op.cu b/paddle/fluid/operators/margin_cross_entropy_op.cu index fd5ba1952caf9336e907dbe959f88e1292eaffa2..1cef3705973e75c6ddac25702f15351a3b086829 100644 --- a/paddle/fluid/operators/margin_cross_entropy_op.cu +++ b/paddle/fluid/operators/margin_cross_entropy_op.cu @@ -20,6 +20,7 @@ namespace cub = hipcub; #endif #include + #include "paddle/fluid/operators/amp/fp16_type_traits.h" #include "paddle/fluid/operators/margin_cross_entropy_op.h" #include "paddle/fluid/operators/math/softmax_impl.h" @@ -298,16 +299,16 @@ class MarginCrossEntropyOpCUDAKernel : public framework::OpKernel { // save match_logits, used for gradient computation. if (label_type == framework::proto::VarType::INT32) { typedef int32_t LabelT; - AddMarginToPositiveLogitsKernel< - T><<>>( - logits_ptr, labels->data(), margin1, margin2, margin3, rank, - nranks, N, D, class_interval.data()); + AddMarginToPositiveLogitsKernel + <<>>( + logits_ptr, labels->data(), margin1, margin2, margin3, + rank, nranks, N, D, class_interval.data()); } else if (label_type == framework::proto::VarType::INT64) { typedef int64_t LabelT; - AddMarginToPositiveLogitsKernel< - T><<>>( - logits_ptr, labels->data(), margin1, margin2, margin3, rank, - nranks, N, D, class_interval.data()); + AddMarginToPositiveLogitsKernel + <<>>( + logits_ptr, labels->data(), margin1, margin2, margin3, + rank, nranks, N, D, class_interval.data()); } else { PADDLE_THROW(platform::errors::Unimplemented( "margin_cross_entropy label type noly support int32 and int64, " @@ -386,9 +387,9 @@ class MarginCrossEntropyOpCUDAKernel : public framework::OpKernel { #endif // step 5, (logit - logit_max) - log(sum(exp(logit - logit_max))) - LogitsMinusLogSumKernel< - T><<>>( - logits_ptr, sum_exp_logits_buff, N, D); + LogitsMinusLogSumKernel + <<>>( + logits_ptr, sum_exp_logits_buff, N, D); // step 6, prob = exp((logit - logit_max) - log(sum(exp(logit - // logit_max)))) @@ -397,16 +398,16 @@ class MarginCrossEntropyOpCUDAKernel : public framework::OpKernel { dev_ctx, loss, static_cast(0.0)); if (label_type == framework::proto::VarType::INT32) { typedef int32_t LabelT; - HardLabelSoftmaxWithCrossEntropyKernel< - T, LabelT><<>>( - loss_ptr, logits_ptr, labels->data(), rank, N, D, - class_interval.data()); + HardLabelSoftmaxWithCrossEntropyKernel + <<>>( + loss_ptr, logits_ptr, labels->data(), rank, N, D, + class_interval.data()); } else if (label_type == framework::proto::VarType::INT64) { typedef int64_t LabelT; - HardLabelSoftmaxWithCrossEntropyKernel< - T, LabelT><<>>( - loss_ptr, logits_ptr, labels->data(), rank, N, D, - class_interval.data()); + HardLabelSoftmaxWithCrossEntropyKernel + <<>>( + loss_ptr, logits_ptr, labels->data(), rank, N, D, + class_interval.data()); } #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) diff --git a/paddle/fluid/operators/margin_rank_loss_op.cc b/paddle/fluid/operators/margin_rank_loss_op.cc index b4ff8b6d8dcf5e5fb28bcb85e5268776d1ec4aa9..31055002993edaf9b90e5372cdc3c303094f43be 100644 --- a/paddle/fluid/operators/margin_rank_loss_op.cc +++ b/paddle/fluid/operators/margin_rank_loss_op.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/margin_rank_loss_op.h" + #include + #include "paddle/fluid/platform/enforce.h" namespace paddle { diff --git a/paddle/fluid/operators/marker_op.cu b/paddle/fluid/operators/marker_op.cu index cfa5c6dc7a918b48f0ffcab69d2777ec8337d500..fe61aefe0bb3a528b2f9a45c7496abe039185208 100644 --- a/paddle/fluid/operators/marker_op.cu +++ b/paddle/fluid/operators/marker_op.cu @@ -48,8 +48,8 @@ class MarkerOpCUDAKernel : public framework::OpKernel { "MarkerCUDA", "marker_" + marker_role + "_" + marker_pos, platform::TracerEventType::OperatorInner, 1, platform::EventRole::kInnerOp); - SimpleMarkerKernel<<<1, 32, 0, dev_ctx.stream()>>>(in_temp, out_temp, - 32); + SimpleMarkerKernel + <<<1, 32, 0, dev_ctx.stream()>>>(in_temp, out_temp, 32); } }; diff --git a/paddle/fluid/operators/match_matrix_tensor_op.cc b/paddle/fluid/operators/match_matrix_tensor_op.cc index d32ab65509e5efb7275b76afb913cbfc682842a6..2ae4fbdbe103fa5cfbc5706487b9d1a1b2f2ea00 100644 --- a/paddle/fluid/operators/match_matrix_tensor_op.cc +++ b/paddle/fluid/operators/match_matrix_tensor_op.cc @@ -12,13 +12,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/operators/match_matrix_tensor_op.h" + #include #include #include #include #include -#include "paddle/fluid/operators/match_matrix_tensor_op.h" #include "paddle/fluid/operators/search_compute.h" namespace paddle { diff --git a/paddle/fluid/operators/math.h b/paddle/fluid/operators/math.h index d4b9e35bccedcd5bdad2e171509cf64ce21fb545..47281fb0280f0fc5128d978d9aedaeb4e8d19cd3 100644 --- a/paddle/fluid/operators/math.h +++ b/paddle/fluid/operators/math.h @@ -14,11 +14,10 @@ #pragma once +#include "math.h" // NOLINT #include "paddle/fluid/platform/float16.h" #include "paddle/phi/core/hostdevice.h" -#include "math.h" // NOLINT - namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/math/beam_search.cu b/paddle/fluid/operators/math/beam_search.cu index 486979aa0a8b3009d09f73de54f9b7b3ac8a77ad..7a21f2f64978dbc455231b68d376d5b47fb7a9a3 100644 --- a/paddle/fluid/operators/math/beam_search.cu +++ b/paddle/fluid/operators/math/beam_search.cu @@ -348,11 +348,10 @@ class BeamSearchFunctor { float* selected_scores_data = selected_scores->mutable_data(selected_dims, context.GetPlace()); int* parent_idx_data = - parent_idx - ? parent_idx->mutable_data( - {static_cast(num_seqs * beam_size)}, - context.GetPlace()) - : nullptr; + parent_idx ? parent_idx->mutable_data( + {static_cast(num_seqs * beam_size)}, + context.GetPlace()) + : nullptr; framework::LoD selected_lod(2); selected_lod[0].assign(abs_lod[level].begin(), abs_lod[level].end()); @@ -369,8 +368,8 @@ class BeamSearchFunctor { static_cast(beam_size)); switch (platform::RoundToPowerOfTwo(beam_size * seq_width)) { CUDA_LAUNCH_KERNEL_HELPER( - BeamSearchKernelSingle<<< - 1, kMaxThreadsPerSeq, 0, context.stream()>>>( + BeamSearchKernelSingle + <<<1, kMaxThreadsPerSeq, 0, context.stream()>>>( selected_ids_data, selected_scores_data, parent_idx_data, selected_offsets, pre_ids_data, pre_scores_data, ids_data, scores_data, seq_length, static_cast(seq_width), @@ -387,8 +386,8 @@ class BeamSearchFunctor { static_cast(beam_size)); switch (platform::RoundToPowerOfTwo(beam_size * num_seqs * 32)) { CUDA_LAUNCH_KERNEL_HELPER( - BeamSearchKernel<<< - 1, num_seqs * kMaxThreadsPerSeq, 0, context.stream()>>>( + BeamSearchKernel + <<<1, num_seqs * kMaxThreadsPerSeq, 0, context.stream()>>>( selected_ids_data, selected_scores_data, parent_idx_data, selected_offsets, pre_ids_data, pre_scores_data, ids_data, scores_data, seq_offsets, static_cast(num_seqs), diff --git a/paddle/fluid/operators/math/beam_search.h b/paddle/fluid/operators/math/beam_search.h index 4474e7ea52affed792572d02202ec2577c471e50..c0d39aa2d8fa963d3adb1ec8100e589b2e70d23d 100644 --- a/paddle/fluid/operators/math/beam_search.h +++ b/paddle/fluid/operators/math/beam_search.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/platform/device_context.h" diff --git a/paddle/fluid/operators/math/beam_search_test.cc b/paddle/fluid/operators/math/beam_search_test.cc index b0547ef9d956ca54015da4cae7dc913dacce4965..7cf4c867db7a3f67b149eedcee24a24e734b89f7 100644 --- a/paddle/fluid/operators/math/beam_search_test.cc +++ b/paddle/fluid/operators/math/beam_search_test.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/fluid/operators/math/beam_search.h" #include + #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/operators/math/bert_encoder_functor.cu b/paddle/fluid/operators/math/bert_encoder_functor.cu index 0cdad6beeb9f66e473b8bdc0c2a16de15a5b5b5a..4aba6f3c0b9e97ba17ec01c91a8876728a9ba816 100644 --- a/paddle/fluid/operators/math/bert_encoder_functor.cu +++ b/paddle/fluid/operators/math/bert_encoder_functor.cu @@ -815,23 +815,23 @@ void SkipLayerNormFunctor::operator()(const int num, const int hidden, const int threads = 256; if (hidden % 2 == 0) { if (std::is_same::value) { - SkipLayerNormKernel2<<>>( - num, hidden / 2, reinterpret_cast(input1), - reinterpret_cast(input2), - reinterpret_cast(output), - reinterpret_cast(scale), - reinterpret_cast(bias), eps); + SkipLayerNormKernel2 + <<>>( + num, hidden / 2, reinterpret_cast(input1), + reinterpret_cast(input2), + reinterpret_cast(output), + reinterpret_cast(scale), + reinterpret_cast(bias), eps); // HIP defined __HIP_NO_HALF_CONVERSIONS__ in hip.cmake #ifndef __HIPCC__ } else if (std::is_same::value) { - SkipLayerNormKernel2<__half, __half2, - threads><<>>( - num, hidden / 2, reinterpret_cast(input1), - reinterpret_cast(input2), - reinterpret_cast<__half2 *>(output), - reinterpret_cast(scale), - reinterpret_cast(bias), eps); + SkipLayerNormKernel2<__half, __half2, threads> + <<>>( + num, hidden / 2, reinterpret_cast(input1), + reinterpret_cast(input2), + reinterpret_cast<__half2 *>(output), + reinterpret_cast(scale), + reinterpret_cast(bias), eps); #endif } else { assert(false); diff --git a/paddle/fluid/operators/math/bert_encoder_functor.h b/paddle/fluid/operators/math/bert_encoder_functor.h index 683606ec73383d02f8bedbf265c0fdc5f073b05c..fd40ac540bfdc81442782da3a72beea4ae20b820 100644 --- a/paddle/fluid/operators/math/bert_encoder_functor.h +++ b/paddle/fluid/operators/math/bert_encoder_functor.h @@ -17,10 +17,12 @@ limitations under the License. */ #ifdef PADDLE_WITH_CUDA #include #include + #include // NOLINT #endif #ifdef PADDLE_WITH_HIP #include + #include namespace cub = hipcub; #endif diff --git a/paddle/fluid/operators/math/bloomfilter.h b/paddle/fluid/operators/math/bloomfilter.h index fa3d37ed5f41eb0195d3eaee645f182c3ca4db39..f16fdd135b5a49784f43816961821a3bce54e652 100644 --- a/paddle/fluid/operators/math/bloomfilter.h +++ b/paddle/fluid/operators/math/bloomfilter.h @@ -16,11 +16,9 @@ limitations under the License. */ #define BLOOMFILTER_MAGIC_NUM_NEW 17070416 #include -#include - #include +#include #include - #include namespace paddle { diff --git a/paddle/fluid/operators/math/concat_and_split.cu b/paddle/fluid/operators/math/concat_and_split.cu index e51631385eb75a63083e0cbbd2a8632d689be8f1..1ea8cafd25e0822ff4d67d987b29f974aece46d4 100644 --- a/paddle/fluid/operators/math/concat_and_split.cu +++ b/paddle/fluid/operators/math/concat_and_split.cu @@ -13,7 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/math/concat_and_split.h" - #include "paddle/phi/kernels/funcs/concat_and_split_functor.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/math/concat_and_split.h b/paddle/fluid/operators/math/concat_and_split.h index b5b0aae23ac875c7afeb4148309138aae49e5b4a..3b6a12e24023e31e327ae391d056481264c92731 100644 --- a/paddle/fluid/operators/math/concat_and_split.h +++ b/paddle/fluid/operators/math/concat_and_split.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/lod_tensor.h" diff --git a/paddle/fluid/operators/math/concat_test.cc b/paddle/fluid/operators/math/concat_test.cc index de358bf623e6121592c53d6f7e3ab07586e1fb7f..542dcda963aea38b9508c569394fa707dd1416b6 100644 --- a/paddle/fluid/operators/math/concat_test.cc +++ b/paddle/fluid/operators/math/concat_test.cc @@ -119,13 +119,13 @@ void ConcatCase1(DeviceContext* context) { } /** - * case 2: - * inputs: - * t_a.shape: [2, 3, 4] - * t_b.shape: [2, 4, 4] - * output: - * out.shape: [2, 7, 4] - */ + * case 2: + * inputs: + * t_a.shape: [2, 3, 4] + * t_b.shape: [2, 4, 4] + * output: + * out.shape: [2, 7, 4] + */ template void ConcatCase2(DeviceContext* context) { paddle::framework::Tensor input_a_cpu; @@ -222,13 +222,13 @@ void ConcatCase2(DeviceContext* context) { } /** - * case 3: - * inputs: - * t_a.shape: [2, 3, 5] - * t_b.shape: [2, 3, 4] - * output: - * out.shape: [2, 3, 9] - */ + * case 3: + * inputs: + * t_a.shape: [2, 3, 5] + * t_b.shape: [2, 3, 4] + * output: + * out.shape: [2, 3, 9] + */ template void ConcatCase3(DeviceContext* context) { paddle::framework::Tensor input_a_cpu; @@ -326,14 +326,14 @@ void ConcatCase3(DeviceContext* context) { } /** - * case 4: - * inputs: - * axis = 1 - * t_a.shape: [2, 3, 4] - * t_b.shape: [2, 3, 4] - * output: - * out.shape: [2, 6, 4] - */ + * case 4: + * inputs: + * axis = 1 + * t_a.shape: [2, 3, 4] + * t_b.shape: [2, 3, 4] + * output: + * out.shape: [2, 6, 4] + */ template void ConcatCase4(DeviceContext* context) { paddle::framework::Tensor input_a_cpu; diff --git a/paddle/fluid/operators/math/cross_entropy.cc b/paddle/fluid/operators/math/cross_entropy.cc index cb2f59182c11125d5c30d589ccf88a288d1b53eb..a2b83f998566f7206d23bcf037a9720f4ea7aefe 100644 --- a/paddle/fluid/operators/math/cross_entropy.cc +++ b/paddle/fluid/operators/math/cross_entropy.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/math/cross_entropy.h" + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/phi/backends/cpu/cpu_context.h" diff --git a/paddle/fluid/operators/math/cross_entropy.h b/paddle/fluid/operators/math/cross_entropy.h index da7340e4eb0b363877b61b49fe6204fb9c046b1f..e562816d6dab6d7cbb869efc9005ae4ec57b9bbb 100644 --- a/paddle/fluid/operators/math/cross_entropy.h +++ b/paddle/fluid/operators/math/cross_entropy.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/tensor.h" #include "paddle/phi/core/hostdevice.h" diff --git a/paddle/fluid/operators/math/eigen_values_vectors.h b/paddle/fluid/operators/math/eigen_values_vectors.h index 1ade2190bb96e092ad546ace121192a87c8082ff..22ce162a44ce01930b480ebeb3550a62abe367c0 100644 --- a/paddle/fluid/operators/math/eigen_values_vectors.h +++ b/paddle/fluid/operators/math/eigen_values_vectors.h @@ -42,9 +42,10 @@ static void CheckEighResult(const int batch, const int info) { "tridiagonal form did not converge to zero", batch, info)); PADDLE_ENFORCE_GE( - info, 0, platform::errors::PreconditionNotMet( - "For batch [%d]: the [%d] argument had an illegal value", - batch, info)); + info, 0, + platform::errors::PreconditionNotMet( + "For batch [%d]: the [%d] argument had an illegal value", batch, + info)); } template diff --git a/paddle/fluid/operators/math/gru_compute.cu b/paddle/fluid/operators/math/gru_compute.cu index 9b03895cdef2509196dd406cfd3934aec27339aa..946a1477c3b6a881f3ea163e275d96646ac464e8 100644 --- a/paddle/fluid/operators/math/gru_compute.cu +++ b/paddle/fluid/operators/math/gru_compute.cu @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/operators/math/detail/gru_gpu_kernel.h" #include "paddle/fluid/operators/math/detail/gru_kernel.h" #include "paddle/fluid/operators/math/gru_compute.h" @@ -36,35 +37,35 @@ struct GRUUnitFunctor { int frame_blocks = (frame_size * 2 + tiled_size - 1) / tiled_size; threads = dim3(tiled_size, 1); grid = dim3(frame_blocks, 1); - detail::KeFastCollectiveGruGate< - T, tiled_size><<>>( - value.gate_value, value.prev_out_value, value.gate_weight, - value.reset_output_value, frame_size, active_gate); + detail::KeFastCollectiveGruGate + <<>>( + value.gate_value, value.prev_out_value, value.gate_weight, + value.reset_output_value, frame_size, active_gate); frame_blocks = (frame_size + tiled_size - 1) / tiled_size; grid = dim3(frame_blocks, 1); - detail::KeFastCollectiveGruOut< - T, tiled_size><<>>( - value.state_weight, value.prev_out_value, value.output_value, - value.gate_value, value.reset_output_value, frame_size, - active_node, origin_mode); + detail::KeFastCollectiveGruOut + <<>>( + value.state_weight, value.prev_out_value, value.output_value, + value.gate_value, value.reset_output_value, frame_size, + active_node, origin_mode); } else { constexpr int tiled_size = 16; int frame_blocks = (frame_size * 2 + tiled_size - 1) / tiled_size; threads = dim3(tiled_size, 1); grid = dim3(frame_blocks, 1); - detail::KeFastCollectiveGruGate< - T, tiled_size><<>>( - value.gate_value, value.prev_out_value, value.gate_weight, - value.reset_output_value, frame_size, active_gate); + detail::KeFastCollectiveGruGate + <<>>( + value.gate_value, value.prev_out_value, value.gate_weight, + value.reset_output_value, frame_size, active_gate); frame_blocks = (frame_size + tiled_size - 1) / tiled_size; grid = dim3(frame_blocks, 1); - detail::KeFastCollectiveGruOut< - T, tiled_size><<>>( - value.state_weight, value.prev_out_value, value.output_value, - value.gate_value, value.reset_output_value, frame_size, - active_node, origin_mode); + detail::KeFastCollectiveGruOut + <<>>( + value.state_weight, value.prev_out_value, value.output_value, + value.gate_value, value.reset_output_value, frame_size, + active_node, origin_mode); } return; } else { @@ -86,18 +87,18 @@ struct GRUUnitFunctor { if (batch_size == 1) { detail::KeGruForwardResetOutput, - /* is_batch= */ false, - T><<>>( - detail::forward::gru_resetOutput(), value.gate_value, - value.reset_output_value, value.prev_out_value, frame_size, - batch_size, active_gate); + /* is_batch= */ false, T> + <<>>( + detail::forward::gru_resetOutput(), value.gate_value, + value.reset_output_value, value.prev_out_value, frame_size, + batch_size, active_gate); } else { detail::KeGruForwardResetOutput, - /* is_batch= */ true, - T><<>>( - detail::forward::gru_resetOutput(), value.gate_value, - value.reset_output_value, value.prev_out_value, frame_size, - batch_size, active_gate); + /* is_batch= */ true, T> + <<>>( + detail::forward::gru_resetOutput(), value.gate_value, + value.reset_output_value, value.prev_out_value, frame_size, + batch_size, active_gate); } if (value.prev_out_value) { @@ -109,18 +110,18 @@ struct GRUUnitFunctor { if (batch_size == 1) { detail::KeGruForwardFinalOutput, - /* is_batch= */ false, - T><<>>( - detail::forward::gru_finalOutput(), value.gate_value, - value.prev_out_value, value.output_value, frame_size, batch_size, - active_node, origin_mode); + /* is_batch= */ false, T> + <<>>(detail::forward::gru_finalOutput(), + value.gate_value, value.prev_out_value, + value.output_value, frame_size, + batch_size, active_node, origin_mode); } else { detail::KeGruForwardFinalOutput, - /* is_batch= */ true, - T><<>>( - detail::forward::gru_finalOutput(), value.gate_value, - value.prev_out_value, value.output_value, frame_size, batch_size, - active_node, origin_mode); + /* is_batch= */ true, T> + <<>>(detail::forward::gru_finalOutput(), + value.gate_value, value.prev_out_value, + value.output_value, frame_size, + batch_size, active_node, origin_mode); } } }; @@ -147,19 +148,21 @@ struct GRUUnitGradFunctor { } if (batch_size == 1) { - detail::KeGruBackwardStateGrad< - detail::backward::gru_stateGrad, - /* is_batch= */ false><<>>( - detail::backward::gru_stateGrad(), value.gate_value, - grad.gate_grad, value.prev_out_value, grad.prev_out_grad, - grad.output_grad, frame_size, batch_size, active_node, origin_mode); + detail::KeGruBackwardStateGrad, + /* is_batch= */ false> + <<>>( + detail::backward::gru_stateGrad(), value.gate_value, + grad.gate_grad, value.prev_out_value, grad.prev_out_grad, + grad.output_grad, frame_size, batch_size, active_node, + origin_mode); } else { - detail::KeGruBackwardStateGrad< - detail::backward::gru_stateGrad, - /* is_batch= */ true><<>>( - detail::backward::gru_stateGrad(), value.gate_value, - grad.gate_grad, value.prev_out_value, grad.prev_out_grad, - grad.output_grad, frame_size, batch_size, active_node, origin_mode); + detail::KeGruBackwardStateGrad, + /* is_batch= */ true> + <<>>( + detail::backward::gru_stateGrad(), value.gate_value, + grad.gate_grad, value.prev_out_value, grad.prev_out_grad, + grad.output_grad, frame_size, batch_size, active_node, + origin_mode); } auto blas = phi::funcs::GetBlas(context); @@ -179,19 +182,19 @@ struct GRUUnitGradFunctor { } if (batch_size == 1) { - detail::KeGruBackwardResetGrad< - detail::backward::gru_resetGrad, - /* is_batch= */ false><<>>( - detail::backward::gru_resetGrad(), value.gate_value, - grad.gate_grad, value.prev_out_value, grad.prev_out_grad, - grad.reset_output_grad, frame_size, batch_size, active_gate); + detail::KeGruBackwardResetGrad, + /* is_batch= */ false> + <<>>( + detail::backward::gru_resetGrad(), value.gate_value, + grad.gate_grad, value.prev_out_value, grad.prev_out_grad, + grad.reset_output_grad, frame_size, batch_size, active_gate); } else { - detail::KeGruBackwardResetGrad< - detail::backward::gru_resetGrad, - /* is_batch= */ true><<>>( - detail::backward::gru_resetGrad(), value.gate_value, - grad.gate_grad, value.prev_out_value, grad.prev_out_grad, - grad.reset_output_grad, frame_size, batch_size, active_gate); + detail::KeGruBackwardResetGrad, + /* is_batch= */ true> + <<>>( + detail::backward::gru_resetGrad(), value.gate_value, + grad.gate_grad, value.prev_out_value, grad.prev_out_grad, + grad.reset_output_grad, frame_size, batch_size, active_gate); } if (grad.prev_out_grad && value.prev_out_value) { diff --git a/paddle/fluid/operators/math/im2col.cc b/paddle/fluid/operators/math/im2col.cc index 8fc6c52122abfe48d87a14ae274849a18c020546..1f5f575c7c3504361389f7ed38a00e10b9458e7c 100644 --- a/paddle/fluid/operators/math/im2col.cc +++ b/paddle/fluid/operators/math/im2col.cc @@ -111,16 +111,18 @@ class Col2ImFunctor #include + #include "paddle/fluid/operators/math/im2col.h" #include "paddle/fluid/platform/device/gpu/gpu_launch_config.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" @@ -220,16 +221,18 @@ class Col2ImFunctor + #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/platform/device_context.h" diff --git a/paddle/fluid/operators/math/im2col_cfo_cpu.h b/paddle/fluid/operators/math/im2col_cfo_cpu.h index 01f1e220e65d9de00de5b82d2f7c278494be8f32..f3755653f28d4def8bdfa12cd40a3b3ca5b9d789 100644 --- a/paddle/fluid/operators/math/im2col_cfo_cpu.h +++ b/paddle/fluid/operators/math/im2col_cfo_cpu.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/tensor.h" namespace paddle { diff --git a/paddle/fluid/operators/math/im2col_test.cc b/paddle/fluid/operators/math/im2col_test.cc index 0e4032986cf0cdebe70b33480c14e8d0969f0ef7..ff766cfad2cb1a75d5248273af7289ee6147a67b 100644 --- a/paddle/fluid/operators/math/im2col_test.cc +++ b/paddle/fluid/operators/math/im2col_test.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/math/im2col.h" + #include + #include "paddle/fluid/operators/math/im2col_cfo_cpu.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/operators/math/inclusive_scan.h b/paddle/fluid/operators/math/inclusive_scan.h index b77e23450360c836ae3efe0a6dc2c77216e660f0..bd170b674042d6a45dc384727bfd70d2ed384c18 100644 --- a/paddle/fluid/operators/math/inclusive_scan.h +++ b/paddle/fluid/operators/math/inclusive_scan.h @@ -24,6 +24,7 @@ namespace cub = hipcub; #include #include + #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/platform/enforce.h" @@ -196,15 +197,15 @@ static void InclusiveScanInnerDim(const T *x, T *y, size_t outer_dim, grid_dim = std::min(grid_dim, dev_ctx.GetCUDAMaxGridDimSize()[0]); dim3 thread_dims(kThreadNumX, kThreadNumY); if (reverse) { - InclusiveScanInnerDimCUDAKernel< - T, BinaryOp, kThreadNumX, kThreadNumY, - /*kReverse=*/true><<>>( - x, y, outer_dim, inner_dim, init, op); + InclusiveScanInnerDimCUDAKernel + <<>>(x, y, outer_dim, + inner_dim, init, op); } else { - InclusiveScanInnerDimCUDAKernel< - T, BinaryOp, kThreadNumX, kThreadNumY, - /*kReverse=*/false><<>>( - x, y, outer_dim, inner_dim, init, op); + InclusiveScanInnerDimCUDAKernel + <<>>(x, y, outer_dim, + inner_dim, init, op); } } diff --git a/paddle/fluid/operators/math/math_function.cc b/paddle/fluid/operators/math/math_function.cc index 083d6967ff03ab94ee28dafb95ec15903db6c27f..a3c1d23e89b37d95b01d5f106f5d9b951453753b 100644 --- a/paddle/fluid/operators/math/math_function.cc +++ b/paddle/fluid/operators/math/math_function.cc @@ -25,6 +25,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/operators/math/math_function_impl.h" #include "paddle/fluid/platform/bfloat16.h" diff --git a/paddle/fluid/operators/math/matrix_bit_code.h b/paddle/fluid/operators/math/matrix_bit_code.h index 359552a0717a0af1232c6464395abc26be3ce29c..1d6afa50cc93074c5a73e1830172a5a7b690bcf1 100644 --- a/paddle/fluid/operators/math/matrix_bit_code.h +++ b/paddle/fluid/operators/math/matrix_bit_code.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/selected_rows_utils.h" diff --git a/paddle/fluid/operators/math/matrix_solve.cc b/paddle/fluid/operators/math/matrix_solve.cc index 7b239b8166644697581d0051f12b6abacc6832fa..f2b083b833701e4f0457a86a36e98a72aa98963d 100644 --- a/paddle/fluid/operators/math/matrix_solve.cc +++ b/paddle/fluid/operators/math/matrix_solve.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/math/matrix_solve.h" + #include "Eigen/Core" #include "Eigen/LU" #include "paddle/phi/kernels/funcs/blas/blas.h" diff --git a/paddle/fluid/operators/math/matrix_solve.cu.cc b/paddle/fluid/operators/math/matrix_solve.cu.cc index 737196dde1dfc26269fe083fe17037c829ef8109..59c8c07e6e1863775a7dfec9db0433f9eb2d9710 100644 --- a/paddle/fluid/operators/math/matrix_solve.cu.cc +++ b/paddle/fluid/operators/math/matrix_solve.cu.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/math/matrix_solve.h" + #include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/operators/solve_op.h" #include "paddle/fluid/platform/device_context.h" diff --git a/paddle/fluid/operators/math/matrix_solve.h b/paddle/fluid/operators/math/matrix_solve.h index 415d0c6dd8e0cf51958783c32aa49c66cce9e15c..cecc3517934c7a44fd18646fc0bd445eeeb81085 100644 --- a/paddle/fluid/operators/math/matrix_solve.h +++ b/paddle/fluid/operators/math/matrix_solve.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "Eigen/Core" #include "Eigen/LU" #include "paddle/fluid/framework/tensor.h" diff --git a/paddle/fluid/operators/math/sample_prob.cu b/paddle/fluid/operators/math/sample_prob.cu index f86eb103449f642fbbd325ba781f34c68788bde6..1ae0c709e4da98ed6f2bbe84729e5d9030ebabd0 100644 --- a/paddle/fluid/operators/math/sample_prob.cu +++ b/paddle/fluid/operators/math/sample_prob.cu @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include #include + #include #include diff --git a/paddle/fluid/operators/math/sampler.cc b/paddle/fluid/operators/math/sampler.cc index 5f1cd259416145cd5e41c0790ed3f568195b2617..d645e1994f1018ea56856ea72a70ba20dec3ab0b 100644 --- a/paddle/fluid/operators/math/sampler.cc +++ b/paddle/fluid/operators/math/sampler.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/fluid/operators/math/sampler.h" #include + #include "paddle/fluid/framework/generator.h" namespace paddle { diff --git a/paddle/fluid/operators/math/selected_rows_functor.cc b/paddle/fluid/operators/math/selected_rows_functor.cc index e4b033b6c5857262d72ec062da5dcaaca2a12d2e..7689c31838d33d7f3a89b91e545f19019962ab3a 100644 --- a/paddle/fluid/operators/math/selected_rows_functor.cc +++ b/paddle/fluid/operators/math/selected_rows_functor.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/math/selected_rows_functor.h" + #include "paddle/fluid/framework/mixed_vector.h" #include "paddle/fluid/platform/device/device_wrapper.h" diff --git a/paddle/fluid/operators/math/selected_rows_functor.cu b/paddle/fluid/operators/math/selected_rows_functor.cu index db5c66d319701ba587f194fc43cb2832eb031569..edcb21cb56a255d4b840201c9b874cf2132be613 100644 --- a/paddle/fluid/operators/math/selected_rows_functor.cu +++ b/paddle/fluid/operators/math/selected_rows_functor.cu @@ -163,10 +163,10 @@ struct SelectedRowsAddTensor { dim3 threads(block_size, 1); dim3 grid(in1_rows.size(), 1); paddle::framework::MixVector mixv_in1_rows(&in1_rows); - SelectedRowsAddTensorKernel< - T, block_size><<>>( - in1_data, mixv_in1_rows.CUDAData(context.GetPlace()), out_data, - in1_row_numel); + SelectedRowsAddTensorKernel + <<>>( + in1_data, mixv_in1_rows.CUDAData(context.GetPlace()), out_data, + in1_row_numel); auto out_eigen = framework::EigenVector::Flatten(*output); auto in2_eigen = framework::EigenVector::Flatten(input2); @@ -223,10 +223,10 @@ struct SelectedRowsAddTensor { dim3 threads(block_size, 1); dim3 grid(in1_rows.size(), 1); paddle::framework::MixVector mixv_in1_rows(&in1_rows); - SelectedRowsAddTensorKernel< - T, block_size><<>>( - in1_data, mixv_in1_rows.CUDAData(context.GetPlace()), out_data, - in1_row_numel); + SelectedRowsAddTensorKernel + <<>>( + in1_data, mixv_in1_rows.CUDAData(context.GetPlace()), out_data, + in1_row_numel); auto out_eigen = framework::EigenVector::Flatten(*output); auto in2_eigen = framework::EigenVector::Flatten(input2); @@ -343,10 +343,10 @@ struct SelectedRowsAddToTensor { dim3 threads(block_size, 1); dim3 grid(in1_rows.size(), 1); paddle::framework::MixVector mixv_in1_rows(&in1_rows); - SelectedRowsAddToTensorKernel< - T, block_size><<>>( - in1_data, mixv_in1_rows.CUDAData(context.GetPlace()), in2_data, - in1_row_numel); + SelectedRowsAddToTensorKernel + <<>>( + in1_data, mixv_in1_rows.CUDAData(context.GetPlace()), in2_data, + in1_row_numel); } }; @@ -380,10 +380,10 @@ struct SelectedRowsAddToTensor { dim3 threads(block_size, 1); dim3 grid(in1_rows.size(), 1); paddle::framework::MixVector mixv_in1_rows(&in1_rows); - SelectedRowsAddToTensorKernel< - T, block_size><<>>( - in1_data, mixv_in1_rows.CUDAData(context.GetPlace()), in2_data, - in1_row_numel); + SelectedRowsAddToTensorKernel + <<>>( + in1_data, mixv_in1_rows.CUDAData(context.GetPlace()), in2_data, + in1_row_numel); } }; @@ -695,9 +695,9 @@ struct UpdateToTensor { dim3 threads(platform::PADDLE_CUDA_NUM_THREADS, 1); dim3 grid(in1_rows.size(), 1); - UpdateToTensorKernel<<< - grid, threads, 0, context.stream()>>>(in1_data, in1_rows.cuda_data(), - op, in2_data, in1_row_numel); + UpdateToTensorKernel + <<>>(in1_data, in1_rows.cuda_data(), + op, in2_data, in1_row_numel); } }; } // namespace scatter diff --git a/paddle/fluid/operators/math/selected_rows_functor_test.cc b/paddle/fluid/operators/math/selected_rows_functor_test.cc index e0e28f93f367e5a30bcb13ff638199858af10dfa..e6358cda274f6fe9d7386dfb5f7a7739e76378cf 100644 --- a/paddle/fluid/operators/math/selected_rows_functor_test.cc +++ b/paddle/fluid/operators/math/selected_rows_functor_test.cc @@ -457,8 +457,9 @@ TEST(selected_rows_functor, cpu_sum_to) { paddle::operators::math::SelectedRowsSumTo sum_to_functor; - sum_to_functor(ctx, std::vector( - {selected_rows1.get(), selected_rows2.get()}), + sum_to_functor(ctx, + std::vector( + {selected_rows1.get(), selected_rows2.get()}), std::vector({0, in1_value->numel()}), output.get()); auto out_height = output->height(); EXPECT_EQ(out_height, height); diff --git a/paddle/fluid/operators/math/selected_rows_functor_test.cu.cc b/paddle/fluid/operators/math/selected_rows_functor_test.cu.cc index 0912a964792a8c67d41afe1330928c7cd47356b6..6e1d0bb36705065938dcc3bcc22ac0c0a5afb00e 100644 --- a/paddle/fluid/operators/math/selected_rows_functor_test.cu.cc +++ b/paddle/fluid/operators/math/selected_rows_functor_test.cu.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/math/selected_rows_functor.h" + #include "gtest/gtest.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/math/sequence_padding.cc b/paddle/fluid/operators/math/sequence_padding.cc index 35ba8c1d118a82ac63b9db91c7e289bb75c80722..97e276fff02d7926d7d057e6282532200c48f95b 100644 --- a/paddle/fluid/operators/math/sequence_padding.cc +++ b/paddle/fluid/operators/math/sequence_padding.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/math/sequence_padding.h" + #include "paddle/phi/backends/cpu/cpu_context.h" namespace phi { diff --git a/paddle/fluid/operators/math/sequence_padding.cu b/paddle/fluid/operators/math/sequence_padding.cu index 9aca6ad0f5a2f4d7d2dec23736bf71b6b6667ac8..ef7981858a96df9e500e4eb37ff986000710c9a1 100644 --- a/paddle/fluid/operators/math/sequence_padding.cu +++ b/paddle/fluid/operators/math/sequence_padding.cu @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/operators/math/sequence_padding.h" #include "paddle/phi/backends/gpu/gpu_context.h" diff --git a/paddle/fluid/operators/math/sequence_padding.h b/paddle/fluid/operators/math/sequence_padding.h index 956a4ff6a2d45cb619183f9beba1b7e35b7f229c..687c64fc23e5de6892811df1ab5d2c9e5e24fd06 100644 --- a/paddle/fluid/operators/math/sequence_padding.h +++ b/paddle/fluid/operators/math/sequence_padding.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/platform/device_context.h" @@ -64,13 +65,14 @@ inline static void CheckDims(const framework::DDim& seq_tensor_dims, PADDLE_ENFORCE_EQ( seq_tensor_dims.size() + 1 == pad_tensor_dims.size() || seq_tensor_dims.size() == pad_tensor_dims.size(), - true, platform::errors::InvalidArgument( - "pad_tensor's rank should be 1 greater than seq_tensor's " - "rank, or be equal with it. The pad_tensor's rank is %ld, " - "expected the seq_tensor's rank is %ld or %ld, but got %ld. " - "Please check the input value.", - pad_tensor_dims.size(), pad_tensor_dims.size(), - pad_tensor_dims.size() - 1, seq_tensor_dims.size())); + true, + platform::errors::InvalidArgument( + "pad_tensor's rank should be 1 greater than seq_tensor's " + "rank, or be equal with it. The pad_tensor's rank is %ld, " + "expected the seq_tensor's rank is %ld or %ld, but got %ld. " + "Please check the input value.", + pad_tensor_dims.size(), pad_tensor_dims.size(), + pad_tensor_dims.size() - 1, seq_tensor_dims.size())); } /* diff --git a/paddle/fluid/operators/math/sequence_pooling.cc b/paddle/fluid/operators/math/sequence_pooling.cc index 8312d7cd9b72b2b49e0d38a0f824da5479b15c86..9abe9e598881a0c582f3cc70263c0ceee1451f83 100644 --- a/paddle/fluid/operators/math/sequence_pooling.cc +++ b/paddle/fluid/operators/math/sequence_pooling.cc @@ -12,10 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/operators/math/sequence_pooling.h" + #include #include "paddle/fluid/operators/jit/kernels.h" -#include "paddle/fluid/operators/math/sequence_pooling.h" #include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/math/sequence_pooling.cu b/paddle/fluid/operators/math/sequence_pooling.cu index fa7b043153851460c9c8d5586ddce88872b7e3c7..217b29e1b6b18e6f2e0f0010c38f786f0ef0281d 100644 --- a/paddle/fluid/operators/math/sequence_pooling.cu +++ b/paddle/fluid/operators/math/sequence_pooling.cu @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/operators/math/sequence_pooling.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" #include "paddle/fluid/platform/macros.h" @@ -170,41 +171,41 @@ class SequencePoolFunctor { dim3 grid(std::max(static_cast(lod.size()) - 1, 1), 1); paddle::framework::MixVector mix_vector(&lod); if (pooltype == "MAX") { - sequence_pool_kernel< - T, MaxPoolFunctor><<>>( - MaxPoolFunctor(), input.data(), pad_value, - mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, - output->mutable_data(context.GetPlace()), index->data()); + sequence_pool_kernel> + <<>>( + MaxPoolFunctor(), input.data(), pad_value, + mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, + output->mutable_data(context.GetPlace()), index->data()); } else if (pooltype == "AVERAGE") { - sequence_pool_kernel< - T, AvgPoolFunctor><<>>( - AvgPoolFunctor(), input.data(), pad_value, - mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, - output->mutable_data(context.GetPlace()), nullptr); + sequence_pool_kernel> + <<>>( + AvgPoolFunctor(), input.data(), pad_value, + mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, + output->mutable_data(context.GetPlace()), nullptr); } else if (pooltype == "SUM") { - sequence_pool_kernel< - T, SumPoolFunctor><<>>( - SumPoolFunctor(), input.data(), pad_value, - mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, - output->mutable_data(context.GetPlace()), nullptr); + sequence_pool_kernel> + <<>>( + SumPoolFunctor(), input.data(), pad_value, + mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, + output->mutable_data(context.GetPlace()), nullptr); } else if (pooltype == "SQRT") { - sequence_pool_kernel< - T, SqrtPoolFunctor><<>>( - SqrtPoolFunctor(), input.data(), pad_value, - mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, - output->mutable_data(context.GetPlace()), nullptr); + sequence_pool_kernel> + <<>>( + SqrtPoolFunctor(), input.data(), pad_value, + mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, + output->mutable_data(context.GetPlace()), nullptr); } else if (pooltype == "LAST") { - sequence_pool_kernel< - T, LastPoolFunctor><<>>( - LastPoolFunctor(), input.data(), pad_value, - mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, - output->mutable_data(context.GetPlace()), nullptr); + sequence_pool_kernel> + <<>>( + LastPoolFunctor(), input.data(), pad_value, + mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, + output->mutable_data(context.GetPlace()), nullptr); } else if (pooltype == "FIRST") { - sequence_pool_kernel< - T, FirstPoolFunctor><<>>( - FirstPoolFunctor(), input.data(), pad_value, - mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, - output->mutable_data(context.GetPlace()), nullptr); + sequence_pool_kernel> + <<>>( + FirstPoolFunctor(), input.data(), pad_value, + mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, + output->mutable_data(context.GetPlace()), nullptr); } else { PADDLE_THROW(platform::errors::InvalidArgument( "unsupported pooling pooltype: %s. Only support \"MAX\", " @@ -338,41 +339,41 @@ class SequencePoolGradFunctor { dim3 grid(std::max(static_cast(lod.size()) - 1, 1), 1); paddle::framework::MixVector mix_vector(&lod); if (pooltype == "MAX") { - sequence_pool_grad_kernel< - T, MaxPoolGradFunctor><<>>( - MaxPoolGradFunctor(), out_grad.data(), - mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, - in_grad->mutable_data(context.GetPlace()), index->data()); + sequence_pool_grad_kernel> + <<>>( + MaxPoolGradFunctor(), out_grad.data(), + mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, + in_grad->mutable_data(context.GetPlace()), index->data()); } else if (pooltype == "AVERAGE") { - sequence_pool_grad_kernel< - T, AvgPoolGradFunctor><<>>( - AvgPoolGradFunctor(), out_grad.data(), - mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, - in_grad->mutable_data(context.GetPlace()), nullptr); + sequence_pool_grad_kernel> + <<>>( + AvgPoolGradFunctor(), out_grad.data(), + mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, + in_grad->mutable_data(context.GetPlace()), nullptr); } else if (pooltype == "SUM") { - sequence_pool_grad_kernel< - T, SumPoolGradFunctor><<>>( - SumPoolGradFunctor(), out_grad.data(), - mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, - in_grad->mutable_data(context.GetPlace()), nullptr); + sequence_pool_grad_kernel> + <<>>( + SumPoolGradFunctor(), out_grad.data(), + mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, + in_grad->mutable_data(context.GetPlace()), nullptr); } else if (pooltype == "SQRT") { - sequence_pool_grad_kernel< - T, SqrtPoolGradFunctor><<>>( - SqrtPoolGradFunctor(), out_grad.data(), - mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, - in_grad->mutable_data(context.GetPlace()), nullptr); + sequence_pool_grad_kernel> + <<>>( + SqrtPoolGradFunctor(), out_grad.data(), + mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, + in_grad->mutable_data(context.GetPlace()), nullptr); } else if (pooltype == "LAST") { - sequence_pool_grad_kernel< - T, LastPoolGradFunctor><<>>( - LastPoolGradFunctor(), out_grad.data(), - mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, - in_grad->mutable_data(context.GetPlace()), nullptr); + sequence_pool_grad_kernel> + <<>>( + LastPoolGradFunctor(), out_grad.data(), + mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, + in_grad->mutable_data(context.GetPlace()), nullptr); } else if (pooltype == "FIRST") { - sequence_pool_grad_kernel< - T, FirstPoolGradFunctor><<>>( - FirstPoolGradFunctor(), out_grad.data(), - mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, - in_grad->mutable_data(context.GetPlace()), nullptr); + sequence_pool_grad_kernel> + <<>>( + FirstPoolGradFunctor(), out_grad.data(), + mix_vector.CUDAData(context.GetPlace()), lod.size(), item_dim, + in_grad->mutable_data(context.GetPlace()), nullptr); } else { PADDLE_THROW(platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/math/sequence_pooling.h b/paddle/fluid/operators/math/sequence_pooling.h index 847d0bca951a7e54a74a6c803a4f24d50672228f..f5b6701b46ef4fb374caa6bd0ad2ab33c1cff2c9 100644 --- a/paddle/fluid/operators/math/sequence_pooling.h +++ b/paddle/fluid/operators/math/sequence_pooling.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/platform/device_context.h" diff --git a/paddle/fluid/operators/math/sequence_pooling_test.cc b/paddle/fluid/operators/math/sequence_pooling_test.cc index 815d221e2556a1b378353cbcaac9636510cffd7f..6d9c75f955041980d9c005db71b999f1928287fc 100644 --- a/paddle/fluid/operators/math/sequence_pooling_test.cc +++ b/paddle/fluid/operators/math/sequence_pooling_test.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/math/sequence_pooling.h" + #include template diff --git a/paddle/fluid/operators/math/sequence_scale.cc b/paddle/fluid/operators/math/sequence_scale.cc index bc8832a1bbc56b57e111496b8dc5364e1cedf218..8f954e068c048dd45d3a8de5482e624a4d255f55 100644 --- a/paddle/fluid/operators/math/sequence_scale.cc +++ b/paddle/fluid/operators/math/sequence_scale.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/math/sequence_scale.h" + #include "paddle/phi/backends/cpu/cpu_context.h" namespace phi { diff --git a/paddle/fluid/operators/math/sequence_scale.cu b/paddle/fluid/operators/math/sequence_scale.cu index 253a67c2c8cbe5788471f52e233bc9256f973353..c0b97497cc7bf38ec0c6c129d81fa6e5479830db 100644 --- a/paddle/fluid/operators/math/sequence_scale.cu +++ b/paddle/fluid/operators/math/sequence_scale.cu @@ -53,10 +53,10 @@ class ScaleLoDTensorFunctor { seq_data, mix_vector.CUDAMutableData(context.GetPlace()), scales, seq_width); #else - SequenceScaleKernel<<< - num_seq, PADDLE_CUDA_NUM_THREADS, 0, context.stream()>>>( - seq_data, mix_vector.CUDAMutableData(context.GetPlace()), scales, - seq_width); + SequenceScaleKernel + <<>>( + seq_data, mix_vector.CUDAMutableData(context.GetPlace()), scales, + seq_width); #endif mix_vector.CopyToCPU(); } @@ -82,10 +82,10 @@ class ScaleLoDTensorFunctor { seq_data, mix_vector.CUDAMutableData(context.GetPlace()), scales, seq_width); #else - SequenceScaleKernel<<< - num_seq, PADDLE_CUDA_NUM_THREADS, 0, context.stream()>>>( - seq_data, mix_vector.CUDAMutableData(context.GetPlace()), scales, - seq_width); + SequenceScaleKernel + <<>>( + seq_data, mix_vector.CUDAMutableData(context.GetPlace()), scales, + seq_width); #endif mix_vector.CopyToCPU(); } diff --git a/paddle/fluid/operators/math/softmax.cc b/paddle/fluid/operators/math/softmax.cc index c855cb763a97b24222c77f064f80fbc2a50e1f9f..adea86a6c5a87c6abd5579aad546ce1aabf69d02 100644 --- a/paddle/fluid/operators/math/softmax.cc +++ b/paddle/fluid/operators/math/softmax.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/math/softmax.h" + #include "paddle/fluid/operators/math/softmax_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" diff --git a/paddle/fluid/operators/math/softmax_impl.h b/paddle/fluid/operators/math/softmax_impl.h index 69642c81942218b195b167a69044a54ceb97e3a9..33da631d27b1472b8ff9f96992ee47baeb495518 100644 --- a/paddle/fluid/operators/math/softmax_impl.h +++ b/paddle/fluid/operators/math/softmax_impl.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/operators/jit/kernels.h" @@ -66,34 +67,32 @@ class SoftmaxEigen { if (num_remain == 1) { // axis == -1, axis and class in same dimension, calculate along // class dimension directly for higher performance - softmax.device(*context.eigen_device()) = (logits - - logits.maximum(along_axis) - .eval() - .reshape(batch_by_one) - .broadcast(one_by_class)) - .unaryExpr(ValueClip()); + softmax.device(*context.eigen_device()) = + (logits - logits.maximum(along_axis) + .eval() + .reshape(batch_by_one) + .broadcast(one_by_class)) + .unaryExpr(ValueClip()); } else { // axis != -1, class dimension split into (axis, remain), max and sum // should be calculated along axis dimension softmax.device(*context.eigen_device()) = - (logits.reshape(batch_axis_remain) - - logits.reshape(batch_axis_remain) - .maximum(along_axis) - .eval() - .reshape(batch_one_remain) - .broadcast(one_axis_one) - .reshape(batch_classes)) + (logits.reshape(batch_axis_remain) - logits.reshape(batch_axis_remain) + .maximum(along_axis) + .eval() + .reshape(batch_one_remain) + .broadcast(one_axis_one) + .reshape(batch_classes)) .unaryExpr(ValueClip()); } softmax.device(*context.eigen_device()) = softmax.exp(); softmax.device(*context.eigen_device()) = - (softmax * - softmax.reshape(batch_axis_remain) - .sum(along_axis) - .inverse() - .eval() - .broadcast(one_axis)); + (softmax * softmax.reshape(batch_axis_remain) + .sum(along_axis) + .inverse() + .eval() + .broadcast(one_axis)); } }; @@ -128,31 +127,28 @@ class SoftmaxEigen { // axis == -1, axis and class in same dimension, calculate along // class dimension directly for higher performance softmax.device(*context.eigen_device()) = - (logits - - logits.maximum(along_axis) - .reshape(batch_by_one) - .broadcast(one_by_class)) + (logits - logits.maximum(along_axis) + .reshape(batch_by_one) + .broadcast(one_by_class)) .unaryExpr(ValueClip()); } else { // axis != -1, class dimension split into (axis, remain), max and sum // should be calculated along axis dimension softmax.device(*context.eigen_device()) = - (logits.reshape(batch_axis_remain) - - logits.reshape(batch_axis_remain) - .maximum(along_axis) - .reshape(batch_one_remain) - .broadcast(one_axis_one) - .reshape(batch_classes)) + (logits.reshape(batch_axis_remain) - logits.reshape(batch_axis_remain) + .maximum(along_axis) + .reshape(batch_one_remain) + .broadcast(one_axis_one) + .reshape(batch_classes)) .unaryExpr(ValueClip()); } softmax.device(*context.eigen_device()) = softmax.exp(); softmax.device(*context.eigen_device()) = - (softmax * - softmax.reshape(batch_axis_remain) - .sum(along_axis) - .inverse() - .broadcast(one_axis)); + (softmax * softmax.reshape(batch_axis_remain) + .sum(along_axis) + .inverse() + .broadcast(one_axis)); } }; @@ -187,31 +183,28 @@ class SoftmaxEigen { // axis == -1, axis and class in same dimension, calculate along // class dimension directly for higher performance softmax.device(*context.eigen_device()) = - (logits - - logits.maximum(along_axis) - .reshape(batch_by_one) - .broadcast(one_by_class)) + (logits - logits.maximum(along_axis) + .reshape(batch_by_one) + .broadcast(one_by_class)) .unaryExpr(ValueClip()); } else { // axis != -1, class dimension split into (axis, remain), max and sum // should be calculated along axis dimension softmax.device(*context.eigen_device()) = - (logits.reshape(batch_axis_remain) - - logits.reshape(batch_axis_remain) - .maximum(along_axis) - .reshape(batch_one_remain) - .broadcast(one_axis_one) - .reshape(batch_classes)) + (logits.reshape(batch_axis_remain) - logits.reshape(batch_axis_remain) + .maximum(along_axis) + .reshape(batch_one_remain) + .broadcast(one_axis_one) + .reshape(batch_classes)) .unaryExpr(ValueClip()); } softmax.device(*context.eigen_device()) = softmax.exp(); softmax.device(*context.eigen_device()) = - (softmax * - softmax.reshape(batch_axis_remain) - .sum(along_axis) - .inverse() - .broadcast(one_axis)); + (softmax * softmax.reshape(batch_axis_remain) + .sum(along_axis) + .inverse() + .broadcast(one_axis)); } }; diff --git a/paddle/fluid/operators/math/sparse_impl.cu.h b/paddle/fluid/operators/math/sparse_impl.cu.h index dd2d256dd73b2bee0438c439ad9ea43724e20d65..03f94ed573604905869f6587a836ad5402cf3883 100644 --- a/paddle/fluid/operators/math/sparse_impl.cu.h +++ b/paddle/fluid/operators/math/sparse_impl.cu.h @@ -14,11 +14,10 @@ #pragma once +#include "paddle/fluid/platform/device/gpu/gpu_info.h" #include "paddle/fluid/platform/dynload/cusparse.h" #include "paddle/phi/kernels/funcs/math_function.h" -#include "paddle/fluid/platform/device/gpu/gpu_info.h" - namespace paddle { namespace operators { namespace math { diff --git a/paddle/fluid/operators/math/tree2col.cc b/paddle/fluid/operators/math/tree2col.cc index cd1fa13001ce2a2cad14e8249de77067963d97bf..8ad0a17c27ea9f50ef335a3dfc329117f4766f66 100644 --- a/paddle/fluid/operators/math/tree2col.cc +++ b/paddle/fluid/operators/math/tree2col.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/math/tree2col.h" + #include #include diff --git a/paddle/fluid/operators/math/tree2col.cu b/paddle/fluid/operators/math/tree2col.cu index bdaab212ab170df713a18ea8c9febc4ee02c9d3b..c8bba20a423e5faaca08d41391465c8f1470b3b8 100644 --- a/paddle/fluid/operators/math/tree2col.cu +++ b/paddle/fluid/operators/math/tree2col.cu @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/operators/math/tree2col.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/math/tree2col.h b/paddle/fluid/operators/math/tree2col.h index 88104b858ba018e07a226ce9a9597b8a47c24392..df4b233a763d7b02b4e2d37c140761a45095bd85 100644 --- a/paddle/fluid/operators/math/tree2col.h +++ b/paddle/fluid/operators/math/tree2col.h @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/fluid/framework/tensor.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/math/vol2col.cu b/paddle/fluid/operators/math/vol2col.cu index fb61a36a8e1a7c59a5e44235c59199a0a9db8bb5..d8581d731e82b6d15e8197d03b12e9badfc867ee 100644 --- a/paddle/fluid/operators/math/vol2col.cu +++ b/paddle/fluid/operators/math/vol2col.cu @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/operators/math/vol2col.h" #include "paddle/fluid/platform/device/gpu/gpu_launch_config.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" diff --git a/paddle/fluid/operators/math/vol2col.h b/paddle/fluid/operators/math/vol2col.h index 3122828b2eeba5fb1428235dd3a5f926705bd78e..cddcb0af467dcb5331677107eda12be988893fdd 100644 --- a/paddle/fluid/operators/math/vol2col.h +++ b/paddle/fluid/operators/math/vol2col.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/platform/device_context.h" diff --git a/paddle/fluid/operators/math/vol2col_test.cc b/paddle/fluid/operators/math/vol2col_test.cc index 210cf10d8879d60a7547b4dc8984e6f4e5a46f14..4889817cd9eacd95a25617b5406316d403c4e930 100644 --- a/paddle/fluid/operators/math/vol2col_test.cc +++ b/paddle/fluid/operators/math/vol2col_test.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/fluid/operators/math/vol2col.h" #include + #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/operators/matmul_op.cc b/paddle/fluid/operators/matmul_op.cc index 9d381e1f22b5f9233f7d8e919f6680b28870ba94..2c16774e324a7dace61d91d38489ab488278d4d1 100644 --- a/paddle/fluid/operators/matmul_op.cc +++ b/paddle/fluid/operators/matmul_op.cc @@ -12,6 +12,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/phi/kernels/funcs/blas/blas.h" @@ -258,13 +259,14 @@ class MatMulGradKernel : public framework::OpKernel { MatMul(context, a, trans_a, b, trans_b, out); } else { auto &ctx = context.template device_context(); - MatMul(context, is_fold_init_dims_a - ? FoldInitDims(a) - : FoldHeadAndLastDims(ctx, a), - trans_a, is_fold_init_dims_b - ? FoldInitDims(b) - : FoldHeadAndLastDims(ctx, b), - trans_b, out); + MatMul( + context, + is_fold_init_dims_a ? FoldInitDims(a) + : FoldHeadAndLastDims(ctx, a), + trans_a, + is_fold_init_dims_b ? FoldInitDims(b) + : FoldHeadAndLastDims(ctx, b), + trans_b, out); } } @@ -425,13 +427,14 @@ class MatMulDoubleGradKernel : public framework::OpKernel { MatMul(context, a, trans_a, b, trans_b, flag, out); } else { auto &ctx = context.template device_context(); - MatMul(context, is_fold_init_dims_a - ? FoldInitDims(a) - : FoldHeadAndLastDims(ctx, a), - trans_a, is_fold_init_dims_b - ? FoldInitDims(b) - : FoldHeadAndLastDims(ctx, b), - trans_b, flag, out); + MatMul( + context, + is_fold_init_dims_a ? FoldInitDims(a) + : FoldHeadAndLastDims(ctx, a), + trans_a, + is_fold_init_dims_b ? FoldInitDims(b) + : FoldHeadAndLastDims(ctx, b), + trans_b, flag, out); } } @@ -602,12 +605,13 @@ class MatMulOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ( mat_dim_x.batch_size_ == mat_dim_y.batch_size_ || mat_dim_x.batch_size_ == 0 || mat_dim_y.batch_size_ == 0, - true, platform::errors::InvalidArgument( - "The batch size of the two matrices should be equal, or " - "at least one is zero.\n" - "But received X's shape: %s, Y's shape: %s.", - DumpMatrixShape(mat_dim_x).c_str(), - DumpMatrixShape(mat_dim_y).c_str())); + true, + platform::errors::InvalidArgument( + "The batch size of the two matrices should be equal, or " + "at least one is zero.\n" + "But received X's shape: %s, Y's shape: %s.", + DumpMatrixShape(mat_dim_x).c_str(), + DumpMatrixShape(mat_dim_y).c_str())); } int64_t dim_out_y = mat_dim_y.width_; #if defined(PADDLE_WITH_MKLML) && !defined(PADDLE_WITH_CUDA) && \ @@ -996,13 +1000,12 @@ REGISTER_OP_CUDA_KERNEL( ops::MatMulDoubleGradKernel); #endif -REGISTER_OP_VERSION(matmul) - .AddCheckpoint( - R"ROC(Register matmul for adding the attribute of +REGISTER_OP_VERSION(matmul).AddCheckpoint( + R"ROC(Register matmul for adding the attribute of fused_reshape_Y)ROC", - paddle::framework::compatible::OpVersionDesc().NewAttr( - "fused_reshape_Y", - "In order to support the function of fused the input Y " - " and input X into the input X when " - "using the operator of matmul, and get raw shape of input Y.", - std::vector{})); + paddle::framework::compatible::OpVersionDesc().NewAttr( + "fused_reshape_Y", + "In order to support the function of fused the input Y " + " and input X into the input X when " + "using the operator of matmul, and get raw shape of input Y.", + std::vector{})); diff --git a/paddle/fluid/operators/matmul_op_xpu.cc b/paddle/fluid/operators/matmul_op_xpu.cc index 80d4492e04981dbc2622a5010470b132b8b711c2..3477715d6d3dec2ffb100576ce0fd4d002706b69 100644 --- a/paddle/fluid/operators/matmul_op_xpu.cc +++ b/paddle/fluid/operators/matmul_op_xpu.cc @@ -315,14 +315,15 @@ class MatMulGradXPUKernel : public framework::OpKernel { MatMul(context, a, trans_a, b, trans_b, out); } else { auto &dev_ctx = context.template device_context(); - MatMul( - context, is_fold_init_dims_a - ? FoldInitDims(a) - : XPUFoldHeadAndLastDims(dev_ctx, a), - trans_a, is_fold_init_dims_b - ? FoldInitDims(b) - : XPUFoldHeadAndLastDims(dev_ctx, b), - trans_b, out); + MatMul(context, + is_fold_init_dims_a + ? FoldInitDims(a) + : XPUFoldHeadAndLastDims(dev_ctx, a), + trans_a, + is_fold_init_dims_b + ? FoldInitDims(b) + : XPUFoldHeadAndLastDims(dev_ctx, b), + trans_b, out); } } diff --git a/paddle/fluid/operators/matmul_v2_op.cc b/paddle/fluid/operators/matmul_v2_op.cc index 162ebdafec1cb89c1531e03d78ecb383519d5357..168a3dbfeaac11ec413a989738bef23fca0245ac 100644 --- a/paddle/fluid/operators/matmul_v2_op.cc +++ b/paddle/fluid/operators/matmul_v2_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/matmul_v2_op.h" + #include #include diff --git a/paddle/fluid/operators/matmul_v2_op.h b/paddle/fluid/operators/matmul_v2_op.h index 34a8e97af2e1c43dbff982b7e99ced361b831d55..b47cdf6e8cb0dc83706e58050e87affba4d9a571 100644 --- a/paddle/fluid/operators/matmul_v2_op.h +++ b/paddle/fluid/operators/matmul_v2_op.h @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/dot_op.h" diff --git a/paddle/fluid/operators/matmul_v2_op_xpu.cc b/paddle/fluid/operators/matmul_v2_op_xpu.cc index 87df75ac465042a0f7894abecb4be4c213e5d807..f85e714ce9555015da3a86a04fbc93035df13f08 100644 --- a/paddle/fluid/operators/matmul_v2_op_xpu.cc +++ b/paddle/fluid/operators/matmul_v2_op_xpu.cc @@ -14,10 +14,10 @@ #ifdef PADDLE_WITH_XPU -#include "paddle/fluid/operators/matmul_v2_op.h" #include #include +#include "paddle/fluid/operators/matmul_v2_op.h" #include "paddle/fluid/operators/xpu_api_wrapper.h" namespace paddle { diff --git a/paddle/fluid/operators/matrix_power_op.cc b/paddle/fluid/operators/matrix_power_op.cc index 56f65340ea999f48702294f912c4354d83990881..ffbb8538d947a73bb98f404b5885489e3457705e 100644 --- a/paddle/fluid/operators/matrix_power_op.cc +++ b/paddle/fluid/operators/matrix_power_op.cc @@ -14,6 +14,7 @@ #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/tensor_util.h" diff --git a/paddle/fluid/operators/matrix_rank_op.cc b/paddle/fluid/operators/matrix_rank_op.cc index e7d08b6597360bb0431add6ae63eb99f401c8ce0..fddfaa3526a07e5859d11585eafc58f4e523985f 100644 --- a/paddle/fluid/operators/matrix_rank_op.cc +++ b/paddle/fluid/operators/matrix_rank_op.cc @@ -14,6 +14,7 @@ #include #include + #include "paddle/fluid/operators/elementwise/elementwise_op_function.h" #include "paddle/fluid/operators/svd_helper.h" #include "paddle/phi/kernels/funcs/compare_functors.h" diff --git a/paddle/fluid/operators/mean_iou_op.h b/paddle/fluid/operators/mean_iou_op.h index 9fa00e60e05504e0bb8658c6908e4d4ac46b2ca4..1cf9f4433bc2cc1e749b6227b11b1bbd034093b1 100644 --- a/paddle/fluid/operators/mean_iou_op.h +++ b/paddle/fluid/operators/mean_iou_op.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/mean_op_xpu.cc b/paddle/fluid/operators/mean_op_xpu.cc index ef96fe2f03ba41b7599cb9324eef16ee5b37e944..811b138c8d10dbf26bdfbe92c981ae88a0a460ed 100644 --- a/paddle/fluid/operators/mean_op_xpu.cc +++ b/paddle/fluid/operators/mean_op_xpu.cc @@ -56,8 +56,9 @@ class MeanGradXPUKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& context) const override { auto OG = context.Input(framework::GradVarName("Out")); - PADDLE_ENFORCE_EQ(OG->numel(), 1, platform::errors::InvalidArgument( - "Mean Gradient should be scalar")); + PADDLE_ENFORCE_EQ( + OG->numel(), 1, + platform::errors::InvalidArgument("Mean Gradient should be scalar")); auto IG = context.Output(framework::GradVarName("X")); IG->mutable_data(context.GetPlace()); auto& dev_ctx = context.template device_context(); diff --git a/paddle/fluid/operators/merge_lod_tensor_op.cc b/paddle/fluid/operators/merge_lod_tensor_op.cc index e2b86bd0e3b92af750a3af065f8701b2d24085f5..0d4c2f7b3b4b0a70015bd1946b9a4114126635b2 100644 --- a/paddle/fluid/operators/merge_lod_tensor_op.cc +++ b/paddle/fluid/operators/merge_lod_tensor_op.cc @@ -13,7 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/op_registry.h" - #include "paddle/phi/core/lod_utils.h" namespace phi { diff --git a/paddle/fluid/operators/merge_selected_rows_op.cc b/paddle/fluid/operators/merge_selected_rows_op.cc index ea223ad1b3231e9fd3614f50662305d04a22a493..cfb8aa1f8a76e858865fa8de7bede4f31375f6e7 100644 --- a/paddle/fluid/operators/merge_selected_rows_op.cc +++ b/paddle/fluid/operators/merge_selected_rows_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/merge_selected_rows_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/merge_selected_rows_op.h b/paddle/fluid/operators/merge_selected_rows_op.h index 4c87a4a641194c3daac1e25382ca8ceb68ca2fa1..d0f18b22b27971b9c45e921be5a8f1390bb041d5 100644 --- a/paddle/fluid/operators/merge_selected_rows_op.h +++ b/paddle/fluid/operators/merge_selected_rows_op.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/math/selected_rows_functor.h" diff --git a/paddle/fluid/operators/meshgrid_op.cc b/paddle/fluid/operators/meshgrid_op.cc index 5a6862f380da1f917197b682ef88380efb187ce5..cc57a25a1fb342c71d18006fb734999712bab703 100644 --- a/paddle/fluid/operators/meshgrid_op.cc +++ b/paddle/fluid/operators/meshgrid_op.cc @@ -16,10 +16,9 @@ #include #include +#include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" - -#include "paddle/fluid/framework/infershape_utils.h" #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/infermeta/multiary.h" diff --git a/paddle/fluid/operators/miopen_lstm_cache.h b/paddle/fluid/operators/miopen_lstm_cache.h index c307218baa406ed70b6930e007ecdf01973452c1..045f917de7016a162ad65098454a82e73886e6e0 100644 --- a/paddle/fluid/operators/miopen_lstm_cache.h +++ b/paddle/fluid/operators/miopen_lstm_cache.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/platform/device/gpu/gpu_dnn.h" diff --git a/paddle/fluid/operators/miopen_rnn_cache.h b/paddle/fluid/operators/miopen_rnn_cache.h index 38cea39abd5dedea99cd1b3b1088b24ca349f32f..438163cd77eaa5f5113317e105d2c401adf3d75a 100644 --- a/paddle/fluid/operators/miopen_rnn_cache.h +++ b/paddle/fluid/operators/miopen_rnn_cache.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/platform/device/gpu/gpu_dnn.h" diff --git a/paddle/fluid/operators/mkldnn/activation_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/activation_mkldnn_op.cc index 393247644c2e88aa9295d24933bc0048e116e31a..db74b24b405eda3a3aeb533232dd9f197341b4ff 100644 --- a/paddle/fluid/operators/mkldnn/activation_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/activation_mkldnn_op.cc @@ -30,11 +30,11 @@ class MKLDNNDeviceContext; namespace paddle { namespace operators { -using framework::DataLayout; -using framework::Tensor; using dnnl::memory; using dnnl::primitive; using dnnl::stream; +using framework::DataLayout; +using framework::Tensor; using platform::GetMKLDNNFormat; using platform::MKLDNNDeviceContext; using platform::to_void_cast; diff --git a/paddle/fluid/operators/mkldnn/axpy_handler.cc b/paddle/fluid/operators/mkldnn/axpy_handler.cc index ee630fe186a24b828f153c4938d7fd1b6b3fbed3..80f74195d8e3cc66503ff7c92744c4dea3fc8f3a 100644 --- a/paddle/fluid/operators/mkldnn/axpy_handler.cc +++ b/paddle/fluid/operators/mkldnn/axpy_handler.cc @@ -12,13 +12,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/operators/mkldnn/axpy_handler.h" + #include #include #include #include #include "dnnl.hpp" -#include "paddle/fluid/operators/mkldnn/axpy_handler.h" #include "paddle/fluid/platform/bfloat16.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/mkldnn_helper.h" @@ -82,7 +83,7 @@ static void naive_axpy(int n, T alpha, const T *x, T *y) { } } -} // anonnymouse namespace +} // namespace template class OneDNNAXPYHandler::Impl { diff --git a/paddle/fluid/operators/mkldnn/concat_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/concat_mkldnn_op.cc index 5095fa067193a6de0c0b1671203306e25a048c4a..0881baa6f8eea1662f5c08984da8caa892098f86 100644 --- a/paddle/fluid/operators/mkldnn/concat_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/concat_mkldnn_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/operators/concat_op.h" #include "paddle/fluid/operators/utils.h" #include "paddle/fluid/platform/mkldnn_helper.h" @@ -21,13 +22,13 @@ limitations under the License. */ namespace paddle { namespace operators { -using framework::DataLayout; -using framework::Tensor; -using framework::LoDTensor; +using dnnl::concat; using dnnl::memory; using dnnl::primitive; -using dnnl::concat; using dnnl::stream; +using framework::DataLayout; +using framework::LoDTensor; +using framework::Tensor; using platform::to_void_cast; template diff --git a/paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc index fba17d303f282e155ffd123c6178e1b7e21bd72f..65092e059f4afe0bff98cce3e63a520e2d736a6c 100644 --- a/paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc @@ -203,8 +203,9 @@ class ConvMKLDNNHandlerT dnnl::memory::desc src_md, weights_md; if (platform::is_int8()) { src_md = platform::MKLDNNMemDesc( - src_tz, framework::ToMKLDNNDataType( - framework::TransToProtoVarType(input->dtype())), + src_tz, + framework::ToMKLDNNDataType( + framework::TransToProtoVarType(input->dtype())), chosen_memory_format); weights_md = platform::MKLDNNMemDesc( weights_tz, dnnl::memory::data_type::s8, chosen_memory_format); @@ -459,13 +460,12 @@ class ConvMKLDNNHandlerT auto scale_weights_data = ctx.Attr>("Scale_weights"); bool is_multi_channel = scale_weights_data.size() > 1; bool has_activation = !ctx.Attr("fuse_activation").empty(); - float activation_scale = - force_fp32_output ? 1.0f : has_activation ? ctx.Attr("Scale_out") - : 1.0f; - auto scale_out_data = - force_fp32_output ? 1.0f : has_activation - ? 1.0f - : ctx.Attr("Scale_out"); + float activation_scale = force_fp32_output ? 1.0f + : has_activation ? ctx.Attr("Scale_out") + : 1.0f; + auto scale_out_data = force_fp32_output ? 1.0f + : has_activation ? 1.0f + : ctx.Attr("Scale_out"); float sum_scale = fuse_residual_conn ? scale_out_data / scale_in_eltwise_data : 1.0f; int count = diff --git a/paddle/fluid/operators/mkldnn/dequantize_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/dequantize_mkldnn_op.cc index 747e4603d7fe7774b039d60200d5db7cdf0952d6..e507b2429b7d9b163788fbab704ac91b0d2847ed 100644 --- a/paddle/fluid/operators/mkldnn/dequantize_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/dequantize_mkldnn_op.cc @@ -28,8 +28,8 @@ using dnnl::primitive; using dnnl::reorder; using platform::to_void_cast; using Tensor = framework::Tensor; -using framework::DataLayout; using dnnl::stream; +using framework::DataLayout; using platform::GetMKLDNNFormat; template diff --git a/paddle/fluid/operators/mkldnn/expand_v2_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/expand_v2_mkldnn_op.cc index 91dccbee0aef2a3dc9fb59c430df98bd857f43b9..035add5fd834d9dc4a354020c45dc28b96235f96 100644 --- a/paddle/fluid/operators/mkldnn/expand_v2_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/expand_v2_mkldnn_op.cc @@ -18,11 +18,11 @@ limitations under the License. */ namespace { -using paddle::framework::Tensor; -using phi::vectorize; -using paddle::framework::GradVarName; using paddle::framework::ExecutionContext; +using paddle::framework::GradVarName; +using paddle::framework::Tensor; using paddle::platform::MKLDNNDeviceContext; +using phi::vectorize; template class ExpandMKLDNNKernel : public paddle::framework::OpKernel { diff --git a/paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc index 4078d012fce900a804a42d0a9633620bba132a56..5cbcad5d965a4760883c690bb05c0e7537d77313 100644 --- a/paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc @@ -31,19 +31,19 @@ class MKLDNNDeviceContext; namespace paddle { namespace operators { +using dnnl::inner_product_forward; +using dnnl::memory; +using dnnl::primitive; +using dnnl::prop_kind; +using dnnl::stream; using framework::DataLayout; -using framework::Tensor; -using framework::LoDTensor; using framework::DDim; using framework::ExecutionContext; +using framework::LoDTensor; +using framework::Tensor; +using platform::GetMKLDNNFormat; using platform::MKLDNNDeviceContext; using platform::to_void_cast; -using platform::GetMKLDNNFormat; -using dnnl::memory; -using dnnl::inner_product_forward; -using dnnl::primitive; -using dnnl::stream; -using dnnl::prop_kind; template class FCPrimitiveFactory { diff --git a/paddle/fluid/operators/mkldnn/interpolate_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/interpolate_mkldnn_op.cc index 37d6c07290312a2e55f21c0393f7c2a01da5e10e..a53a30b737dc4be18b780a859d40ccb4e79d70d1 100644 --- a/paddle/fluid/operators/mkldnn/interpolate_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/interpolate_mkldnn_op.cc @@ -19,12 +19,12 @@ namespace paddle { namespace operators { -using framework::DataLayout; using dnnl::memory; using dnnl::primitive; using dnnl::reorder; -using dnnl::stream; using dnnl::resampling_forward; +using dnnl::stream; +using framework::DataLayout; using platform::GetMKLDNNFormat; using platform::to_void_cast; @@ -114,9 +114,10 @@ class InterpolateMKLDNNKernel : public framework::OpKernel { PADDLE_ENFORCE_GT(std::all_of(out_dims.begin(), out_dims.end(), [](int i) { return i > 0; }), - 0, platform::errors::InvalidArgument( - "out_d, out_h, out_w of Op(interpolate) " - "should be greater than 0.")); + 0, + platform::errors::InvalidArgument( + "out_d, out_h, out_w of Op(interpolate) " + "should be greater than 0.")); const std::vector nc_dims = {in_dims[0], in_dims[1]}; out_dims.insert(out_dims.begin(), nc_dims.begin(), nc_dims.end()); diff --git a/paddle/fluid/operators/mkldnn/matmul_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/matmul_mkldnn_op.cc index e9abe84e67980377c254fdcadae6a6e764acb869..8921db6cbcef98b7fcf325a3a8e9c61e0e67df74 100644 --- a/paddle/fluid/operators/mkldnn/matmul_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/matmul_mkldnn_op.cc @@ -13,19 +13,21 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/mkldnn/matmul_mkldnn_op.h" + #include + #include "paddle/fluid/framework/convert_utils.h" using dnnl::memory; using dnnl::primitive; using paddle::framework::DataLayout; using paddle::framework::ExecutionContext; -using phi::vectorize; using paddle::platform::GetMKLDNNFormat; -using paddle::platform::MKLDNNFormatForSize; using paddle::platform::MKLDNNDeviceContext; +using paddle::platform::MKLDNNFormatForSize; using paddle::platform::MKLDNNGetDataType; using paddle::platform::to_void_cast; +using phi::vectorize; using Tensor = paddle::framework::Tensor; namespace { diff --git a/paddle/fluid/operators/mkldnn/matmul_mkldnn_op.h b/paddle/fluid/operators/mkldnn/matmul_mkldnn_op.h index 583dcd04018b28f3fc05c149f9ee50d5e1333af6..07cb2173a7ec5d2c3f7d3f8ff865e82fdad3251c 100644 --- a/paddle/fluid/operators/mkldnn/matmul_mkldnn_op.h +++ b/paddle/fluid/operators/mkldnn/matmul_mkldnn_op.h @@ -22,8 +22,8 @@ limitations under the License. */ namespace paddle { namespace operators { -using platform::MKLDNNDeviceContext; using framework::ExecutionContext; +using platform::MKLDNNDeviceContext; using Tensor = framework::Tensor; template diff --git a/paddle/fluid/operators/mkldnn/matmul_v2_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/matmul_v2_mkldnn_op.cc index 6e7ba59cf1ad83963da8d0ed5429836ede1ea24f..424faf30d3a9f279eb99bde0f402665610231068 100644 --- a/paddle/fluid/operators/mkldnn/matmul_v2_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/matmul_v2_mkldnn_op.cc @@ -20,8 +20,8 @@ using dnnl::memory; using dnnl::primitive; using paddle::framework::DataLayout; using paddle::framework::ExecutionContext; -using paddle::platform::MatMulV2MKLDNNHandler; using paddle::platform::GetMKLDNNFormat; +using paddle::platform::MatMulV2MKLDNNHandler; using paddle::platform::MKLDNNDeviceContext; using paddle::platform::MKLDNNGetDataType; using paddle::platform::to_void_cast; @@ -206,11 +206,12 @@ class MatMulV2MKLDNNKernel : public paddle::framework::OpKernel { PADDLE_ENFORCE_EQ( x_bd_dims[i] == y_bd_dims[i] || x_bd_dims[i] == 1 || y_bd_dims[i] == 1, - true, paddle::platform::errors::InvalidArgument( - "Tensor dimensions are incorrect for broadcasting." - "Dimensions in X and Y must be same or equal to 1, but " - "received x_dim[%d]=%d and y_dims[%d]= %d", - i, x_bd_dims[i], i, y_bd_dims[i])); + true, + paddle::platform::errors::InvalidArgument( + "Tensor dimensions are incorrect for broadcasting." + "Dimensions in X and Y must be same or equal to 1, but " + "received x_dim[%d]=%d and y_dims[%d]= %d", + i, x_bd_dims[i], i, y_bd_dims[i])); out_dims[i] = std::max(x_bd_dims[i], y_bd_dims[i]); } out->Resize(phi::make_ddim(out_dims)); diff --git a/paddle/fluid/operators/mkldnn/pool_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/pool_mkldnn_op.cc index 77763531c8296de110cbc41ed60240f7b420d2ca..dbf3adcdad07d8d10aa34410691c47f0b767f3a1 100644 --- a/paddle/fluid/operators/mkldnn/pool_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/pool_mkldnn_op.cc @@ -20,14 +20,14 @@ limitations under the License. */ namespace paddle { namespace operators { -using framework::DataLayout; -using framework::Tensor; using dnnl::memory; using dnnl::pooling_backward; using dnnl::pooling_forward; using dnnl::primitive; using dnnl::reorder; using dnnl::stream; +using framework::DataLayout; +using framework::Tensor; using platform::to_void_cast; template diff --git a/paddle/fluid/operators/mkldnn/quantize_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/quantize_mkldnn_op.cc index 8cbe46bee481abd896683d82107efa273127dedc..8f3a3e8ba65e761da7f261a36197e7b5287ca2b6 100644 --- a/paddle/fluid/operators/mkldnn/quantize_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/quantize_mkldnn_op.cc @@ -27,8 +27,8 @@ using dnnl::primitive; using dnnl::reorder; using platform::to_void_cast; using Tensor = framework::Tensor; -using framework::DataLayout; using dnnl::stream; +using framework::DataLayout; using platform::GetMKLDNNFormat; template diff --git a/paddle/fluid/operators/mkldnn/requantize_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/requantize_mkldnn_op.cc index 9a7ac6d505522c50e59671d7f7ea2aff3a1fdd59..778a33f27af0a1c644e8565c32eb7d06a735a7de 100644 --- a/paddle/fluid/operators/mkldnn/requantize_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/requantize_mkldnn_op.cc @@ -46,10 +46,12 @@ class ReQuantOpKernel : public framework::OpKernel { bool with_shift = shift_in != 0.0f || shift_out != 0.0f; auto* output = ctx.Output("Output"); - PADDLE_ENFORCE_NE(scale_in, 0.0f, platform::errors::InvalidArgument( - "Scale of input cannot be 0.0")); - PADDLE_ENFORCE_NE(scale_out, 0.0f, platform::errors::InvalidArgument( - "Scale of output cannot be 0.0")); + PADDLE_ENFORCE_NE( + scale_in, 0.0f, + platform::errors::InvalidArgument("Scale of input cannot be 0.0")); + PADDLE_ENFORCE_NE( + scale_out, 0.0f, + platform::errors::InvalidArgument("Scale of output cannot be 0.0")); if (shift_in != 0.0f) { PADDLE_ENFORCE_EQ( framework::TransToProtoVarType(input->dtype()), diff --git a/paddle/fluid/operators/mkldnn/reshape_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/reshape_mkldnn_op.cc index a21034d48baaa5a64a64ab9c1a32ce40ff0233a0..f1c5153240ee2dc95a83af79b7e28a6d0d6911b2 100644 --- a/paddle/fluid/operators/mkldnn/reshape_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/reshape_mkldnn_op.cc @@ -31,8 +31,8 @@ namespace paddle { namespace operators { using paddle::framework::LoDTensor; -using platform::to_void_cast; using platform::GetMKLDNNFormat; +using platform::to_void_cast; static std::vector extract_shape( const std::vector& list_new_shape_tensor) { diff --git a/paddle/fluid/operators/mkldnn/stack_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/stack_mkldnn_op.cc index 28a00be5fa47ec3b34e7a40e204fd4d76e2c0239..798fe51901df0fa2cf23b8e90dbdd64fe5d7ccc3 100644 --- a/paddle/fluid/operators/mkldnn/stack_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/stack_mkldnn_op.cc @@ -17,13 +17,13 @@ limitations under the License. */ namespace paddle { namespace operators { -using framework::DataLayout; -using framework::Tensor; -using framework::LoDTensor; +using dnnl::concat; using dnnl::memory; using dnnl::primitive; -using dnnl::concat; using dnnl::stream; +using framework::DataLayout; +using framework::LoDTensor; +using framework::Tensor; using platform::to_void_cast; template diff --git a/paddle/fluid/operators/mkldnn/sum_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/sum_mkldnn_op.cc index de21c2687bd44271389ea7e3b120e1c687df0484..b564602fdaada8a1244789596fbf83109fb7a91f 100644 --- a/paddle/fluid/operators/mkldnn/sum_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/sum_mkldnn_op.cc @@ -116,8 +116,9 @@ class SumMKLDNNOpKernel : public paddle::framework::OpKernel { const auto& mkldnn_engine = dev_ctx.GetEngine(); auto in_vars = ctx.MultiInputVar("X"); - PADDLE_ENFORCE_NE(in_vars.empty(), true, platform::errors::InvalidArgument( - "Input variable is empty.")); + PADDLE_ENFORCE_NE( + in_vars.empty(), true, + platform::errors::InvalidArgument("Input variable is empty.")); auto& input0 = in_vars[0]->Get(); LoDTensor* output = ctx.Output("Out"); diff --git a/paddle/fluid/operators/mkldnn/test_mkldnn_caching.cc b/paddle/fluid/operators/mkldnn/test_mkldnn_caching.cc index b5fb0c54c7812f6a022d3c61f6e225a576765f00..1e04cc8a8a525bf2938e319ecbb52ae2523f9252 100644 --- a/paddle/fluid/operators/mkldnn/test_mkldnn_caching.cc +++ b/paddle/fluid/operators/mkldnn/test_mkldnn_caching.cc @@ -16,6 +16,7 @@ #include #include #include + #include "gtest/gtest.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/op_registry.h" @@ -121,8 +122,9 @@ void RunOperator(const platform::Place &place, const std::string &op_type, auto op = num_inputs[op_type] > 1 ? framework::OpRegistry::CreateOp( - op_type, {{first_input_var_name, {first_input}}, - {second_input_var_name, {"x1"}}}, + op_type, + {{first_input_var_name, {first_input}}, + {second_input_var_name, {"x1"}}}, {{output_var_name, {output_name}}}, {{"use_mkldnn", {true}}}) : framework::OpRegistry::CreateOp( op_type, {{first_input_var_name, {first_input}}}, diff --git a/paddle/fluid/operators/mkldnn/test_mkldnn_op_inplace.cc b/paddle/fluid/operators/mkldnn/test_mkldnn_op_inplace.cc index 4090d5ffca801512e423b02bfda3dd1a1bc49f03..a1acf3706c590aab5720d5312887a2002c77c0bd 100644 --- a/paddle/fluid/operators/mkldnn/test_mkldnn_op_inplace.cc +++ b/paddle/fluid/operators/mkldnn/test_mkldnn_op_inplace.cc @@ -16,6 +16,7 @@ #include #include #include + #include "gtest/gtest.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/mkldnn/test_mkldnn_op_nhwc.cc b/paddle/fluid/operators/mkldnn/test_mkldnn_op_nhwc.cc index b9866ba8c364794f67935c2855ae2b51c4b443b5..f4b79a0216332c2bfd311c736991e6d44a74123a 100644 --- a/paddle/fluid/operators/mkldnn/test_mkldnn_op_nhwc.cc +++ b/paddle/fluid/operators/mkldnn/test_mkldnn_op_nhwc.cc @@ -16,6 +16,7 @@ #include #include #include + #include "gtest/gtest.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/mkldnn/transpose_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/transpose_mkldnn_op.cc index ee9922773147cc20710446dcf98a881ccb93bbc5..13f9dba9eeb8f2c11551c33c218088e4c350b9c2 100644 --- a/paddle/fluid/operators/mkldnn/transpose_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/transpose_mkldnn_op.cc @@ -66,7 +66,7 @@ class TransposeMKLDNNHandler { protected: dnnl::memory::desc Axis2MemoryDesc(std::vector& nchw_tz, // NOLINT std::vector& axis // NOLINT - ) { + ) { size_t ndims = axis.size(); std::vector strides(ndims); diff --git a/paddle/fluid/operators/mlu/mlu_baseop.cc b/paddle/fluid/operators/mlu/mlu_baseop.cc index 9d3b8e2407fbfb8aa4cd5eeb640ab06ae961eb1c..1ff27454013e133d8e15b4015d1424b3d772caa7 100644 --- a/paddle/fluid/operators/mlu/mlu_baseop.cc +++ b/paddle/fluid/operators/mlu/mlu_baseop.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/mlu/mlu_baseop.h" + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/framework.pb.h" diff --git a/paddle/fluid/operators/mode_op.cc b/paddle/fluid/operators/mode_op.cc index 9c16ccb138f7da56568ce6224dc30deb5bbccb7f..d946f177545b4121f3b674ae9de03c2d3c8c288c 100644 --- a/paddle/fluid/operators/mode_op.cc +++ b/paddle/fluid/operators/mode_op.cc @@ -13,10 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/generator.h" +#include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" - -#include "paddle/fluid/framework/infershape_utils.h" #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/infermeta/unary.h" diff --git a/paddle/fluid/operators/modified_huber_loss_op.cc b/paddle/fluid/operators/modified_huber_loss_op.cc index 9a53c7162ff6d30658d0676ebd1ab132ea4f6b03..4216ee097be52aaf77432cfea3058d11e4903e87 100644 --- a/paddle/fluid/operators/modified_huber_loss_op.cc +++ b/paddle/fluid/operators/modified_huber_loss_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/modified_huber_loss_op.h" + #include namespace paddle { @@ -29,10 +30,11 @@ class ModifiedHuberLossOp : public framework::OperatorWithKernel { auto x_dims = ctx->GetInputDim("X"); auto y_dims = ctx->GetInputDim("Y"); - PADDLE_ENFORCE_EQ(x_dims.size(), 2, platform::errors::InvalidArgument( - "Input(input) rank should be 2, " - "but received input rank(%d) != 2", - x_dims.size())); + PADDLE_ENFORCE_EQ( + x_dims.size(), 2, + platform::errors::InvalidArgument("Input(input) rank should be 2, " + "but received input rank(%d) != 2", + x_dims.size())); if (ctx->IsRuntime() || (phi::product(x_dims) > 0 && phi::product(y_dims) > 0)) { diff --git a/paddle/fluid/operators/modified_huber_loss_op.cu b/paddle/fluid/operators/modified_huber_loss_op.cu index 8f1894b5af0a16d50982b10dff1d0656fe6bb3bb..ad34a54a9bf29f059767159d9f8fda890daa2228 100644 --- a/paddle/fluid/operators/modified_huber_loss_op.cu +++ b/paddle/fluid/operators/modified_huber_loss_op.cu @@ -15,6 +15,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/modified_huber_loss_op.h" #include "paddle/phi/core/hostdevice.h" diff --git a/paddle/fluid/operators/mul_op.cc b/paddle/fluid/operators/mul_op.cc index ef04d5582d3c03d34375293b91eef873d3776d9a..b31935cefc2358a62e61ab233199b299042ef641 100644 --- a/paddle/fluid/operators/mul_op.cc +++ b/paddle/fluid/operators/mul_op.cc @@ -16,6 +16,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #ifdef PADDLE_WITH_MKLDNN #include "paddle/fluid/platform/mkldnn_helper.h" diff --git a/paddle/fluid/operators/mul_op_xpu.cc b/paddle/fluid/operators/mul_op_xpu.cc index 7410b3b607c82e9bff68f176cc4c32551fa7da55..9f52dc8559d42c1ce52f637b028c5b99c1f55f05 100644 --- a/paddle/fluid/operators/mul_op_xpu.cc +++ b/paddle/fluid/operators/mul_op_xpu.cc @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/xpu_api_wrapper.h" #include "paddle/fluid/platform/device/device_wrapper.h" diff --git a/paddle/fluid/operators/multiplex_op.cc b/paddle/fluid/operators/multiplex_op.cc index 4e6ad35e612b7ea0392840be863f8820957765ac..72243b408f4be5a71ab0c416ff9a6afb56ff17ee 100644 --- a/paddle/fluid/operators/multiplex_op.cc +++ b/paddle/fluid/operators/multiplex_op.cc @@ -17,7 +17,6 @@ limitations under the License. */ #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" - #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/infermeta/multiary.h" diff --git a/paddle/fluid/operators/nanmedian_op.cc b/paddle/fluid/operators/nanmedian_op.cc index 23a497bdb1d3d8b1ba18d722a805315207a370d7..63bfea650ac00f400ba09760b4c4506b5b014a89 100644 --- a/paddle/fluid/operators/nanmedian_op.cc +++ b/paddle/fluid/operators/nanmedian_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" diff --git a/paddle/fluid/operators/nccl/nccl_gpu_common.cc b/paddle/fluid/operators/nccl/nccl_gpu_common.cc index bcbc96ea1b6d1041e43498c7c6e32ec1be2029f3..8a0112fa11d80e95e2ce22aa1656345f863ebb35 100644 --- a/paddle/fluid/operators/nccl/nccl_gpu_common.cc +++ b/paddle/fluid/operators/nccl/nccl_gpu_common.cc @@ -25,7 +25,7 @@ size_t last_num_gpus = -1; // TODO(panyx0718): Need to decide whether Paddle supports parallel // runs with different number GPUs. If true, current solution is not enough. std::mutex comm_mu; -} +} // namespace int Communicator::GetCommId(int device_id) const { std::lock_guard guard(comm_mu); diff --git a/paddle/fluid/operators/nccl/nccl_op.cu.cc b/paddle/fluid/operators/nccl/nccl_op.cu.cc index 65c3447ff23eedff40cfef46a04de149c947208c..b99800ecd64be9eb5b93d219d435ab873db6e074 100644 --- a/paddle/fluid/operators/nccl/nccl_op.cu.cc +++ b/paddle/fluid/operators/nccl/nccl_op.cu.cc @@ -19,9 +19,9 @@ limitations under the License. */ namespace paddle { namespace operators { +using framework::LoDTensor; using framework::Tensor; using platform::Communicator; -using framework::LoDTensor; template class NCCLTypeWrapper; diff --git a/paddle/fluid/operators/nccl/nccl_op_test.cu.cc b/paddle/fluid/operators/nccl/nccl_op_test.cu.cc index 80144c6f25894345d5f77b7469852ab38ef00a81..21649bfcd378f12a1df07e6bb6680607e1eed52f 100644 --- a/paddle/fluid/operators/nccl/nccl_op_test.cu.cc +++ b/paddle/fluid/operators/nccl/nccl_op_test.cu.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include #include // NOLINT #include // NOLINT diff --git a/paddle/fluid/operators/nce_op.h b/paddle/fluid/operators/nce_op.h index c8af241559429c105ea2ef91d46c209937b95ad9..38c9b809eb6e4f40e348cd839060ac9bafdebbe7 100644 --- a/paddle/fluid/operators/nce_op.h +++ b/paddle/fluid/operators/nce_op.h @@ -15,11 +15,13 @@ limitations under the License. */ #pragma once #include + #include #include #include #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/selected_rows_utils.h" diff --git a/paddle/fluid/operators/nll_loss_op.cc b/paddle/fluid/operators/nll_loss_op.cc index 8f14bc10d50942f55e29f196e9ca3f35e8f71d14..d3cbec495fdb546261e347ebd4e42040342084ac 100644 --- a/paddle/fluid/operators/nll_loss_op.cc +++ b/paddle/fluid/operators/nll_loss_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/infermeta/backward.h" diff --git a/paddle/fluid/operators/norm_op.cc b/paddle/fluid/operators/norm_op.cc index 51daccce0e8822a1eec25ac428e5a56c632805e2..0a1f647627a9affa5904a7fdfa2c0d6c9b119a4e 100644 --- a/paddle/fluid/operators/norm_op.cc +++ b/paddle/fluid/operators/norm_op.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/infermeta/unary.h" diff --git a/paddle/fluid/operators/norm_utils.cu.h b/paddle/fluid/operators/norm_utils.cu.h index 0ed1f2719de25bd2c138c23dd69b914a66961464..18ae152a689e8a1f176c59a8f6d3bbdaebf7c065 100644 --- a/paddle/fluid/operators/norm_utils.cu.h +++ b/paddle/fluid/operators/norm_utils.cu.h @@ -450,27 +450,27 @@ void NormDoubleGradFunctor(const DeviceContext &ctx, set_constant(ctx, dX, static_cast(0)); if (use_global_stats) { if (data_layout == DataLayout::kNHWC) { - DoubleGradComputeDXWithGlobal< - T, DataLayout::kNHWC><<>>( - dy_data, ddscale_data, variance_data, epsilon, C, sample_size, num, - dx_data); + DoubleGradComputeDXWithGlobal + <<>>(dy_data, ddscale_data, + variance_data, epsilon, C, + sample_size, num, dx_data); } else { - DoubleGradComputeDXWithGlobal< - T, DataLayout::kNCHW><<>>( - dy_data, ddscale_data, variance_data, epsilon, C, sample_size, num, - dx_data); + DoubleGradComputeDXWithGlobal + <<>>(dy_data, ddscale_data, + variance_data, epsilon, C, + sample_size, num, dx_data); } } else { if (data_layout == DataLayout::kNHWC) { - DoubleGradComputeDX< - T, block, DataLayout::kNHWC><<>>( - x_data, mean_data, variance_data, ddx_data, dy_data, scale_data, - ddscale_data, N, C, sample_size, epsilon, dx_data); + DoubleGradComputeDX + <<>>( + x_data, mean_data, variance_data, ddx_data, dy_data, scale_data, + ddscale_data, N, C, sample_size, epsilon, dx_data); } else { - DoubleGradComputeDX< - T, block, DataLayout::kNCHW><<>>( - x_data, mean_data, variance_data, ddx_data, dy_data, scale_data, - ddscale_data, N, C, sample_size, epsilon, dx_data); + DoubleGradComputeDX + <<>>( + x_data, mean_data, variance_data, ddx_data, dy_data, scale_data, + ddscale_data, N, C, sample_size, epsilon, dx_data); } } } @@ -479,27 +479,27 @@ void NormDoubleGradFunctor(const DeviceContext &ctx, set_constant(ctx, dScale, static_cast(0)); if (use_global_stats) { if (data_layout == DataLayout::kNHWC) { - DoubleGradComputeDScaleWithGlobal< - T, block, DataLayout::kNHWC><<>>( - ddx_data, variance_data, dy_data, epsilon, N, C, sample_size, - dscale_data); + DoubleGradComputeDScaleWithGlobal + <<>>(ddx_data, variance_data, dy_data, + epsilon, N, C, sample_size, + dscale_data); } else { - DoubleGradComputeDScaleWithGlobal< - T, block, DataLayout::kNCHW><<>>( - ddx_data, variance_data, dy_data, epsilon, N, C, sample_size, - dscale_data); + DoubleGradComputeDScaleWithGlobal + <<>>(ddx_data, variance_data, dy_data, + epsilon, N, C, sample_size, + dscale_data); } } else { if (data_layout == DataLayout::kNHWC) { - DoubleGradComputeDScale< - T, block, DataLayout::kNHWC><<>>( - x_data, mean_data, variance_data, ddx_data, dy_data, N, C, - sample_size, epsilon, dscale_data); + DoubleGradComputeDScale + <<>>( + x_data, mean_data, variance_data, ddx_data, dy_data, N, C, + sample_size, epsilon, dscale_data); } else { - DoubleGradComputeDScale< - T, block, DataLayout::kNCHW><<>>( - x_data, mean_data, variance_data, ddx_data, dy_data, N, C, - sample_size, epsilon, dscale_data); + DoubleGradComputeDScale + <<>>( + x_data, mean_data, variance_data, ddx_data, dy_data, N, C, + sample_size, epsilon, dscale_data); } } } @@ -508,27 +508,29 @@ void NormDoubleGradFunctor(const DeviceContext &ctx, set_constant(ctx, ddY, static_cast(0)); if (use_global_stats) { if (data_layout == DataLayout::kNHWC) { - DoubleGradComputeDDYWithGlobal< - T, DataLayout::kNHWC><<>>( - ddx_data, scale_data, mean_data, variance_data, x_data, ddbias_data, - ddscale_data, epsilon, C, sample_size, num, ddy_data); + DoubleGradComputeDDYWithGlobal + <<>>( + ddx_data, scale_data, mean_data, variance_data, x_data, + ddbias_data, ddscale_data, epsilon, C, sample_size, num, + ddy_data); } else { - DoubleGradComputeDDYWithGlobal< - T, DataLayout::kNCHW><<>>( - ddx_data, scale_data, mean_data, variance_data, x_data, ddbias_data, - ddscale_data, epsilon, C, sample_size, num, ddy_data); + DoubleGradComputeDDYWithGlobal + <<>>( + ddx_data, scale_data, mean_data, variance_data, x_data, + ddbias_data, ddscale_data, epsilon, C, sample_size, num, + ddy_data); } } else { if (data_layout == DataLayout::kNHWC) { - DoubleGradComputeDDY< - T, block, DataLayout::kNHWC><<>>( - x_data, mean_data, variance_data, ddscale_data, ddbias_data, - ddx_data, scale_data, N, C, sample_size, epsilon, ddy_data); + DoubleGradComputeDDY + <<>>( + x_data, mean_data, variance_data, ddscale_data, ddbias_data, + ddx_data, scale_data, N, C, sample_size, epsilon, ddy_data); } else { - DoubleGradComputeDDY< - T, block, DataLayout::kNCHW><<>>( - x_data, mean_data, variance_data, ddscale_data, ddbias_data, - ddx_data, scale_data, N, C, sample_size, epsilon, ddy_data); + DoubleGradComputeDDY + <<>>( + x_data, mean_data, variance_data, ddscale_data, ddbias_data, + ddx_data, scale_data, N, C, sample_size, epsilon, ddy_data); } } } diff --git a/paddle/fluid/operators/norm_utils.h b/paddle/fluid/operators/norm_utils.h index fee06fe5dd4fae2e843bc639bba4afc259b78ea5..363702459221db2d8425ce20f35121715544bdda 100644 --- a/paddle/fluid/operators/norm_utils.h +++ b/paddle/fluid/operators/norm_utils.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/number_count_op.cu b/paddle/fluid/operators/number_count_op.cu index 923d89c24853f7902e55988cf4b656105e8ff826..2fc180fe678e9f023fcd48f7ddfe1e94cc3f9612 100644 --- a/paddle/fluid/operators/number_count_op.cu +++ b/paddle/fluid/operators/number_count_op.cu @@ -97,13 +97,13 @@ class NumberCountOpCUDAKernel : public framework::OpKernel { auto out_data = number_count->mutable_data(out_dims, place); const T* gate_data = numbers->data(); - initialize_zero_kernel< - T><<>>( - out_data, upper_range); + initialize_zero_kernel + <<>>( + out_data, upper_range); - NumberCount< - T><<>>( - gate_data, out_data, batch_size, upper_range); + NumberCount + <<>>( + gate_data, out_data, batch_size, upper_range); } }; diff --git a/paddle/fluid/operators/one_hot_op.cc b/paddle/fluid/operators/one_hot_op.cc index 64323e588c628542742a4233647cd425ae889b21..e6b6320898fb14be81b17d26e7b67941edb933ef 100644 --- a/paddle/fluid/operators/one_hot_op.cc +++ b/paddle/fluid/operators/one_hot_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/one_hot_op.h" + #include #include diff --git a/paddle/fluid/operators/one_hot_op_npu.cc b/paddle/fluid/operators/one_hot_op_npu.cc index 24b506ebf8a06dc917eb43711fd1883b29f79b2f..4e11cbb38883b045f2aa0fca7605aa346da7c564 100644 --- a/paddle/fluid/operators/one_hot_op_npu.cc +++ b/paddle/fluid/operators/one_hot_op_npu.cc @@ -13,7 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/one_hot_op.h" - #include "paddle/fluid/platform/device/npu/npu_op_runner.h" namespace paddle { diff --git a/paddle/fluid/operators/one_hot_v2_op.cc b/paddle/fluid/operators/one_hot_v2_op.cc index 122b6a8a80aac95ab98ad95ed3e6339684978d12..cb7b9963bbdf33b5798184f5299a5915bb86a984 100644 --- a/paddle/fluid/operators/one_hot_v2_op.cc +++ b/paddle/fluid/operators/one_hot_v2_op.cc @@ -14,6 +14,7 @@ #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/one_hot_v2_op_npu.cc b/paddle/fluid/operators/one_hot_v2_op_npu.cc index e5702a37bb2b4a4180e209bb5e306be64830bd99..dcf098f105c217fd969d90bd039a8521ed1cb4dd 100644 --- a/paddle/fluid/operators/one_hot_v2_op_npu.cc +++ b/paddle/fluid/operators/one_hot_v2_op_npu.cc @@ -13,7 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/op_registry.h" - #include "paddle/fluid/platform/device/npu/npu_op_runner.h" namespace paddle { diff --git a/paddle/fluid/operators/optimizers/adagrad_op.cc b/paddle/fluid/operators/optimizers/adagrad_op.cc index 91bad1430615fd1b0d8afbb636adeebc48b5f027..64f22cced3bafa7f6b3cfc43e2960d433c024b5b 100644 --- a/paddle/fluid/operators/optimizers/adagrad_op.cc +++ b/paddle/fluid/operators/optimizers/adagrad_op.cc @@ -15,13 +15,12 @@ limitations under the License. */ #include #include +#include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/math/selected_rows_functor.h" -#include "paddle/phi/kernels/funcs/math_function.h" - -#include "paddle/fluid/framework/infershape_utils.h" #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/infermeta/multiary.h" +#include "paddle/phi/kernels/funcs/math_function.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/optimizers/adam_op_npu.cc b/paddle/fluid/operators/optimizers/adam_op_npu.cc index 1ea91f6ebfa3e59ca2a6af2fea15a24b8a32e4e0..e13805f694bd6a029d468e1c60c8fe333025f353 100644 --- a/paddle/fluid/operators/optimizers/adam_op_npu.cc +++ b/paddle/fluid/operators/optimizers/adam_op_npu.cc @@ -183,16 +183,25 @@ class AdamNPUKernel : public framework::OpKernel { auto stream = ctx.template device_context() .stream(); - const auto& runner = - NpuOpRunner("ApplyAdamD", - { - *param, *mom1, *mom2, *beta1_pow, *beta2_pow, *lr, - *beta1_tensor, *beta2_tensor, *epsilon_tensor, *grad, - }, - { - *param_out, *mom1_out, *mom2_out, - }, - {}); + const auto& runner = NpuOpRunner("ApplyAdamD", + { + *param, + *mom1, + *mom2, + *beta1_pow, + *beta2_pow, + *lr, + *beta1_tensor, + *beta2_tensor, + *epsilon_tensor, + *grad, + }, + { + *param_out, + *mom1_out, + *mom2_out, + }, + {}); runner.Run(stream); // NOTE(zhiqiu): ApplyAdamD updates params inplace, so diff --git a/paddle/fluid/operators/optimizers/adam_op_xpu.cc b/paddle/fluid/operators/optimizers/adam_op_xpu.cc index 6ea0b2054cdea6a11b29e0d1f8c37a7472bb55ec..37467c7ba9614ee386ce0ed75282f52b022ace67 100644 --- a/paddle/fluid/operators/optimizers/adam_op_xpu.cc +++ b/paddle/fluid/operators/optimizers/adam_op_xpu.cc @@ -306,8 +306,9 @@ class AdamOpXPUKernel : public framework::OpKernel { } xpu_wait(dev_ctx.x_context()->xpu_stream); } else { - PADDLE_ENFORCE_EQ(1, 2, platform::errors::InvalidArgument( - "Variable type not supported by adam_op")); + PADDLE_ENFORCE_EQ(1, 2, + platform::errors::InvalidArgument( + "Variable type not supported by adam_op")); } } }; diff --git a/paddle/fluid/operators/optimizers/adamw_op.cc b/paddle/fluid/operators/optimizers/adamw_op.cc index e2670625d4e50b76cfeff7d189a0fead9ddbca90..43e9dc0cae8ef5fec9343402aecd8d673831eaac 100644 --- a/paddle/fluid/operators/optimizers/adamw_op.cc +++ b/paddle/fluid/operators/optimizers/adamw_op.cc @@ -12,9 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/operators/optimizers/adam_op.h" - #include "paddle/fluid/framework/infershape_utils.h" +#include "paddle/fluid/operators/optimizers/adam_op.h" #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/infermeta/multiary.h" diff --git a/paddle/fluid/operators/optimizers/adamw_op_xpu.cc b/paddle/fluid/operators/optimizers/adamw_op_xpu.cc index d86d2bd2ffb4a0166934c9104983f664efe8b2b4..57a6b744fd6db221c11e87d4d660fe21a6530181 100644 --- a/paddle/fluid/operators/optimizers/adamw_op_xpu.cc +++ b/paddle/fluid/operators/optimizers/adamw_op_xpu.cc @@ -205,8 +205,9 @@ class AdamwOpXPUKernel : public framework::OpKernel { } } } else { - PADDLE_ENFORCE_EQ(1, 2, platform::errors::InvalidArgument( - "Variable type not supported by adamw_op")); + PADDLE_ENFORCE_EQ(1, 2, + platform::errors::InvalidArgument( + "Variable type not supported by adamw_op")); } } }; diff --git a/paddle/fluid/operators/optimizers/cast_with_ptr.h b/paddle/fluid/operators/optimizers/cast_with_ptr.h index a3fbb0e59e24e9be67da5048ebc644f08b385bbf..eb031ae0c933a5258e4a951e85f5b157f7d5e0e3 100644 --- a/paddle/fluid/operators/optimizers/cast_with_ptr.h +++ b/paddle/fluid/operators/optimizers/cast_with_ptr.h @@ -43,9 +43,9 @@ static void VecCastKernel(const platform::CUDADeviceContext &ctx, const InT *x, in_arr[0] = reinterpret_cast(x); phi::Array<_ptr_ OutT *, 1> out_arr; out_arr[0] = y; - phi::funcs::VectorizedElementwiseKernel< - OutT, FunctorT, 1, 1, VecSize><<>>( - in_arr, out_arr, n, main_offset, FunctorT()); + phi::funcs::VectorizedElementwiseKernel + <<>>(in_arr, out_arr, n, main_offset, + FunctorT()); } } // namespace details diff --git a/paddle/fluid/operators/optimizers/dgc_momentum_op.cc b/paddle/fluid/operators/optimizers/dgc_momentum_op.cc index 7f0b2b7d064ed12875577fee2265ab17c1fce08f..40ac044e6475e152ca84e1bc4ed13b3bccad623d 100644 --- a/paddle/fluid/operators/optimizers/dgc_momentum_op.cc +++ b/paddle/fluid/operators/optimizers/dgc_momentum_op.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "paddle/fluid/operators/optimizers/dgc_momentum_op.h" +#include + namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/optimizers/distributed_fused_lamb_init_op.cu b/paddle/fluid/operators/optimizers/distributed_fused_lamb_init_op.cu index 3688b8067c23143a44612ab5c5d4e9700ef982b9..7cbc52f4235def1b5b81b91bd45c0016ca037d3a 100644 --- a/paddle/fluid/operators/optimizers/distributed_fused_lamb_init_op.cu +++ b/paddle/fluid/operators/optimizers/distributed_fused_lamb_init_op.cu @@ -83,10 +83,12 @@ static void GetParamGradShardInfo(const std::vector &infos, VLOG(10) << "start_size = " << start_size << " , end_size = " << end_size; if (infos.empty()) { - PADDLE_ENFORCE_EQ(start_size, 0, platform::errors::InvalidArgument( - "start_size should be 0.")); - PADDLE_ENFORCE_EQ(end_size, 0, platform::errors::InvalidArgument( - "end_size should be 0.")); + PADDLE_ENFORCE_EQ( + start_size, 0, + platform::errors::InvalidArgument("start_size should be 0.")); + PADDLE_ENFORCE_EQ( + end_size, 0, + platform::errors::InvalidArgument("end_size should be 0.")); *start_idx = 0; *end_idx = 0; *start_numel_offset = 0; @@ -104,15 +106,17 @@ static void GetParamGradShardInfo(const std::vector &infos, infos.begin()); if (i == n || infos[i].numel_offset != start_size) { PADDLE_ENFORCE_GT( - i, 0, platform::errors::InvalidArgument( - "Cannot find suitable sharding which is between [%d, %d)", - start_size, end_size)); + i, 0, + platform::errors::InvalidArgument( + "Cannot find suitable sharding which is between [%d, %d)", + start_size, end_size)); --i; } PADDLE_ENFORCE_LT( - i, n, platform::errors::InvalidArgument( - "Cannot find suitable sharding which is between [%d, %d)", - start_size, end_size)); + i, n, + platform::errors::InvalidArgument( + "Cannot find suitable sharding which is between [%d, %d)", start_size, + end_size)); *start_idx = i; *start_numel_offset = start_size - infos[i].numel_offset; auto j = static_cast( @@ -450,8 +454,9 @@ class DistributedFusedLambInitOpKernel platform::errors::InvalidArgument( "The attr(alignment) should be the power of 2.")); PADDLE_ENFORCE_GE( - rank, 0, platform::errors::InvalidArgument( - "The attr(rank) should be equal to or larger than 0.")); + rank, 0, + platform::errors::InvalidArgument( + "The attr(rank) should be equal to or larger than 0.")); PADDLE_ENFORCE_LT( rank, nranks, platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/optimizers/distributed_fused_lamb_op.cu b/paddle/fluid/operators/optimizers/distributed_fused_lamb_op.cu index c857c6de4d0936d22279b015a14ec8e86154e26d..eb354ef6d7576c0ce6ab64d9e477b0d04c184f05 100644 --- a/paddle/fluid/operators/optimizers/distributed_fused_lamb_op.cu +++ b/paddle/fluid/operators/optimizers/distributed_fused_lamb_op.cu @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/memory/buffer.h" #include "paddle/fluid/operators/amp/fp16_type_traits.h" #include "paddle/fluid/operators/optimizers/cast_with_ptr.h" @@ -32,6 +33,7 @@ #ifdef __HIPCC__ #include + #include "math.h" // NOLINT namespace cub = hipcub; #endif @@ -190,9 +192,8 @@ static void MultiTensorL2Norm(const platform::CUDAPlace &place, PD_VEC_LAUNCH_KERNEL(vec_size, PD_LAUNCH_MULTI_TENSOR_APPLY_L2_NORM_KERNEL); #undef PD_LAUNCH_MULTI_TENSOR_APPLY_L2_NORM_KERNEL - MultiTensorL2NormReduceAgainCUDAKernel< - MT, OutT, kBlockDim><<>>(tmp_out_ptr, y, - max_chunk_num); + MultiTensorL2NormReduceAgainCUDAKernel + <<>>(tmp_out_ptr, y, max_chunk_num); } template @@ -508,14 +509,14 @@ static void MultiTensorUpdateLambMomentAndTrustRatioDiv( "Output(Step) cannot be nullptr.")); } -#define PD_LAUNCH_LAMB_MOM_TRUST_RATIO_DIV_KERNEL \ - do { \ - UpdateLambMomentAndTrustRatioDivCUDAKernel<<< \ - config.block_per_grid, config.thread_per_block, 0, stream>>>( \ - param_p, grad_p, square_grad_norm_p, global_scale, beta1pow_p, \ - beta2pow_p, mom1_p, mom2_p, trust_ratio_div_p, found_inf_p, step, \ - weight_decay, weight_decay_end_numel, beta1, beta2, epsilon, \ - max_global_grad_norm, numel, rescale_grad); \ +#define PD_LAUNCH_LAMB_MOM_TRUST_RATIO_DIV_KERNEL \ + do { \ + UpdateLambMomentAndTrustRatioDivCUDAKernel \ + <<>>( \ + param_p, grad_p, square_grad_norm_p, global_scale, beta1pow_p, \ + beta2pow_p, mom1_p, mom2_p, trust_ratio_div_p, found_inf_p, step, \ + weight_decay, weight_decay_end_numel, beta1, beta2, epsilon, \ + max_global_grad_norm, numel, rescale_grad); \ } while (0) PD_VEC_LAUNCH_KERNEL(vec_size, PD_LAUNCH_LAMB_MOM_TRUST_RATIO_DIV_KERNEL); @@ -705,8 +706,9 @@ static void MultiTensorUpdateLambParamAndBetaPows( PADDLE_ENFORCE_NOT_NULL(beta2pow, platform::errors::InvalidArgument( "Beta2Pow should not be nullptr.")); } else { - PADDLE_ENFORCE_EQ(beta2pow, nullptr, platform::errors::InvalidArgument( - "Beta2Pow should be nullptr.")); + PADDLE_ENFORCE_EQ( + beta2pow, nullptr, + platform::errors::InvalidArgument("Beta2Pow should be nullptr.")); } const int block_dim = 512; @@ -744,21 +746,21 @@ static void MultiTensorUpdateLambParamAndBetaPows( betapow_helper); \ } while (0) -#define PD_LAUNCH_VEC_MULTI_TENSOR_UPDATE_PARAM_BETAPOW_CASE \ - do { \ - auto callback = [&]( \ - const MultiTensorLauncher &launcher, \ - int launch_n) { \ - if (has_beta_pow && launch_n == 0) { \ - PD_LAUNCH_MULTI_TENSOR_UPDATE_PARAM_BETAPOW(true); \ - beta1pow = nullptr; \ - beta2pow = nullptr; \ - } else { \ - PD_LAUNCH_MULTI_TENSOR_UPDATE_PARAM_BETAPOW(false); \ - } \ - }; \ - MultiTensorApplyWithCallback( \ - stream, offsets, n, chunk_size, block_dim, callback); \ +#define PD_LAUNCH_VEC_MULTI_TENSOR_UPDATE_PARAM_BETAPOW_CASE \ + do { \ + auto callback = \ + [&](const MultiTensorLauncher &launcher, \ + int launch_n) { \ + if (has_beta_pow && launch_n == 0) { \ + PD_LAUNCH_MULTI_TENSOR_UPDATE_PARAM_BETAPOW(true); \ + beta1pow = nullptr; \ + beta2pow = nullptr; \ + } else { \ + PD_LAUNCH_MULTI_TENSOR_UPDATE_PARAM_BETAPOW(false); \ + } \ + }; \ + MultiTensorApplyWithCallback( \ + stream, offsets, n, chunk_size, block_dim, callback); \ } while (0) PD_VEC_LAUNCH_KERNEL(vec_size, @@ -793,11 +795,11 @@ static void LaunchScaleKernel(const platform::CUDADeviceContext &dev_ctx, int vec_size = std::min(GetChunkedVecSize(x, 0), GetChunkedVecSize(y, 0)); auto config = platform::GetGpuLaunchConfig1D(dev_ctx, n, vec_size); -#define PD_LAMB_VEC_SCALE_KERNEL_CASE \ - do { \ - ScaleCUDAKernel<<>>( \ - x, scale, y, n); \ +#define PD_LAMB_VEC_SCALE_KERNEL_CASE \ + do { \ + ScaleCUDAKernel \ + <<>>( \ + x, scale, y, n); \ } while (0) PD_VEC_LAUNCH_KERNEL(vec_size, PD_LAMB_VEC_SCALE_KERNEL_CASE); @@ -1015,7 +1017,7 @@ static void CheckHasNanInfGrad(const float *fp32_grad, int fp32_numel, if (fp32_numel > 0) { fp32_has_nan_inf = reinterpret_cast(nan_inf_flag + 1); cub::TransformInputIterator, const float *> - iter(fp32_grad, IsNanInfFunctor()); + iter(fp32_grad, IsNanInfFunctor()); CubDeviceReduce(iter, fp32_has_nan_inf, fp32_numel, OrFunctor(), false, stream, cub_tmp_buffer); } @@ -1082,11 +1084,11 @@ static void LaunchElementwiseAddWithCastKernel( GetChunkedVecSize(z, 0)); auto config = platform::GetGpuLaunchConfig1D(dev_ctx, n, vec_size); -#define PD_LAUNCH_ELEMENTWISE_ADD_WITH_CAST_KERNEL \ - do { \ - ElementwiseAddWithCastCUDAKernel<<< \ - config.block_per_grid, config.thread_per_block, 0, stream>>>(x, y, z, \ - n); \ +#define PD_LAUNCH_ELEMENTWISE_ADD_WITH_CAST_KERNEL \ + do { \ + ElementwiseAddWithCastCUDAKernel \ + <<>>(x, y, \ + z, n); \ } while (0) PD_VEC_LAUNCH_KERNEL(vec_size, PD_LAUNCH_ELEMENTWISE_ADD_WITH_CAST_KERNEL); @@ -1445,10 +1447,10 @@ class DistributedFusedLambOpKernel if (is_grad_scaled_by_nranks) { clip_scale *= num_devices; } - CalcGradNormClipBeforeAllReduceScale< - float, platform::float16><<<1, 1, 0, stream>>>( - global_scale, max_global_grad_norm, fp32_square_grad_norm, - fp32_scale, fp16_scale, clip_scale); + CalcGradNormClipBeforeAllReduceScale + <<<1, 1, 0, stream>>>(global_scale, max_global_grad_norm, + fp32_square_grad_norm, fp32_scale, fp16_scale, + clip_scale); if (fp32_scale) { VLOG(1) << "Grad scale: " << FlattenToString(fp32_scale, 1, place); } else { @@ -1567,11 +1569,12 @@ class DistributedFusedLambOpKernel fp16_partial_fused_offsets, fp16_local_param_num, param_square_norm + fp16_local_start_idx); } else { - MultiTensorL2Norm( - place, stream, fp16_param + fused_offsets[fp16_local_start_idx] - - fused_offsets[fp32_global_param_num], - fused_offsets + fp16_local_start_idx, fp16_local_param_num, - param_square_norm + fp16_local_start_idx); + MultiTensorL2Norm(place, stream, + fp16_param + fused_offsets[fp16_local_start_idx] - + fused_offsets[fp32_global_param_num], + fused_offsets + fp16_local_start_idx, + fp16_local_param_num, + param_square_norm + fp16_local_start_idx); } MultiTensorL2Norm(place, stream, trust_ratio_div, diff --git a/paddle/fluid/operators/optimizers/dpsgd_op.h b/paddle/fluid/operators/optimizers/dpsgd_op.h index 688a7f1ad8435bda3197fd6d7d385802b46821b6..69a853c5d1846bb94d1fb5bd5b5106008bcc3d07 100644 --- a/paddle/fluid/operators/optimizers/dpsgd_op.h +++ b/paddle/fluid/operators/optimizers/dpsgd_op.h @@ -15,7 +15,9 @@ limitations under the License. */ #pragma once #include #include + #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" @@ -108,9 +110,8 @@ class DpsgdOpKernel : public framework::OpKernel { // update parameters for (int64_t i = 0; i < grad->numel(); ++i) { - out_data[i] = - param_data[i] - - lr[0] * (grad_data[i] / scale + gaussian_noise / batch_size); + out_data[i] = param_data[i] - lr[0] * (grad_data[i] / scale + + gaussian_noise / batch_size); } // CCS16 - Deep Learning with Differential Privacy. // [https://arxiv.org/abs/1607.00133] diff --git a/paddle/fluid/operators/optimizers/ftrl_op.h b/paddle/fluid/operators/optimizers/ftrl_op.h index 596ed05df3ffd740958bc123582139464722ac23..73fd7ceb67b0e0d18adc938b67bd6f788c556c63 100644 --- a/paddle/fluid/operators/optimizers/ftrl_op.h +++ b/paddle/fluid/operators/optimizers/ftrl_op.h @@ -74,9 +74,8 @@ class SparseFTRLFunctor { l_acc_out_[j] += g - (std::sqrt(new_acc) - std::sqrt(s_acc)) / lr * p; } else { l_acc_out_[j] += - g - - (std::pow(new_acc, -lr_power_) - std::pow(s_acc, -lr_power_)) / lr * - p; + g - (std::pow(new_acc, -lr_power_) - std::pow(s_acc, -lr_power_)) / + lr * p; } auto l_acc = l_acc_out_[j]; diff --git a/paddle/fluid/operators/optimizers/lamb_op.cc b/paddle/fluid/operators/optimizers/lamb_op.cc index 48ceba3695f837cf1958f5d26c895f5ab800dce7..fb2a78d28edfc71e54971a995809d3a784939cfa 100644 --- a/paddle/fluid/operators/optimizers/lamb_op.cc +++ b/paddle/fluid/operators/optimizers/lamb_op.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/optimizers/lamb_op.h" + #include + #include "paddle/fluid/framework/op_version_registry.h" namespace paddle { @@ -227,13 +229,12 @@ REGISTER_OP_CPU_KERNEL( ops::LambOpKernel); /* ========================== register checkpoint ===========================*/ -REGISTER_OP_VERSION(lamb) - .AddCheckpoint( - R"ROC(Upgrade lamb, add two new outputs [Beta1PowOut] and [Beta2PowOut].)ROC", - paddle::framework::compatible::OpVersionDesc() - .NewInput("Beta1PowOut", - "The Output beta1 power accumulator. 'Beta1PowOut' is " - "dispensable.") - .NewInput("Beta2PowOut", - "The Output beta2 power accumulator. 'Beta2PowOut' is " - "dispensable.")); +REGISTER_OP_VERSION(lamb).AddCheckpoint( + R"ROC(Upgrade lamb, add two new outputs [Beta1PowOut] and [Beta2PowOut].)ROC", + paddle::framework::compatible::OpVersionDesc() + .NewInput("Beta1PowOut", + "The Output beta1 power accumulator. 'Beta1PowOut' is " + "dispensable.") + .NewInput("Beta2PowOut", + "The Output beta2 power accumulator. 'Beta2PowOut' is " + "dispensable.")); diff --git a/paddle/fluid/operators/optimizers/lamb_op.cu b/paddle/fluid/operators/optimizers/lamb_op.cu index b46fa19ea135207ec889db20d9d4a03593f01b62..a9f880fdbb67d380f4975174eafbb2f951cb3a4c 100644 --- a/paddle/fluid/operators/optimizers/lamb_op.cu +++ b/paddle/fluid/operators/optimizers/lamb_op.cu @@ -16,7 +16,8 @@ limitations under the License. */ namespace ops = paddle::operators; REGISTER_OP_CUDA_KERNEL( - lamb, ops::LambOpKernel, + lamb, + ops::LambOpKernel, ops::LambOpKernel, ops::LambOpKernel); diff --git a/paddle/fluid/operators/optimizers/lamb_op.h b/paddle/fluid/operators/optimizers/lamb_op.h index 45acf2b3e48345c6a17c75f8409744776a03b243..2956ff204679eb5071c6fdbbb91d865eabd76c88 100644 --- a/paddle/fluid/operators/optimizers/lamb_op.h +++ b/paddle/fluid/operators/optimizers/lamb_op.h @@ -14,8 +14,10 @@ limitations under the License. */ #pragma once #include // for sqrt in CPU and CUDA + #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/memory/buffer.h" #include "paddle/fluid/operators/amp/fp16_type_traits.h" @@ -655,10 +657,10 @@ class LambOpKernel : public framework::OpKernel { // TODO(zengjinle): remove the following Eigen operations when // *skip_update == true. memory::Buffer buffer(dev_ctx.GetPlace()); - math::SquaredL2Norm( - dev_ctx, reinterpret_cast(IsMultiPrecision ? master_param_ptr - : param_ptr), - p_norm_ptr, numel, &buffer); + math::SquaredL2Norm(dev_ctx, + reinterpret_cast( + IsMultiPrecision ? master_param_ptr : param_ptr), + p_norm_ptr, numel, &buffer); math::SquaredL2Norm(dev_ctx, trust_ratio_div_ptr, trust_ratio_div_norm_ptr, numel, &buffer); @@ -675,12 +677,12 @@ class LambOpKernel : public framework::OpKernel { #define CALL_PADDLE_UPDATE_LAMB_PARAM_FUNC(__should_update_beta_pow) \ do { \ LambParamUpateFunctor \ - param_update_functor( \ - lr.template data(), static_cast(param_ptr), \ - static_cast(master_param_ptr), p_norm_ptr, \ - trust_ratio_div_ptr, trust_ratio_div_norm_ptr, \ - static_cast(param_out_ptr), \ - static_cast(master_param_out_ptr), skip_update_flag); \ + param_update_functor( \ + lr.template data(), static_cast(param_ptr), \ + static_cast(master_param_ptr), p_norm_ptr, \ + trust_ratio_div_ptr, trust_ratio_div_norm_ptr, \ + static_cast(param_out_ptr), \ + static_cast(master_param_out_ptr), skip_update_flag); \ if (__should_update_beta_pow) { \ param_update_functor.SetBetaPows(beta1_pow_ptr, beta2_pow_ptr, \ beta1_pow_out_ptr, beta2_pow_out_ptr, \ diff --git a/paddle/fluid/operators/optimizers/lamb_op_xpu.cc b/paddle/fluid/operators/optimizers/lamb_op_xpu.cc index 7aa5783a01bfd5942410670212b1c81cdee06809..ef224382cd091d337ae96fad7ef7bad11c7d57bb 100644 --- a/paddle/fluid/operators/optimizers/lamb_op_xpu.cc +++ b/paddle/fluid/operators/optimizers/lamb_op_xpu.cc @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/optimizers/lamb_op.h" #include "gflags/gflags.h" +#include "paddle/fluid/operators/optimizers/lamb_op.h" #include "paddle/fluid/platform/device/device_wrapper.h" namespace paddle { diff --git a/paddle/fluid/operators/optimizers/lars_momentum_op.cu b/paddle/fluid/operators/optimizers/lars_momentum_op.cu index 5b883a11e57335114cb90b34b9e77ca0e07e209d..553ac69edcac7d2a692c559a4d4862d991c7cbf3 100644 --- a/paddle/fluid/operators/optimizers/lars_momentum_op.cu +++ b/paddle/fluid/operators/optimizers/lars_momentum_op.cu @@ -129,8 +129,9 @@ __device__ inline void VectorizeLarsUpdate( for (int i = tid + tail_offset; i < numel; i += grid_stride) { MT grad_val = static_cast(grad[i]) * rescale_grad; MT param_val = param[i]; - MT velocity_tmp = Fma(velocity[i], mu, local_lr * Fma(lars_weight_decay, - param_val, grad_val)); + MT velocity_tmp = + Fma(velocity[i], mu, + local_lr * Fma(lars_weight_decay, param_val, grad_val)); MT param_tmp = param_val - velocity_tmp; param_out[i] = static_cast(param_tmp); velocity_out[i] = velocity_tmp; @@ -314,10 +315,10 @@ inline void SeparatedLarsMomentumOpCUDAKernel( const MT rescale_grad, const int64_t numel, const MT* master_param_data, MT* master_out_data, const bool is_amp) { LarsThreadConfig lars_thread_config(numel); - L2NormKernel<<>>( - param_data, grad_data, p_buffer, g_buffer, numel, - lars_thread_config.repeat_times, rescale_grad); + L2NormKernel + <<>>(param_data, grad_data, p_buffer, g_buffer, numel, + lars_thread_config.repeat_times, rescale_grad); MomentumLarsKernel<<>>( diff --git a/paddle/fluid/operators/optimizers/merged_momentum_op_mlu.cc b/paddle/fluid/operators/optimizers/merged_momentum_op_mlu.cc index 54ead6d3df7f056d1da41661348a30bf260dce49..280c0930e91d5144712db89021c17fa823a92499 100644 --- a/paddle/fluid/operators/optimizers/merged_momentum_op_mlu.cc +++ b/paddle/fluid/operators/optimizers/merged_momentum_op_mlu.cc @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/operators/optimizers/merged_momentum_op.h" #include "paddle/fluid/operators/mlu/mlu_baseop.h" +#include "paddle/fluid/operators/optimizers/merged_momentum_op.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/optimizers/merged_momentum_op_npu.cc b/paddle/fluid/operators/optimizers/merged_momentum_op_npu.cc index 5fad5eca9affc4d44e2fc196616c776df6d8702b..d405500d60768162f9cfccfa5420e6affe4a9c63 100644 --- a/paddle/fluid/operators/optimizers/merged_momentum_op_npu.cc +++ b/paddle/fluid/operators/optimizers/merged_momentum_op_npu.cc @@ -13,7 +13,6 @@ // limitations under the License. #include "paddle/fluid/operators/optimizers/merged_momentum_op.h" - #include "paddle/fluid/platform/device/npu/npu_op_runner.h" #include "paddle/phi/kernels/impl/momentum_kernel_impl.h" @@ -151,10 +150,11 @@ class NPUMergedMomentumOpKernel : public framework::OpKernel { framework::TensorCopy(*param, ctx.GetPlace(), dev_ctx, param_out); framework::TensorCopy(*velocity, ctx.GetPlace(), dev_ctx, velocity_out); // NOTE: ApplyMomentum will change the input - const auto& runner = NpuOpRunner( - "ApplyMomentum", {*param_out, *velocity_out, *learning_rate, - regularized_grad, mu_tensor}, - {*param_out}, {{"use_nesterov", use_nesterov}}); + const auto& runner = + NpuOpRunner("ApplyMomentum", + {*param_out, *velocity_out, *learning_rate, + regularized_grad, mu_tensor}, + {*param_out}, {{"use_nesterov", use_nesterov}}); runner.Run(dev_ctx.stream()); } } diff --git a/paddle/fluid/operators/optimizers/momentum_op.cc b/paddle/fluid/operators/optimizers/momentum_op.cc index 50d2c946f3afee12632735f207ceabfee91cd6fc..94fb4c156ef5f1a48565cce23ca00dea87b6adcc 100644 --- a/paddle/fluid/operators/optimizers/momentum_op.cc +++ b/paddle/fluid/operators/optimizers/momentum_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/optimizers/momentum_op.h" + #include "paddle/fluid/framework/op_version_registry.h" namespace paddle { @@ -109,28 +110,26 @@ REGISTER_OPERATOR( paddle::framework::EmptyGradOpMaker, ops::MomentumOpInferVarType); -REGISTER_OP_VERSION(momentum) - .AddCheckpoint( - R"ROC( +REGISTER_OP_VERSION(momentum).AddCheckpoint( + R"ROC( Upgrade momentum add 4 attributes [regularization_method, regularization_coeff, multi_precision, rescale_grad]. )ROC", - paddle::framework::compatible::OpVersionDesc() - .NewInput("MasterParam", "FP32 master weight for AMP.") - .NewOutput("MasterParamOut", - "The updated FP32 master weight for AMP. " - "It shared memory with Input(MasterParam).") - .NewAttr("regularization_method", - "(string) regularization_method, right now only support " - "l2decay or none", - std::string("")) - .NewAttr("regularization_coeff", "(float) regularization_coeff", - 0.0f) - .NewAttr( - "multi_precision", - "(bool) Whether to use multi-precision during weight updating.", - false) - .NewAttr("rescale_grad", - "(float) Multiply the gradient with `rescale_grad`" - "before updating. Often choose to be `1.0/batch_size`.", - 1.0f)); + paddle::framework::compatible::OpVersionDesc() + .NewInput("MasterParam", "FP32 master weight for AMP.") + .NewOutput("MasterParamOut", + "The updated FP32 master weight for AMP. " + "It shared memory with Input(MasterParam).") + .NewAttr("regularization_method", + "(string) regularization_method, right now only support " + "l2decay or none", + std::string("")) + .NewAttr("regularization_coeff", "(float) regularization_coeff", 0.0f) + .NewAttr( + "multi_precision", + "(bool) Whether to use multi-precision during weight updating.", + false) + .NewAttr("rescale_grad", + "(float) Multiply the gradient with `rescale_grad`" + "before updating. Often choose to be `1.0/batch_size`.", + 1.0f)); diff --git a/paddle/fluid/operators/optimizers/momentum_op.h b/paddle/fluid/operators/optimizers/momentum_op.h index 017f33d7458fcd5552e540d944775a38c78b06b8..2f6a9758a2cf54fce1d410f20da983af59924a3b 100644 --- a/paddle/fluid/operators/optimizers/momentum_op.h +++ b/paddle/fluid/operators/optimizers/momentum_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/amp/fp16_type_traits.h" diff --git a/paddle/fluid/operators/optimizers/momentum_op_mlu.cc b/paddle/fluid/operators/optimizers/momentum_op_mlu.cc index b8fa81b2e71237f30a80ff81709e93e8a53e0951..417f89410cf88133bfe04067941cca9b81836f1e 100644 --- a/paddle/fluid/operators/optimizers/momentum_op_mlu.cc +++ b/paddle/fluid/operators/optimizers/momentum_op_mlu.cc @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/optimizers/momentum_op.h" #include "paddle/fluid/operators/mlu/mlu_baseop.h" +#include "paddle/fluid/operators/optimizers/momentum_op.h" #include "paddle/phi/kernels/impl/momentum_kernel_impl.h" namespace paddle { @@ -77,8 +77,9 @@ class MLUMomentumOpKernel : public framework::OpKernel { GetBasePtr(learning_rate), GetBasePtr(&mu_tensor), GetBasePtr(param_out), GetBasePtr(velocity_out)); } else if (grad_var->IsType()) { - PADDLE_ENFORCE_EQ(false, true, platform::errors::PermissionDenied( - "Unsupport SparseMomentum")); + PADDLE_ENFORCE_EQ( + false, true, + platform::errors::PermissionDenied("Unsupport SparseMomentum")); } else { PADDLE_ENFORCE_EQ(false, true, platform::errors::PermissionDenied( diff --git a/paddle/fluid/operators/optimizers/momentum_op_npu.cc b/paddle/fluid/operators/optimizers/momentum_op_npu.cc index 2d73766b9736429bbe6b2de77363961d0c977cbb..d3ffeb18be7b95f202d318472ac517f6b1af9a2b 100644 --- a/paddle/fluid/operators/optimizers/momentum_op_npu.cc +++ b/paddle/fluid/operators/optimizers/momentum_op_npu.cc @@ -12,7 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/optimizers/momentum_op.h" - #include "paddle/fluid/operators/optimizers/sgd_op.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" #include "paddle/phi/kernels/impl/momentum_kernel_impl.h" @@ -70,14 +69,16 @@ class NPUMomentumOpKernel : public framework::OpKernel { framework::TensorCopy(*param, ctx.GetPlace(), dev_ctx, param_out); framework::TensorCopy(*velocity, ctx.GetPlace(), dev_ctx, velocity_out); // NOTE: ApplyMomentum will change the input - const auto& runner = NpuOpRunner( - "ApplyMomentum", {*param_out, *velocity_out, *learning_rate, - regularized_grad, mu_tensor}, - {*param_out}, {{"use_nesterov", use_nesterov}}); + const auto& runner = + NpuOpRunner("ApplyMomentum", + {*param_out, *velocity_out, *learning_rate, + regularized_grad, mu_tensor}, + {*param_out}, {{"use_nesterov", use_nesterov}}); runner.Run(dev_ctx.stream()); } else if (grad_var->IsType()) { - PADDLE_ENFORCE_EQ(false, true, platform::errors::PermissionDenied( - "Unsupport SparseMomentum")); + PADDLE_ENFORCE_EQ( + false, true, + platform::errors::PermissionDenied("Unsupport SparseMomentum")); } else { PADDLE_ENFORCE_EQ(false, true, platform::errors::PermissionDenied( diff --git a/paddle/fluid/operators/optimizers/momentum_op_xpu.cc b/paddle/fluid/operators/optimizers/momentum_op_xpu.cc index 6897213c91a34350c10a405329c2ffff4325c495..749d38f315e00a0bb9be15ccb18f4e60cfd5c7eb 100644 --- a/paddle/fluid/operators/optimizers/momentum_op_xpu.cc +++ b/paddle/fluid/operators/optimizers/momentum_op_xpu.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #ifdef PADDLE_WITH_XPU #include + #include "paddle/fluid/operators/optimizers/sgd_op.h" #include "paddle/fluid/platform/device/device_wrapper.h" namespace paddle { diff --git a/paddle/fluid/operators/optimizers/multi_tensor_apply.h b/paddle/fluid/operators/optimizers/multi_tensor_apply.h index 179e8f452545c437e373e42d59d18f524f260cd5..98850aa816bdc4e57183c41256d448a08f04643a 100644 --- a/paddle/fluid/operators/optimizers/multi_tensor_apply.h +++ b/paddle/fluid/operators/optimizers/multi_tensor_apply.h @@ -15,6 +15,7 @@ #pragma once #include + #include "math.h" // NOLINT namespace paddle { @@ -108,11 +109,11 @@ class MultiTensorLauncher { stream_(stream) {} template - void Launch(Functor &&functor, Args &&... args) const { - MultiTensorApplyCUDAKernel< - Functor, MaxTensorNumPerLaunch, - MaxChunkNumPerLaunch><<>>( - functor, meta_, chunk_size_, args...); + void Launch(Functor &&functor, Args &&...args) const { + MultiTensorApplyCUDAKernel + <<>>(functor, meta_, chunk_size_, + args...); } private: @@ -189,7 +190,7 @@ template static void MultiTensorApply(Functor functor, gpuStream_t stream, const int *offsets, int n, int chunk_size, - int block_dim, Args &&... args) { + int block_dim, Args &&...args) { auto callback = [&](const MultiTensorLauncher &launcher, int i) { launcher.Launch(functor, args...); }; diff --git a/paddle/fluid/operators/optimizers/pow2_decay_with_linear_warmup_op.cc b/paddle/fluid/operators/optimizers/pow2_decay_with_linear_warmup_op.cc index 6893e5d6b9b2c2309c4410564763f32baa8554e9..5eeeb7353072e9b4542b62d163d2272b6bf13f49 100644 --- a/paddle/fluid/operators/optimizers/pow2_decay_with_linear_warmup_op.cc +++ b/paddle/fluid/operators/optimizers/pow2_decay_with_linear_warmup_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/optimizers/pow2_decay_with_linear_warmup_op.h" + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/float16.h" diff --git a/paddle/fluid/operators/optimizers/pow2_decay_with_linear_warmup_op.h b/paddle/fluid/operators/optimizers/pow2_decay_with_linear_warmup_op.h index 74cf76274507734bff555bd9ee0355b63f2f5ef9..353d8777a84ab3f09c80fad5d07af50a224e22f6 100644 --- a/paddle/fluid/operators/optimizers/pow2_decay_with_linear_warmup_op.h +++ b/paddle/fluid/operators/optimizers/pow2_decay_with_linear_warmup_op.h @@ -47,9 +47,8 @@ struct Pow2DecayWithLinearWarmupFunctor { auto new_lr = static_cast(step) / warmup_steps_ * base_lr_; *lr_ = static_cast(new_lr); } else if (step < total_steps_) { - auto factor = 1 - - static_cast(step - warmup_steps_) / - (total_steps_ - warmup_steps_); + auto factor = 1 - static_cast(step - warmup_steps_) / + (total_steps_ - warmup_steps_); auto new_lr = static_cast(base_lr_ - end_lr_) * (factor * factor) + end_lr_; *lr_ = static_cast(new_lr); @@ -76,9 +75,10 @@ class Pow2DecayWithLinearWarmupOpKernel : public framework::OpKernel { auto *lr_out = ctx.Output("LearningRateOut"); auto *step_out = ctx.Output("StepOut"); PADDLE_ENFORCE_EQ( - lr, lr_out, platform::errors::InvalidArgument("Input(LearningRate) and " - "Output(LearningRateOut) " - "must be the same.")); + lr, lr_out, + platform::errors::InvalidArgument("Input(LearningRate) and " + "Output(LearningRateOut) " + "must be the same.")); PADDLE_ENFORCE_NOT_NULL(lr, platform::errors::InvalidArgument( "Input(LearingRate) should not be nullptr.")); diff --git a/paddle/fluid/operators/optimizers/rmsprop_op.cc b/paddle/fluid/operators/optimizers/rmsprop_op.cc index b3458724482e943b7baeb712478690437a57d4fa..874e21cc6ccbf9f7b324d3324292c3399dfd3c4c 100644 --- a/paddle/fluid/operators/optimizers/rmsprop_op.cc +++ b/paddle/fluid/operators/optimizers/rmsprop_op.cc @@ -12,9 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/framework/op_registry.h" - #include "paddle/fluid/framework/infershape_utils.h" +#include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/infermeta/multiary.h" diff --git a/paddle/fluid/operators/optimizers/rmsprop_op_xpu.cc b/paddle/fluid/operators/optimizers/rmsprop_op_xpu.cc index b53d51686cfd73947aed8e2aabd6fbccd3d022ea..7f4810ea4207af78f4e626c4517aa2303d89a817 100644 --- a/paddle/fluid/operators/optimizers/rmsprop_op_xpu.cc +++ b/paddle/fluid/operators/optimizers/rmsprop_op_xpu.cc @@ -15,7 +15,9 @@ limitations under the License. */ #ifdef PADDLE_WITH_XPU #include + #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device/device_wrapper.h" diff --git a/paddle/fluid/operators/optimizers/sgd_op.cc b/paddle/fluid/operators/optimizers/sgd_op.cc index a2af131cb505e4d0cb499f304382949c92c8ad99..b5822fd5c446edd2eb808cdf45fca427d9b354b8 100644 --- a/paddle/fluid/operators/optimizers/sgd_op.cc +++ b/paddle/fluid/operators/optimizers/sgd_op.cc @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include - #include "paddle/fluid/operators/optimizers/sgd_op.h" + +#include #ifdef PADDLE_WITH_MKLDNN #include "paddle/fluid/platform/mkldnn_helper.h" #endif @@ -76,10 +76,11 @@ class SGDOpInferVarType : public framework::VarTypeInference { auto in_var_type = ctx->GetInputType("Param"); PADDLE_ENFORCE_EQ(in_var_type == framework::proto::VarType::SELECTED_ROWS || in_var_type == framework::proto::VarType::LOD_TENSOR, - true, platform::errors::InvalidArgument( - "The input Var's type should be LoDtensor or " - "SelectedRows, but the received type is %s", - in_var_type)); + true, + platform::errors::InvalidArgument( + "The input Var's type should be LoDtensor or " + "SelectedRows, but the received type is %s", + in_var_type)); ctx->SetOutputType("ParamOut", in_var_type, framework::ALL_ELEMENTS); } diff --git a/paddle/fluid/operators/optimizers/sgd_op.cu b/paddle/fluid/operators/optimizers/sgd_op.cu index 222244a2fd1e34ace573ad4fa06775c0e5113925..ba2e84a6a789d3bbeadaf6e7db3c311963c4f11b 100644 --- a/paddle/fluid/operators/optimizers/sgd_op.cu +++ b/paddle/fluid/operators/optimizers/sgd_op.cu @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/operators/amp/fp16_type_traits.h" #include "paddle/fluid/operators/optimizers/sgd_op.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" @@ -106,11 +107,11 @@ class SGDOpKernel int block = 512; int grid = (param->numel() + block - 1) / block; - SGDKernelMT< - T, MPDType><<>>( - param->data(), grad->data(), learning_rate->data(), - param->numel(), param_out->mutable_data(ctx.GetPlace()), - master_in_data, master_out_data); + SGDKernelMT + <<>>( + param->data(), grad->data(), learning_rate->data(), + param->numel(), param_out->mutable_data(ctx.GetPlace()), + master_in_data, master_out_data); } else if (grad_var->IsType()) { // TODO(qijun): In Sparse SGD operator, in-place update is enforced. diff --git a/paddle/fluid/operators/optimizers/sgd_op_xpu.cc b/paddle/fluid/operators/optimizers/sgd_op_xpu.cc index e7c03be95cae1e1cfb01ab5ec42252f1e888e55e..7203357db10e3c0873e8b71d61ae16e2aa88d985 100644 --- a/paddle/fluid/operators/optimizers/sgd_op_xpu.cc +++ b/paddle/fluid/operators/optimizers/sgd_op_xpu.cc @@ -12,8 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifdef PADDLE_WITH_XPU -#include "paddle/fluid/operators/optimizers/sgd_op.h" #include + +#include "paddle/fluid/operators/optimizers/sgd_op.h" #include "paddle/fluid/platform/device/device_wrapper.h" namespace paddle { diff --git a/paddle/fluid/operators/optimizers/sparse_momentum_op.cc b/paddle/fluid/operators/optimizers/sparse_momentum_op.cc index c38545df173115112afbad58d941112fee61f40f..0c4fa916f4331185196ecf206b0196be86c888f4 100644 --- a/paddle/fluid/operators/optimizers/sparse_momentum_op.cc +++ b/paddle/fluid/operators/optimizers/sparse_momentum_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/optimizers/sparse_momentum_op.h" + #include "paddle/fluid/framework/op_version_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/optimizers/sparse_momentum_op.h b/paddle/fluid/operators/optimizers/sparse_momentum_op.h index 08b2d3764febaad385dd4705f5d975c9b494f50e..296a3d5b889750099ce751e2f0005ca4771729ca 100644 --- a/paddle/fluid/operators/optimizers/sparse_momentum_op.h +++ b/paddle/fluid/operators/optimizers/sparse_momentum_op.h @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/p_norm_op.cc b/paddle/fluid/operators/p_norm_op.cc index c7c8ebf562b4d7c6a31b210118c6db75a56af2a2..21254521fa9121a01546b1d678db08cbf5624f40 100644 --- a/paddle/fluid/operators/p_norm_op.cc +++ b/paddle/fluid/operators/p_norm_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" @@ -124,11 +125,10 @@ REGISTER_OPERATOR(p_norm, ops::PnormOp, ops::PnormOpMaker, PNormInferShapeFunctor); REGISTER_OPERATOR(p_norm_grad, ops::PnormOpGrad, PNormGradInferShapeFunctor); -REGISTER_OP_VERSION(p_norm) - .AddCheckpoint( - R"ROC( +REGISTER_OP_VERSION(p_norm).AddCheckpoint( + R"ROC( Upgrade p_norm, add 1 attribute [asvector]. )ROC", - paddle::framework::compatible::OpVersionDesc().NewAttr( - "asvector", - "Compute as vector when axis is None and input is matrix", false)); + paddle::framework::compatible::OpVersionDesc().NewAttr( + "asvector", "Compute as vector when axis is None and input is matrix", + false)); diff --git a/paddle/fluid/operators/pad2d_op.cc b/paddle/fluid/operators/pad2d_op.cc index 38fa3316a6e27cdb8c55c5bdda08755e4af49395..6d27433512e9036056edc45bac6ad291ccfa99f0 100644 --- a/paddle/fluid/operators/pad2d_op.cc +++ b/paddle/fluid/operators/pad2d_op.cc @@ -16,6 +16,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/pad2d_op.cu b/paddle/fluid/operators/pad2d_op.cu index 80931fea90f9c2effaddf574c8442c3403a10eaa..b7f9977f3edb725b40c8c9a0d2eb40922fbfe760 100644 --- a/paddle/fluid/operators/pad2d_op.cu +++ b/paddle/fluid/operators/pad2d_op.cu @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device/gpu/gpu_info.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" diff --git a/paddle/fluid/operators/pad3d_op.cc b/paddle/fluid/operators/pad3d_op.cc index e4952a243262bedc5477908cd8aedeb158e344b8..b7a638d7ce930068e37bc305575e9500f91460be 100644 --- a/paddle/fluid/operators/pad3d_op.cc +++ b/paddle/fluid/operators/pad3d_op.cc @@ -16,6 +16,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/infermeta/unary.h" diff --git a/paddle/fluid/operators/pad_constant_like_op.cc b/paddle/fluid/operators/pad_constant_like_op.cc index 087b8ecba6e1fb8b4a0ec44bf6b4dffd5b0e3fb5..61a2120e1e43e5f54d40d92522607b71e9acfc91 100644 --- a/paddle/fluid/operators/pad_constant_like_op.cc +++ b/paddle/fluid/operators/pad_constant_like_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/pad_constant_like_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/pad_constant_like_op.h b/paddle/fluid/operators/pad_constant_like_op.h index 0aedd800e1a237d4baf0092eef9bac9f7dbe862d..cc7c39d12cd1a0cacc7b636fc71bcbc81313e524 100644 --- a/paddle/fluid/operators/pad_constant_like_op.h +++ b/paddle/fluid/operators/pad_constant_like_op.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/tensor.h" diff --git a/paddle/fluid/operators/pad_op.cc b/paddle/fluid/operators/pad_op.cc index dc162ae5782f2690fcf6378603268369e4aeb9ca..eaf343dde0f0fbaa822597cd10dca91c7dd24063 100644 --- a/paddle/fluid/operators/pad_op.cc +++ b/paddle/fluid/operators/pad_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/complex.h" diff --git a/paddle/fluid/operators/partial_concat_op.cc b/paddle/fluid/operators/partial_concat_op.cc index fedadc7581e7136bed3a78c8bbf7e06d72a53d2a..e0e6ec31e41e0b41b402fa3fb8332185050cf4d4 100644 --- a/paddle/fluid/operators/partial_concat_op.cc +++ b/paddle/fluid/operators/partial_concat_op.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/partial_concat_op.h" + #include #include #include @@ -93,8 +94,9 @@ class PartialConcatOp : public framework::OperatorWithKernel { break; } } - PADDLE_ENFORCE_EQ(flag, 1, platform::errors::InvalidArgument( - "All Inputs of PartialSum OP are Empty!")); + PADDLE_ENFORCE_EQ(flag, 1, + platform::errors::InvalidArgument( + "All Inputs of PartialSum OP are Empty!")); return framework::OpKernelType(input_data_type, ctx.GetPlace()); } diff --git a/paddle/fluid/operators/partial_concat_op.cu b/paddle/fluid/operators/partial_concat_op.cu index 322e84ae8b9c20db64cc48662554f3a0328c79d2..d36a73037151dc88ca8c0f323d96a2118e20d791 100644 --- a/paddle/fluid/operators/partial_concat_op.cu +++ b/paddle/fluid/operators/partial_concat_op.cu @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/operators/partial_concat_op.h" diff --git a/paddle/fluid/operators/partial_concat_op.h b/paddle/fluid/operators/partial_concat_op.h index 20a6639e23301a5e7d210cf1f93d7923cb7737d2..b12cb0a0293e7c80ecd3ef881bc9c4663e73b09f 100644 --- a/paddle/fluid/operators/partial_concat_op.h +++ b/paddle/fluid/operators/partial_concat_op.h @@ -14,6 +14,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/math/concat_and_split.h" #include "paddle/fluid/operators/strided_memcpy.h" diff --git a/paddle/fluid/operators/partial_sum_op.cc b/paddle/fluid/operators/partial_sum_op.cc index 72630998d433785a48429f8c147050b2b26f2609..a3ce78054acde0822ac59fe0b082fc32a931f7a1 100644 --- a/paddle/fluid/operators/partial_sum_op.cc +++ b/paddle/fluid/operators/partial_sum_op.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/partial_sum_op.h" + #include #include #include @@ -96,8 +97,9 @@ class PartialSumOp : public framework::OperatorWithKernel { } } - PADDLE_ENFORCE_EQ(flag, 1, platform::errors::InvalidArgument( - "All Inputs of PartialSum OP are Empty!")); + PADDLE_ENFORCE_EQ(flag, 1, + platform::errors::InvalidArgument( + "All Inputs of PartialSum OP are Empty!")); return framework::OpKernelType(input_data_type, platform::CPUPlace()); } }; diff --git a/paddle/fluid/operators/partial_sum_op.cu b/paddle/fluid/operators/partial_sum_op.cu index 63d140d6769b895a0054200d0d8d0608a03d337b..b363483fe6945fb957511c665c60011e88dc2df2 100644 --- a/paddle/fluid/operators/partial_sum_op.cu +++ b/paddle/fluid/operators/partial_sum_op.cu @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/operators/partial_sum_op.h" diff --git a/paddle/fluid/operators/partial_sum_op.h b/paddle/fluid/operators/partial_sum_op.h index d9c6fd758f44c37e65bfd1521c1de59aa6072c17..21c16ed2f6227b11dd555704c55c74d2c7736262 100644 --- a/paddle/fluid/operators/partial_sum_op.h +++ b/paddle/fluid/operators/partial_sum_op.h @@ -14,6 +14,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/pixel_shuffle_op.cc b/paddle/fluid/operators/pixel_shuffle_op.cc index 1724aedbe9b249d6c6dacbc1560be8a27db88796..026a1749c39d08ff22c4107a3db05f19d818a4db 100644 --- a/paddle/fluid/operators/pixel_shuffle_op.cc +++ b/paddle/fluid/operators/pixel_shuffle_op.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" diff --git a/paddle/fluid/operators/poisson_op.cc b/paddle/fluid/operators/poisson_op.cc index d5896c4105932ef7327d7093a15cf50e87308ae5..b964d8fe116e912ac57118f834f4c6a0620aa3a4 100644 --- a/paddle/fluid/operators/poisson_op.cc +++ b/paddle/fluid/operators/poisson_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/pool_op.cc b/paddle/fluid/operators/pool_op.cc index 44f3d8090e565c1581a49387db4b834b1abf8b62..30ead84d1a9871c12d773b419c24f710719f69a7 100644 --- a/paddle/fluid/operators/pool_op.cc +++ b/paddle/fluid/operators/pool_op.cc @@ -15,13 +15,13 @@ limitations under the License. */ #include "paddle/fluid/operators/pool_op.h" #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" +#include "paddle/fluid/platform/device/gpu/gpu_dnn.h" #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/infermeta/backward.h" #include "paddle/phi/infermeta/unary.h" - -#include "paddle/fluid/platform/device/gpu/gpu_dnn.h" #ifdef PADDLE_WITH_MKLDNN #include "paddle/fluid/platform/mkldnn_helper.h" #endif diff --git a/paddle/fluid/operators/pool_op_xpu.cc b/paddle/fluid/operators/pool_op_xpu.cc index f178a966e1e08e07f8a7602b65c1a007a5231a38..d2ec4089f9da960cd69d600a6d76b287c298e58f 100644 --- a/paddle/fluid/operators/pool_op_xpu.cc +++ b/paddle/fluid/operators/pool_op_xpu.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/tensor.h" @@ -112,11 +113,12 @@ class PoolGradXPUKernel : public framework::OpKernel { bool exclusive = context.Attr("exclusive"); bool adaptive = context.Attr("adaptive"); const int* index_data = nullptr; - PADDLE_ENFORCE_EQ(ksize.size(), 2, platform::errors::InvalidArgument( - "The Pool2d XPU OP only support 2 " - "dimension pooling!, but received " - "%d-dimension pool kernel size", - ksize.size())); + PADDLE_ENFORCE_EQ( + ksize.size(), 2, + platform::errors::InvalidArgument("The Pool2d XPU OP only support 2 " + "dimension pooling!, but received " + "%d-dimension pool kernel size", + ksize.size())); PADDLE_ENFORCE_EQ(!adaptive || (ksize[0] * ksize[1] == 1), true, platform::errors::InvalidArgument( "The Pool2d XPU OP does not support (adaptive == " diff --git a/paddle/fluid/operators/pool_with_index_op.cc b/paddle/fluid/operators/pool_with_index_op.cc index e0341f4a4b4716d0ee82c9437ddc4d8bd1e35fb2..8619cc28d50d3509be7f212f297c38c593ac1a92 100644 --- a/paddle/fluid/operators/pool_with_index_op.cc +++ b/paddle/fluid/operators/pool_with_index_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/positive_negative_pair_op.cc b/paddle/fluid/operators/positive_negative_pair_op.cc index cbe58644f53810ed04329dc53e0a5eb83491f70b..02273b7943ae29fc52293a43a16660c8907ae3e2 100644 --- a/paddle/fluid/operators/positive_negative_pair_op.cc +++ b/paddle/fluid/operators/positive_negative_pair_op.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/positive_negative_pair_op.h" + #include "paddle/fluid/platform/enforce.h" namespace paddle { @@ -41,11 +42,12 @@ class PositiveNegativePairOp : public framework::OperatorWithKernel { ctx->HasInput("AccumulatePositivePair") && ctx->HasInput("AccumulateNegativePair") && ctx->HasInput("AccumulateNeutralPair"), - true, platform::errors::InvalidArgument( - "All optional inputs(AccumulatePositivePair, " - "AccumulateNegativePair, AccumulateNeutralPair) of " - "PositiveNegativePairOp are required if one of them " - "is specified.")); + true, + platform::errors::InvalidArgument( + "All optional inputs(AccumulatePositivePair, " + "AccumulateNegativePair, AccumulateNeutralPair) of " + "PositiveNegativePairOp are required if one of them " + "is specified.")); PADDLE_ENFORCE_EQ( ctx->GetInputDim("AccumulatePositivePair"), scalar_dim, platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/positive_negative_pair_op.h b/paddle/fluid/operators/positive_negative_pair_op.h index a47deb18b6fccae672c9cfe19d91b151e43c92da..972258350bf19d407f5287f1e0657ddf8f13e3a0 100644 --- a/paddle/fluid/operators/positive_negative_pair_op.h +++ b/paddle/fluid/operators/positive_negative_pair_op.h @@ -12,6 +12,7 @@ limitations under the License. */ #pragma once #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/prelu_op.cc b/paddle/fluid/operators/prelu_op.cc index de35f67405810180554bfd556f91b7501f9c4ba2..50dc9d6429af0757de9cae48239b30ed34f535b8 100644 --- a/paddle/fluid/operators/prelu_op.cc +++ b/paddle/fluid/operators/prelu_op.cc @@ -11,6 +11,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" diff --git a/paddle/fluid/operators/prim_ops/prim_op_test.cc b/paddle/fluid/operators/prim_ops/prim_op_test.cc index 2d65149d130bbc7d8e317233df9f78846e2f66af..e5b84d00f1f28927d78b605627890d4122acc609 100644 --- a/paddle/fluid/operators/prim_ops/prim_op_test.cc +++ b/paddle/fluid/operators/prim_ops/prim_op_test.cc @@ -13,7 +13,6 @@ // limitations under the License. #include "gtest/gtest.h" - #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/program_desc.h" diff --git a/paddle/fluid/operators/print_op.cc b/paddle/fluid/operators/print_op.cc index 4dd4114d378e9cd9b2db8d582a00937960617732..16d6185e87e155a35b2fb3b722fa264dc5ba2372 100644 --- a/paddle/fluid/operators/print_op.cc +++ b/paddle/fluid/operators/print_op.cc @@ -178,10 +178,8 @@ REGISTER_OPERATOR(print, ops::PrintOp, ops::PrintOpProtoAndCheckMaker, ops::PrintOpGradientMaker, ops::PrintOpInferShape, ops::PrintOpVarTypeInference); -REGISTER_OP_VERSION(print) - .AddCheckpoint( - R"ROC(Upgrade print add a new attribute [print_tensor_layout] to " +REGISTER_OP_VERSION(print).AddCheckpoint( + R"ROC(Upgrade print add a new attribute [print_tensor_layout] to " "contorl whether to print tensor's layout.)ROC", - paddle::framework::compatible::OpVersionDesc().NewAttr( - "print_tensor_layout", "Whether to print the tensor's layout.", - true)); + paddle::framework::compatible::OpVersionDesc().NewAttr( + "print_tensor_layout", "Whether to print the tensor's layout.", true)); diff --git a/paddle/fluid/operators/prroi_pool_op.cc b/paddle/fluid/operators/prroi_pool_op.cc index f03a392bfc7367de5cd50416df3073b500aea139..51bd079849a52799ca15ff7d2e55216df6bf1d9b 100644 --- a/paddle/fluid/operators/prroi_pool_op.cc +++ b/paddle/fluid/operators/prroi_pool_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/prroi_pool_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/prroi_pool_op.h b/paddle/fluid/operators/prroi_pool_op.h index 0fdccc729added5ac26f16aa760f523094797b4d..8431d945749f3c8120fce3fce6094b3af0a4b135 100644 --- a/paddle/fluid/operators/prroi_pool_op.h +++ b/paddle/fluid/operators/prroi_pool_op.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/math_function.h" #if defined(__NVCC__) || defined(__HIPCC__) diff --git a/paddle/fluid/operators/prune_gate_by_capacity_op.cu b/paddle/fluid/operators/prune_gate_by_capacity_op.cu index 6a2ed6592e7fef0ac9e436842d052820ff97d722..2e729f94dc8f3f1c17ddf8cee76ee72e307ff46d 100644 --- a/paddle/fluid/operators/prune_gate_by_capacity_op.cu +++ b/paddle/fluid/operators/prune_gate_by_capacity_op.cu @@ -79,9 +79,10 @@ class PruneGateByCapacityFunctor { int blocks = NumBlocks(batch_size); int threads = kNumCUDAThreads; - prune_gate_by_capacity_kernel<<>>( - gate_idx_data, new_gate_idx_data_, expert_count_out_data, batch_size); + prune_gate_by_capacity_kernel + <<>>( + gate_idx_data, new_gate_idx_data_, expert_count_out_data, + batch_size); } private: diff --git a/paddle/fluid/operators/pscore/distributed_lookup_table_op.cc b/paddle/fluid/operators/pscore/distributed_lookup_table_op.cc index f101e509d936f803c1b7bb8f53d1401a3cdbb3bb..d09b1c7aa068e63832a9ec58f3a286a4b3da0812 100644 --- a/paddle/fluid/operators/pscore/distributed_lookup_table_op.cc +++ b/paddle/fluid/operators/pscore/distributed_lookup_table_op.cc @@ -9,11 +9,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/operators/pscore/distributed_lookup_table_op.h" + #include #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/op_registry.h" -#include "paddle/fluid/operators/pscore/distributed_lookup_table_op.h" #include "paddle/phi/kernels/funcs/math_function.h" namespace paddle { diff --git a/paddle/fluid/operators/pscore/distributed_lookup_table_op.h b/paddle/fluid/operators/pscore/distributed_lookup_table_op.h index c2717c19b2d8e9eb958534496ffdeffd4be6387c..c9390aa42a656194bd6db0dd0be0b0ddd937a79b 100644 --- a/paddle/fluid/operators/pscore/distributed_lookup_table_op.h +++ b/paddle/fluid/operators/pscore/distributed_lookup_table_op.h @@ -13,6 +13,7 @@ #include #include #include + #include "paddle/fluid/distributed/ps/wrapper/fleet.h" #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/pscore/distributed_push_sparse_op.cc b/paddle/fluid/operators/pscore/distributed_push_sparse_op.cc index 9868a6257924e5a4ded2a106c75a099235e3007f..701b6250445bdb63e66b75bc39a40578b17d5821 100644 --- a/paddle/fluid/operators/pscore/distributed_push_sparse_op.cc +++ b/paddle/fluid/operators/pscore/distributed_push_sparse_op.cc @@ -9,11 +9,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/operators/pscore/distributed_push_sparse_op.h" + #include #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/op_registry.h" -#include "paddle/fluid/operators/pscore/distributed_push_sparse_op.h" #include "paddle/phi/kernels/funcs/math_function.h" namespace paddle { diff --git a/paddle/fluid/operators/pscore/distributed_push_sparse_op.h b/paddle/fluid/operators/pscore/distributed_push_sparse_op.h index 6d3faae6a2d09ba48d05d03587bd903bf98671c5..7c361dfd1a7dc32eff0686b401e14b0e858add0e 100644 --- a/paddle/fluid/operators/pscore/distributed_push_sparse_op.h +++ b/paddle/fluid/operators/pscore/distributed_push_sparse_op.h @@ -13,6 +13,7 @@ #include #include #include + #include "paddle/fluid/distributed/ps/wrapper/fleet.h" #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/pscore/heter_listen_and_serv_op.cc b/paddle/fluid/operators/pscore/heter_listen_and_serv_op.cc index 457e37744d3163a74c8ecf73d2bf2a37e138a4fb..5d77851b72a24f9f98070b5b83e203d21e02f25f 100644 --- a/paddle/fluid/operators/pscore/heter_listen_and_serv_op.cc +++ b/paddle/fluid/operators/pscore/heter_listen_and_serv_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/pscore/heter_listen_and_serv_op.h" + #include "paddle/fluid/framework/op_registry.h" PADDLE_DEFINE_EXPORTED_int32(rpc_send_thread_num, 12, @@ -92,8 +93,9 @@ void HeterListenAndServOp::RunAsyncLoop(framework::ProgramDesc *program) const { auto blkid = block_list[i]; auto it = message_to_block_id.find_value(blkid); heter_server_->RegisterServiceHandler( - it->first, [&](const MultiVarMsg *request, MultiVarMsg *response, - brpc::Controller *cntl) -> int { + it->first, + [&](const MultiVarMsg *request, MultiVarMsg *response, + brpc::Controller *cntl) -> int { return send_and_recv_variable_handler_->Handle(request, response, cntl); }); diff --git a/paddle/fluid/operators/pscore/heter_listen_and_serv_op.h b/paddle/fluid/operators/pscore/heter_listen_and_serv_op.h old mode 100755 new mode 100644 index 3ecff083b00c7811e35fbedd8bb7d976cf3377f5..29cc041d68216d78422fbdfa98cdff4d278e2543 --- a/paddle/fluid/operators/pscore/heter_listen_and_serv_op.h +++ b/paddle/fluid/operators/pscore/heter_listen_and_serv_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include #include #include diff --git a/paddle/fluid/operators/pscore/heter_listen_and_server_test.cc b/paddle/fluid/operators/pscore/heter_listen_and_server_test.cc index ab2fcba51062fb83fcba0c0fd57ab89dbf7d689a..da57660a74d39de5b3a8ef254acdaebc5589a323 100644 --- a/paddle/fluid/operators/pscore/heter_listen_and_server_test.cc +++ b/paddle/fluid/operators/pscore/heter_listen_and_server_test.cc @@ -14,11 +14,11 @@ limitations under the License. */ #include #include -#include -#include // NOLINT #include #include +#include +#include // NOLINT #include "gtest/gtest.h" #include "paddle/fluid/distributed/ps/service/heter_client.h" diff --git a/paddle/fluid/operators/pscore/heter_server_test.cc b/paddle/fluid/operators/pscore/heter_server_test.cc index d4ee00d10a50bbdcbc890ef85f93cfa1d241b239..db647dfaf238bd9e8c11dcc1bf9b6692fa39795b 100644 --- a/paddle/fluid/operators/pscore/heter_server_test.cc +++ b/paddle/fluid/operators/pscore/heter_server_test.cc @@ -12,17 +12,18 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/distributed/ps/service/heter_server.h" + #include -#include -#include -#include // NOLINT +#include #include #include +#include +#include // NOLINT #include "gtest/gtest.h" #include "paddle/fluid/distributed/ps/service/heter_client.h" -#include "paddle/fluid/distributed/ps/service/heter_server.h" #include "paddle/fluid/framework/op_registry.h" namespace framework = paddle::framework; @@ -181,13 +182,15 @@ void StartSendAndRecvServer(std::string endpoint) { heter_server_ptr_->SetEndPoint(endpoint); LOG(INFO) << "before HeterServer::RegisterServiceHandler"; heter_server_ptr_->RegisterServiceHandler( - in_var_name, [&](const MultiVarMsg* request, MultiVarMsg* response, - brpc::Controller* cntl) -> int { + in_var_name, + [&](const MultiVarMsg* request, MultiVarMsg* response, + brpc::Controller* cntl) -> int { return b_req_handler->Handle(request, response, cntl); }); heter_server_ptr_->RegisterServiceHandler( - in_var_name2, [&](const MultiVarMsg* request, MultiVarMsg* response, - brpc::Controller* cntl) -> int { + in_var_name2, + [&](const MultiVarMsg* request, MultiVarMsg* response, + brpc::Controller* cntl) -> int { return b_req_handler->Handle(request, response, cntl); }); diff --git a/paddle/fluid/operators/pscore/send_and_recv_op_cpu_test.cc b/paddle/fluid/operators/pscore/send_and_recv_op_cpu_test.cc old mode 100755 new mode 100644 index 7c25d38d1ebada2396dda2ea3b573597ea151dd2..a21d11ee1b19e4ee72ad1fa6188d64bdedefc6dd --- a/paddle/fluid/operators/pscore/send_and_recv_op_cpu_test.cc +++ b/paddle/fluid/operators/pscore/send_and_recv_op_cpu_test.cc @@ -14,12 +14,13 @@ limitations under the License. */ #if defined PADDLE_WITH_PSCORE #include + #include +#include +#include #include #include // NOLINT -#include -#include #include "gtest/gtest.h" #include "paddle/fluid/distributed/ps/service/heter_client.h" #include "paddle/fluid/distributed/ps/service/heter_server.h" @@ -158,8 +159,9 @@ void StartSendAndRecvServer(std::string endpoint) { b_rpc_service->SetEndPoint(endpoint); LOG(INFO) << "before HeterServer::RegisterServiceHandler"; b_rpc_service->RegisterServiceHandler( - in_var_name, [&](const MultiVarMsg* request, MultiVarMsg* response, - brpc::Controller* cntl) -> int { + in_var_name, + [&](const MultiVarMsg* request, MultiVarMsg* response, + brpc::Controller* cntl) -> int { return b_req_handler->Handle(request, response, cntl); }); diff --git a/paddle/fluid/operators/pscore/send_and_recv_op_gpu_test.cc b/paddle/fluid/operators/pscore/send_and_recv_op_gpu_test.cc index 4054846460b0719558a06dd7cb454cecb9b874fd..c8e24c77734f8e166c3223a1790ffb0edf7e17aa 100644 --- a/paddle/fluid/operators/pscore/send_and_recv_op_gpu_test.cc +++ b/paddle/fluid/operators/pscore/send_and_recv_op_gpu_test.cc @@ -15,12 +15,12 @@ limitations under the License. */ #if (defined PADDLE_WITH_CUDA) && (defined PADDLE_WITH_PSCORE) #include -#include -#include -#include // NOLINT +#include #include #include +#include +#include // NOLINT #include "gtest/gtest.h" #include "paddle/fluid/distributed/ps/service/heter_client.h" @@ -178,8 +178,9 @@ void StartSendAndRecvServer(std::string endpoint) { b_rpc_service2->SetEndPoint(endpoint); LOG(INFO) << "before HeterServer::RegisterServiceHandler"; b_rpc_service2->RegisterServiceHandler( - in_var_name, [&](const MultiVarMsg* request, MultiVarMsg* response, - brpc::Controller* cntl) -> int { + in_var_name, + [&](const MultiVarMsg* request, MultiVarMsg* response, + brpc::Controller* cntl) -> int { return b_req_handler->Handle(request, response, cntl); }); diff --git a/paddle/fluid/operators/pull_box_extended_sparse_op.h b/paddle/fluid/operators/pull_box_extended_sparse_op.h index 559c7eed84e6f85e1e6789ca49ce460c5a48a3bc..f803b57b187f8ad31a7d3a12d8c38222c557a9e6 100644 --- a/paddle/fluid/operators/pull_box_extended_sparse_op.h +++ b/paddle/fluid/operators/pull_box_extended_sparse_op.h @@ -15,6 +15,7 @@ #pragma once #include #include + #include "paddle/fluid/framework/fleet/box_wrapper.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/tensor.h" diff --git a/paddle/fluid/operators/pull_gpups_sparse_op.h b/paddle/fluid/operators/pull_gpups_sparse_op.h index abfdb62ec34ac3633c530f175da54fb17c9389c6..58e1172552135864d787f40da8e6ac92760c0740 100644 --- a/paddle/fluid/operators/pull_gpups_sparse_op.h +++ b/paddle/fluid/operators/pull_gpups_sparse_op.h @@ -15,6 +15,7 @@ #pragma once #include #include + #include "paddle/fluid/framework/fleet/ps_gpu_wrapper.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/tensor.h" diff --git a/paddle/fluid/operators/pull_sparse_op.cc b/paddle/fluid/operators/pull_sparse_op.cc index fb83746de19ecccad8c47d6dd104ee0bde45dfad..57d361b7a77bbd4bd8d0f9b609cb1ff1389fe1a8 100644 --- a/paddle/fluid/operators/pull_sparse_op.cc +++ b/paddle/fluid/operators/pull_sparse_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/pull_sparse_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/pull_sparse_op.h b/paddle/fluid/operators/pull_sparse_op.h index 2498adc141cd7a7d650811866f7496d43fc64dab..e3f0f88ce5552691a1a8bc4eee7885c344f1a53b 100644 --- a/paddle/fluid/operators/pull_sparse_op.h +++ b/paddle/fluid/operators/pull_sparse_op.h @@ -16,6 +16,7 @@ #include #include #include + #include "paddle/fluid/framework/fleet/fleet_wrapper.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/tensor.h" diff --git a/paddle/fluid/operators/pull_sparse_v2_op.cc b/paddle/fluid/operators/pull_sparse_v2_op.cc index f5f2e728e38c04909f926fb9c18dfc3667eb64f3..a8fc84b9c2b738e560710c28a3111e9cbc52a1e9 100644 --- a/paddle/fluid/operators/pull_sparse_v2_op.cc +++ b/paddle/fluid/operators/pull_sparse_v2_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/pull_sparse_v2_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/pull_sparse_v2_op.h b/paddle/fluid/operators/pull_sparse_v2_op.h index 29337cc2d94b465fc2fde5ebeb774b4b98d8a202..c24d0a4f338e7d95a7f700a9470bd824da6415a2 100644 --- a/paddle/fluid/operators/pull_sparse_v2_op.h +++ b/paddle/fluid/operators/pull_sparse_v2_op.h @@ -16,6 +16,7 @@ #include #include #include + #include "paddle/fluid/framework/fleet/fleet_wrapper.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/tensor.h" diff --git a/paddle/fluid/operators/push_dense_op.cc b/paddle/fluid/operators/push_dense_op.cc index 5b9f05bd126b8aa7f895af1f659f705617491643..5284a1a61e5ef17f58c851077192e3344e5b1538 100644 --- a/paddle/fluid/operators/push_dense_op.cc +++ b/paddle/fluid/operators/push_dense_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/push_dense_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/push_dense_op.h b/paddle/fluid/operators/push_dense_op.h index 592ef5ff72a65f1d66725197d87749e2d18bdae6..c8f98a1ea9e5d12c77ebabf798caa28349f2cae9 100644 --- a/paddle/fluid/operators/push_dense_op.h +++ b/paddle/fluid/operators/push_dense_op.h @@ -16,6 +16,7 @@ #include #include #include + #include "paddle/fluid/framework/device_worker.h" #include "paddle/fluid/framework/fleet/fleet_wrapper.h" #include "paddle/fluid/framework/no_need_buffer_vars_inference.h" diff --git a/paddle/fluid/operators/py_func_op.cc b/paddle/fluid/operators/py_func_op.cc index f676348bc0af2a8de573c9365b699aefb7f67a02..de46357e497fdf14f8192478ddeb17cb781de7b8 100644 --- a/paddle/fluid/operators/py_func_op.cc +++ b/paddle/fluid/operators/py_func_op.cc @@ -20,6 +20,7 @@ #include #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/py_layer_op.cc b/paddle/fluid/operators/py_layer_op.cc index 14c9e8b0c260f1f0c2e328b4e0f748f3cf922a0d..db8f315366a7b09587b171684fae36b3be920860 100644 --- a/paddle/fluid/operators/py_layer_op.cc +++ b/paddle/fluid/operators/py_layer_op.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "paddle/fluid/operators/py_layer_op.h" +#include + namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/py_layer_op.h b/paddle/fluid/operators/py_layer_op.h index 6625a4a1a753c9ab5c2a1f735e96d8e2ae99e1dc..ea048ee9e5948959ca5677a411dcf6717ff31cde 100644 --- a/paddle/fluid/operators/py_layer_op.h +++ b/paddle/fluid/operators/py_layer_op.h @@ -18,6 +18,7 @@ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/python_headers.h" diff --git a/paddle/fluid/operators/pyramid_hash_op.cc b/paddle/fluid/operators/pyramid_hash_op.cc index 4b0ade99154a1b68588936f93b4caeef3146c378..6650037e4d2f42f3b3084e265d814d0ce98bc44c 100644 --- a/paddle/fluid/operators/pyramid_hash_op.cc +++ b/paddle/fluid/operators/pyramid_hash_op.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include #include + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/search_compute.h" @@ -216,9 +218,8 @@ class CPUPyramidHashOPKernel : public framework::OpKernel { bool should_use_term(math::bloomfilter* _filter, math::bloomfilter* _black_filter, const float* word_repr, int len) const { - return (!_filter || - 1 == math::bloomfilter_get(_filter, word_repr, - len * sizeof(float))) && + return (!_filter || 1 == math::bloomfilter_get(_filter, word_repr, + len * sizeof(float))) && (!_black_filter || 0 == math::bloomfilter_get(_black_filter, word_repr, len * sizeof(float))); diff --git a/paddle/fluid/operators/qr_op.cc b/paddle/fluid/operators/qr_op.cc index 02d5e5f03f02e2ca796555aeeb93167cb916a7c6..55cab539c4d4e7977a74dfb5e014a6f1d17bd254 100644 --- a/paddle/fluid/operators/qr_op.cc +++ b/paddle/fluid/operators/qr_op.cc @@ -13,10 +13,12 @@ // limitations under the License. #include "paddle/fluid/operators/qr_op.h" + #include #include #include #include + #include "paddle/phi/core/ddim.h" #ifdef PADDLE_WITH_MKLDNN #include "paddle/fluid/platform/mkldnn_helper.h" diff --git a/paddle/fluid/operators/qr_op.cu b/paddle/fluid/operators/qr_op.cu index a57a8d5cf8b7f65a892ce9465ce03bd3c9519f1c..695b90e9319e4987734c6bce873456d9bb79f718 100644 --- a/paddle/fluid/operators/qr_op.cu +++ b/paddle/fluid/operators/qr_op.cu @@ -16,8 +16,10 @@ limitations under the License. */ // HIP not support cusolver #include + #include #include + #include "paddle/fluid/memory/memory.h" #include "paddle/fluid/operators/qr_op.h" #include "paddle/fluid/platform/dynload/cusolver.h" @@ -43,8 +45,9 @@ class QrGPUKernel : public framework::OpKernel { std::tie(compute_q, reduced_mode) = _parse_qr_mode(mode); auto numel = x.numel(); - PADDLE_ENFORCE_GT(numel, 0, platform::errors::PreconditionNotMet( - "The input of QR is empty.")); + PADDLE_ENFORCE_GT( + numel, 0, + platform::errors::PreconditionNotMet("The input of QR is empty.")); auto x_dims = x.dims(); int x_rank = x_dims.size(); int m = x_dims[x_rank - 2]; diff --git a/paddle/fluid/operators/qr_op.h b/paddle/fluid/operators/qr_op.h index 5ef02d8942797a720d18358d425cf45f77be82ad..760b2efd21f6b8c94dc02f4b098a8af2273e3cd5 100644 --- a/paddle/fluid/operators/qr_op.h +++ b/paddle/fluid/operators/qr_op.h @@ -16,6 +16,7 @@ #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/operators/svd_helper.h" @@ -89,11 +90,11 @@ class QrGradKernel : public framework::OpKernel { } // m >= n case - auto m_gt_n_case = []( - const framework::ExecutionContext& ctx, - math::DeviceIndependenceTensorOperations& dito, - const Tensor& dQ, const Tensor& dR, const Tensor& A, const Tensor& Q, - const Tensor& R) -> framework::Tensor { + auto m_gt_n_case = + [](const framework::ExecutionContext& ctx, + math::DeviceIndependenceTensorOperations& dito, + const Tensor& dQ, const Tensor& dR, const Tensor& A, const Tensor& Q, + const Tensor& R) -> framework::Tensor { // Hai-Jun Liao, Jin-Guo Liu, Lei Wang, Tao Xiang (2019). Differentiable // Programming Tensor Networks. // https://arxiv.org/abs/1903.09650 Section 3. QR factorization diff --git a/paddle/fluid/operators/quantize_linear_op.cc b/paddle/fluid/operators/quantize_linear_op.cc index 4039f0e9d07e14325e7a3fa841220a18dca590e5..edd2a06a500013b37cd78792b7f7d3df6bfb8f98 100644 --- a/paddle/fluid/operators/quantize_linear_op.cc +++ b/paddle/fluid/operators/quantize_linear_op.cc @@ -10,9 +10,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/quantize_linear_op.h" + #include #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/platform/transform.h" diff --git a/paddle/fluid/operators/quantize_linear_op.cu b/paddle/fluid/operators/quantize_linear_op.cu index 6c7e430f51126835d0ce32d3361eea916880239f..6e3e39562c719a5fdd979b57009c2c5f7864abb7 100644 --- a/paddle/fluid/operators/quantize_linear_op.cu +++ b/paddle/fluid/operators/quantize_linear_op.cu @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/memory/memcpy.h" #include "paddle/fluid/operators/fake_dequantize_op.cu.h" #include "paddle/fluid/operators/fake_quantize_op.cu.h" @@ -46,10 +47,10 @@ struct ChannelDequantizeFunctorV2 { quant_stride *= in_dims[i]; } - DequantizeOneScaleQuantAxisN< - T><<>>( - in_data, scale_factor, max_range, num, in_dims[quant_axis], - quant_stride, out_data); + DequantizeOneScaleQuantAxisN + <<>>( + in_data, scale_factor, max_range, num, in_dims[quant_axis], + quant_stride, out_data); } }; diff --git a/paddle/fluid/operators/quantize_linear_op.h b/paddle/fluid/operators/quantize_linear_op.h index e20b99e85f0b31752764a66b2a001991b1249392..df1a93ba638ae5875acd19bbdadd7101828c613d 100644 --- a/paddle/fluid/operators/quantize_linear_op.h +++ b/paddle/fluid/operators/quantize_linear_op.h @@ -13,6 +13,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/memory/malloc.h" diff --git a/paddle/fluid/operators/quantize_op.cc b/paddle/fluid/operators/quantize_op.cc index 951951253c47a65e714c8ac0df6af8ef8f85a173..62ec77bc2240fc0d0b15898822398561f3c7421b 100644 --- a/paddle/fluid/operators/quantize_op.cc +++ b/paddle/fluid/operators/quantize_op.cc @@ -13,6 +13,7 @@ * limitations under the License. */ #include "paddle/fluid/operators/quantize_op.h" + #include "paddle/fluid/framework/op_version_registry.h" #ifdef PADDLE_WITH_MKLDNN #include "paddle/fluid/platform/mkldnn_helper.h" @@ -57,13 +58,13 @@ namespace ops = paddle::operators; REGISTER_OPERATOR(quantize, ops::QuantOp, ops::QuantOpMaker); REGISTER_OP_VERSION(quantize) - .AddCheckpoint( - R"ROC( Add a new attribute [bfloat16])ROC", - paddle::framework::compatible::OpVersionDesc().NewAttr( - "bfloat16", "If true, float32 input is converted to bfloat16", - false)) - .AddCheckpoint( - R"ROC( Add a new attribute [Shift])ROC", - paddle::framework::compatible::OpVersionDesc().NewAttr( - "Shift", "Quantize data to uint8 if provided non-zero value.", - 0.0f)); + .AddCheckpoint(R"ROC( Add a new attribute [bfloat16])ROC", + paddle::framework::compatible::OpVersionDesc().NewAttr( + "bfloat16", + "If true, float32 input is converted to bfloat16", + false)) + .AddCheckpoint(R"ROC( Add a new attribute [Shift])ROC", + paddle::framework::compatible::OpVersionDesc().NewAttr( + "Shift", + "Quantize data to uint8 if provided non-zero value.", + 0.0f)); diff --git a/paddle/fluid/operators/quantize_op.h b/paddle/fluid/operators/quantize_op.h index 091306e4637c7e2393b6736f0e1edf9dd7fd2c8a..dd1b3c42fb5f9dc41d3fc9b5cb03a07eff23d8dd 100644 --- a/paddle/fluid/operators/quantize_op.h +++ b/paddle/fluid/operators/quantize_op.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/queue_generator_op.cc b/paddle/fluid/operators/queue_generator_op.cc index e2174b9346e1ec61f0ac4287c9fa50347e596bce..3683fbd075db216b4c9d51b9170bac338b1b2d3c 100644 --- a/paddle/fluid/operators/queue_generator_op.cc +++ b/paddle/fluid/operators/queue_generator_op.cc @@ -43,9 +43,10 @@ class QueueGeneratorOp : public framework::OperatorBase { void RunImpl(const framework::Scope& scope, const platform::Place& dev_place) const override { std::vector names = Attr>("names"); - PADDLE_ENFORCE_GT(names.size(), 0, platform::errors::InvalidArgument( - "The attribute 'names' for " - "Op(queue_generator) must be set.")); + PADDLE_ENFORCE_GT( + names.size(), 0, + platform::errors::InvalidArgument("The attribute 'names' for " + "Op(queue_generator) must be set.")); int capacity = Attr("capacity"); PADDLE_ENFORCE_GT(capacity, 0, diff --git a/paddle/fluid/operators/random_crop_op.h b/paddle/fluid/operators/random_crop_op.h index 2928c3b5027810ab312b0aadcb233433ee9872ce..cfda710bd7745cc9ac940bf109342f053bf99727 100644 --- a/paddle/fluid/operators/random_crop_op.h +++ b/paddle/fluid/operators/random_crop_op.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/for_range.h" diff --git a/paddle/fluid/operators/random_routing_op.cu b/paddle/fluid/operators/random_routing_op.cu index fec65518a9d4851128e1ceb74b415971a526dda2..471cfb40e6167c9ad93c212a232970148d44328f 100644 --- a/paddle/fluid/operators/random_routing_op.cu +++ b/paddle/fluid/operators/random_routing_op.cu @@ -71,9 +71,9 @@ class RandomRoutingOpCUDAKernel : public framework::OpKernel { auto topk_idx_data = topk_idx->data(); auto out_data = out->data(); - random_routing_kernel< - T><<>>( - out_data, num_idx, N, D, prob_data, topk_idx_data, topk_value_data); + random_routing_kernel + <<>>( + out_data, num_idx, N, D, prob_data, topk_idx_data, topk_value_data); } }; diff --git a/paddle/fluid/operators/randperm_op.cc b/paddle/fluid/operators/randperm_op.cc index 1b28ab3c133f7d57250e3357b0d732603719ef99..aed1f2b0ed1028ff410b0b54a8e998d6f5362046 100644 --- a/paddle/fluid/operators/randperm_op.cc +++ b/paddle/fluid/operators/randperm_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" @@ -29,10 +30,11 @@ class RandpermOp : public framework::OperatorWithKernel { "The output(Out) of randperm op must not be null.")); int n = ctx->Attrs().Get("n"); PADDLE_ENFORCE_GT( - n, 0, platform::errors::InvalidArgument( - "The input 'n' of randperm op should be greater than 0. " - "But received %d.", - n)); + n, 0, + platform::errors::InvalidArgument( + "The input 'n' of randperm op should be greater than 0. " + "But received %d.", + n)); ctx->SetOutputDim("Out", phi::make_ddim({n})); } diff --git a/paddle/fluid/operators/randperm_op_npu.cc b/paddle/fluid/operators/randperm_op_npu.cc index a16c0d905a555ea07488789f7c216b7161b7eb85..c9f6121101601b96c4fd062bf4036e9ad359c3cf 100644 --- a/paddle/fluid/operators/randperm_op_npu.cc +++ b/paddle/fluid/operators/randperm_op_npu.cc @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/randperm_op.h" #include "paddle/fluid/framework/op_registry.h" +#include "paddle/fluid/operators/randperm_op.h" template using kernel = diff --git a/paddle/fluid/operators/range_op.cc b/paddle/fluid/operators/range_op.cc index 80fdb2ce6c345011acdf6a6cf57f2711277186e2..215f83698186c15bb78cdc643ec4fbaac65667a7 100644 --- a/paddle/fluid/operators/range_op.cc +++ b/paddle/fluid/operators/range_op.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/range_op.h" + #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/range_op.h b/paddle/fluid/operators/range_op.h index 8924b23ce5cf8987be06e6b0c8f55a4773e69294..e2fd16dd629ad64cf528aeb06c6ed9c1a4666bad 100644 --- a/paddle/fluid/operators/range_op.h +++ b/paddle/fluid/operators/range_op.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/math_function.h" @@ -22,13 +23,15 @@ namespace operators { template void GetSize(T start, T end, T step, int64_t* size) { - PADDLE_ENFORCE_NE(step, 0, platform::errors::InvalidArgument( - "The step of range op should not be 0.")); + PADDLE_ENFORCE_NE(step, 0, + platform::errors::InvalidArgument( + "The step of range op should not be 0.")); if (start < end) { PADDLE_ENFORCE_GT( - step, 0, platform::errors::InvalidArgument( - "The step should be greater than 0 while start < end.")); + step, 0, + platform::errors::InvalidArgument( + "The step should be greater than 0 while start < end.")); } if (start > end) { diff --git a/paddle/fluid/operators/range_op_xpu.cc b/paddle/fluid/operators/range_op_xpu.cc index 6672968de3a028d4fd69e1c390432eec7bc0ae71..bfc0d27f7ca26bc5de04070380ecd8b86be2c65e 100644 --- a/paddle/fluid/operators/range_op_xpu.cc +++ b/paddle/fluid/operators/range_op_xpu.cc @@ -13,8 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. */ #ifdef PADDLE_WITH_XPU -#include "paddle/fluid/operators/range_op.h" #include "paddle/fluid/framework/op_registry.h" +#include "paddle/fluid/operators/range_op.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/rank_attention_op.cc b/paddle/fluid/operators/rank_attention_op.cc index e5332da6475d79be600d82b68604753f8ce32d5c..89bdeb57b5fdf39c30643977984b2959a4aa785e 100644 --- a/paddle/fluid/operators/rank_attention_op.cc +++ b/paddle/fluid/operators/rank_attention_op.cc @@ -10,9 +10,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/rank_attention_op.h" + #include #include #include + #include "paddle/fluid/framework/op_version_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/rank_attention_op.cu b/paddle/fluid/operators/rank_attention_op.cu index 9b3a1e56371153c0331ae930afce2a9aed0086a3..61d723c27f7e55c2626446f0de2e9177a19e5fda 100644 --- a/paddle/fluid/operators/rank_attention_op.cu +++ b/paddle/fluid/operators/rank_attention_op.cu @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/operators/rank_attention.cu.h" #include "paddle/fluid/operators/rank_attention_op.h" diff --git a/paddle/fluid/operators/reader/blocking_queue.h b/paddle/fluid/operators/reader/blocking_queue.h index f126070a7eb96ab38022e9dea932f4cfd62b40d9..38c45ca2803ff9c9ff3a8c3e8ab4a29e454f2108 100644 --- a/paddle/fluid/operators/reader/blocking_queue.h +++ b/paddle/fluid/operators/reader/blocking_queue.h @@ -161,9 +161,10 @@ class BlockingQueue { private: inline void EnforceNotKilled() { - PADDLE_ENFORCE_NE(killed_, true, platform::errors::Fatal( - "Blocking queue is killed because the " - "data reader raises an exception.")); + PADDLE_ENFORCE_NE( + killed_, true, + platform::errors::Fatal("Blocking queue is killed because the " + "data reader raises an exception.")); } private: diff --git a/paddle/fluid/operators/reader/buffered_reader.cc b/paddle/fluid/operators/reader/buffered_reader.cc index db0f5758d2f53263d0f4166a55fb4e64c8f0e2c5..193f6c29724b79fdce8190c61176a30ccbed0b6e 100644 --- a/paddle/fluid/operators/reader/buffered_reader.cc +++ b/paddle/fluid/operators/reader/buffered_reader.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/reader/buffered_reader.h" + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/platform/device/device_wrapper.h" #include "paddle/fluid/platform/profiler.h" diff --git a/paddle/fluid/operators/reader/create_ctr_reader_op.cc b/paddle/fluid/operators/reader/create_ctr_reader_op.cc index 86fbddc0ec2cf10055d11b303a0d3e519b641587..b83d08528417567242e90dac1e5acad321bc45ec 100644 --- a/paddle/fluid/operators/reader/create_ctr_reader_op.cc +++ b/paddle/fluid/operators/reader/create_ctr_reader_op.cc @@ -13,7 +13,6 @@ // limitations under the License. #include "paddle/fluid/operators/reader/ctr_reader.h" - #include "paddle/fluid/operators/reader/lod_tensor_blocking_queue.h" #include "paddle/fluid/operators/reader/reader_op_registry.h" diff --git a/paddle/fluid/operators/recurrent_op.cc b/paddle/fluid/operators/recurrent_op.cc index 8557ef950b3e9860439e5ce08d0cb8963d4c5e63..8b2809b286cfee92f06a74e70897d19be27d64cd 100644 --- a/paddle/fluid/operators/recurrent_op.cc +++ b/paddle/fluid/operators/recurrent_op.cc @@ -322,9 +322,10 @@ void RecurrentGradOp::RunImpl(const framework::Scope &scope, framework::Executor executor(place); auto *block = Attr(kStepBlock); auto *program = block->Program(); - auto ctx = executor.Prepare( - *program, block->ID(), Attr>( - kSkipEagerDeletionVars) /*skip_ref_cnt_vars*/); + auto ctx = + executor.Prepare(*program, block->ID(), + Attr>( + kSkipEagerDeletionVars) /*skip_ref_cnt_vars*/); for (size_t step_id = 0; step_id < seq_len; ++step_id) { size_t seq_offset = reverse ? step_id : seq_len - step_id - 1; @@ -387,19 +388,19 @@ void RecurrentGradOp::RunImpl(const framework::Scope &scope, // outside::output[seq_offset: seq_offset + 1] = inside::output executor.CreateVariables(ctx->prog_, &cur_scope, ctx->block_id_); if (step_id > 0) { - LinkTensorWithCallback(scope, Outputs(kInputGrads), cur_scope, - GradVarLists(Inputs(kInputs)), - [&](const framework::LoDTensor &src_tensor, - framework::LoDTensor *dst_tensor) { - if (src_tensor.memory_size() == - 0) { // Inside Gradient is not created. - return; - } - framework::Tensor src_slice = - src_tensor.Slice(seq_offset, seq_offset + 1); - dst_tensor->ShareDataWith(src_slice); - }, - true /*is_backward*/); + LinkTensorWithCallback( + scope, Outputs(kInputGrads), cur_scope, GradVarLists(Inputs(kInputs)), + [&](const framework::LoDTensor &src_tensor, + framework::LoDTensor *dst_tensor) { + if (src_tensor.memory_size() == + 0) { // Inside Gradient is not created. + return; + } + framework::Tensor src_slice = + src_tensor.Slice(seq_offset, seq_offset + 1); + dst_tensor->ShareDataWith(src_slice); + }, + true /*is_backward*/); } VLOG(5) << "Recurrent memory linking finished "; @@ -604,7 +605,8 @@ if reverse is True | | | | v v v v o o o o -)DOC").SetDefault(false); +)DOC") + .SetDefault(false); AddAttr(RecurrentBase::kIsTrain, "").SetDefault(true); AddAttr>(RecurrentBase::kSkipEagerDeletionVars, "Vars that would skip eager deletion." @@ -663,14 +665,16 @@ class RecurrentGradOpShapeInference : public framework::InferShapeBase { ctx->Attrs() .Get>(RecurrentBase::kExStates) .size(), - 0, platform::errors::InvalidArgument("The Attr(%s) should be empty.", - RecurrentBase::kExStates)); + 0, + platform::errors::InvalidArgument("The Attr(%s) should be empty.", + RecurrentBase::kExStates)); PADDLE_ENFORCE_EQ( ctx->Attrs() .Get>(RecurrentBase::kStates) .size(), - 0, platform::errors::InvalidArgument("The Attr(%s) should be empty.", - RecurrentBase::kStates)); + 0, + platform::errors::InvalidArgument("The Attr(%s) should be empty.", + RecurrentBase::kStates)); } PADDLE_ENFORCE_EQ( @@ -702,9 +706,10 @@ class RecurrentGradOpShapeInference : public framework::InferShapeBase { if (ctx->HasInputs(RecurrentBase::kParameters)) { PADDLE_ENFORCE_EQ( ctx->HasOutputs(framework::GradVarName(RecurrentBase::kParameters)), - true, platform::errors::InvalidArgument( - "The output of(%s) should not be empty.", - framework::GradVarName(RecurrentBase::kParameters))); + true, + platform::errors::InvalidArgument( + "The output of(%s) should not be empty.", + framework::GradVarName(RecurrentBase::kParameters))); ctx->SetOutputsDim(framework::GradVarName(RecurrentBase::kParameters), ctx->GetInputsDim(RecurrentBase::kParameters)); } diff --git a/paddle/fluid/operators/reduce_ops/frobenius_norm_op.cc b/paddle/fluid/operators/reduce_ops/frobenius_norm_op.cc index 83a21a919dcaaf6341bc13c2503f0c772c9ec6f6..063f7ca041a862ea9579f06fbd263fafd20ce045 100644 --- a/paddle/fluid/operators/reduce_ops/frobenius_norm_op.cc +++ b/paddle/fluid/operators/reduce_ops/frobenius_norm_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/reduce_ops/reduce_op.h" diff --git a/paddle/fluid/operators/reduce_ops/logsumexp_op.cc b/paddle/fluid/operators/reduce_ops/logsumexp_op.cc index 0602c73db6bbc92727c5a5d7673a4d0c20265458..4128d51559c307b00c0f3abd3c89d5398a344407 100644 --- a/paddle/fluid/operators/reduce_ops/logsumexp_op.cc +++ b/paddle/fluid/operators/reduce_ops/logsumexp_op.cc @@ -15,6 +15,7 @@ #include #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/operators/reduce_ops/reduce_op_function.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/reduce_ops/reduce_amax_op.cc b/paddle/fluid/operators/reduce_ops/reduce_amax_op.cc index c5bc66e23ce8a3a4575a75efe0fef980095e8f43..29587faa4800516c54208a7009a094266303bb22 100644 --- a/paddle/fluid/operators/reduce_ops/reduce_amax_op.cc +++ b/paddle/fluid/operators/reduce_ops/reduce_amax_op.cc @@ -16,16 +16,18 @@ REGISTER_REDUCE_OP(reduce_amax); REGISTER_OP_CPU_KERNEL( - reduce_amax, ops::ReduceKernel, + reduce_amax, + ops::ReduceKernel, ops::ReduceKernel, ops::ReduceKernel, ops::ReduceKernel); REGISTER_OP_CPU_KERNEL( - reduce_amax_grad, ops::ReduceGradKernel, + reduce_amax_grad, + ops::ReduceGradKernel, ops::ReduceGradKernel, ops::ReduceGradKernel, + reduce_amax_grad, + ops::ReduceGradKernel, ops::ReduceGradKernel, ops::ReduceGradKernel, + reduce_amin, + ops::ReduceKernel, ops::ReduceKernel, ops::ReduceKernel, ops::ReduceKernel); REGISTER_OP_CPU_KERNEL( - reduce_amin_grad, ops::ReduceGradKernel, + reduce_amin_grad, + ops::ReduceGradKernel, ops::ReduceGradKernel, ops::ReduceGradKernel, + reduce_amin_grad, + ops::ReduceGradKernel, ops::ReduceGradKernel, ops::ReduceGradKernel #include + #include "paddle/fluid/operators/reduce_ops/reduce_op_xpu.h" #include "paddle/fluid/platform/device/xpu/xpu_header.h" diff --git a/paddle/fluid/operators/reduce_ops/reduce_mean_op.cc b/paddle/fluid/operators/reduce_ops/reduce_mean_op.cc index dc41979defb9314f2efb942f0f530c3b5da3bb8b..8ce115ce66921193644a0882a149bfed27b6375c 100644 --- a/paddle/fluid/operators/reduce_ops/reduce_mean_op.cc +++ b/paddle/fluid/operators/reduce_ops/reduce_mean_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/reduce_ops/reduce_mean_op.h" + #include #include #include diff --git a/paddle/fluid/operators/reduce_ops/reduce_mean_op_npu.cc b/paddle/fluid/operators/reduce_ops/reduce_mean_op_npu.cc index 715dcb25c209f2d1867feebb2a34ee9dae4a358b..111537f64558c25141e9244a71cbe673409db150 100644 --- a/paddle/fluid/operators/reduce_ops/reduce_mean_op_npu.cc +++ b/paddle/fluid/operators/reduce_ops/reduce_mean_op_npu.cc @@ -11,8 +11,8 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/reduce_ops/reduce_mean_op.h" #include "paddle/fluid/operators/elementwise/elementwise_npu.h" +#include "paddle/fluid/operators/reduce_ops/reduce_mean_op.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" namespace paddle { diff --git a/paddle/fluid/operators/reduce_ops/reduce_min_op.cc b/paddle/fluid/operators/reduce_ops/reduce_min_op.cc index 5e5b04d57b002d8e8ecab9ddaf8186118f4bf187..f6d8aa1318234c96de17e8834f59d3cede56b295 100644 --- a/paddle/fluid/operators/reduce_ops/reduce_min_op.cc +++ b/paddle/fluid/operators/reduce_ops/reduce_min_op.cc @@ -12,9 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/operators/reduce_ops/reduce_min_max_op.h" - #include "paddle/fluid/framework/infershape_utils.h" +#include "paddle/fluid/operators/reduce_ops/reduce_min_max_op.h" #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/infermeta/unary.h" diff --git a/paddle/fluid/operators/reduce_ops/reduce_op.cu.h b/paddle/fluid/operators/reduce_ops/reduce_op.cu.h index b21e41c5b8548273bcd81a882ed696819b1de62f..a2048004615b7ca2948bfe8f80b64750fc45101b 100644 --- a/paddle/fluid/operators/reduce_ops/reduce_op.cu.h +++ b/paddle/fluid/operators/reduce_ops/reduce_op.cu.h @@ -21,7 +21,6 @@ #include #include "paddle/fluid/framework/tensor.h" - #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/kernels/funcs/reduce_function.h" namespace paddle { diff --git a/paddle/fluid/operators/reduce_ops/reduce_op.h b/paddle/fluid/operators/reduce_ops/reduce_op.h index 76641698ead67aa6e1c665dacd27630b65db3ab3..322ef1fdff67abd861c6603c3e7c4fc6b5d19f39 100644 --- a/paddle/fluid/operators/reduce_ops/reduce_op.h +++ b/paddle/fluid/operators/reduce_ops/reduce_op.h @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/data_type_transform.h" #include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/operators/cast_op.h" @@ -484,8 +485,9 @@ class ReduceOp : public framework::OperatorWithKernel { platform::is_gpu_place(ctx.GetPlace()) || platform::is_npu_place(ctx.GetPlace()) || platform::is_mlu_place(ctx.GetPlace()), - true, platform::errors::InvalidArgument( - "float16 can only be used on GPU or NPU or MLU place")); + true, + platform::errors::InvalidArgument( + "float16 can only be used on GPU or NPU or MLU place")); } return framework::OpKernelType(input_data_type, ctx.GetPlace()); } diff --git a/paddle/fluid/operators/reduce_ops/reduce_op_function.h b/paddle/fluid/operators/reduce_ops/reduce_op_function.h index c144e65cbf6476ae83475c25426dd749e248f8e4..a9d5863558cf70ff9b07648484e80ba698b69ffd 100644 --- a/paddle/fluid/operators/reduce_ops/reduce_op_function.h +++ b/paddle/fluid/operators/reduce_ops/reduce_op_function.h @@ -14,6 +14,7 @@ #pragma once #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/reduce_ops/reduce_op_mlu.h b/paddle/fluid/operators/reduce_ops/reduce_op_mlu.h index 95dda354cae7d4407b9a3940a510152aaf69113b..96e496217d04fdfa0b5090c417189c11dcad0a04 100644 --- a/paddle/fluid/operators/reduce_ops/reduce_op_mlu.h +++ b/paddle/fluid/operators/reduce_ops/reduce_op_mlu.h @@ -17,6 +17,7 @@ #ifdef PADDLE_WITH_MLU #include #include + #include "paddle/fluid/operators/mlu/mlu_baseop.h" #include "paddle/fluid/operators/reduce_ops/reduce_op.h" diff --git a/paddle/fluid/operators/reduce_ops/reduce_op_xpu.h b/paddle/fluid/operators/reduce_ops/reduce_op_xpu.h index 324fd369e82b597dfd318397f1273b4e4e4291f5..f9ae575e801b90cd1ec8bbcd3b47f1738d62079f 100644 --- a/paddle/fluid/operators/reduce_ops/reduce_op_xpu.h +++ b/paddle/fluid/operators/reduce_ops/reduce_op_xpu.h @@ -20,6 +20,7 @@ #include #include #include + #include "paddle/fluid/operators/reduce_ops/reduce_op.h" #include "paddle/fluid/platform/device/xpu/xpu_header.h" diff --git a/paddle/fluid/operators/reduce_ops/reduce_sum_op_xpu.cc b/paddle/fluid/operators/reduce_ops/reduce_sum_op_xpu.cc index 7a5c86c35c6a2a99466476e04082ea683d2172aa..f50cfd0417aaf32a0abd22840e144c5c248c90e0 100644 --- a/paddle/fluid/operators/reduce_ops/reduce_sum_op_xpu.cc +++ b/paddle/fluid/operators/reduce_ops/reduce_sum_op_xpu.cc @@ -15,6 +15,7 @@ #ifdef PADDLE_WITH_XPU #include #include + #include "paddle/fluid/operators/reduce_ops/reduce_op_xpu.h" #include "paddle/fluid/platform/device/xpu/xpu_header.h" diff --git a/paddle/fluid/operators/renorm_op.cu b/paddle/fluid/operators/renorm_op.cu index e40bd147b9925035f39f024f632ec1ad4877fef5..028f5a7f51567459ef26d17a249347ed7997b700 100644 --- a/paddle/fluid/operators/renorm_op.cu +++ b/paddle/fluid/operators/renorm_op.cu @@ -12,14 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/operators/renorm_op.h" - #include #include #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/elementwise/elementwise_op_impl.cu.h" #include "paddle/fluid/operators/reduce_ops/reduce_op.cu.h" +#include "paddle/fluid/operators/renorm_op.h" #include "paddle/fluid/operators/utils.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" @@ -107,10 +106,10 @@ __global__ void RenormGradKernelFunc2(const T* x_data, const T* dout_data, __syncthreads(); if (i < size) { dx_data[i] = dim_value[dim_index] * dout_data[i]; - dx_data[i] = dx_data[i] + - weight_derivative[dim_index] * dim_power_sum[dim_index] * - pow(abs(x_data[i]), T(p - 1.0)) * - (x_data[i] >= 0 ? 1 : -1); + dx_data[i] = dx_data[i] + weight_derivative[dim_index] * + dim_power_sum[dim_index] * + pow(abs(x_data[i]), T(p - 1.0)) * + (x_data[i] >= 0 ? 1 : -1); } } diff --git a/paddle/fluid/operators/repeat_interleave_op.cc b/paddle/fluid/operators/repeat_interleave_op.cc index d6f9df5d79e60f23a1d9266cbbc8931a2bc96e42..daa45bf78f27d820c223053924fa294115345c9a 100644 --- a/paddle/fluid/operators/repeat_interleave_op.cc +++ b/paddle/fluid/operators/repeat_interleave_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/repeat_interleave_op.h" + #include namespace paddle { @@ -51,11 +52,12 @@ class RepeatInterleaveOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ( repeats_dim.size() == 1 || (repeats_dim.size() == 2 && repeats_dim[1] == 1), - true, platform::errors::InvalidArgument( - "The 'shape' of Input(RepeatsTensor) must be 1-D tensor. " - "But received: the 'shape' of Input(Index) is [%s], " - "the dimension of Input(Index) is [%d].", - repeats_dim, repeats_dim.size())); + true, + platform::errors::InvalidArgument( + "The 'shape' of Input(RepeatsTensor) must be 1-D tensor. " + "But received: the 'shape' of Input(Index) is [%s], " + "the dimension of Input(Index) is [%d].", + repeats_dim, repeats_dim.size())); PADDLE_ENFORCE_EQ(repeats_dim[0] != 0, true, platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/repeat_interleave_op.cu b/paddle/fluid/operators/repeat_interleave_op.cu index 5f48a4a94ac9980c822a4b4ee617dc1390280716..2b8464d5bf6bf3fe518f14970db494e4ea66b463 100644 --- a/paddle/fluid/operators/repeat_interleave_op.cu +++ b/paddle/fluid/operators/repeat_interleave_op.cu @@ -127,10 +127,10 @@ class RepeatInterleaveCUDAKernel : public framework::OpKernel { int64_t size = output_dim[dim]; int64_t delta = input_dim[dim] - size; - index_select_cuda_kernel<<< - (numel + PADDLE_CUDA_NUM_THREADS - 1) / PADDLE_CUDA_NUM_THREADS, - PADDLE_CUDA_NUM_THREADS, 0, stream>>>(in_data, out_data, index_data, - numel, stride, size, delta); + index_select_cuda_kernel + <<<(numel + PADDLE_CUDA_NUM_THREADS - 1) / PADDLE_CUDA_NUM_THREADS, + PADDLE_CUDA_NUM_THREADS, 0, stream>>>( + in_data, out_data, index_data, numel, stride, size, delta); } else { RepeatsTensor2IndexTensor(*repeats_tensor, &index); @@ -143,10 +143,10 @@ class RepeatInterleaveCUDAKernel : public framework::OpKernel { int64_t size = output_dim[dim]; int64_t delta = input_dim[dim] - size; - index_select_cuda_kernel<<< - (numel + PADDLE_CUDA_NUM_THREADS - 1) / PADDLE_CUDA_NUM_THREADS, - PADDLE_CUDA_NUM_THREADS, 0, stream>>>(in_data, out_data, index_data, - numel, stride, size, delta); + index_select_cuda_kernel + <<<(numel + PADDLE_CUDA_NUM_THREADS - 1) / PADDLE_CUDA_NUM_THREADS, + PADDLE_CUDA_NUM_THREADS, 0, stream>>>( + in_data, out_data, index_data, numel, stride, size, delta); } } else if (repeats > 0) { int64_t index_size = in->dims()[dim] * repeats; @@ -169,10 +169,10 @@ class RepeatInterleaveCUDAKernel : public framework::OpKernel { int64_t delta = input_dim[dim] - size; const int* index_data = index.data(); - index_select_cuda_kernel<<<(numel + PADDLE_CUDA_NUM_THREADS - 1) / - PADDLE_CUDA_NUM_THREADS, - PADDLE_CUDA_NUM_THREADS, 0, stream>>>( - in_data, out_data, index_data, numel, stride, size, delta); + index_select_cuda_kernel + <<<(numel + PADDLE_CUDA_NUM_THREADS - 1) / PADDLE_CUDA_NUM_THREADS, + PADDLE_CUDA_NUM_THREADS, 0, stream>>>( + in_data, out_data, index_data, numel, stride, size, delta); platform::GpuStreamSync(stream); } else { PADDLE_THROW(platform::errors::InvalidArgument( @@ -206,9 +206,9 @@ class RepeatInterleaveGradCUDAKernel : public framework::OpKernel { auto stream = context.template device_context().stream(); - index_select_grad_init< - T><<<(numel + PADDLE_CUDA_NUM_THREADS - 1) / PADDLE_CUDA_NUM_THREADS, - PADDLE_CUDA_NUM_THREADS, 0, stream>>>(in_grad_data, numel); + index_select_grad_init + <<<(numel + PADDLE_CUDA_NUM_THREADS - 1) / PADDLE_CUDA_NUM_THREADS, + PADDLE_CUDA_NUM_THREADS, 0, stream>>>(in_grad_data, numel); int repeats = context.Attr("Repeats"); framework::LoDTensor index; @@ -237,22 +237,24 @@ class RepeatInterleaveGradCUDAKernel : public framework::OpKernel { int64_t index_nums = index.numel(); const int64_t* index_data = index.data(); - index_select_grad_cuda_kernel<<< - (out_nums + PADDLE_CUDA_NUM_THREADS - 1) / PADDLE_CUDA_NUM_THREADS, - PADDLE_CUDA_NUM_THREADS, 0, stream>>>( - output_grad_data, in_grad_data, index_data, index_nums, out_nums, - stride, size, delta); + index_select_grad_cuda_kernel + <<<(out_nums + PADDLE_CUDA_NUM_THREADS - 1) / + PADDLE_CUDA_NUM_THREADS, + PADDLE_CUDA_NUM_THREADS, 0, stream>>>( + output_grad_data, in_grad_data, index_data, index_nums, + out_nums, stride, size, delta); platform::GpuStreamSync(stream); } else { RepeatsTensor2IndexTensor(*repeats_tensor, &index); int64_t index_nums = index.numel(); const int* index_data = index.data(); - index_select_grad_cuda_kernel<<< - (out_nums + PADDLE_CUDA_NUM_THREADS - 1) / PADDLE_CUDA_NUM_THREADS, - PADDLE_CUDA_NUM_THREADS, 0, stream>>>( - output_grad_data, in_grad_data, index_data, index_nums, out_nums, - stride, size, delta); + index_select_grad_cuda_kernel + <<<(out_nums + PADDLE_CUDA_NUM_THREADS - 1) / + PADDLE_CUDA_NUM_THREADS, + PADDLE_CUDA_NUM_THREADS, 0, stream>>>( + output_grad_data, in_grad_data, index_data, index_nums, + out_nums, stride, size, delta); platform::GpuStreamSync(stream); } } else if (repeats > 0) { @@ -268,11 +270,11 @@ class RepeatInterleaveGradCUDAKernel : public framework::OpKernel { const int* index_data = index.data(); int64_t index_nums = index.numel(); - index_select_grad_cuda_kernel<<< - (out_nums + PADDLE_CUDA_NUM_THREADS - 1) / PADDLE_CUDA_NUM_THREADS, - PADDLE_CUDA_NUM_THREADS, 0, stream>>>(output_grad_data, in_grad_data, - index_data, index_nums, - out_nums, stride, size, delta); + index_select_grad_cuda_kernel + <<<(out_nums + PADDLE_CUDA_NUM_THREADS - 1) / PADDLE_CUDA_NUM_THREADS, + PADDLE_CUDA_NUM_THREADS, 0, stream>>>( + output_grad_data, in_grad_data, index_data, index_nums, out_nums, + stride, size, delta); platform::GpuStreamSync(stream); } else { PADDLE_THROW(platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/repeat_interleave_op.h b/paddle/fluid/operators/repeat_interleave_op.h index 68b66bd534ca83ed07973594e7eb64d8fe5922f7..f8e39fdc90762852d4f5d7b444eb88bacf617bef 100644 --- a/paddle/fluid/operators/repeat_interleave_op.h +++ b/paddle/fluid/operators/repeat_interleave_op.h @@ -14,11 +14,11 @@ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" +#include "paddle/fluid/operators/index_select_op.h" #include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/math_function.h" - -#include "paddle/fluid/operators/index_select_op.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/requantize_op.cc b/paddle/fluid/operators/requantize_op.cc index 2d87ae91fbe6089cfec8bded7b1986974eace920..d9345c1145ba65f99960e2ea7c5d674cb9efbd25 100644 --- a/paddle/fluid/operators/requantize_op.cc +++ b/paddle/fluid/operators/requantize_op.cc @@ -13,6 +13,7 @@ * limitations under the License. */ #include "paddle/fluid/operators/requantize_op.h" + #include "paddle/fluid/framework/op_version_registry.h" #ifdef PADDLE_WITH_MKLDNN #include "paddle/fluid/platform/mkldnn_helper.h" diff --git a/paddle/fluid/operators/requantize_op.h b/paddle/fluid/operators/requantize_op.h index c2b154db11dc713fdce1b9ef2f2616428bc09202..8166aa98f076fd0ade01256d8f329479d4575c72 100644 --- a/paddle/fluid/operators/requantize_op.h +++ b/paddle/fluid/operators/requantize_op.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/rnn_op.cc b/paddle/fluid/operators/rnn_op.cc index caf90219935de5e8ff33009acc159ea40ddbb801..d3c6ee7c1e1a871dc12a8c694e0699b6b3ef0d2e 100644 --- a/paddle/fluid/operators/rnn_op.cc +++ b/paddle/fluid/operators/rnn_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" diff --git a/paddle/fluid/operators/roi_align_op.cc b/paddle/fluid/operators/roi_align_op.cc index bf78b6a696559cab152a6de2c4730a32dfdbb780..db84387e6cfa79c5a3ee2106c7c865061a187644 100644 --- a/paddle/fluid/operators/roi_align_op.cc +++ b/paddle/fluid/operators/roi_align_op.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" diff --git a/paddle/fluid/operators/roi_align_op_xpu.cc b/paddle/fluid/operators/roi_align_op_xpu.cc index 7be1c19012099d1e39ebdffe039f9ea03bd5d5b3..18938d71832000b4192d97b506ac2682f2846340 100644 --- a/paddle/fluid/operators/roi_align_op_xpu.cc +++ b/paddle/fluid/operators/roi_align_op_xpu.cc @@ -15,6 +15,7 @@ limitations under the License. */ #ifdef PADDLE_WITH_XPU #include #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/roi_pool_op.cc b/paddle/fluid/operators/roi_pool_op.cc index 12e33d56c0020858ba44709572ee8e526bc949df..e47145535a38945b99f37907b39e3e369efabab9 100644 --- a/paddle/fluid/operators/roi_pool_op.cc +++ b/paddle/fluid/operators/roi_pool_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" diff --git a/paddle/fluid/operators/row_conv_op.cc b/paddle/fluid/operators/row_conv_op.cc index 07a6117d7111906488414592a6f8ea0a18d4af7b..9c66566fdfd891822eb6172246d73207366b0f75 100644 --- a/paddle/fluid/operators/row_conv_op.cc +++ b/paddle/fluid/operators/row_conv_op.cc @@ -12,9 +12,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/row_conv_op.h" + #include #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/operators/row_conv_op.cu b/paddle/fluid/operators/row_conv_op.cu index c5794948aaec6b47396cbae66a962058812aba11..b1cabb018b9e020368c81c885ffa00169344c701 100644 --- a/paddle/fluid/operators/row_conv_op.cu +++ b/paddle/fluid/operators/row_conv_op.cu @@ -344,9 +344,9 @@ class RowConvKernel dim3 block_dim = dim3(32, 32); dim3 grid_dim = dim3(DivUp(input_dim, block_dim.x), 1); int mem_per_block = (future_context * block_dim.x) * sizeof(T); - RowConvForwardSharedMemory< - T><<>>( - in, weight, num_sequence, input_dim, future_context, idx, out); + RowConvForwardSharedMemory + <<>>( + in, weight, num_sequence, input_dim, future_context, idx, out); } else { dim3 block_dim = dim3(32, 32); dim3 grid_dim = dim3(DivUp(input_dim, block_dim.x), 1); @@ -413,10 +413,10 @@ class RowConvGradKernel (block_y * block_x + block_y * (block_x + future_context - 1) + future_context * block_y) * sizeof(T); - RowConvGradFilterImproved< - T><<>>( - in, dout, num_sequence, input_dim, future_context, block_x, block_y, - idx, dfilter); + RowConvGradFilterImproved + <<>>( + in, dout, num_sequence, input_dim, future_context, block_x, + block_y, idx, dfilter); } else { dim3 block_dim = dim3(32, 32); dim3 grid_dim = dim3(DivUp(input_dim, block_dim.x), 1); @@ -424,10 +424,10 @@ class RowConvGradKernel int block_y = block_dim.y; int mem_per_block = (block_x * block_y * 2) * sizeof(T); // For 2 arrays of size 32x32 - RowConvGradFilter< - T><<>>( - in, dout, num_sequence, input_dim, future_context, block_x, block_y, - idx, dfilter); + RowConvGradFilter + <<>>( + in, dout, num_sequence, input_dim, future_context, block_x, + block_y, idx, dfilter); } } @@ -437,9 +437,10 @@ class RowConvGradKernel dim3 block_dim = dim3(32, 32); dim3 grid_dim = dim3(DivUp(input_dim, block_dim.x), 1); int mem_per_block = (future_context * block_dim.x) * sizeof(T); - RowConvGradInputSharedMemory< - T><<>>( - dout, weights, num_sequence, input_dim, future_context, idx, din); + RowConvGradInputSharedMemory + <<>>( + dout, weights, num_sequence, input_dim, future_context, idx, + din); } else { dim3 block_dim = dim3(32, 32); dim3 grid_dim = dim3(DivUp(input_dim, block_dim.x), 1); diff --git a/paddle/fluid/operators/rrelu_op.cc b/paddle/fluid/operators/rrelu_op.cc index c543a088e9d7fe2c8f176b5dc07549dc22b7c731..558c77b5b9220c108eee6fdf503591b32931f0aa 100644 --- a/paddle/fluid/operators/rrelu_op.cc +++ b/paddle/fluid/operators/rrelu_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/infermeta/unary.h" diff --git a/paddle/fluid/operators/run_program_op.h b/paddle/fluid/operators/run_program_op.h index 8007f0bc37b1ff9a022ccaa130e83b236b97d88c..bfd33efe833d2b0a7805aa14680280934abfa1e6 100644 --- a/paddle/fluid/operators/run_program_op.h +++ b/paddle/fluid/operators/run_program_op.h @@ -99,11 +99,12 @@ static void CheckOutputVarStatus(const Variable &src_var, var_name, platform::demangle(framework::ToTypeName(src_var.Type())))); PADDLE_ENFORCE_EQ(src_var.Get().value().IsInitialized(), - true, platform::errors::InvalidArgument( - "The tensor in output variable %s get from " - "RunProgram(Grad)Op's " - "internal scope is not initialized.", - var_name)); + true, + platform::errors::InvalidArgument( + "The tensor in output variable %s get from " + "RunProgram(Grad)Op's " + "internal scope is not initialized.", + var_name)); } else { PADDLE_THROW(platform::errors::InvalidArgument( @@ -224,7 +225,7 @@ class RunProgramOpKernel : public framework::OpKernel { framework::PEAndGraphPair pe_and_graph; auto callable = [this, is_test, &pe_and_graph]( - const framework::ExecutionContext &exe_ctx) { + const framework::ExecutionContext &exe_ctx) { pe_and_graph = ComputeImpl(exe_ctx, is_test, true); }; inner_graphs[graph_idx] = CaptureCUDAGraph( diff --git a/paddle/fluid/operators/sample_logits_op.cc b/paddle/fluid/operators/sample_logits_op.cc index e02c7ade9a11a2b8e9175b5bc52f44e9fff3e598..a80d527fd5c385e113ec25799b3c1319f26a567e 100644 --- a/paddle/fluid/operators/sample_logits_op.cc +++ b/paddle/fluid/operators/sample_logits_op.cc @@ -12,7 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/sample_logits_op.h" + #include + #include "paddle/fluid/operators/math/sample_prob.h" namespace paddle { diff --git a/paddle/fluid/operators/sample_logits_op.cu b/paddle/fluid/operators/sample_logits_op.cu index 273010e5443f8562f02dcc1704a8675dd7ca699a..7eff9429244fc2dc0b4a40928abdf6c0c6d23da3 100644 --- a/paddle/fluid/operators/sample_logits_op.cu +++ b/paddle/fluid/operators/sample_logits_op.cu @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/tensor_util.h" @@ -146,9 +147,9 @@ class SampleLogitsCUDAKernel : public framework::OpKernel { int threads = 512; size_t size = batch_size * num_true; int grid = (size + threads - 1) / threads; - GPUSetLabel< - T><<>>( - size, num_true, sampled_labels_data); + GPUSetLabel + <<>>( + size, num_true, sampled_labels_data); if (use_customized_samples) { const Tensor* customized_samples = @@ -190,17 +191,17 @@ class SampleLogitsCUDAKernel : public framework::OpKernel { size = batch_size * num_take; grid = (size + threads - 1) / threads; - GPUTakeAlongD1< - T><<>>( - size, batch_size, array_slice_size, idx_slice_size, p_array, p_index, - p_value); + GPUTakeAlongD1 + <<>>( + size, batch_size, array_slice_size, idx_slice_size, p_array, + p_index, p_value); if (remove_accidental_hits) { const size_t size = batch_size * (num_true + num_samples); int grid = (size + threads - 1) / threads; - gpu_compute_remove_accidental_hits< - T><<>>( - size, num_true, idx_slice_size, p_index, p_value); + gpu_compute_remove_accidental_hits + <<>>( + size, num_true, idx_slice_size, p_index, p_value); } // subtracted sampled logits with logQ(y|x) @@ -246,10 +247,10 @@ class SampleLogitsGradCUDAKernel : public framework::OpKernel { const size_t size = batch_size; int grid = (size + threads - 1) / threads; - GPUPutAlongD1< - T><<>>( - size, batch_size, array_slice_size, idx_slice_size, p_array, p_index, - p_value); + GPUPutAlongD1 + <<>>( + size, batch_size, array_slice_size, idx_slice_size, p_array, + p_index, p_value); } }; diff --git a/paddle/fluid/operators/sample_logits_op.h b/paddle/fluid/operators/sample_logits_op.h index ae741ae321292d11b7210c866b46a634f87b69d9..815a2897d5d20fe62bfe48a501480f803458cf23 100644 --- a/paddle/fluid/operators/sample_logits_op.h +++ b/paddle/fluid/operators/sample_logits_op.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/tensor_util.h" diff --git a/paddle/fluid/operators/save_combine_op.cc b/paddle/fluid/operators/save_combine_op.cc index 7fe6623dcca14afc8fafc4875ccfb7546e4456f0..23aa88459cec1bc4f9f0cf821bcf9605e4491cb8 100644 --- a/paddle/fluid/operators/save_combine_op.cc +++ b/paddle/fluid/operators/save_combine_op.cc @@ -12,10 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include - #include "paddle/fluid/operators/save_combine_op.h" +#include + namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/save_combine_op.h b/paddle/fluid/operators/save_combine_op.h index 8b8e27b79b96ba7d2bcff3254acdb8cd633b0e12..a419e862501f61a54d86f8f9f3246309f728cfd4 100644 --- a/paddle/fluid/operators/save_combine_op.h +++ b/paddle/fluid/operators/save_combine_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include #include #include diff --git a/paddle/fluid/operators/save_load_combine_op_test.cc b/paddle/fluid/operators/save_load_combine_op_test.cc index 493f5081ee42b9232a680dace585473d3217eedc..797321efd6c45b634fda0e6ec11d8bb03ef58065 100644 --- a/paddle/fluid/operators/save_load_combine_op_test.cc +++ b/paddle/fluid/operators/save_load_combine_op_test.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include #include #include + #include "gtest/gtest.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/bfloat16.h" diff --git a/paddle/fluid/operators/save_op.cc b/paddle/fluid/operators/save_op.cc index d819c172e4a9d7b6911cd3f4bac66b342882b347..02774c6b72aca3cc160b03fbfafd30bb9336479b 100644 --- a/paddle/fluid/operators/save_op.cc +++ b/paddle/fluid/operators/save_op.cc @@ -12,14 +12,15 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/operators/save_op.h" + #include + #include #include #include #include -#include "paddle/fluid/operators/save_op.h" - namespace paddle { namespace operators { class SaveOp : public framework::OperatorWithKernel { diff --git a/paddle/fluid/operators/save_op.h b/paddle/fluid/operators/save_op.h index e4ca1423afaea44312e7b5f715761e83b0bd2f9c..64aca1ab6b71f3d52d5aad8ee35d93de82d1d3ba 100644 --- a/paddle/fluid/operators/save_op.h +++ b/paddle/fluid/operators/save_op.h @@ -12,6 +12,7 @@ limitations under the License. */ #pragma once #include + #include #include #include diff --git a/paddle/fluid/operators/scale_op.cc b/paddle/fluid/operators/scale_op.cc index cbf2b9152079e13acd4a221ece402b946b844999..ebc4c6441489c239f688dc6a7f9b604a1713c277 100644 --- a/paddle/fluid/operators/scale_op.cc +++ b/paddle/fluid/operators/scale_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/float16.h" diff --git a/paddle/fluid/operators/scale_op_xpu.cc b/paddle/fluid/operators/scale_op_xpu.cc index 40f5699a29b355864652b5d899d1918ec663cf0b..fdc98d084ed0715f4dc99226a957aab7b07294be 100644 --- a/paddle/fluid/operators/scale_op_xpu.cc +++ b/paddle/fluid/operators/scale_op_xpu.cc @@ -15,6 +15,7 @@ limitations under the License. */ #ifdef PADDLE_WITH_XPU #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/scale_kernel.h" diff --git a/paddle/fluid/operators/scatter_nd_add_op.cc b/paddle/fluid/operators/scatter_nd_add_op.cc index 0ae0e1500c16627fc269b31c57b25c47055d7d34..0cfc3a77aadb2b2c8f984c1f9601f1cd003645f2 100644 --- a/paddle/fluid/operators/scatter_nd_add_op.cc +++ b/paddle/fluid/operators/scatter_nd_add_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/ddim.h" diff --git a/paddle/fluid/operators/scatter_op.cc b/paddle/fluid/operators/scatter_op.cc index 5f6b04cf59e0e3c8c05d44ad6c4a3321ff2516e4..a2e8071e0135371cba1920415fe4c992595d5795 100644 --- a/paddle/fluid/operators/scatter_op.cc +++ b/paddle/fluid/operators/scatter_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/ddim.h" diff --git a/paddle/fluid/operators/scatter_op_xpu.cc b/paddle/fluid/operators/scatter_op_xpu.cc index 07dd2f2d85fe9ac330be1f85d283c85207b1b78c..3ab084b660a0ab7896f4ae2c89caaa008226a0cf 100644 --- a/paddle/fluid/operators/scatter_op_xpu.cc +++ b/paddle/fluid/operators/scatter_op_xpu.cc @@ -56,11 +56,12 @@ class ScatterOpXPUKernel : public framework::OpKernel { PADDLE_ENFORCE_EQ( index->dims().size() == 1 || (index->dims().size() == 2 && index->dims()[1] == 1), - true, platform::errors::InvalidArgument( - "index's shape is error, " - "expect index'dims shape is 1 or 2 and index.dims[1] is 1" - "but got index'dims shape is %d", - index->dims().size())); + true, + platform::errors::InvalidArgument( + "index's shape is error, " + "expect index'dims shape is 1 or 2 and index.dims[1] is 1" + "but got index'dims shape is %d", + index->dims().size())); int index_size = static_cast(index->dims()[0]); auto x_dims = x->dims(); diff --git a/paddle/fluid/operators/seed_op.cc b/paddle/fluid/operators/seed_op.cc index 837ccae0284f5ec8840e730b9f48452981865caa..7cad6dcab7ca3e13519ae797486b971284af199d 100644 --- a/paddle/fluid/operators/seed_op.cc +++ b/paddle/fluid/operators/seed_op.cc @@ -74,13 +74,12 @@ REGISTER_OP_CPU_KERNEL( seed, ops::CPUSeedKernel); /* ========================== register checkpoint ===========================*/ -REGISTER_OP_VERSION(seed) - .AddCheckpoint( - R"ROC( +REGISTER_OP_VERSION(seed).AddCheckpoint( + R"ROC( Upgrade seed add a new attribute [force_cpu])ROC", - paddle::framework::compatible::OpVersionDesc().NewAttr( - "force_cpu", - "If true, Force fill output variable to cpu." - "memory. Otherwise, fill output variable to the running " - "device", - false)); + paddle::framework::compatible::OpVersionDesc().NewAttr( + "force_cpu", + "If true, Force fill output variable to cpu." + "memory. Otherwise, fill output variable to the running " + "device", + false)); diff --git a/paddle/fluid/operators/segment_pool_op.cc b/paddle/fluid/operators/segment_pool_op.cc index 9d4c8532a82c064b1b7aef759934ad8dad894ec5..92010e8afc058ff8a8531598b4cd443eb108d049 100644 --- a/paddle/fluid/operators/segment_pool_op.cc +++ b/paddle/fluid/operators/segment_pool_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/sequence_ops/sequence_concat_op.cc b/paddle/fluid/operators/sequence_ops/sequence_concat_op.cc index f6523255e2438e1ffcb9a58d3b8e66d92c925d8f..0f17ff1e1b7bc2289ba6a17b623d4f5e1d454e14 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_concat_op.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_concat_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/sequence_ops/sequence_concat_op.h" + #include #include diff --git a/paddle/fluid/operators/sequence_ops/sequence_concat_op.cu.cc b/paddle/fluid/operators/sequence_ops/sequence_concat_op.cu.cc index d58a2da29c941d270c6be08355648aeaf582ae61..4856e38011bae9afc9c0652d337ac7ba703146af 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_concat_op.cu.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_concat_op.cu.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/sequence_ops/sequence_concat_op.h" + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/sequence_ops/sequence_concat_op.h b/paddle/fluid/operators/sequence_ops/sequence_concat_op.h index 1b8525febe2d4953c816e04a3a1fac9107be5459..f27e6535d31998fbda35a1102638b279a22a0838 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_concat_op.h +++ b/paddle/fluid/operators/sequence_ops/sequence_concat_op.h @@ -16,6 +16,7 @@ #include #include + #include "boost/optional.hpp" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/math/concat_and_split.h" @@ -49,7 +50,7 @@ inline framework::LoD ConcatLoD(const Container &xs, template inline std::vector> GetDataVectorSafely( - const std::vector &vec, ARGS &&... args) { + const std::vector &vec, ARGS &&...args) { std::vector> result; result.reserve(vec.size()); for (auto *ptr : vec) { diff --git a/paddle/fluid/operators/sequence_ops/sequence_conv_op.h b/paddle/fluid/operators/sequence_ops/sequence_conv_op.h index 62fa5bc26aca27fec10431eef431c41889cf6bb4..1935a62621de40ad8a0862489ffdcca72747b7d7 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_conv_op.h +++ b/paddle/fluid/operators/sequence_ops/sequence_conv_op.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/math/context_project.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/sequence_ops/sequence_conv_op_xpu.cc b/paddle/fluid/operators/sequence_ops/sequence_conv_op_xpu.cc index 23c6a0133e1edafba5621825db78a52b88e6947a..ef440a580f91346d09b6f3745783093de1495889 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_conv_op_xpu.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_conv_op_xpu.cc @@ -54,10 +54,12 @@ class SequenceConvXPUKernel : public framework::OpKernel { int up_pad = std::max(0, -context_start); int down_pad = std::max(0, context_start + context_length - 1); - PADDLE_ENFORCE_EQ(up_pad, 2, platform::errors::InvalidArgument( - "Only support up_pad equal 2.")); - PADDLE_ENFORCE_EQ(down_pad, 2, platform::errors::InvalidArgument( - "Only support down_pad equal 2.")); + PADDLE_ENFORCE_EQ( + up_pad, 2, + platform::errors::InvalidArgument("Only support up_pad equal 2.")); + PADDLE_ENFORCE_EQ( + down_pad, 2, + platform::errors::InvalidArgument("Only support down_pad equal 2.")); auto xpu_context = context.template device_context().x_context(); @@ -75,8 +77,9 @@ class SequenceConvXPUKernel : public framework::OpKernel { // If batch size set to 256, the lod is {0, batch[0] - 0, // batch[1] - batch [0], ..., batch[255] - batch[254]}, // so the lod_size will be 257. - PADDLE_ENFORCE_LE(lod_size, 257, platform::errors::InvalidArgument( - "Only support batch size <= 256.")); + PADDLE_ENFORCE_LE( + lod_size, 257, + platform::errors::InvalidArgument("Only support batch size <= 256.")); std::vector cpu_lodx(lod_size); for (int i = 0; i < lod_size; i++) { @@ -155,15 +158,18 @@ class SequenceConvGradXPUKernel : public framework::OpKernel { int up_pad = std::max(0, -context_start); int down_pad = std::max(0, context_start + context_length - 1); - PADDLE_ENFORCE_EQ(up_pad, 2, platform::errors::InvalidArgument( - "Only support up_pad equal 2.")); - PADDLE_ENFORCE_EQ(down_pad, 2, platform::errors::InvalidArgument( - "Only support down_pad equal 2.")); + PADDLE_ENFORCE_EQ( + up_pad, 2, + platform::errors::InvalidArgument("Only support up_pad equal 2.")); + PADDLE_ENFORCE_EQ( + down_pad, 2, + platform::errors::InvalidArgument("Only support down_pad equal 2.")); auto lod_level_0 = in->lod()[0]; int lod_size = lod_level_0.size(); - PADDLE_ENFORCE_LE(lod_size, 257, platform::errors::InvalidArgument( - "Only support batch size <= 256.")); + PADDLE_ENFORCE_LE( + lod_size, 257, + platform::errors::InvalidArgument("Only support batch size <= 256.")); std::vector cpu_lodx(lod_size); for (int i = 0; i < lod_size; i++) { diff --git a/paddle/fluid/operators/sequence_ops/sequence_enumerate_op.cu b/paddle/fluid/operators/sequence_ops/sequence_enumerate_op.cu index 9591f3e8b5bbfe70cb059b621eaca0ae1fff993e..0f47e8a9c2a980fcafae6fa930c5e66f3dfc6e20 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_enumerate_op.cu +++ b/paddle/fluid/operators/sequence_ops/sequence_enumerate_op.cu @@ -14,6 +14,7 @@ #include #include + #include "paddle/fluid/operators/sequence_ops/sequence_enumerate_op.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" diff --git a/paddle/fluid/operators/sequence_ops/sequence_erase_op.cc b/paddle/fluid/operators/sequence_ops/sequence_erase_op.cc index 79503d9714f5b2b7a0ce902316c923134dacd476..552a8283b367176b39d2d8e9b9af96c45c9d862e 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_erase_op.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_erase_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/sequence_ops/sequence_erase_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/sequence_ops/sequence_erase_op.cu b/paddle/fluid/operators/sequence_ops/sequence_erase_op.cu index 12d3eee65da70edd3f360d448360bb59d2f1069f..a87c327922425b003ddebcefbac7735a44337ed9 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_erase_op.cu +++ b/paddle/fluid/operators/sequence_ops/sequence_erase_op.cu @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/operators/sequence_ops/sequence_erase_op.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" diff --git a/paddle/fluid/operators/sequence_ops/sequence_erase_op.h b/paddle/fluid/operators/sequence_ops/sequence_erase_op.h index ed98b694b27547ec0adaeaee40a91ae0c16e3dfb..8d10ee508a22daa0baffc7d2546a3725843a6542 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_erase_op.h +++ b/paddle/fluid/operators/sequence_ops/sequence_erase_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/sequence_ops/sequence_expand_as_op.cc b/paddle/fluid/operators/sequence_ops/sequence_expand_as_op.cc index 494c8e3ab74a03ab3158cc0f37d6035f562f1aea..01e9835270cacab1471e728d6551dbd1244e00e0 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_expand_as_op.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_expand_as_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/sequence_ops/sequence_expand_as_op.h" + #include #include diff --git a/paddle/fluid/operators/sequence_ops/sequence_expand_as_op.cu b/paddle/fluid/operators/sequence_ops/sequence_expand_as_op.cu index 7e1a06b9eca5b9046d2b772edee0efdb1a69437f..5cc4ecdd12aa30c166c085a998e54044a15175ae 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_expand_as_op.cu +++ b/paddle/fluid/operators/sequence_ops/sequence_expand_as_op.cu @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/operators/sequence_ops/sequence_expand_as_op.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" diff --git a/paddle/fluid/operators/sequence_ops/sequence_expand_as_op.h b/paddle/fluid/operators/sequence_ops/sequence_expand_as_op.h index 117fa504ff3547cdffdc524d9a3b0ab9bc719477..5abe6df09e52dec0c62e5e688dc62b65d3c691b0 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_expand_as_op.h +++ b/paddle/fluid/operators/sequence_ops/sequence_expand_as_op.h @@ -17,6 +17,7 @@ limitations under the License. */ #include // std::iota #include #include + #include "glog/logging.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/sequence_ops/sequence_expand_op.cc b/paddle/fluid/operators/sequence_ops/sequence_expand_op.cc index e4f2c1b2b8fd1d94ebad57880565f05999fcf303..4817b003a2870b13539c97cea6603e5ae2286e2e 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_expand_op.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_expand_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/sequence_ops/sequence_expand_op.h" + #include namespace paddle { @@ -64,10 +65,11 @@ class SequenceExpandOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ( ref_level == -1 || (ref_level >= 0 && ref_level < static_cast(y_lod.size())), - true, platform::errors::InvalidArgument( - "Invlid `ref_level`, which should be either equal to -1 " - "or in [0, %d), but received `ref_level` = %u.", - y_lod.size(), ref_level)); + true, + platform::errors::InvalidArgument( + "Invlid `ref_level`, which should be either equal to -1 " + "or in [0, %d), but received `ref_level` = %u.", + y_lod.size(), ref_level)); if (ref_level == -1) ref_level = y_lod.size() - 1; diff --git a/paddle/fluid/operators/sequence_ops/sequence_expand_op.cu b/paddle/fluid/operators/sequence_ops/sequence_expand_op.cu index 7b7bc5183bf1f6c98ef386150fcfa4d048e73f01..90f911c438bc91f192cbdb2d1e4b4b6cb4a91e78 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_expand_op.cu +++ b/paddle/fluid/operators/sequence_ops/sequence_expand_op.cu @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/memory/memcpy.h" #include "paddle/fluid/operators/sequence_ops/sequence_expand_op.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" diff --git a/paddle/fluid/operators/sequence_ops/sequence_mask_op.cc b/paddle/fluid/operators/sequence_ops/sequence_mask_op.cc index f22b424b307359d231b09acca5d4777647dadf0b..060a3e7cab3325756a7bbdd866d5d5eecd409660 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_mask_op.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_mask_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/sequence_ops/sequence_mask_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/sequence_ops/sequence_pad_op.cc b/paddle/fluid/operators/sequence_ops/sequence_pad_op.cc index 5d0e1d0194edde4ea5c4fe47ada9ca6d6869d4f3..7d018e764bdc911ff17420744912f04ca8ab4586 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_pad_op.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_pad_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/sequence_ops/sequence_pad_op.h" + #include #include diff --git a/paddle/fluid/operators/sequence_ops/sequence_pad_op.h b/paddle/fluid/operators/sequence_ops/sequence_pad_op.h index 3aaa2828d5bfbcd7969ea028956fde4bcf7575ca..d4022e80d8000bb51eaabf36b1b9524e5b3079fb 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_pad_op.h +++ b/paddle/fluid/operators/sequence_ops/sequence_pad_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/memory/memcpy.h" #include "paddle/fluid/operators/math/sequence_padding.h" diff --git a/paddle/fluid/operators/sequence_ops/sequence_pool_op.cc b/paddle/fluid/operators/sequence_ops/sequence_pool_op.cc index 01990ebb732915718a2734cea2fbf231d79cb45c..af42285158bcb9408eecad0e5b061ef43e3689fa 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_pool_op.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_pool_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/sequence_ops/sequence_pool_op.h" + #include #include @@ -30,11 +31,12 @@ class SequencePoolOp : public framework::OperatorWithKernel { if (!ctx->IsRuntime()) { // Check the lod_level for compile-time. auto in_lod_level = ctx->GetLoDLevel("X"); - PADDLE_ENFORCE_GT(in_lod_level, 0, platform::errors::InvalidArgument( - "The LoD level of Input(X) should " - "be larger than 0, but received: " - "lod level %u.", - in_lod_level)); + PADDLE_ENFORCE_GT( + in_lod_level, 0, + platform::errors::InvalidArgument("The LoD level of Input(X) should " + "be larger than 0, but received: " + "lod level %u.", + in_lod_level)); ctx->SetLoDLevel("Out", in_lod_level - 1); } diff --git a/paddle/fluid/operators/sequence_ops/sequence_pool_op.h b/paddle/fluid/operators/sequence_ops/sequence_pool_op.h index 4d981e0187aca98b786f1e20a1a37409d1ccb0d0..96d02e6d2e54241004fa6cb146651a45cdc7c0f1 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_pool_op.h +++ b/paddle/fluid/operators/sequence_ops/sequence_pool_op.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/math/sequence_pooling.h" @@ -38,9 +39,10 @@ class SequencePoolKernel : public framework::OpKernel { auto lod = in->lod(); auto lod_level = lod.size(); // InferShape by lod - PADDLE_ENFORCE_GT(lod_level, 0, platform::errors::InvalidArgument( - "Input(X) Tensor of SequencePoolOp " - "does not contain LoD information.")); + PADDLE_ENFORCE_GT( + lod_level, 0, + platform::errors::InvalidArgument("Input(X) Tensor of SequencePoolOp " + "does not contain LoD information.")); PADDLE_ENFORCE_LE(lod_level, 2UL, platform::errors::InvalidArgument( "The lod level of input shall be no more than 2." diff --git a/paddle/fluid/operators/sequence_ops/sequence_reshape_op.cc b/paddle/fluid/operators/sequence_ops/sequence_reshape_op.cc index 980879db4d06efd7baf1d22c3980cac0614d076d..3a62bc554df2cb3d2d45aff202887161d2a02194 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_reshape_op.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_reshape_op.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/operators/sequence_ops/sequence_reshape_op.h" + #include + #include "paddle/phi/core/ddim.h" namespace paddle { diff --git a/paddle/fluid/operators/sequence_ops/sequence_reverse_op.h b/paddle/fluid/operators/sequence_ops/sequence_reverse_op.h index 90a17d713cf299a3a61169cfc6f16fce7bb5901c..85282bf23b48c5dd1d3fbfc744491e02cc80e5c2 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_reverse_op.h +++ b/paddle/fluid/operators/sequence_ops/sequence_reverse_op.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/for_range.h" #include "paddle/phi/kernels/funcs/algorithm.h" diff --git a/paddle/fluid/operators/sequence_ops/sequence_scatter_op.cc b/paddle/fluid/operators/sequence_ops/sequence_scatter_op.cc index 25c12ab565a141f48d254d51bfca64f7422f1f42..6fa151af4e117561d482c22ce1fec62a6bd60cb3 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_scatter_op.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_scatter_op.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/sequence_ops/sequence_scatter_op.h" + #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/sequence_ops/sequence_slice_op.cc b/paddle/fluid/operators/sequence_ops/sequence_slice_op.cc index 06fb444740feea2c490c979e2674440ee8424ca1..fdb24892e09a28cf12fd41e15def8fb283b14695 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_slice_op.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_slice_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/sequence_ops/sequence_slice_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/sequence_ops/sequence_softmax_op.cc b/paddle/fluid/operators/sequence_ops/sequence_softmax_op.cc index e7585f7ab04876de0dc8c94545944b9362ee982a..e3f8d16a7ade92568a824deeb3ad25c58c519178 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_softmax_op.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_softmax_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/sequence_ops/sequence_softmax_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/sequence_ops/sequence_softmax_op.cu b/paddle/fluid/operators/sequence_ops/sequence_softmax_op.cu index c91c59dbfee9993711e777668063bec73a3746d8..0d91832948dc80201f9b2c129b2d88daae8d9dab 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_softmax_op.cu +++ b/paddle/fluid/operators/sequence_ops/sequence_softmax_op.cu @@ -134,10 +134,10 @@ struct SequenceSoftmaxFunctor { dim3 block_size(thread_x); dim3 grid_size(max_blocks); paddle::framework::MixVector mixv_ref_lod(&ref_lod); - sequence_softmax_kernel< - T, kThreadsPerBlock><<>>( - x.data(), mixv_ref_lod.CUDAData(context.GetPlace()), height, - out->mutable_data(context.GetPlace())); + sequence_softmax_kernel + <<>>( + x.data(), mixv_ref_lod.CUDAData(context.GetPlace()), height, + out->mutable_data(context.GetPlace())); } }; @@ -158,11 +158,11 @@ struct SequenceSoftmaxGradFunctor { dim3 grid_size(max_blocks); paddle::framework::MixVector mixv_ref_lod(&ref_lod); - sequence_softmax_grad_kernel< - T, kThreadsPerBlock><<>>( - dout.data(), out.data(), - mixv_ref_lod.CUDAData(context.GetPlace()), height, - dx->mutable_data(context.GetPlace())); + sequence_softmax_grad_kernel + <<>>( + dout.data(), out.data(), + mixv_ref_lod.CUDAData(context.GetPlace()), height, + dx->mutable_data(context.GetPlace())); } }; diff --git a/paddle/fluid/operators/sequence_ops/sequence_topk_avg_pooling_op.cc b/paddle/fluid/operators/sequence_ops/sequence_topk_avg_pooling_op.cc index bacdd7e4ccb74e14da0e79337fa4c4dfa52cc5dc..b1d5ec8e9c65e8eaf8253d3b962b1448b05e1c67 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_topk_avg_pooling_op.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_topk_avg_pooling_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/sequence_ops/sequence_topk_avg_pooling_op.h" + #include #include @@ -44,8 +45,9 @@ class SequenceTopkAvgPoolingOp : public framework::OperatorWithKernel { auto topks = attr.Get>("topks"); auto num_k = topks.size(); PADDLE_ENFORCE_GT( - num_k, 0, platform::errors::InvalidArgument( - "Expected topks.size() > 0, but received %zu.", num_k)); + num_k, 0, + platform::errors::InvalidArgument( + "Expected topks.size() > 0, but received %zu.", num_k)); auto row_dim = ctx->GetInputDim("ROW"); auto row_shape_0 = row_dim[0]; diff --git a/paddle/fluid/operators/sequence_ops/sequence_topk_avg_pooling_op.h b/paddle/fluid/operators/sequence_ops/sequence_topk_avg_pooling_op.h index 47180f123fa7875e41d3bb9431b4d2a4606f3e09..b5ee43387b35e9183924aabd4c8c22f07a2d7a33 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_topk_avg_pooling_op.h +++ b/paddle/fluid/operators/sequence_ops/sequence_topk_avg_pooling_op.h @@ -19,6 +19,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/sequence_ops/sequence_unpad_op.cc b/paddle/fluid/operators/sequence_ops/sequence_unpad_op.cc index 180d14cfada31746169833524b96fce4400d7733..636be3b2f6ca7be3312f7d105d46ee7893e8082d 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_unpad_op.cc +++ b/paddle/fluid/operators/sequence_ops/sequence_unpad_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/sequence_ops/sequence_unpad_op.h" + #include #include diff --git a/paddle/fluid/operators/sequence_ops/sequence_unpad_op.h b/paddle/fluid/operators/sequence_ops/sequence_unpad_op.h index d96dc91f3bc16e9c3a7c8e79fdb4d324befdbf7c..d643ef860c3cac9eb7bf2f54f3e17ab7562c5a06 100644 --- a/paddle/fluid/operators/sequence_ops/sequence_unpad_op.h +++ b/paddle/fluid/operators/sequence_ops/sequence_unpad_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/memory/memcpy.h" #include "paddle/fluid/operators/math/sequence_padding.h" diff --git a/paddle/fluid/operators/set_value_op.cc b/paddle/fluid/operators/set_value_op.cc index 73655bcb18500e54564936eac4400a0c7b49af62..4adedf09aa354f9ee274cb392a0079bfdcd3c990 100644 --- a/paddle/fluid/operators/set_value_op.cc +++ b/paddle/fluid/operators/set_value_op.cc @@ -18,7 +18,6 @@ #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_version_registry.h" - #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/infermeta/unary.h" diff --git a/paddle/fluid/operators/set_value_op_npu.cc b/paddle/fluid/operators/set_value_op_npu.cc index daa033f9dc66d2b7398fe47d605558c92b95ba95..2231eb212a2bcbc64b05fb8808c7d55af7290662 100644 --- a/paddle/fluid/operators/set_value_op_npu.cc +++ b/paddle/fluid/operators/set_value_op_npu.cc @@ -14,7 +14,6 @@ limitations under the License. */ #include "paddle/fluid/operators/set_value_op.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" - #include "paddle/phi/kernels/funcs/slice_utils.h" namespace paddle { diff --git a/paddle/fluid/operators/shape_op.cc b/paddle/fluid/operators/shape_op.cc index 9001ce5d51dece5c6cee481f3f6f92e69c302c2b..38482f7b55edfaffc010adec5232b2ea8c92c6cc 100644 --- a/paddle/fluid/operators/shape_op.cc +++ b/paddle/fluid/operators/shape_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/shape_op_xpu.cc b/paddle/fluid/operators/shape_op_xpu.cc index a62d1b434e76434c3710e45e723060d3f452c91c..d4c7d937d4b7b9c97bf76240fd3cee43285794b7 100644 --- a/paddle/fluid/operators/shape_op_xpu.cc +++ b/paddle/fluid/operators/shape_op_xpu.cc @@ -11,6 +11,7 @@ #ifdef PADDLE_WITH_XPU #include + #include "paddle/fluid/framework/op_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/share_buffer_op.h b/paddle/fluid/operators/share_buffer_op.h index 1d0abf14f577e7493cfbd5222cd862cc37269f95..1b564c3bef09f886200e18bee3df36e280b32d5f 100644 --- a/paddle/fluid/operators/share_buffer_op.h +++ b/paddle/fluid/operators/share_buffer_op.h @@ -27,8 +27,9 @@ class ShareBufferOpKernel : public framework::OpKernel { const auto inputs = ctx.MultiInput("X"); auto outputs = ctx.MultiOutput("Out"); size_t n = inputs.size(); - PADDLE_ENFORCE_EQ(n, outputs.size(), platform::errors::PermissionDenied( - "Variable number not match.")); + PADDLE_ENFORCE_EQ( + n, outputs.size(), + platform::errors::PermissionDenied("Variable number not match.")); const auto &share_dims_and_dtype = ctx.Attr>("share_dims_and_dtype"); if (!share_dims_and_dtype.empty()) { diff --git a/paddle/fluid/operators/share_data_op.cc b/paddle/fluid/operators/share_data_op.cc index 6fcc29e90026165f9ada90d372498c9fced02a39..63e8cb648e84b07d98c29e7956248489c9d55d95 100644 --- a/paddle/fluid/operators/share_data_op.cc +++ b/paddle/fluid/operators/share_data_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/share_data_op.h" + #include "paddle/fluid/framework/op_registry.h" namespace paddle { @@ -31,8 +32,9 @@ class ShareDataOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ( in_type == framework::proto::VarType::LOD_TENSOR || in_type == framework::proto::VarType::SELECTED_ROWS, - true, platform::errors::InvalidArgument( - "Type of Variable[X] must be LoDTensor or SelectedRows!")); + true, + platform::errors::InvalidArgument( + "Type of Variable[X] must be LoDTensor or SelectedRows!")); PADDLE_ENFORCE_EQ( in_type, out_type, platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/shrink_rnn_memory_op.cc b/paddle/fluid/operators/shrink_rnn_memory_op.cc index 1a3666ad823686b040b5b6960d79e224ef292c7b..7388144dda3203e5958208ea5f132893314d5f7f 100644 --- a/paddle/fluid/operators/shrink_rnn_memory_op.cc +++ b/paddle/fluid/operators/shrink_rnn_memory_op.cc @@ -12,9 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/array_operator.h" -#include "paddle/phi/kernels/funcs/math_function.h" - #include "paddle/phi/core/lod_utils.h" +#include "paddle/phi/kernels/funcs/math_function.h" namespace paddle { namespace framework { diff --git a/paddle/fluid/operators/shuffle_batch_op.cc b/paddle/fluid/operators/shuffle_batch_op.cc index 45f7ab278a3c14c83e9405dec7be9758aeab9744..e338b48a4ccaa739028319c082c5e0df469149d8 100644 --- a/paddle/fluid/operators/shuffle_batch_op.cc +++ b/paddle/fluid/operators/shuffle_batch_op.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/operators/shuffle_batch_op.h" + #include + #include "paddle/fluid/framework/no_need_buffer_vars_inference.h" #include "paddle/fluid/framework/var_type_inference.h" diff --git a/paddle/fluid/operators/shuffle_batch_op.h b/paddle/fluid/operators/shuffle_batch_op.h index 2708b4a392d17af66d50dccd8f13192275eb1fc4..f56832f959919eeff58169a158c25799b3552097 100644 --- a/paddle/fluid/operators/shuffle_batch_op.h +++ b/paddle/fluid/operators/shuffle_batch_op.h @@ -21,6 +21,7 @@ #include #include #include + #include "glog/logging.h" #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/lod_tensor.h" diff --git a/paddle/fluid/operators/shuffle_channel_op.cc b/paddle/fluid/operators/shuffle_channel_op.cc index 70fddc9b04712d53af79651bb2c164846268608e..c43d456e94e47d568c1c601ad158f96252b6cd4d 100644 --- a/paddle/fluid/operators/shuffle_channel_op.cc +++ b/paddle/fluid/operators/shuffle_channel_op.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/shuffle_channel_op.h" + #include #include @@ -61,8 +62,9 @@ class ShuffleChannelOpMaker : public framework::OpProtoAndCheckerMaker { AddAttr("group", "the number of groups.") .SetDefault(1) .AddCustomChecker([](const int& group) { - PADDLE_ENFORCE_GE(group, 1, platform::errors::InvalidArgument( - "group should be larger than 0.")); + PADDLE_ENFORCE_GE(group, 1, + platform::errors::InvalidArgument( + "group should be larger than 0.")); }); AddAttr("use_mkldnn", "(bool, default false) Only used in mkldnn kernel") diff --git a/paddle/fluid/operators/shuffle_channel_op.cu b/paddle/fluid/operators/shuffle_channel_op.cu index 582d1ea0f26af3ec57510a80717436e61b3b252e..d3f6224594be30e3842816225ba9134c179c96d7 100644 --- a/paddle/fluid/operators/shuffle_channel_op.cu +++ b/paddle/fluid/operators/shuffle_channel_op.cu @@ -67,10 +67,10 @@ class ShuffleChannelOpCUDAKernel : public framework::OpKernel { const T* input_data = input->data(); T* output_data = output->mutable_data(ctx.GetPlace()); - ShuffleChannel< - T><<>>( - count, feature_map_size, output_data, input_data, group_row, - group_column, sp_sz); + ShuffleChannel + <<>>( + count, feature_map_size, output_data, input_data, group_row, + group_column, sp_sz); } }; @@ -103,10 +103,10 @@ class ShuffleChannelGradOpCUDAKernel : public framework::OpKernel { int threads = kNumCUDAThreads; int count = num * group_column * group_row * sp_sz; - ShuffleChannel< - T><<>>( - count, feature_map_size, input_grad_data, output_grad_data, group_row, - group_column, sp_sz); + ShuffleChannel + <<>>( + count, feature_map_size, input_grad_data, output_grad_data, + group_row, group_column, sp_sz); } }; } // namespace operators diff --git a/paddle/fluid/operators/shuffle_channel_op.h b/paddle/fluid/operators/shuffle_channel_op.h index aeaac486f3f2b2179e8d8f9fc7953804f3648b80..409acdfdff7ba3bc8d3b436f15a11e083ec1ae79 100644 --- a/paddle/fluid/operators/shuffle_channel_op.h +++ b/paddle/fluid/operators/shuffle_channel_op.h @@ -12,6 +12,7 @@ limitations under the License. */ #pragma once #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/sigmoid_cross_entropy_with_logits_op.cc b/paddle/fluid/operators/sigmoid_cross_entropy_with_logits_op.cc index 016ff54645b02e9b3ddfb67595d830ccf5dcfd94..0cf1296fce65079b4c2b413ffd8dbd6ebad810c1 100644 --- a/paddle/fluid/operators/sigmoid_cross_entropy_with_logits_op.cc +++ b/paddle/fluid/operators/sigmoid_cross_entropy_with_logits_op.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/similarity_focus_op.h b/paddle/fluid/operators/similarity_focus_op.h index 4fa4d772aa3a926fa95ba1ea9b45ed2037e1e568..17ea30277b85d725ec47f38838446148d25a09b2 100644 --- a/paddle/fluid/operators/similarity_focus_op.h +++ b/paddle/fluid/operators/similarity_focus_op.h @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" @@ -67,16 +68,16 @@ class SimilarityFocusKernel : public framework::OpKernel { std::vector> array(array_size); - bool (*cmp)(std::pair, std::pair) = []( - std::pair x, std::pair y) { - return x.first > y.first; - }; + bool (*cmp)(std::pair, std::pair) = + [](std::pair x, std::pair y) { + return x.first > y.first; + }; - int64_t (*compute_index)(int64_t*, int, int, int, int) = []( - int64_t* dim, int d1, int d2, int d3, int d4) { - return d1 * dim[1] * dim[2] * dim[3] + d2 * dim[2] * dim[3] + - d3 * dim[3] + d4; - }; + int64_t (*compute_index)(int64_t*, int, int, int, int) = + [](int64_t* dim, int d1, int d2, int d3, int d4) { + return d1 * dim[1] * dim[2] * dim[3] + d2 * dim[2] * dim[3] + + d3 * dim[3] + d4; + }; PADDLE_ENFORCE_GT( axis, 0, diff --git a/paddle/fluid/operators/slice_op.cc b/paddle/fluid/operators/slice_op.cc index c6432d00e9de16b5635aa80f6dabb63c2b84f46e..a815e12d061cfae2d2b3d6afd43503c8f91c3468 100644 --- a/paddle/fluid/operators/slice_op.cc +++ b/paddle/fluid/operators/slice_op.cc @@ -13,10 +13,12 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/slice_op.h" + #include #include #include #include + #include "paddle/phi/kernels/funcs/slice_utils.h" namespace paddle { @@ -85,8 +87,9 @@ class SliceOp : public framework::OperatorWithKernel { } if (ctx->HasInputs("EndsTensorList")) { ends_size = ctx->Inputs("EndsTensorList").size(); - PADDLE_ENFORCE_GT(ends_size, 0, platform::errors::InvalidArgument( - "EndsTensorList size can't be zero")); + PADDLE_ENFORCE_GT(ends_size, 0, + platform::errors::InvalidArgument( + "EndsTensorList size can't be zero")); } if (!ctx->HasInput("StartsTensor")) { diff --git a/paddle/fluid/operators/slice_op.h b/paddle/fluid/operators/slice_op.h index a9a98b46d5eb7f08cb8c4a014e0fa3646dbc49bc..f18ffef3f5834c30dd5092142f44610f81a1d129 100644 --- a/paddle/fluid/operators/slice_op.h +++ b/paddle/fluid/operators/slice_op.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/eigen/eigen_function.h" #include "paddle/fluid/operators/utils.h" diff --git a/paddle/fluid/operators/slice_op_mlu.cc b/paddle/fluid/operators/slice_op_mlu.cc index 43322e4b2e75b2c46584cd63ac8f0ba300e247fb..7645232ec0cbc98a23747bc5ce577f8f0d824cc9 100644 --- a/paddle/fluid/operators/slice_op_mlu.cc +++ b/paddle/fluid/operators/slice_op_mlu.cc @@ -12,9 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/slice_op.h" - #include "paddle/fluid/operators/mlu/mlu_baseop.h" +#include "paddle/fluid/operators/slice_op.h" #include "paddle/phi/kernels/funcs/slice_utils.h" namespace paddle { diff --git a/paddle/fluid/operators/slice_op_npu.cc b/paddle/fluid/operators/slice_op_npu.cc index 0d0d9ab19df30cf414d3bed9b7e639ba3694f733..3441453430e5c810e95227e5e0434085b5196f62 100644 --- a/paddle/fluid/operators/slice_op_npu.cc +++ b/paddle/fluid/operators/slice_op_npu.cc @@ -13,7 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/slice_op.h" - #include "paddle/fluid/platform/device/npu/npu_op_runner.h" #include "paddle/phi/kernels/funcs/slice_utils.h" diff --git a/paddle/fluid/operators/slice_op_xpu.cc b/paddle/fluid/operators/slice_op_xpu.cc index 6ac1027b0ce1957fa7ee10409d7e915c04599013..8f2dfd38d491bd54f5e6f4baa1a5d068fdfa301d 100644 --- a/paddle/fluid/operators/slice_op_xpu.cc +++ b/paddle/fluid/operators/slice_op_xpu.cc @@ -13,11 +13,12 @@ See the License for the specific language governing permissions and limitations under the License. */ #ifdef PADDLE_WITH_XPU -#include "paddle/fluid/operators/slice_op.h" #include #include #include #include + +#include "paddle/fluid/operators/slice_op.h" #include "xpu/refactor/math.h" namespace paddle { @@ -53,8 +54,9 @@ class SliceXPUKernel : public framework::OpKernel { start = std::max(start, 0); end = std::max(end, 0); end = std::min(end, dim_value); - PADDLE_ENFORCE_GT(end, start, platform::errors::InvalidArgument( - "end should greater than start")); + PADDLE_ENFORCE_GT( + end, start, + platform::errors::InvalidArgument("end should greater than start")); starts[i] = start; ends[i] = end; } diff --git a/paddle/fluid/operators/smooth_l1_loss_op.cc b/paddle/fluid/operators/smooth_l1_loss_op.cc index c0318d344aef30008df0fdeaf9d2c251166b37cb..05204354d091200663d6da205a6dd3d8778afbef 100644 --- a/paddle/fluid/operators/smooth_l1_loss_op.cc +++ b/paddle/fluid/operators/smooth_l1_loss_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/smooth_l1_loss_op.h" + #include namespace paddle { diff --git a/paddle/fluid/operators/smooth_l1_loss_op_npu.cc b/paddle/fluid/operators/smooth_l1_loss_op_npu.cc index 136ea68ac9efef93ad1cbad7dee4d0525ce52d73..bdc46abff2ad26dd8c641e36ee17d7b8988b74f7 100644 --- a/paddle/fluid/operators/smooth_l1_loss_op_npu.cc +++ b/paddle/fluid/operators/smooth_l1_loss_op_npu.cc @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/smooth_l1_loss_op.h" #include "paddle/fluid/framework/tensor_util.h" +#include "paddle/fluid/operators/smooth_l1_loss_op.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" namespace paddle { diff --git a/paddle/fluid/operators/softmax_op.cc b/paddle/fluid/operators/softmax_op.cc index 3840b99dd176d5b348533f3e50f7f90fc3250ea1..7304467833a9004bdac1edb4fcc5eda1b16affa5 100644 --- a/paddle/fluid/operators/softmax_op.cc +++ b/paddle/fluid/operators/softmax_op.cc @@ -61,8 +61,9 @@ class SoftmaxOp : public framework::OperatorWithKernel { if (input_data_type == framework::proto::VarType::FP16) { PADDLE_ENFORCE_EQ(platform::is_gpu_place(ctx.GetPlace()) || platform::is_xpu_place(ctx.GetPlace()), - true, platform::errors::InvalidArgument( - "float16 can only be used on GPU/XPU place")); + true, + platform::errors::InvalidArgument( + "float16 can only be used on GPU/XPU place")); } #endif diff --git a/paddle/fluid/operators/softmax_with_cross_entropy_op_xpu.cc b/paddle/fluid/operators/softmax_with_cross_entropy_op_xpu.cc index c07467a9b0ba33ce3bc0d9d140d72ffa4ed7108c..4b55f5af09dc612b9b3dfdb2c1e8e4251999ace2 100644 --- a/paddle/fluid/operators/softmax_with_cross_entropy_op_xpu.cc +++ b/paddle/fluid/operators/softmax_with_cross_entropy_op_xpu.cc @@ -44,8 +44,9 @@ class SoftmaxWithCrossEntropyXPUKernel : public framework::OpKernel { Tensor* loss = context.Output("Loss"); const int rank = logits->dims().size(); const int axis = phi::funcs::CanonicalAxis(context.Attr("axis"), rank); - PADDLE_ENFORCE_EQ(axis, rank - 1, platform::errors::InvalidArgument( - "axis should == rank - 1")); + PADDLE_ENFORCE_EQ( + axis, rank - 1, + platform::errors::InvalidArgument("axis should == rank - 1")); softmax->mutable_data(context.GetPlace()); loss->mutable_data(context.GetPlace()); const int n = phi::funcs::SizeToAxis(axis, logits->dims()); @@ -140,8 +141,9 @@ class SoftmaxWithCrossEntropyGradXPUKernel : public framework::OpKernel { const int rank = logit_grad->dims().size(); const int axis = phi::funcs::CanonicalAxis(context.Attr("axis"), rank); - PADDLE_ENFORCE_EQ(axis, rank - 1, platform::errors::InvalidArgument( - "axis should == rank - 1")); + PADDLE_ENFORCE_EQ( + axis, rank - 1, + platform::errors::InvalidArgument("axis should == rank - 1")); const int n = phi::funcs::SizeToAxis(axis, logit_grad->dims()); const int d = phi::funcs::SizeFromAxis(axis, logit_grad->dims()); diff --git a/paddle/fluid/operators/solve_op.cc b/paddle/fluid/operators/solve_op.cc index 57302ae03427160a06c318a4d420259d73759fb1..4d23f1ce20945bf4f62348fabbafffa099a7b8fb 100644 --- a/paddle/fluid/operators/solve_op.cc +++ b/paddle/fluid/operators/solve_op.cc @@ -13,10 +13,12 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/solve_op.h" + #include #include #include #include + #include "paddle/phi/core/ddim.h" namespace paddle { diff --git a/paddle/fluid/operators/solve_op.h b/paddle/fluid/operators/solve_op.h index 7f3a5748666047715cfe2013629df9c5c5038db7..928fbf755d7f7a5ed8bae7e661f582b6ff026dea 100644 --- a/paddle/fluid/operators/solve_op.h +++ b/paddle/fluid/operators/solve_op.h @@ -92,9 +92,10 @@ static framework::DDim GetOutputShapeUnsqueeze( for (int axis : unsqz_dims) { int cur = axis < 0 ? axis + cur_output_size + 1 : axis; // Vaildity Check: the axis bound - PADDLE_ENFORCE_GE(cur, 0, platform::errors::InvalidArgument( - "The insert dimension value should " - "not be less than 0")); + PADDLE_ENFORCE_GE( + cur, 0, + platform::errors::InvalidArgument("The insert dimension value should " + "not be less than 0")); PADDLE_ENFORCE_LE(cur, cur_output_size, platform::errors::InvalidArgument( "The insert dimension value shoule not be larger " diff --git a/paddle/fluid/operators/space_to_depth_op.cc b/paddle/fluid/operators/space_to_depth_op.cc index 013467396b3a6137fab8cf48ffcc512517ff482f..6a6972f3293e451a467a1fe278726d6599b7c6ac 100644 --- a/paddle/fluid/operators/space_to_depth_op.cc +++ b/paddle/fluid/operators/space_to_depth_op.cc @@ -38,8 +38,9 @@ class SpaceToDepthOp : public framework::OperatorWithKernel { "Output(Out) of SpaceToDepthOp should not be null.")); auto x_dims = ctx->GetInputDim("X"); - PADDLE_ENFORCE_EQ(x_dims.size(), 4, platform::errors::InvalidArgument( - "input should be a 4D tensor")); + PADDLE_ENFORCE_EQ( + x_dims.size(), 4, + platform::errors::InvalidArgument("input should be a 4D tensor")); auto blocksize = ctx->Attrs().Get("blocksize"); PADDLE_ENFORCE_GT(blocksize, 1, diff --git a/paddle/fluid/operators/sparse_attention_op.cc b/paddle/fluid/operators/sparse_attention_op.cc index a6534543a6515a80886fc61953310f6988f20b3f..14d1ffe3f11b0a9b6be5b70e9723437f25b6ac4d 100644 --- a/paddle/fluid/operators/sparse_attention_op.cc +++ b/paddle/fluid/operators/sparse_attention_op.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/sparse_attention_op.cu b/paddle/fluid/operators/sparse_attention_op.cu index 49f8263ab289a131ac58f5d995999c9043d0a33f..2949642d2f3dd7504baa7affdb6c3baa971f7768 100644 --- a/paddle/fluid/operators/sparse_attention_op.cu +++ b/paddle/fluid/operators/sparse_attention_op.cu @@ -13,9 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include #include #include + #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/op_registry.h" #if defined(PADDLE_WITH_CUDA) @@ -90,17 +92,15 @@ __global__ void BlockSparseSoftmaxForward(T* softmax, const T* src, T scale, if (cur_block_col < cur_block_nnz) { // read kp mask T cur_kp_mask; - if ((kp_mask != nullptr) && - std::abs(kp_mask[colindex[cur_block_col]]) < - std::numeric_limits::epsilon()) { + if ((kp_mask != nullptr) && std::abs(kp_mask[colindex[cur_block_col]]) < + std::numeric_limits::epsilon()) { cur_kp_mask = -std::numeric_limits::infinity(); } else { cur_kp_mask = 0; } // do mask operation - if ((attnptr != nullptr) && - std::abs(attnptr[colindex[cur_block_col]]) < - std::numeric_limits::epsilon()) { + if ((attnptr != nullptr) && std::abs(attnptr[colindex[cur_block_col]]) < + std::numeric_limits::epsilon()) { srcdata[cur_reg_index] = -std::numeric_limits::infinity() * scale + cur_kp_mask; } else { @@ -280,37 +280,37 @@ void SparseSoftmaxBackward(const platform::CUDADeviceContext& ctx, T scaling = static_cast(1.0) / sqrt(static_cast(num_cols)); if (num_cols <= 4) { - BlockSparseSoftmaxBackward<<>>( - dx_data, dout_data, out_data, scaling, offset_data, columns_data, - num_rows); + BlockSparseSoftmaxBackward + <<>>(dx_data, dout_data, out_data, scaling, offset_data, + columns_data, num_rows); } else if (num_cols > 4 && num_cols <= 8) { - BlockSparseSoftmaxBackward<<>>( - dx_data, dout_data, out_data, scaling, offset_data, columns_data, - num_rows); + BlockSparseSoftmaxBackward + <<>>(dx_data, dout_data, out_data, scaling, offset_data, + columns_data, num_rows); } else if (num_cols > 8 && num_cols <= 16) { - BlockSparseSoftmaxBackward<<>>( - dx_data, dout_data, out_data, scaling, offset_data, columns_data, - num_rows); + BlockSparseSoftmaxBackward + <<>>(dx_data, dout_data, out_data, scaling, offset_data, + columns_data, num_rows); } else if (num_cols > 16 && num_cols <= 32) { - BlockSparseSoftmaxBackward<<>>( - dx_data, dout_data, out_data, scaling, offset_data, columns_data, - num_rows); + BlockSparseSoftmaxBackward + <<>>(dx_data, dout_data, out_data, scaling, offset_data, + columns_data, num_rows); } else if (num_cols > 32 && num_cols <= 64) { - BlockSparseSoftmaxBackward<<>>( - dx_data, dout_data, out_data, scaling, offset_data, columns_data, - num_rows); + BlockSparseSoftmaxBackward + <<>>(dx_data, dout_data, out_data, scaling, offset_data, + columns_data, num_rows); } else if (num_cols > 64 && num_cols <= 128) { - BlockSparseSoftmaxBackward<<>>( - dx_data, dout_data, out_data, scaling, offset_data, columns_data, - num_rows); + BlockSparseSoftmaxBackward + <<>>(dx_data, dout_data, out_data, scaling, offset_data, + columns_data, num_rows); } else if (num_cols > 128 && num_cols <= 256) { - BlockSparseSoftmaxBackward<<>>( - dx_data, dout_data, out_data, scaling, offset_data, columns_data, - num_rows); + BlockSparseSoftmaxBackward + <<>>(dx_data, dout_data, out_data, scaling, offset_data, + columns_data, num_rows); } else if (num_cols > 256 && num_cols <= 512) { - BlockSparseSoftmaxBackward<<>>( - dx_data, dout_data, out_data, scaling, offset_data, columns_data, - num_rows); + BlockSparseSoftmaxBackward + <<>>(dx_data, dout_data, out_data, scaling, offset_data, + columns_data, num_rows); } else { PADDLE_THROW(platform::errors::InvalidArgument( "The head_dim of query in sparse_attention op should less or equal " diff --git a/paddle/fluid/operators/spectral_norm_op.h b/paddle/fluid/operators/spectral_norm_op.h index ee75c96c23a9f642d4374b0e9253aff161b87390..765b9a4dbfae6d2b9b961be804b23aab1cfa84e1 100644 --- a/paddle/fluid/operators/spectral_norm_op.h +++ b/paddle/fluid/operators/spectral_norm_op.h @@ -11,6 +11,7 @@ #pragma once #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/blas/blas.h" diff --git a/paddle/fluid/operators/spectral_op.cc b/paddle/fluid/operators/spectral_op.cc index 0270f7e0576c8ea85e8464c4bc6236434210a4a3..cd2053b4ef0837f3e30a02979f1a2d37d5126e1c 100644 --- a/paddle/fluid/operators/spectral_op.cc +++ b/paddle/fluid/operators/spectral_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/spectral_op.h" + #include "paddle/fluid/operators/spectral_helper.h" namespace paddle { diff --git a/paddle/fluid/operators/spectral_op.h b/paddle/fluid/operators/spectral_op.h index 71b54caf5ee79473e349b39130be673bf5a1e6bb..4900e88fbe18f8095a9d81a4b6fc92b88ee82cf6 100644 --- a/paddle/fluid/operators/spectral_op.h +++ b/paddle/fluid/operators/spectral_op.h @@ -18,6 +18,7 @@ #include #include #include + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/data_type_transform.h" diff --git a/paddle/fluid/operators/split_op.cc b/paddle/fluid/operators/split_op.cc index dc20952903ab2970f377bf2c4b1eec0c7736e28e..6c60c1a17e017ce97b8bec6c940625fa5f31ec8b 100644 --- a/paddle/fluid/operators/split_op.cc +++ b/paddle/fluid/operators/split_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/split_op.h" + #include #include "paddle/fluid/framework/infershape_utils.h" diff --git a/paddle/fluid/operators/split_op.h b/paddle/fluid/operators/split_op.h index cf44f341b2b645c535a694bee9c54613cf10da05..143e1d72868a10b3d43a8922278eada027828569 100644 --- a/paddle/fluid/operators/split_op.h +++ b/paddle/fluid/operators/split_op.h @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/utils.h" #include "paddle/phi/kernels/split_kernel.h" diff --git a/paddle/fluid/operators/split_op_mlu.cc b/paddle/fluid/operators/split_op_mlu.cc index adc3ea14e32d616bb1dfe7777e339beab84aaa8f..0d438854673cbe1e0056ab3f699fb3976a90a90a 100644 --- a/paddle/fluid/operators/split_op_mlu.cc +++ b/paddle/fluid/operators/split_op_mlu.cc @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/split_op.h" #include "paddle/fluid/operators/mlu/mlu_baseop.h" +#include "paddle/fluid/operators/split_op.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/split_op_xpu.cc b/paddle/fluid/operators/split_op_xpu.cc index 8f02d8157b202451d04a3b587012781fb56a57bc..b24d0a70b05b03a3b0fad1829149ba2639283a46 100644 --- a/paddle/fluid/operators/split_op_xpu.cc +++ b/paddle/fluid/operators/split_op_xpu.cc @@ -12,9 +12,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #ifdef PADDLE_WITH_XPU -#include "paddle/fluid/operators/split_op.h" #include #include + +#include "paddle/fluid/operators/split_op.h" #include "paddle/fluid/platform/device/xpu/xpu_header.h" namespace paddle { diff --git a/paddle/fluid/operators/spp_op.cc b/paddle/fluid/operators/spp_op.cc index b1e0127f4cf915745ae4d031e245ed64721fc906..05230399b300a346db36bd6aeeea74ae57538070 100644 --- a/paddle/fluid/operators/spp_op.cc +++ b/paddle/fluid/operators/spp_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/spp_op.h" + #include #include namespace paddle { diff --git a/paddle/fluid/operators/spp_op.h b/paddle/fluid/operators/spp_op.h index aa944cfcfbb1713aeb27b501083853abb4ffed40..cd81ade1f9d81ccb828d8de8ac6059e5f2ac1a5b 100644 --- a/paddle/fluid/operators/spp_op.h +++ b/paddle/fluid/operators/spp_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/phi_utils.h" #include "paddle/fluid/operators/strided_memcpy.h" diff --git a/paddle/fluid/operators/stack_op.cc b/paddle/fluid/operators/stack_op.cc index 6fc80ca379f3f9ee93fd9d327f7b97deadc1152f..6b0a0657afba8121931afca29c95aff3233612f0 100644 --- a/paddle/fluid/operators/stack_op.cc +++ b/paddle/fluid/operators/stack_op.cc @@ -14,6 +14,7 @@ #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/stack_op_npu.cc b/paddle/fluid/operators/stack_op_npu.cc index 9d4ef0ffa20e24e4f657305adbbaa7b8ecbfd322..c3e6e333e4cf44131450eae1fe53ccdd6ed35367 100644 --- a/paddle/fluid/operators/stack_op_npu.cc +++ b/paddle/fluid/operators/stack_op_npu.cc @@ -30,8 +30,9 @@ class StackNPUKernel : public framework::OpKernel { if (axis < 0) axis += (x[0]->dims().size() + 1); int num = static_cast(x.size()); - PADDLE_ENFORCE_GT(num, 0, platform::errors::InvalidArgument( - "number of input Tensor <= 0")); + PADDLE_ENFORCE_GT( + num, 0, + platform::errors::InvalidArgument("number of input Tensor <= 0")); auto stream = ctx.template device_context() @@ -59,8 +60,9 @@ class StackGradNPUKernel : public framework::OpKernel { if (axis < 0) axis += dy->dims().size(); int num = dy->dims()[axis]; - PADDLE_ENFORCE_GT(num, 0, platform::errors::InvalidArgument( - "number of input Tensor <= 0")); + PADDLE_ENFORCE_GT( + num, 0, + platform::errors::InvalidArgument("number of input Tensor <= 0")); auto stream = ctx.template device_context() diff --git a/paddle/fluid/operators/stack_op_xpu.cc b/paddle/fluid/operators/stack_op_xpu.cc index baaa2b4884ce3d9c17c955758d1f83541f40f689..925fcc08615acf8c859f0a91280e268f61deef00 100644 --- a/paddle/fluid/operators/stack_op_xpu.cc +++ b/paddle/fluid/operators/stack_op_xpu.cc @@ -15,6 +15,7 @@ #ifdef PADDLE_WITH_XPU #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/concat_op.h" #include "paddle/fluid/platform/device/xpu/xpu_header.h" diff --git a/paddle/fluid/operators/stft_op.cc b/paddle/fluid/operators/stft_op.cc index 7d4103ddf3859c6fda71c08395207da1d987a933..36e867417291ca3024b63cdc0557e408911634d3 100644 --- a/paddle/fluid/operators/stft_op.cc +++ b/paddle/fluid/operators/stft_op.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/operators/stft_op.h" + #include "paddle/fluid/operators/spectral_helper.h" namespace paddle { diff --git a/paddle/fluid/operators/stft_op.h b/paddle/fluid/operators/stft_op.h index e75c59232bcaebe0b594b951c9ceb758f308a49a..cc17ed9a43cc160b3a751efa498bc3d20d06b8aa 100644 --- a/paddle/fluid/operators/stft_op.h +++ b/paddle/fluid/operators/stft_op.h @@ -17,7 +17,6 @@ #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/tensor.h" - #include "paddle/fluid/operators/elementwise/elementwise_op_function.h" #include "paddle/fluid/operators/frame_op.h" #include "paddle/fluid/operators/spectral_op.h" diff --git a/paddle/fluid/operators/strided_slice_op_npu.cc b/paddle/fluid/operators/strided_slice_op_npu.cc index b142b8f099b8956416467a1acbbd7a51452f8348..80952e9b5560c2713f7e0b7a76168922ebda2a31 100644 --- a/paddle/fluid/operators/strided_slice_op_npu.cc +++ b/paddle/fluid/operators/strided_slice_op_npu.cc @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/phi/kernels/funcs/strided_slice.h" #include "paddle/fluid/operators/slice_op.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" +#include "paddle/phi/kernels/funcs/strided_slice.h" namespace paddle { namespace operators { @@ -186,14 +186,16 @@ class StridedSliceNPUKernel : public framework::OpKernel { out->Resize(out_dims); out->mutable_data(place); - const auto& runner = NpuOpRunner( - "StridedSlice", {*in, starts_indices_tensor, ends_indices_tensor, - strides_indices_tensor}, - {*out}, {{"begin_mask", 0}, - {"end_mask", 0}, - {"ellipsis_mask", 0}, - {"new_axis_mask", 0}, - {"shrink_axis_mask", 0}}); + const auto& runner = + NpuOpRunner("StridedSlice", + {*in, starts_indices_tensor, ends_indices_tensor, + strides_indices_tensor}, + {*out}, + {{"begin_mask", 0}, + {"end_mask", 0}, + {"ellipsis_mask", 0}, + {"new_axis_mask", 0}, + {"shrink_axis_mask", 0}}); runner.Run(stream); if (need_reverse) { diff --git a/paddle/fluid/operators/string/faster_tokenizer_op.cc b/paddle/fluid/operators/string/faster_tokenizer_op.cc index 42047021b408a8bd2582d68faaf814ff145dc1a0..9e4089680f420f6a33667db0011e1488fd40cc12 100644 --- a/paddle/fluid/operators/string/faster_tokenizer_op.cc +++ b/paddle/fluid/operators/string/faster_tokenizer_op.cc @@ -9,9 +9,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/operators/string/faster_tokenizer_op.h" + #include #include +#include #include #include #include @@ -22,10 +25,7 @@ limitations under the License. */ #include #include -#include - #include "paddle/fluid/framework/string_array.h" -#include "paddle/fluid/operators/string/faster_tokenizer_op.h" namespace paddle { namespace operators { @@ -38,12 +38,11 @@ using std::ifstream; using std::int64_t; using std::min; using std::runtime_error; -using std::unordered_map; -using std::unordered_set; using std::shared_ptr; using std::size_t; -using std::int64_t; using std::string; +using std::unordered_map; +using std::unordered_set; using std::vector; using std::wstring; diff --git a/paddle/fluid/operators/string/faster_tokenizer_op.h b/paddle/fluid/operators/string/faster_tokenizer_op.h index 446be3a1999fc94a5ec062b4c45500ed71be4829..a6b8bfea59c47c7ae9b06eb59f0675c0e76ebd59 100644 --- a/paddle/fluid/operators/string/faster_tokenizer_op.h +++ b/paddle/fluid/operators/string/faster_tokenizer_op.h @@ -26,15 +26,14 @@ namespace operators { using std::endl; using std::int64_t; +using std::shared_ptr; using std::size_t; using std::string; -using std::shared_ptr; -using std::vector; using std::unordered_map; using std::unordered_set; using std::vector; -using std::wstring; using std::wcout; +using std::wstring; inline bool IsControl(const wchar_t& ch); inline bool IsChineseChar(const wchar_t& ch); diff --git a/paddle/fluid/operators/sum_op.cc b/paddle/fluid/operators/sum_op.cc index 51040544fac346cee1f9e40e425d12d7d0fdd954..bc6997e36ebf734496c4581ef080ff614c4256da 100644 --- a/paddle/fluid/operators/sum_op.cc +++ b/paddle/fluid/operators/sum_op.cc @@ -36,9 +36,8 @@ class SumOp : public framework::OperatorWithKernel { OP_INOUT_CHECK(ctx->HasInputs("X"), "Input", "X", "sum"); OP_INOUT_CHECK(ctx->HasOutput("Out"), "Output", "Out", "sum"); - if (ctx->IsRuntime() && - ctx->GetOutputsVarType("Out")[0] == - framework::proto::VarType::LOD_TENSOR_ARRAY) { + if (ctx->IsRuntime() && ctx->GetOutputsVarType("Out")[0] == + framework::proto::VarType::LOD_TENSOR_ARRAY) { return; // skip runtime infershape when is tensor array; } @@ -47,11 +46,12 @@ class SumOp : public framework::OperatorWithKernel { auto N = x_dims.size(); PADDLE_ENFORCE_GT( - N, 0, platform::errors::InvalidArgument( - "The input tensor X's dimensions of SumOp " - "should be larger than 0. But received X's dimensions %d, " - "X's shape = [%s].", - N, &x_dims)); + N, 0, + platform::errors::InvalidArgument( + "The input tensor X's dimensions of SumOp " + "should be larger than 0. But received X's dimensions %d, " + "X's shape = [%s].", + N, &x_dims)); if (N == 1) { VLOG(3) << "Warning: SumOp have only one input, may waste memory"; } @@ -115,8 +115,9 @@ class SumOp : public framework::OperatorWithKernel { framework::LibraryType library{framework::LibraryType::kPlain}; framework::DataLayout layout{framework::DataLayout::kAnyLayout}; - PADDLE_ENFORCE_GT(x_vars.size(), 0, platform::errors::InvalidArgument( - "Input[X] should not be empty")); + PADDLE_ENFORCE_GT( + x_vars.size(), 0, + platform::errors::InvalidArgument("Input[X] should not be empty")); PADDLE_ENFORCE_NOT_NULL( x_vars[0], platform::errors::NotFound( diff --git a/paddle/fluid/operators/sum_op.cu b/paddle/fluid/operators/sum_op.cu index 8c6c083cde880e1e913b1d75446896fce668afb5..3bf249425c2ce9b88796c1a207fbf9e5dca0c8d9 100644 --- a/paddle/fluid/operators/sum_op.cu +++ b/paddle/fluid/operators/sum_op.cu @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/operators/sum_op.h" @@ -205,8 +206,8 @@ void SumToLoDTensor(const framework::ExecutionContext &context) { reinterpret_cast(tmp_sr_in_out_array->ptr()); ComputeKernelParameter(length); - SumSelectedRowsCUDAKernel<<>>( - sr_in_out_array_data, length, rows); + SumSelectedRowsCUDAKernel + <<>>(sr_in_out_array_data, length, rows); dst_write = true; } } diff --git a/paddle/fluid/operators/sum_op.h b/paddle/fluid/operators/sum_op.h index 3c51b3398be4e0d6609f245398263ef040032e64..8c1e3a3dbf191749912a019f4a5b8026b63bf446 100644 --- a/paddle/fluid/operators/sum_op.h +++ b/paddle/fluid/operators/sum_op.h @@ -11,6 +11,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/lod_tensor_array.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/sum_op_mlu.cc b/paddle/fluid/operators/sum_op_mlu.cc index 179c038e837162f5c2c549bc10fd0d70e910af71..68e31c364b64be1ccbc6f818637a81d3e924550f 100644 --- a/paddle/fluid/operators/sum_op_mlu.cc +++ b/paddle/fluid/operators/sum_op_mlu.cc @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/sum_op.h" #include "paddle/fluid/operators/mlu/mlu_baseop.h" +#include "paddle/fluid/operators/sum_op.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/sum_op_xpu.cc b/paddle/fluid/operators/sum_op_xpu.cc index 5899591549eacc831f42accdeec378ad688c294e..a1cdaddd11b42f392cb97880a545df5356e5c531 100644 --- a/paddle/fluid/operators/sum_op_xpu.cc +++ b/paddle/fluid/operators/sum_op_xpu.cc @@ -11,8 +11,9 @@ limitations under the License. */ #ifdef PADDLE_WITH_XPU -#include "paddle/fluid/operators/sum_op.h" #include + +#include "paddle/fluid/operators/sum_op.h" #include "paddle/fluid/platform/device/xpu/xpu_header.h" namespace paddle { diff --git a/paddle/fluid/operators/svd_helper.h b/paddle/fluid/operators/svd_helper.h index 166f49999d552917021a545b2799ae33ff257f06..468c658e5e640a493f0a7d4cb74c0753f0d565d9 100644 --- a/paddle/fluid/operators/svd_helper.h +++ b/paddle/fluid/operators/svd_helper.h @@ -15,9 +15,11 @@ #pragma once #include + #include #include #include + #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/operators/diag_op.h" @@ -101,20 +103,22 @@ struct RealMulComplexFunctor { // y: complex number (c+0j) pretend to be a real number // out: complex number (ac+bcj) inline HOSTDEVICE T operator()(T x, T y) { - PADDLE_ENFORCE_LT(y.imag, 1e-6, platform::errors::InvalidArgument( - "The image part of y must to be 0" - "but got [%d]", - y.imag)); + PADDLE_ENFORCE_LT( + y.imag, 1e-6, + platform::errors::InvalidArgument("The image part of y must to be 0" + "but got [%d]", + y.imag)); return platform::complex>(x.real * y.real, x.imag * y.real); } }; static std::vector GetBroadcastShape(InTensors ins) { - PADDLE_ENFORCE_EQ(ins.size(), 2, platform::errors::InvalidArgument( - "GetBroadcastShape Receive 2 tensors" - "but got [%d]", - ins.size())); + PADDLE_ENFORCE_EQ( + ins.size(), 2, + platform::errors::InvalidArgument("GetBroadcastShape Receive 2 tensors" + "but got [%d]", + ins.size())); auto x_dim = ins[0]->dims(); auto y_dim = ins[1]->dims(); std::vector broadcast_shape = @@ -596,8 +600,9 @@ struct DeviceIndependenceTensorOperations { attrs["lower"] = lower; NameInTensorMap inputs({{"X", {&x}}}); int x_rank = x.dims().size(); - PADDLE_ENFORCE_GE(x_rank, 2, platform::errors::InvalidArgument( - "Rank must be at least 2.")); + PADDLE_ENFORCE_GE( + x_rank, 2, + platform::errors::InvalidArgument("Rank must be at least 2.")); std::vector out_shape = phi::vectorize(x.dims()); return CreateOpRunAndReturnTensor("tril_triu", inputs, attrs, out_shape); } diff --git a/paddle/fluid/operators/svd_op.cc b/paddle/fluid/operators/svd_op.cc index 3ca7320114a8a9f5c4fa7a80e07d721e7b390c80..e68b013d2fb6277175f6f59b5d77f439d31e7d1c 100644 --- a/paddle/fluid/operators/svd_op.cc +++ b/paddle/fluid/operators/svd_op.cc @@ -13,10 +13,12 @@ // limitations under the License. #include "paddle/fluid/operators/svd_op.h" + #include #include #include #include + #include "paddle/phi/core/ddim.h" #ifdef PADDLE_WITH_MKLDNN #include "paddle/fluid/platform/mkldnn_helper.h" diff --git a/paddle/fluid/operators/svd_op.cu b/paddle/fluid/operators/svd_op.cu index e987589e83c19c4d64c4c2ad31ce05ec7c7bd4d5..317ea7c5363b90d4902cb8ca67c18df54dd26775 100644 --- a/paddle/fluid/operators/svd_op.cu +++ b/paddle/fluid/operators/svd_op.cu @@ -16,8 +16,10 @@ limitations under the License. */ // HIP not support cusolver #include + #include #include + #include "paddle/fluid/memory/memory.h" #include "paddle/fluid/operators/svd_op.h" #include "paddle/fluid/platform/dynload/cusolver.h" diff --git a/paddle/fluid/operators/svd_op.h b/paddle/fluid/operators/svd_op.h index 42a847206a3cb6fecc421effa9e9d10bacc80be4..1008a69e6de0fa7d0de4d9edf8307b5705762aac 100644 --- a/paddle/fluid/operators/svd_op.h +++ b/paddle/fluid/operators/svd_op.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/operators/svd_helper.h" diff --git a/paddle/fluid/operators/sync_batch_norm_op.cu.h b/paddle/fluid/operators/sync_batch_norm_op.cu.h index 17c96544988b6433ff5ae5c5ad508b33f70f902f..9818aa3651baffda2d79a5ca71c6b5b86dbcd8be 100644 --- a/paddle/fluid/operators/sync_batch_norm_op.cu.h +++ b/paddle/fluid/operators/sync_batch_norm_op.cu.h @@ -137,7 +137,7 @@ void SyncBatchNormFunctor(const framework::ExecutionContext &ctx, const float momentum, const bool is_test, const bool use_global_stats - ) { +) { const auto &x_dims = x->dims(); PADDLE_ENFORCE_GE(x_dims.size(), 2, platform::errors::InvalidArgument( @@ -178,13 +178,11 @@ void SyncBatchNormFunctor(const framework::ExecutionContext &ctx, const int threads = 256; int grid = std::min(C, (max_threads + threads - 1) / threads); if (layout == framework::DataLayout::kNCHW) { - KeLocalStats<<>>( - x_d, N, H * W * D, C, stats); + KeLocalStats + <<>>(x_d, N, H * W * D, C, stats); } else { - KeLocalStats<<>>( - x_d, N, H * W * D, C, stats); + KeLocalStats + <<>>(x_d, N, H * W * D, C, stats); } #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) @@ -221,13 +219,13 @@ void SyncBatchNormFunctor(const framework::ExecutionContext &ctx, int grid2 = (std::min(x_numel, max_threads) + block - 1) / block; if (layout == framework::DataLayout::kNCHW) { - KeNormAffine<<>>( - x_d, s_d, b_d, mean_data, var_data, epsilon, C, H * W * D, x_numel, - y_d); + KeNormAffine + <<>>(x_d, s_d, b_d, mean_data, var_data, + epsilon, C, H * W * D, x_numel, y_d); } else { - KeNormAffine<<>>( - x_d, s_d, b_d, mean_data, var_data, epsilon, C, H * W * D, x_numel, - y_d); + KeNormAffine + <<>>(x_d, s_d, b_d, mean_data, var_data, + epsilon, C, H * W * D, x_numel, y_d); } } @@ -436,30 +434,30 @@ void SyncBatchNormGradFunctor( if (is_inplace) { if (layout == framework::DataLayout::kNCHW) { - KeBNRestoreData< - T, framework::DataLayout::kNCHW><<>>( - px.mutable_data(ctx.GetPlace()), - scale->data>(), - bias->data>(), saved_mean, saved_inv_var, - epsilon, C, H * W * D, x_numel, x->data()); + KeBNRestoreData + <<>>(px.mutable_data(ctx.GetPlace()), + scale->data>(), + bias->data>(), + saved_mean, saved_inv_var, epsilon, C, + H * W * D, x_numel, x->data()); } else { - KeBNRestoreData< - T, framework::DataLayout::kNHWC><<>>( - px.mutable_data(ctx.GetPlace()), - scale->data>(), - bias->data>(), saved_mean, saved_inv_var, - epsilon, C, H * W * D, x_numel, x->data()); + KeBNRestoreData + <<>>(px.mutable_data(ctx.GetPlace()), + scale->data>(), + bias->data>(), + saved_mean, saved_inv_var, epsilon, C, + H * W * D, x_numel, x->data()); } } if (layout == framework::DataLayout::kNCHW) { - KeBackwardLocalStats< - T, threads, framework::DataLayout::kNCHW><<>>( - dy_d, x_d, saved_mean, N, fsize, C, stats); + KeBackwardLocalStats + <<>>(dy_d, x_d, saved_mean, N, fsize, C, + stats); } else { - KeBackwardLocalStats< - T, threads, framework::DataLayout::kNHWC><<>>( - dy_d, x_d, saved_mean, N, fsize, C, stats); + KeBackwardLocalStats + <<>>(dy_d, x_d, saved_mean, N, fsize, C, + stats); } #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) @@ -476,35 +474,33 @@ void SyncBatchNormGradFunctor( if (layout == framework::DataLayout::kNCHW) { if (d_scale && d_bias) { - KeBNBackwardScaleBias< - T, threads, - framework::DataLayout::kNCHW><<>>( - dy_d, x_d, saved_mean, saved_inv_var, epsilon, N, C, fsize, - d_scale->data>(), - d_bias->data>()); + KeBNBackwardScaleBias + <<>>(dy_d, x_d, saved_mean, saved_inv_var, + epsilon, N, C, fsize, + d_scale->data>(), + d_bias->data>()); } if (d_x) { - KeBNBackwardData< - T, framework::DataLayout::kNCHW><<>>( - dy_d, x_d, scale->data>(), saved_mean, - saved_inv_var, stats, stats + C, stats + 2 * C, epsilon, C, fsize, - x->numel(), d_x->data()); + KeBNBackwardData + <<>>( + dy_d, x_d, scale->data>(), saved_mean, + saved_inv_var, stats, stats + C, stats + 2 * C, epsilon, C, fsize, + x->numel(), d_x->data()); } } else { if (d_scale && d_bias) { - KeBNBackwardScaleBias< - T, threads, - framework::DataLayout::kNHWC><<>>( - dy_d, x_d, saved_mean, saved_inv_var, epsilon, N, C, fsize, - d_scale->data>(), - d_bias->data>()); + KeBNBackwardScaleBias + <<>>(dy_d, x_d, saved_mean, saved_inv_var, + epsilon, N, C, fsize, + d_scale->data>(), + d_bias->data>()); } if (d_x) { - KeBNBackwardData< - T, framework::DataLayout::kNHWC><<>>( - dy_d, x_d, scale->data>(), saved_mean, - saved_inv_var, stats, stats + C, stats + 2 * C, epsilon, C, fsize, - x->numel(), d_x->data()); + KeBNBackwardData + <<>>( + dy_d, x_d, scale->data>(), saved_mean, + saved_inv_var, stats, stats + C, stats + 2 * C, epsilon, C, fsize, + x->numel(), d_x->data()); } } } diff --git a/paddle/fluid/operators/sync_batch_norm_op_npu.cc b/paddle/fluid/operators/sync_batch_norm_op_npu.cc index b5632f4fe4a8427e09f5bc0bbd8922b960934b9e..604f8f97a3f417245c9f57e7b787949dc86bad71 100644 --- a/paddle/fluid/operators/sync_batch_norm_op_npu.cc +++ b/paddle/fluid/operators/sync_batch_norm_op_npu.cc @@ -566,8 +566,9 @@ class SyncBatchNormNPUGradKernel : public framework::OpKernel { paddle::framework::TensorToVector( device_count_tensor, ctx.device_context(), &device_count_vec); device_counts = device_count_vec[0]; - PADDLE_ENFORCE_GE(device_counts, 2, platform::errors::PreconditionNotMet( - "device_counts should >= 2.")); + PADDLE_ENFORCE_GE( + device_counts, 2, + platform::errors::PreconditionNotMet("device_counts should >= 2.")); } // cacl var_ref diff --git a/paddle/fluid/operators/tdm_child_op.cc b/paddle/fluid/operators/tdm_child_op.cc index a60fc537e3216ea3768575fb73a6069f2aaf4987..a7a218972ecf9a6819b00fdf4d091dc70a85e949 100644 --- a/paddle/fluid/operators/tdm_child_op.cc +++ b/paddle/fluid/operators/tdm_child_op.cc @@ -13,7 +13,9 @@ limitations under the License. */ #include "paddle/fluid/operators/tdm_child_op.h" + #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/math/sampler.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/operators/tdm_child_op.h b/paddle/fluid/operators/tdm_child_op.h index e437975320cc5e1ad51c8d06adac5168cb3b328e..c39d8260a8b363c638ef96e0f0647e49d58c0c7b 100644 --- a/paddle/fluid/operators/tdm_child_op.h +++ b/paddle/fluid/operators/tdm_child_op.h @@ -20,6 +20,7 @@ #include #include #include + #include "gflags/gflags.h" #include "paddle/fluid/framework/mixed_vector.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/tdm_sampler_op.cc b/paddle/fluid/operators/tdm_sampler_op.cc index 6aad72a0d9cbe66664c6d48d1b6b1e3c54a45a2b..68d079e6793020282523f4248de753022b8fd527 100644 --- a/paddle/fluid/operators/tdm_sampler_op.cc +++ b/paddle/fluid/operators/tdm_sampler_op.cc @@ -13,7 +13,9 @@ limitations under the License. */ #include "paddle/fluid/operators/tdm_sampler_op.h" + #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/math/sampler.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/operators/tdm_sampler_op.h b/paddle/fluid/operators/tdm_sampler_op.h index bf752a9c8ad785053ed6a9cde2b9dbda94f0c8b0..c3ed90ae68ebdd54aee51a8e1058678768d64450 100644 --- a/paddle/fluid/operators/tdm_sampler_op.h +++ b/paddle/fluid/operators/tdm_sampler_op.h @@ -20,6 +20,7 @@ #include #include #include + #include "gflags/gflags.h" #include "paddle/fluid/framework/mixed_vector.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/temporal_shift_op.cc b/paddle/fluid/operators/temporal_shift_op.cc index 3bdb9cb972fc6b235526f3aa8c6960c25af45c9f..12d0f288d97c92fc05f1e5137a928999b145ea76 100644 --- a/paddle/fluid/operators/temporal_shift_op.cc +++ b/paddle/fluid/operators/temporal_shift_op.cc @@ -10,12 +10,13 @@ limitations under the License. */ #include "paddle/fluid/operators/temporal_shift_op.h" + #include #include #include -#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/infershape_utils.h" +#include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/infermeta/unary.h" diff --git a/paddle/fluid/operators/temporal_shift_op.cu b/paddle/fluid/operators/temporal_shift_op.cu index 1d7aeec142ff0e5476bd979f2e213836754e6097..f8e642cdb897cca8b778a1d93ce14f9b3f19218d 100644 --- a/paddle/fluid/operators/temporal_shift_op.cu +++ b/paddle/fluid/operators/temporal_shift_op.cu @@ -179,13 +179,13 @@ class TemporalShiftOpCUDAKernel : public framework::OpKernel { grid = std::min(dev_ctx.GetSMCount() * blocks_per_sm, grid); if (data_layout == DataLayout::kNCHW) { - KeTemporalShiftFwNCHW< - T><<>>( - input_data, output_data, ntchw, tchw, chw, hw, t, c1, c2); + KeTemporalShiftFwNCHW + <<>>( + input_data, output_data, ntchw, tchw, chw, hw, t, c1, c2); } else { - KeTemporalShiftFwNHWC< - T><<>>( - input_data, output_data, ntchw, tchw, chw, t, c, c1, c2); + KeTemporalShiftFwNHWC + <<>>( + input_data, output_data, ntchw, tchw, chw, t, c, c1, c2); } } }; @@ -233,13 +233,15 @@ class TemporalShiftGradOpCUDAKernel : public framework::OpKernel { grid = std::min(dev_ctx.GetSMCount() * blocks_per_sm, grid); if (data_layout == DataLayout::kNCHW) { - KeTemporalShiftBwNCHW< - T><<>>( - output_grad_data, input_grad_data, ntchw, tchw, chw, hw, t, c1, c2); + KeTemporalShiftBwNCHW + <<>>( + output_grad_data, input_grad_data, ntchw, tchw, chw, hw, t, c1, + c2); } else { - KeTemporalShiftBwNHWC< - T><<>>( - output_grad_data, input_grad_data, ntchw, tchw, chw, t, c, c1, c2); + KeTemporalShiftBwNHWC + <<>>( + output_grad_data, input_grad_data, ntchw, tchw, chw, t, c, c1, + c2); } } }; diff --git a/paddle/fluid/operators/tensor_array_to_tensor_op.cc b/paddle/fluid/operators/tensor_array_to_tensor_op.cc index 95ae32fa2ea6fffa3ca1d5dfdbdba80c387ba385..41d1fc2356e4b5c1b80af006d3e5a78fc0ac751e 100644 --- a/paddle/fluid/operators/tensor_array_to_tensor_op.cc +++ b/paddle/fluid/operators/tensor_array_to_tensor_op.cc @@ -96,10 +96,11 @@ class LoDTensorArray2TensorOp : public framework::OperatorBase { *scope.FindVar(Output("OutIndex"))->GetMutable(); const size_t n = inx.size(); - PADDLE_ENFORCE_GT(n, 0, platform::errors::InvalidArgument( - "Input tensorarray size should > 0," - "but the received is %d", - n)); + PADDLE_ENFORCE_GT( + n, 0, + platform::errors::InvalidArgument("Input tensorarray size should > 0," + "but the received is %d", + n)); std::string base_name = Inputs("X")[0]; std::vector names; @@ -235,10 +236,11 @@ class LoDTensorArray2TensorGradOp : public framework::OperatorBase { auto &inx = scope.FindVar(Input("X"))->Get(); const size_t n = inx.size(); - PADDLE_ENFORCE_GT(n, 0, platform::errors::InvalidArgument( - "Input tensorarray size should > 0, " - "but the received is: %d. ", - n)); + PADDLE_ENFORCE_GT( + n, 0, + platform::errors::InvalidArgument("Input tensorarray size should > 0, " + "but the received is: %d. ", + n)); std::string base_name = Inputs("X")[0]; std::vector names; diff --git a/paddle/fluid/operators/tensor_formatter.cc b/paddle/fluid/operators/tensor_formatter.cc index ef46ee25156e5ed49eb5d21c91ea352b2eb00624..8f02bc870e2fb952117f0a45a412c38ac2ce71b5 100644 --- a/paddle/fluid/operators/tensor_formatter.cc +++ b/paddle/fluid/operators/tensor_formatter.cc @@ -15,6 +15,7 @@ #include "paddle/fluid/operators/tensor_formatter.h" #include + #include "paddle/fluid/framework/convert_utils.h" namespace paddle { diff --git a/paddle/fluid/operators/tensor_to_string.h b/paddle/fluid/operators/tensor_to_string.h index bd9e7f6219b4a73dade5d48a5de30c87051f6a2a..c1ca1dff9ffe706c40da645b0218aab8f59cca3d 100644 --- a/paddle/fluid/operators/tensor_to_string.h +++ b/paddle/fluid/operators/tensor_to_string.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/memory/memcpy.h" #include "paddle/fluid/platform/device_context.h" @@ -56,7 +57,7 @@ static std::vector ToVector(const framework::Tensor &src) { } template -static std::string FlattenToString(Args &&... args) { +static std::string FlattenToString(Args &&...args) { const auto &vec = ToVector(std::forward(args)...); return "[" + string::join_strings(vec, ',') + "]"; } diff --git a/paddle/fluid/operators/tensorrt/tensorrt_engine_op.h b/paddle/fluid/operators/tensorrt/tensorrt_engine_op.h index 0a71875d8931ef80846aa7e0c95ce1beab86fd7c..1e5ce6fa3e80c7171546ca84e76b4e05e6234e6a 100644 --- a/paddle/fluid/operators/tensorrt/tensorrt_engine_op.h +++ b/paddle/fluid/operators/tensorrt/tensorrt_engine_op.h @@ -52,9 +52,9 @@ namespace operators { using inference::Singleton; using inference::tensorrt::TensorRTEngine; -using inference::tensorrt::TRTInt8Calibrator; using inference::tensorrt::TRTCalibratorEngine; using inference::tensorrt::TRTCalibratorEngineManager; +using inference::tensorrt::TRTInt8Calibrator; static void RuntimeStaticShapeCheck(std::vector runtime_input_shape, std::vector model_input_shape) { @@ -111,10 +111,10 @@ static void RuntimeDynamicShapeCheck( // "TRT engine runtime input %s dims size(%d) inconsistent " // "with the dynamic shape size(%d)", // x, runtime_input_shape.size(), min_input_shape.size())); - auto is_input_shape_valid = [&]( - const std::vector &runtime_input_shape, - const std::vector &min_input_shape, - const std::vector &max_input_shape) -> bool { + auto is_input_shape_valid = + [&](const std::vector &runtime_input_shape, + const std::vector &min_input_shape, + const std::vector &max_input_shape) -> bool { for (size_t i = 0; i < runtime_input_shape.size(); i++) { if (runtime_input_shape[i] <= max_input_shape[i] && runtime_input_shape[i] >= min_input_shape[i]) { diff --git a/paddle/fluid/operators/tensorrt/tensorrt_engine_op_test.cc b/paddle/fluid/operators/tensorrt/tensorrt_engine_op_test.cc index 243ae757277a8e8ad413b79e4a320280ccc47dfc..c4278cfeb58c588a316e3ba932670e5b1e25f5c1 100644 --- a/paddle/fluid/operators/tensorrt/tensorrt_engine_op_test.cc +++ b/paddle/fluid/operators/tensorrt/tensorrt_engine_op_test.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/tensorrt/tensorrt_engine_op.h" + #include + #include "paddle/fluid/framework/block_desc.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/op_desc.h" diff --git a/paddle/fluid/operators/tile_op_npu.cc b/paddle/fluid/operators/tile_op_npu.cc index cea6b458aec782923722cb37fe41c1c4d59292e5..ee2d38fea7033f3f8b8f64afd4b3c3a82458463f 100644 --- a/paddle/fluid/operators/tile_op_npu.cc +++ b/paddle/fluid/operators/tile_op_npu.cc @@ -27,10 +27,11 @@ class TileNPUKernel : public framework::OpKernel { void Compute(const framework::ExecutionContext& context) const override { auto rank = context.Input("X")->dims().size(); PADDLE_ENFORCE_GE( - rank, 1, platform::errors::InvalidArgument( - "The rank of the input 'x' for tile op must be a positive " - "integer, but the value received is %d.", - rank)); + rank, 1, + platform::errors::InvalidArgument( + "The rank of the input 'x' for tile op must be a positive " + "integer, but the value received is %d.", + rank)); PADDLE_ENFORCE_LE( rank, MAX_RANK_SUPPORTED, platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/tile_op_xpu.cc b/paddle/fluid/operators/tile_op_xpu.cc index 598377587d6f73e0c21abbc4d3819d16eacb1f23..a0ce4a2bebeb718b9ea6fef0ef8d3b98bfe1adcd 100644 --- a/paddle/fluid/operators/tile_op_xpu.cc +++ b/paddle/fluid/operators/tile_op_xpu.cc @@ -25,10 +25,11 @@ class TileXPUKernel : public framework::OpKernel { void Compute(const framework::ExecutionContext& context) const override { auto rank = context.Input("X")->dims().size(); PADDLE_ENFORCE_GE( - rank, 1, platform::errors::InvalidArgument( - "The rank of the input 'x' for tile op must be a positive " - "integer, but the value received is %d.", - rank)); + rank, 1, + platform::errors::InvalidArgument( + "The rank of the input 'x' for tile op must be a positive " + "integer, but the value received is %d.", + rank)); PADDLE_ENFORCE_LE( rank, MAX_RANK_SUPPORTED, platform::errors::InvalidArgument( diff --git a/paddle/fluid/operators/top_k_function_cuda.h b/paddle/fluid/operators/top_k_function_cuda.h index 848ab1cb556e098b4df001ab9a9c751082dc72b9..a7981c86c450c4d1571538307eb391cfa48d6585 100644 --- a/paddle/fluid/operators/top_k_function_cuda.h +++ b/paddle/fluid/operators/top_k_function_cuda.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include #include #ifdef __NVCC__ diff --git a/paddle/fluid/operators/top_k_op.cc b/paddle/fluid/operators/top_k_op.cc index cce5ad2631733392fb08dffaba71d931bb0a6bcc..d8fc129588a0362e4e4f778d0a50a61e5a6f44f9 100644 --- a/paddle/fluid/operators/top_k_op.cc +++ b/paddle/fluid/operators/top_k_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/top_k_op.h" + #include namespace paddle { @@ -39,8 +40,9 @@ class TopkOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_GE(k, 1, platform::errors::InvalidArgument( "Attribute k must be >= 1, but got k is %d.", k)); - PADDLE_ENFORCE_GE(input_dims.size(), 1, platform::errors::InvalidArgument( - "input must have >= 1d shape")); + PADDLE_ENFORCE_GE( + input_dims.size(), 1, + platform::errors::InvalidArgument("input must have >= 1d shape")); if (ctx->IsRuntime()) { PADDLE_ENFORCE_GE( diff --git a/paddle/fluid/operators/top_k_op.cu b/paddle/fluid/operators/top_k_op.cu index 30a5a802a536031dad5844d79f727c642995789b..fc8f08ca4805a747f6a33aa757bf64fcd1320cbb 100644 --- a/paddle/fluid/operators/top_k_op.cu +++ b/paddle/fluid/operators/top_k_op.cu @@ -96,8 +96,8 @@ class TopkOpCUDAKernel : public framework::OpKernel { int gridx = input_height < kMaxHeight ? input_height : kMaxHeight; switch (GetDesiredBlockDim(input_width)) { FIXED_BLOCK_DIM( - KeMatrixTopK<<>>( + KeMatrixTopK + <<>>( output_data, k, indices_data, input_data, input_width, input_width, static_cast(k), gridx, input_height)); default: @@ -133,8 +133,8 @@ class TopkOpGradCUDAKernel : public framework::OpKernel { int gridx = row < kMaxHeight ? row : kMaxHeight; switch (GetDesiredBlockDim(col)) { FIXED_BLOCK_DIM( - AssignGrad<<>>( + AssignGrad + <<>>( x_grad_data, indices_data, out_grad_data, row, col, k)); default: PADDLE_THROW( diff --git a/paddle/fluid/operators/top_k_op.h b/paddle/fluid/operators/top_k_op.h index aad2f096a536edcc5566edb4080f517f0dfb096c..9d933eb5c47ed994e1caa6a7af6f89a73d0d43cb 100644 --- a/paddle/fluid/operators/top_k_op.h +++ b/paddle/fluid/operators/top_k_op.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/op_registry.h" diff --git a/paddle/fluid/operators/top_k_op_mlu.cc b/paddle/fluid/operators/top_k_op_mlu.cc index 102902bdaaaaf4a6a94699f561a5e91213be8c44..16b2ac9807e832da92c23371f257ebdde6dff57e 100644 --- a/paddle/fluid/operators/top_k_op_mlu.cc +++ b/paddle/fluid/operators/top_k_op_mlu.cc @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/top_k_op.h" #include "paddle/fluid/operators/mlu/mlu_baseop.h" +#include "paddle/fluid/operators/top_k_op.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/top_k_v2_op_npu.cc b/paddle/fluid/operators/top_k_v2_op_npu.cc index 04e4d88b008e0c293cf206c63badb12121cca30a..051cb9611bab1049d2064c8d754342bc294acff5 100644 --- a/paddle/fluid/operators/top_k_v2_op_npu.cc +++ b/paddle/fluid/operators/top_k_v2_op_npu.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" diff --git a/paddle/fluid/operators/trace_op.cc b/paddle/fluid/operators/trace_op.cc index c6c0fa3c0019eac742a9c70ea53a438f5a474895..36ad2d74869c66872e1fa39dff70c5032768d232 100644 --- a/paddle/fluid/operators/trace_op.cc +++ b/paddle/fluid/operators/trace_op.cc @@ -118,19 +118,16 @@ REGISTER_OPERATOR(trace_grad, ops::TraceGradOp, ops::TraceGradNoNeedBufferVarsInferer); /* ========================== register checkpoint ===========================*/ -REGISTER_OP_VERSION(trace) - .AddCheckpoint( - R"ROC(Upgrade trace add a new attribute [axis2])ROC", - paddle::framework::compatible::OpVersionDesc() - .NewAttr("axis1", - "The added attribute 'axis1' is not yet registered.", - std::vector{0.0f}) - .NewAttr("axis2", - "The added attribute 'axis2' is not yet registered.", - std::vector{1.0f}) - .DeleteAttr("dim1", - "The attribute 'dim1' is not recommend according to " - "the specification 2.0.") - .DeleteAttr("dim2", - "The attribute 'dim2' is not recommend according to " - "the specification 2.0.")); +REGISTER_OP_VERSION(trace).AddCheckpoint( + R"ROC(Upgrade trace add a new attribute [axis2])ROC", + paddle::framework::compatible::OpVersionDesc() + .NewAttr("axis1", "The added attribute 'axis1' is not yet registered.", + std::vector{0.0f}) + .NewAttr("axis2", "The added attribute 'axis2' is not yet registered.", + std::vector{1.0f}) + .DeleteAttr("dim1", + "The attribute 'dim1' is not recommend according to " + "the specification 2.0.") + .DeleteAttr("dim2", + "The attribute 'dim2' is not recommend according to " + "the specification 2.0.")); diff --git a/paddle/fluid/operators/transfer_layout_op.cc b/paddle/fluid/operators/transfer_layout_op.cc index f26bcdca4a7b316115aa0988eef4f9b861d5186f..3b55631900d30b8d17132121767f19cc0dea4bb5 100644 --- a/paddle/fluid/operators/transfer_layout_op.cc +++ b/paddle/fluid/operators/transfer_layout_op.cc @@ -146,7 +146,7 @@ REGISTER_OPERATOR( REGISTER_OP_CPU_KERNEL_FUNCTOR(transfer_layout, float, ops::TransferLayoutKernel); REGISTER_OP_VERSION(transfer_layout) - .AddCheckpoint( - R"ROC(refine transfer_layout, add src_layout attribute)ROC", - paddle::framework::compatible::OpVersionDesc().NewAttr( - "src_layout", "(int, the layout of the input tensor", -1)); + .AddCheckpoint(R"ROC(refine transfer_layout, add src_layout attribute)ROC", + paddle::framework::compatible::OpVersionDesc().NewAttr( + "src_layout", "(int, the layout of the input tensor", + -1)); diff --git a/paddle/fluid/operators/transpose_op.cc b/paddle/fluid/operators/transpose_op.cc index a45d32b34b9836fa411fa80237228cf759b3df4e..4eceb69e8ce45290a5546f9e50a7e2a954eca714 100644 --- a/paddle/fluid/operators/transpose_op.cc +++ b/paddle/fluid/operators/transpose_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/transpose_op.h" + #include #include #include diff --git a/paddle/fluid/operators/transpose_op.cu.h b/paddle/fluid/operators/transpose_op.cu.h index a31ac28c9910c0c36b28c98fd3d83476f002df7e..40a967b11f7a92a5237227c822784cfd2966ea09 100644 --- a/paddle/fluid/operators/transpose_op.cu.h +++ b/paddle/fluid/operators/transpose_op.cu.h @@ -96,12 +96,15 @@ __global__ void TilingSwapDim1And2(const T* __restrict__ input, Dim3 input_dims, int x = threadIdx.x; Dim3 output_dims = { - input_dims[0], input_dims[2], input_dims[1], + input_dims[0], + input_dims[2], + input_dims[1], }; // Align dim to Tiles Dim3 tile_aligned_input_dim = { - input_dims[0], (input_dims[1] + TileX - 1) / TileX, + input_dims[0], + (input_dims[1] + TileX - 1) / TileX, (input_dims[2] + TileY - 1) / TileY, }; @@ -111,7 +114,8 @@ __global__ void TilingSwapDim1And2(const T* __restrict__ input, Dim3 input_dims, // Compute real index align to tile:0, 32, 64... Index3 block_tile_index_in_input = { - input_block_tile_index[0], input_block_tile_index[1] * TileX, + input_block_tile_index[0], + input_block_tile_index[1] * TileX, input_block_tile_index[2] * TileY, }; @@ -165,12 +169,14 @@ __global__ void TilingSwapDim1And2(const T* __restrict__ input, Dim3 input_dims, // Store sm value back to out Index3 output_block_tile_index = { - input_block_tile_index[0], input_block_tile_index[2], + input_block_tile_index[0], + input_block_tile_index[2], input_block_tile_index[1], }; Index3 block_tile_index_in_output = { - output_block_tile_index[0], output_block_tile_index[1] * TileY, + output_block_tile_index[0], + output_block_tile_index[1] * TileY, output_block_tile_index[2] * TileX, }; @@ -265,15 +271,13 @@ void LaunchNarrowDims2TransposeKernel(const phi::GPUContext& d, int tile_size_i, T* output) { constexpr int NumThreads = tile_long; if (tile_size_i <= tile_long && tile_size_j <= tile_short) { - TilingSwapDim1And2< - T, NumThreads, tile_long, - tile_short><<>>( - input, input_dims, output); + TilingSwapDim1And2 + <<>>(input, input_dims, + output); } else { - TilingSwapDim1And2< - T, NumThreads, tile_short, - tile_long><<>>( - input, input_dims, output); + TilingSwapDim1And2 + <<>>(input, input_dims, + output); } } @@ -392,10 +396,10 @@ void SwapDim1And2InNarrow(const phi::GPUContext& d, const T* input, // data may not aligned to tile, so some threads wasted, we need // to find least wasted threads, which means we need to find tile // can split input properly, in another words: num_wasted_threads=0. - int num_wasted_threads = input_long_edge - - framework::CeilOrFloor( - input_long_edge, proposed_tile_long_edge) * - proposed_tile_long_edge; + int num_wasted_threads = + input_long_edge - framework::CeilOrFloor( + input_long_edge, proposed_tile_long_edge) * + proposed_tile_long_edge; int num_full_tiles = framework::CeilOrFloor( input_long_edge, proposed_tile_long_edge); @@ -499,10 +503,9 @@ void SendSwapDim1And2InTranspose(const phi::GPUContext& d, const T* input, int total_tiles_count = input_dims_aligned[0] * input_dims_aligned[1] * input_dims_aligned[2]; - TilingSwapDim1And2< - T, kNumThreads, kTileSize, - kTileSize><<>>( - input, input_dims, output); + TilingSwapDim1And2 + <<>>(input, input_dims, + output); } else if (narrow_tile) { // If input shape is like Rect, such as 2X100, use Narrow tile size. @@ -513,9 +516,9 @@ void SendSwapDim1And2InTranspose(const phi::GPUContext& d, const T* input, // If input shape is small, such as 8X8, just do simple copy int total_elements = input_dims[0] * input_dims[1] * input_dims[2]; auto config = phi::backends::gpu::GetGpuLaunchConfig1D(d, total_elements); - TransposeSimpleKernel<<< - config.block_per_grid.x, config.thread_per_block.x, 0, d.stream()>>>( - total_elements, input, input_dims, output); + TransposeSimpleKernel + <<>>( + total_elements, input, input_dims, output); } } @@ -543,9 +546,9 @@ struct SwapDim0And2InTranspose { size_t total_size = combined_dims[0] * combined_dims[1] * combined_dims[2]; auto config = phi::backends::gpu::GetGpuLaunchConfig1D(d, total_size); - TransposeSimpleKernel<<< - config.block_per_grid.x, config.thread_per_block.x, 0, d.stream()>>>( - total_size, in, input_dims, out); + TransposeSimpleKernel + <<>>( + total_size, in, input_dims, out); } }; diff --git a/paddle/fluid/operators/transpose_op.h b/paddle/fluid/operators/transpose_op.h index a9e4876cc82a44ef8e87049a199ce0b58a96f6ea..891aa312f69ffac834eb245d09e50887bcf84a41 100644 --- a/paddle/fluid/operators/transpose_op.h +++ b/paddle/fluid/operators/transpose_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/transpose_op_mlu.cc b/paddle/fluid/operators/transpose_op_mlu.cc index 40cb22bab50ec0de5cc0fb9a2c6953637a238599..38f6114e48d3f5deb46d71016accf1b0932274d4 100644 --- a/paddle/fluid/operators/transpose_op_mlu.cc +++ b/paddle/fluid/operators/transpose_op_mlu.cc @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/transpose_op.h" #include "paddle/fluid/operators/mlu/mlu_baseop.h" +#include "paddle/fluid/operators/transpose_op.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/transpose_op_xpu.cc b/paddle/fluid/operators/transpose_op_xpu.cc index 00a43c74d873663f651c6c1930175292f00ed72a..32b303238ab816ddcb773651cc127de579b8c494 100644 --- a/paddle/fluid/operators/transpose_op_xpu.cc +++ b/paddle/fluid/operators/transpose_op_xpu.cc @@ -13,10 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. */ #ifdef PADDLE_WITH_XPU -#include "paddle/fluid/operators/transpose_op.h" #include #include #include + +#include "paddle/fluid/operators/transpose_op.h" #include "paddle/fluid/platform/device/xpu/xpu_header.h" namespace paddle { diff --git a/paddle/fluid/operators/tree_conv_op.h b/paddle/fluid/operators/tree_conv_op.h index afe5379dc3f2a4465429ca8db708d18f26664dad..8c479076175dd1b2ae52b17cfab76605854063c4 100644 --- a/paddle/fluid/operators/tree_conv_op.h +++ b/paddle/fluid/operators/tree_conv_op.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/math/tree2col.h" #include "paddle/phi/kernels/funcs/blas/blas.h" diff --git a/paddle/fluid/operators/tril_indices_op.cc b/paddle/fluid/operators/tril_indices_op.cc index be42f53dd23440001bf617140dd07b5b7c3110c9..63b5c1a2431ced35ef9cb2a656bcf054cb241aa3 100644 --- a/paddle/fluid/operators/tril_indices_op.cc +++ b/paddle/fluid/operators/tril_indices_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/tril_triu_op.cc b/paddle/fluid/operators/tril_triu_op.cc index b941fa3d03ae12928ab85486f1dabb54f3b514f4..8ca83ed881099e98b3f64f9e5cbefea0236d7b74 100644 --- a/paddle/fluid/operators/tril_triu_op.cc +++ b/paddle/fluid/operators/tril_triu_op.cc @@ -13,9 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" - #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/infermeta/unary.h" diff --git a/paddle/fluid/operators/truncated_gaussian_random_op.cc b/paddle/fluid/operators/truncated_gaussian_random_op.cc index dc5a66dce16d698f9cfac01e3bdc776d08c2af19..21e2061e73b6c40aebd4141342463d4ffeafb68a 100644 --- a/paddle/fluid/operators/truncated_gaussian_random_op.cc +++ b/paddle/fluid/operators/truncated_gaussian_random_op.cc @@ -12,6 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/operators/truncated_gaussian_random_op.h" + #include #include #include @@ -19,7 +21,6 @@ limitations under the License. */ #include "paddle/fluid/framework/generator.h" #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" -#include "paddle/fluid/operators/truncated_gaussian_random_op.h" #include "paddle/phi/infermeta/nullary.h" namespace paddle { diff --git a/paddle/fluid/operators/truncated_gaussian_random_op_npu.cc b/paddle/fluid/operators/truncated_gaussian_random_op_npu.cc index 261d9cee2d5cd25c510aacb280b9623f985eb1f7..363d909d84dcf7e6e4a2ed2bb718c1ebb2fab0f1 100644 --- a/paddle/fluid/operators/truncated_gaussian_random_op_npu.cc +++ b/paddle/fluid/operators/truncated_gaussian_random_op_npu.cc @@ -12,10 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/truncated_gaussian_random_op.h" #include #include + #include "paddle/fluid/framework/convert_utils.h" +#include "paddle/fluid/operators/truncated_gaussian_random_op.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h" namespace paddle { diff --git a/paddle/fluid/operators/truncated_gaussian_random_op_xpu.cc b/paddle/fluid/operators/truncated_gaussian_random_op_xpu.cc index 803b61fbe813f85f48b71d1de7fc41eb26e4b8da..45a4b6a3bab7e0bed266216e4356ea1452965116 100644 --- a/paddle/fluid/operators/truncated_gaussian_random_op_xpu.cc +++ b/paddle/fluid/operators/truncated_gaussian_random_op_xpu.cc @@ -14,11 +14,12 @@ limitations under the License. */ #ifdef PADDLE_WITH_XPU -#include "paddle/fluid/operators/truncated_gaussian_random_op.h" #include #include + #include "paddle/fluid/framework/generator.h" #include "paddle/fluid/framework/op_registry.h" +#include "paddle/fluid/operators/truncated_gaussian_random_op.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/unbind_op.cc b/paddle/fluid/operators/unbind_op.cc index f2fc08308c6b32868adc8057c9bc2a92c4247c60..739fc98f3f086bf2b647a33ba1946e5cb492aeb1 100644 --- a/paddle/fluid/operators/unbind_op.cc +++ b/paddle/fluid/operators/unbind_op.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/unbind_op.h" + #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/phi/core/infermeta_utils.h" #include "paddle/phi/infermeta/unary.h" diff --git a/paddle/fluid/operators/unbind_op.h b/paddle/fluid/operators/unbind_op.h index 6e35f262de420744b5299fbf1ab540e34c711d92..8e6cd391578c768cf51b8817e727c0e7b48a5d48 100644 --- a/paddle/fluid/operators/unbind_op.h +++ b/paddle/fluid/operators/unbind_op.h @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/math/concat_and_split.h" #include "paddle/fluid/operators/strided_memcpy.h" diff --git a/paddle/fluid/operators/uniform_random_op.h b/paddle/fluid/operators/uniform_random_op.h index 3e27402c86947974a247f89a23c2ea43a3eefd61..a988c6843893c527b60c29c31b8d561fc22915e6 100644 --- a/paddle/fluid/operators/uniform_random_op.h +++ b/paddle/fluid/operators/uniform_random_op.h @@ -16,10 +16,12 @@ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" #if defined(__NVCC__) || defined(__HIPCC__) #include + #include "paddle/fluid/framework/generator.h" #include "paddle/phi/kernels/full_kernel.h" #include "paddle/phi/kernels/funcs/distribution_helper.h" @@ -102,8 +104,9 @@ inline std::vector GetNewDataFromShapeTensorList( "Expected dtype of ShapeTensorList of %d-th must be int32, int64. " "But got " "unsupport dtype: %s.", - i, paddle::framework::DataTypeToString( - framework::TransToProtoVarType(tensor->dtype())))); + i, + paddle::framework::DataTypeToString( + framework::TransToProtoVarType(tensor->dtype())))); } } diff --git a/paddle/fluid/operators/uniform_random_op_mlu.cc b/paddle/fluid/operators/uniform_random_op_mlu.cc index 2c5f13f5a930788651c2e287febab7ad06aefd20..fdf1252eb0ded0dd1d1227df7c701d227400b434 100644 --- a/paddle/fluid/operators/uniform_random_op_mlu.cc +++ b/paddle/fluid/operators/uniform_random_op_mlu.cc @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/operators/uniform_random_op.h" #include "paddle/fluid/framework/generator.h" #include "paddle/fluid/operators/mlu/mlu_baseop.h" +#include "paddle/fluid/operators/uniform_random_op.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/uniform_random_op_xpu.cc b/paddle/fluid/operators/uniform_random_op_xpu.cc index ae2adf834194daf5c3d9b47dc9ac618b815833de..23d0f61c2bd1daea9d29b560b30fe314e3b77608 100644 --- a/paddle/fluid/operators/uniform_random_op_xpu.cc +++ b/paddle/fluid/operators/uniform_random_op_xpu.cc @@ -14,11 +14,12 @@ limitations under the License. */ #ifdef PADDLE_WITH_XPU -#include "paddle/fluid/operators/uniform_random_op.h" #include + #include "paddle/fluid/framework/generator.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" +#include "paddle/fluid/operators/uniform_random_op.h" namespace paddle { namespace operators { diff --git a/paddle/fluid/operators/unique_consecutive_op.cc b/paddle/fluid/operators/unique_consecutive_op.cc index 24ef3a85ee2cecddeb02cfe6ccc1a93f33754fa4..567f7bac34be7e22875e95c6ef80524cad9c705b 100644 --- a/paddle/fluid/operators/unique_consecutive_op.cc +++ b/paddle/fluid/operators/unique_consecutive_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/unique_consecutive_op.h" + #include "paddle/fluid/framework/op_version_registry.h" namespace paddle { diff --git a/paddle/fluid/operators/unique_consecutive_op.cu b/paddle/fluid/operators/unique_consecutive_op.cu index fbffb01ed19b6f03c45f6cdf3479728e32abc336..9db14e82b25b113924dd3827e9dea75f1f8d7e6e 100644 --- a/paddle/fluid/operators/unique_consecutive_op.cu +++ b/paddle/fluid/operators/unique_consecutive_op.cu @@ -18,8 +18,10 @@ limitations under the License. */ #include #include #include + #include #include + #include "paddle/fluid/framework/tensor_util.h" // TensorToVector() #include "paddle/fluid/operators/unique_consecutive_op.h" // TransComute() diff --git a/paddle/fluid/operators/unique_consecutive_op.h b/paddle/fluid/operators/unique_consecutive_op.h index b31c2aa67a587b6fd939adf42ec2290689abf2bc..4dc1871b5d1406e19e1fa7d63a4daf639e0fae97 100644 --- a/paddle/fluid/operators/unique_consecutive_op.h +++ b/paddle/fluid/operators/unique_consecutive_op.h @@ -20,6 +20,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/math/concat_and_split.h" #include "paddle/fluid/operators/transpose_op.h" diff --git a/paddle/fluid/operators/unique_op.cc b/paddle/fluid/operators/unique_op.cc index 5c103e088b5594e2d8ae245af679b8be2f8dd336..fbbd562c1b8a2a0c964103265cc6277d0b2a7e5a 100644 --- a/paddle/fluid/operators/unique_op.cc +++ b/paddle/fluid/operators/unique_op.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/unique_op.h" + #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/fluid/operators/unique_op.h b/paddle/fluid/operators/unique_op.h index 01439d2182464c115a39cc53a6468b45fc7e03a0..d59e6590a88f372aa4bebf0dcc308767c23975d9 100644 --- a/paddle/fluid/operators/unique_op.h +++ b/paddle/fluid/operators/unique_op.h @@ -20,6 +20,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/math/concat_and_split.h" #include "paddle/fluid/operators/transpose_op.h" diff --git a/paddle/fluid/operators/unique_with_counts_op.h b/paddle/fluid/operators/unique_with_counts_op.h index af8bfe813a6b0ed01bd468d7eb177ccdf283c80e..227fdef222432c120c3d23b19237be87a9a4ee86 100644 --- a/paddle/fluid/operators/unique_with_counts_op.h +++ b/paddle/fluid/operators/unique_with_counts_op.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/unique_op.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/unpool_op.cc b/paddle/fluid/operators/unpool_op.cc index 36e9d894541b09ba08aeacaf281cf0c336cbda0e..b18c4e4de4475e2eab8d58441ce133e41ef886a7 100644 --- a/paddle/fluid/operators/unpool_op.cc +++ b/paddle/fluid/operators/unpool_op.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/unpool_op.h" + #include #include #include diff --git a/paddle/fluid/operators/unpool_op.h b/paddle/fluid/operators/unpool_op.h index 35aeb4e0d610ec7d6e3fda90e63151d73dad2bd5..062008f95ea3ca29d3bd88759840e33dfc683961 100644 --- a/paddle/fluid/operators/unpool_op.h +++ b/paddle/fluid/operators/unpool_op.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/math/unpooling.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/operators/unsqueeze_op.cc b/paddle/fluid/operators/unsqueeze_op.cc index 445e8cd468bf3d55215fb4e756a849500a3fbb2d..82edcd5a9fcf726fcf320efcc80e37d40da3fcce 100644 --- a/paddle/fluid/operators/unsqueeze_op.cc +++ b/paddle/fluid/operators/unsqueeze_op.cc @@ -101,9 +101,10 @@ class UnsqueezeOp : public framework::OperatorWithKernel { for (int axis : unsqz_dims) { int cur = axis < 0 ? axis + cur_output_size + 1 : axis; // Vaildity Check: the axis bound - PADDLE_ENFORCE_GE(cur, 0, platform::errors::InvalidArgument( - "The insert dimension value should " - "not be less than 0")); + PADDLE_ENFORCE_GE( + cur, 0, + platform::errors::InvalidArgument("The insert dimension value should " + "not be less than 0")); PADDLE_ENFORCE_LE(cur, cur_output_size, platform::errors::InvalidArgument( "The insert dimension value shoud not be larger " diff --git a/paddle/fluid/operators/unsqueeze_op.h b/paddle/fluid/operators/unsqueeze_op.h index f6112fb59c12252255861825ff9d7b534c542665..86038aced3846a89353b223d28f9cd50ba7f7d12 100644 --- a/paddle/fluid/operators/unsqueeze_op.h +++ b/paddle/fluid/operators/unsqueeze_op.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/utils.h" #include "paddle/fluid/platform/device_context.h" @@ -72,9 +73,10 @@ class UnsqueezeKernel : public framework::OpKernel { for (int axis : unsqz_dims) { int cur = axis < 0 ? axis + cur_output_size + 1 : axis; // Vaildity Check: the axis bound - PADDLE_ENFORCE_GE(cur, 0, platform::errors::InvalidArgument( - "The insert dimension value should " - "not be less than 0")); + PADDLE_ENFORCE_GE( + cur, 0, + platform::errors::InvalidArgument("The insert dimension value should " + "not be less than 0")); PADDLE_ENFORCE_LE(cur, cur_output_size, platform::errors::InvalidArgument( "The insert dimension value shoule not be larger " diff --git a/paddle/fluid/operators/unstack_op.cc b/paddle/fluid/operators/unstack_op.cc index 8c8684bf4b0350e761a53cf5fb1c6a0c6b1f5174..df2325f5dc523b0e01daec7777af25f303aade1d 100644 --- a/paddle/fluid/operators/unstack_op.cc +++ b/paddle/fluid/operators/unstack_op.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/for_range.h" diff --git a/paddle/fluid/operators/utils.h b/paddle/fluid/operators/utils.h index d84f7b165fd99e0f0661835e1195d30af00249df..009e883ccb64256b235146df29ac6d6e8adfc242 100644 --- a/paddle/fluid/operators/utils.h +++ b/paddle/fluid/operators/utils.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include #include diff --git a/paddle/fluid/operators/var_conv_2d_op.cc b/paddle/fluid/operators/var_conv_2d_op.cc index 3dffa0be2e28a9c69eeca0f7e2264ee26826e14e..977cd99984ca0388d301bc48fb64fcd494e260ea 100644 --- a/paddle/fluid/operators/var_conv_2d_op.cc +++ b/paddle/fluid/operators/var_conv_2d_op.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/operators/var_conv_2d_op.h" + #include #include + #include "paddle/fluid/platform/dynload/mklml.h" #include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/fluid/platform/aligned_vector.h b/paddle/fluid/platform/aligned_vector.h index 6d48917ba1f6d64c01a1d3b02f1572f595ec1d0d..b42ae15405e7ff0cb8d24fa7bf14aac442c16163 100644 --- a/paddle/fluid/platform/aligned_vector.h +++ b/paddle/fluid/platform/aligned_vector.h @@ -43,11 +43,11 @@ HOSTDEVICE inline void Store(const AlignedVector& vec, T* addr) { } /* -* Only the address of input data is the multiplier of 1,2,4, vectorized load -* with corresponding multiplier-value is possible. Moreover, the maximum length -* of vectorized load is 128 bits once. Hence, valid length of vectorized load -* shall be determined under both former constraints. -*/ + * Only the address of input data is the multiplier of 1,2,4, vectorized load + * with corresponding multiplier-value is possible. Moreover, the maximum length + * of vectorized load is 128 bits once. Hence, valid length of vectorized load + * shall be determined under both former constraints. + */ template int GetVectorizedSize(const T* pointer) { constexpr int max_load_bits = 128; @@ -58,11 +58,11 @@ int GetVectorizedSize(const T* pointer) { constexpr int vec2 = std::alignment_of>::value; // NOLINT if (address % vec8 == 0) { /* - * Currently, decide to deal with no more than 4 data once while adopting - * vectorization load/store, if performance test shows that dealing with - * 8 data once in vectorization load/store does get optimized, return code - * below can be changed into " return std::min(8, valid_vec_size); " . - */ + * Currently, decide to deal with no more than 4 data once while adopting + * vectorization load/store, if performance test shows that dealing with + * 8 data once in vectorization load/store does get optimized, return code + * below can be changed into " return std::min(8, valid_vec_size); " . + */ return std::min(4, valid_vec_size); } else if (address % vec4 == 0) { return std::min(4, valid_vec_size); diff --git a/paddle/fluid/platform/bfloat16_test.cc b/paddle/fluid/platform/bfloat16_test.cc index 794c1ff684c8dc8f87e1ea8f1980e88233063987..f824716ab922466dacd7cc44467169890f1cb443 100644 --- a/paddle/fluid/platform/bfloat16_test.cc +++ b/paddle/fluid/platform/bfloat16_test.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/bfloat16.h" + #include "paddle/phi/kernels/funcs/eigen/extensions.h" #define GLOG_NO_ABBREVIATED_SEVERITIES // msvc conflict logging with windows.h diff --git a/paddle/fluid/platform/bfloat16_test.cu b/paddle/fluid/platform/bfloat16_test.cu index 391b91487fa8ac3d00c85b089c4b86c4fbafcaba..c5f38cf94eedb42f029a8a3022b0bb9783736ba1 100644 --- a/paddle/fluid/platform/bfloat16_test.cu +++ b/paddle/fluid/platform/bfloat16_test.cu @@ -17,7 +17,9 @@ limitations under the License. */ #define GLOG_NO_ABBREVIATED_SEVERITIES // msvc conflict logging with windows.h #include #include + #include + #include "paddle/fluid/framework/lod_tensor.h" #if defined(PADDLE_CUDA_BF16) diff --git a/paddle/fluid/platform/collective_helper.cc b/paddle/fluid/platform/collective_helper.cc index d05de900e5e77fdeabd22aa1b6ec1571c84480b0..8f0e4204772f86741415018843980ef3198070be 100644 --- a/paddle/fluid/platform/collective_helper.cc +++ b/paddle/fluid/platform/collective_helper.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/platform/collective_helper.h" + #include #include "paddle/fluid/memory/allocation/allocator_facade.h" diff --git a/paddle/fluid/platform/complex_test.cc b/paddle/fluid/platform/complex_test.cc index c7ded7587172ec20cccd85c8a1c2f6943491415f..3547631064d39c793517d4433ec094e8a11ba0a0 100644 --- a/paddle/fluid/platform/complex_test.cc +++ b/paddle/fluid/platform/complex_test.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/platform/complex.h" + #include + #include "paddle/phi/kernels/funcs/eigen/extensions.h" #define GLOG_NO_ABBREVIATED_SEVERITIES // msvc conflict logging with windows.h diff --git a/paddle/fluid/platform/complex_test.cu b/paddle/fluid/platform/complex_test.cu index 08ec75878b82729d1b8daa4c9fabc8e35859946e..b814bcde6841fe6beabc0aad32b7402c7994fb76 100644 --- a/paddle/fluid/platform/complex_test.cu +++ b/paddle/fluid/platform/complex_test.cu @@ -18,6 +18,7 @@ #include #include #include + #include #include diff --git a/paddle/fluid/platform/cpu_info.cc b/paddle/fluid/platform/cpu_info.cc index e4860444865719ede3eb7fb388fbf734ecf284e6..c32af3b37a409e51069d18b37d055701581895fe 100644 --- a/paddle/fluid/platform/cpu_info.cc +++ b/paddle/fluid/platform/cpu_info.cc @@ -31,6 +31,7 @@ limitations under the License. */ #endif // _WIN32 #include + #include "paddle/fluid/platform/flags.h" DECLARE_double(fraction_of_cpu_memory_to_use); diff --git a/paddle/fluid/platform/cuda_graph_with_memory_pool.cc b/paddle/fluid/platform/cuda_graph_with_memory_pool.cc index c40a43dbfb876c0ee997580dd128bff19c0aac45..4ef2a9709a59d52ef644d53c29690508d4c7c0d4 100644 --- a/paddle/fluid/platform/cuda_graph_with_memory_pool.cc +++ b/paddle/fluid/platform/cuda_graph_with_memory_pool.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/platform/cuda_graph_with_memory_pool.h" + #include "paddle/fluid/memory/allocation/allocator_facade.h" #include "paddle/fluid/platform/device_context.h" diff --git a/paddle/fluid/platform/cuda_graph_with_memory_pool.h b/paddle/fluid/platform/cuda_graph_with_memory_pool.h index 81b68a5c6786eaa45f930fe1c12e7a1c13f3dcd3..b8831126be052cf727ccb40c676ab41ea91ff69b 100644 --- a/paddle/fluid/platform/cuda_graph_with_memory_pool.h +++ b/paddle/fluid/platform/cuda_graph_with_memory_pool.h @@ -24,10 +24,9 @@ namespace paddle { namespace platform { #ifdef PADDLE_WITH_CUDA -#define PD_RECORD_CUDA_GRAPH_RANDOM_KERNEL(__cond, __kernel_func, __grid, \ - __block, __sm_size, __stream, \ - __seed_inc, __seed_expr, \ - __offset_expr, ...) \ +#define PD_RECORD_CUDA_GRAPH_RANDOM_KERNEL( \ + __cond, __kernel_func, __grid, __block, __sm_size, __stream, __seed_inc, \ + __seed_expr, __offset_expr, ...) \ do { \ if (::paddle::platform::CUDAGraph::IsThisThreadCapturing() && (__cond)) { \ using __Helper = \ @@ -36,9 +35,9 @@ namespace platform { auto *dev_ctx = \ ::paddle::platform::DeviceContextPool::Instance().GetByPlace( \ ::paddle::platform::CUDAGraph::CapturingPlace()); \ - auto __set_seed_func = [=]( \ - ::paddle::platform::CUDAKernelParams *__params, \ - bool __check_only) -> bool { \ + auto __set_seed_func = \ + [=](::paddle::platform::CUDAKernelParams *__params, \ + bool __check_only) -> bool { \ if (__check_only) { \ return __params->func() == &__kernel_func && \ __Helper::Compare(*__params, __VA_ARGS__); \ @@ -56,12 +55,11 @@ namespace platform { __kernel_func<<<__grid, __block, __sm_size, __stream>>>(__VA_ARGS__); \ } while (0) #else -#define PD_RECORD_CUDA_GRAPH_RANDOM_KERNEL(__cond, __kernel_func, __grid, \ - __block, __sm_size, __stream, \ - __seed_inc, __seed_expr, \ - __offset_expr, ...) \ - do { \ - __kernel_func<<<__grid, __block, __sm_size, __stream>>>(__VA_ARGS__); \ +#define PD_RECORD_CUDA_GRAPH_RANDOM_KERNEL( \ + __cond, __kernel_func, __grid, __block, __sm_size, __stream, __seed_inc, \ + __seed_expr, __offset_expr, ...) \ + do { \ + __kernel_func<<<__grid, __block, __sm_size, __stream>>>(__VA_ARGS__); \ } while (0) #endif diff --git a/paddle/fluid/platform/denormal.cc b/paddle/fluid/platform/denormal.cc index 4af156d1577dd9ad538af586710a86ed647d9e7c..4cfb082544322d47749a748fed19af44743e1826 100644 --- a/paddle/fluid/platform/denormal.cc +++ b/paddle/fluid/platform/denormal.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/platform/denormal.h" + #include #include diff --git a/paddle/fluid/platform/device/gpu/cuda/cuda_graph.cc b/paddle/fluid/platform/device/gpu/cuda/cuda_graph.cc index ae6d90510f480433fba6069e8ca57b4b2d54fe3b..c5a515ce4361195a8c0992a569fed1725d1e6817 100644 --- a/paddle/fluid/platform/device/gpu/cuda/cuda_graph.cc +++ b/paddle/fluid/platform/device/gpu/cuda/cuda_graph.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/platform/device/gpu/cuda/cuda_graph.h" + #include #include #include diff --git a/paddle/fluid/platform/device/gpu/cuda/cuda_graph.h b/paddle/fluid/platform/device/gpu/cuda/cuda_graph.h index 083478ed7e65996fabf171217e5f6ad9ded9b603..b3704fc628adcf1ba85ec7e2db0b6a61eae7d0eb 100644 --- a/paddle/fluid/platform/device/gpu/cuda/cuda_graph.h +++ b/paddle/fluid/platform/device/gpu/cuda/cuda_graph.h @@ -20,10 +20,10 @@ #include #include #include + #include "cuda.h" // NOLINT #include "cuda_runtime.h" // NOLINT #include "paddle/fluid/platform/device/gpu/gpu_types.h" - #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/macros.h" #include "paddle/fluid/platform/place.h" diff --git a/paddle/fluid/platform/device/gpu/cuda/cuda_helper.h b/paddle/fluid/platform/device/gpu/cuda/cuda_helper.h index a32db3a9921e3db0f9eee933b9f98264050d695b..7185d2356aae5afbd798cf083df1e4c69d69731d 100644 --- a/paddle/fluid/platform/device/gpu/cuda/cuda_helper.h +++ b/paddle/fluid/platform/device/gpu/cuda/cuda_helper.h @@ -68,7 +68,7 @@ namespace platform { * } * } * -*/ + */ #define CUDA_KERNEL_LOOP_TYPE(i, num, index_type) \ int64_t __index__ = blockIdx.x * blockDim.x + threadIdx.x; \ diff --git a/paddle/fluid/platform/device/gpu/cuda/cudnn_helper_test.cc b/paddle/fluid/platform/device/gpu/cuda/cudnn_helper_test.cc index 851d0d18c604cdc593c00fd1463d7f87d7c8dcfc..86c72769eb56efd5790afa215d314c558d285fda 100644 --- a/paddle/fluid/platform/device/gpu/cuda/cudnn_helper_test.cc +++ b/paddle/fluid/platform/device/gpu/cuda/cudnn_helper_test.cc @@ -15,13 +15,13 @@ limitations under the License. */ #define GLOG_NO_ABBREVIATED_SEVERITIES #define GOOGLE_GLOG_DLL_DECL -#include "paddle/fluid/platform/device/gpu/gpu_dnn.h" - #include +#include "paddle/fluid/platform/device/gpu/gpu_dnn.h" + TEST(CudnnHelper, ScopedTensorDescriptor) { - using paddle::platform::ScopedTensorDescriptor; using paddle::platform::DataLayout; + using paddle::platform::ScopedTensorDescriptor; ScopedTensorDescriptor tensor_desc; std::vector shape = {2, 4, 6, 6}; @@ -65,8 +65,8 @@ TEST(CudnnHelper, ScopedTensorDescriptor) { } TEST(CudnnHelper, ScopedFilterDescriptor) { - using paddle::platform::ScopedFilterDescriptor; using paddle::platform::DataLayout; + using paddle::platform::ScopedFilterDescriptor; ScopedFilterDescriptor filter_desc; std::vector shape = {2, 3, 3}; @@ -129,8 +129,8 @@ TEST(CudnnHelper, ScopedConvolutionDescriptor) { } TEST(CudnnHelper, ScopedPoolingDescriptor) { - using paddle::platform::ScopedPoolingDescriptor; using paddle::platform::PoolingMode; + using paddle::platform::ScopedPoolingDescriptor; ScopedPoolingDescriptor pool_desc; std::vector src_kernel = {2, 2, 5}; diff --git a/paddle/fluid/platform/device/gpu/cuda_helper_test.cu b/paddle/fluid/platform/device/gpu/cuda_helper_test.cu index ab8bb2cad8c512d442d80a5ca89dad1dce853cf6..28c0e0ef9acf86e7fd1ba102b30cb001b3aa0090 100644 --- a/paddle/fluid/platform/device/gpu/cuda_helper_test.cu +++ b/paddle/fluid/platform/device/gpu/cuda_helper_test.cu @@ -13,6 +13,7 @@ // limitations under the License. #include + #include #include #ifdef _WIN32 @@ -22,13 +23,12 @@ #define PADDLE_CUDA_FP16 #include "paddle/fluid/platform/device/gpu/gpu_device_function.h" +#include "paddle/fluid/platform/device/gpu/gpu_helper.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" #include "paddle/fluid/platform/float16.h" -#include "paddle/fluid/platform/device/gpu/gpu_helper.h" - -using paddle::platform::PADDLE_CUDA_NUM_THREADS; using paddle::platform::float16; +using paddle::platform::PADDLE_CUDA_NUM_THREADS; template __global__ void AddKernel(const T* data_a, T* data_b, size_t num) { diff --git a/paddle/fluid/platform/device/gpu/cudnn_desc_test.cc b/paddle/fluid/platform/device/gpu/cudnn_desc_test.cc index 8ea30027e8adeda56657eb441b414c616b223849..2e58e71cc2c0612a21df6b6c7d2e6f450829a79f 100644 --- a/paddle/fluid/platform/device/gpu/cudnn_desc_test.cc +++ b/paddle/fluid/platform/device/gpu/cudnn_desc_test.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/fluid/platform/device/gpu/gpu_dnn.h" - #include +#include "paddle/fluid/platform/device/gpu/gpu_dnn.h" + namespace paddle { namespace platform { diff --git a/paddle/fluid/platform/device/gpu/gpu_info.cc b/paddle/fluid/platform/device/gpu/gpu_info.cc index 8c04e935134c7c5002f8b5626553d26f7f1194b5..6b302d2449da57bf4a942d9051e828651325770b 100644 --- a/paddle/fluid/platform/device/gpu/gpu_info.cc +++ b/paddle/fluid/platform/device/gpu/gpu_info.cc @@ -19,6 +19,7 @@ limitations under the License. */ #include #include #include + #include "gflags/gflags.h" #include "paddle/fluid/memory/memory.h" #include "paddle/fluid/platform/cuda_device_guard.h" @@ -100,8 +101,9 @@ static size_t GpuAllocSize(bool realloc) { size_t flag_mb = realloc ? FLAGS_reallocate_gpu_memory_in_mb : FLAGS_initial_gpu_memory_in_mb; size_t alloc_bytes = - (flag_mb > 0ul ? flag_mb << 20 : available_to_alloc * - FLAGS_fraction_of_gpu_memory_to_use); + (flag_mb > 0ul + ? flag_mb << 20 + : available_to_alloc * FLAGS_fraction_of_gpu_memory_to_use); PADDLE_ENFORCE_GE( available_to_alloc, alloc_bytes, platform::errors::ResourceExhausted("Not enough available GPU memory.")); diff --git a/paddle/fluid/platform/device/gpu/gpu_info.h b/paddle/fluid/platform/device/gpu/gpu_info.h index 94b47cca948e66c7e0b6af72aed7c54fa2a5fa9b..3a97797c98260a65a6d6f2495f7203f3f9c7fdc4 100644 --- a/paddle/fluid/platform/device/gpu/gpu_info.h +++ b/paddle/fluid/platform/device/gpu/gpu_info.h @@ -14,6 +14,7 @@ limitations under the License. */ #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) #include + #include #include #include diff --git a/paddle/fluid/platform/device/gpu/gpu_launch_config.h b/paddle/fluid/platform/device/gpu/gpu_launch_config.h index 80d60ca95bf6fb37e37f835602d2bdea8e38f2e4..5cacdfcb12f03cbdcafcf689f9c258325688eda9 100644 --- a/paddle/fluid/platform/device/gpu/gpu_launch_config.h +++ b/paddle/fluid/platform/device/gpu/gpu_launch_config.h @@ -25,9 +25,11 @@ #endif #include + #include #include #include + #include "paddle/fluid/platform/device_context.h" #ifdef __HIPCC__ @@ -93,9 +95,9 @@ struct GpuLaunchConfig { }; /* According to NVIDIA, if number of threads per block is 64/128/256/512, - * cuda performs better. And number of blocks should be greater (at least - * 2x~4x) than number of SMs. Hence, SM count is took into account within - * this function to determine the right number of threads per block. */ + * cuda performs better. And number of blocks should be greater (at least + * 2x~4x) than number of SMs. Hence, SM count is took into account within + * this function to determine the right number of threads per block. */ inline GpuLaunchConfig GetGpuLaunchConfig1D( const platform::CUDADeviceContext& context, int64_t numel, int vec_size = 1) { @@ -143,14 +145,16 @@ inline GpuLaunchConfig GetGpuLaunchConfig1D( inline GpuLaunchConfig GetGpuLaunchConfig2D( const platform::CUDADeviceContext& context, int x_dim, int y_dim) { - PADDLE_ENFORCE_GT(x_dim, 0, platform::errors::InvalidArgument( - "x dim number should greater than 0," - " but received value is: %d", - x_dim)); - PADDLE_ENFORCE_GT(y_dim, 0, platform::errors::InvalidArgument( - "y dim number should greater than 0," - " but received value is: %d", - y_dim)); + PADDLE_ENFORCE_GT( + x_dim, 0, + platform::errors::InvalidArgument("x dim number should greater than 0," + " but received value is: %d", + x_dim)); + PADDLE_ENFORCE_GT( + y_dim, 0, + platform::errors::InvalidArgument("y dim number should greater than 0," + " but received value is: %d", + y_dim)); const int kThreadsPerBlock = 256; int block_cols = (std::min)(x_dim, kThreadsPerBlock); diff --git a/paddle/fluid/platform/device/gpu/gpu_primitives.h b/paddle/fluid/platform/device/gpu/gpu_primitives.h index 803674779e756f000005d106f950659ea765c5ce..a0e9d459721fd70eb36250ff661a6fa09c77820b 100644 --- a/paddle/fluid/platform/device/gpu/gpu_primitives.h +++ b/paddle/fluid/platform/device/gpu/gpu_primitives.h @@ -20,6 +20,7 @@ limitations under the License. */ #include #endif #include + #include "paddle/fluid/platform/bfloat16.h" #include "paddle/fluid/platform/complex.h" #include "paddle/fluid/platform/float16.h" diff --git a/paddle/fluid/platform/device/gpu/gpu_resource_pool.cc b/paddle/fluid/platform/device/gpu/gpu_resource_pool.cc index 2c55eb972b765739efdaf116baaba52241f3b4ce..56fdb0da340571988f5abdf84d4bf6db39049cb8 100644 --- a/paddle/fluid/platform/device/gpu/gpu_resource_pool.cc +++ b/paddle/fluid/platform/device/gpu/gpu_resource_pool.cc @@ -14,6 +14,7 @@ #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) #include "paddle/fluid/platform/device/gpu/gpu_resource_pool.h" + #include "paddle/fluid/platform/device/gpu/gpu_info.h" namespace paddle { diff --git a/paddle/fluid/platform/device/gpu/gpu_types.h b/paddle/fluid/platform/device/gpu/gpu_types.h index d0b48eca5021bdd971eecd38642cc780e9d6a6bb..2cadd55d2dc77c33eb5d1c8a460cf0adec4cf1f6 100644 --- a/paddle/fluid/platform/device/gpu/gpu_types.h +++ b/paddle/fluid/platform/device/gpu/gpu_types.h @@ -19,11 +19,13 @@ #ifdef PADDLE_WITH_HIP #include + #include "paddle/fluid/platform/dynload/miopen.h" #include "paddle/fluid/platform/dynload/rocblas.h" #else #include + #include "paddle/fluid/platform/dynload/cublas.h" #include "paddle/fluid/platform/dynload/cublasLt.h" #include "paddle/fluid/platform/dynload/cudnn.h" diff --git a/paddle/fluid/platform/device/gpu/nccl_helper.h b/paddle/fluid/platform/device/gpu/nccl_helper.h index d0cb9c953a5bfa31129be8746f24de37a7b3bc3c..b9e612b98def970aa5e7dfea59977b34023b6deb 100644 --- a/paddle/fluid/platform/device/gpu/nccl_helper.h +++ b/paddle/fluid/platform/device/gpu/nccl_helper.h @@ -16,6 +16,7 @@ #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) #include + #include #include #include // NOLINT @@ -264,7 +265,7 @@ class NCCLCommunicator { *allreduce ophandle and sync_batch_norm_op use ncclallreduce parallelly. So *create a new nccl comm for sync_batch_norm_op. And these codes should be *polished with a unified nccl management. - */ + */ NCCLContextMap *GetSyncBatchNormCtx( framework::Scope *scope, const std::vector &places) { auto *nccl_id_var = scope->FindVar(NCCL_ID_VARNAME); diff --git a/paddle/fluid/platform/device/gpu/rocm/miopen_helper_test.cc b/paddle/fluid/platform/device/gpu/rocm/miopen_helper_test.cc index 13cf52dc2c6a30892297153065031228817e35b5..e99fc7f37a8f8cb5f91737c3539d3b4280f598da 100644 --- a/paddle/fluid/platform/device/gpu/rocm/miopen_helper_test.cc +++ b/paddle/fluid/platform/device/gpu/rocm/miopen_helper_test.cc @@ -15,13 +15,13 @@ limitations under the License. */ #define GLOG_NO_ABBREVIATED_SEVERITIES #define GOOGLE_GLOG_DLL_DECL -#include "paddle/fluid/platform/device/gpu/gpu_dnn.h" - #include +#include "paddle/fluid/platform/device/gpu/gpu_dnn.h" + TEST(MIOpenHelper, ScopedTensorDescriptor) { - using paddle::platform::ScopedTensorDescriptor; using paddle::platform::DataLayout; + using paddle::platform::ScopedTensorDescriptor; ScopedTensorDescriptor tensor_desc; std::vector shape = {2, 4, 6, 6}; diff --git a/paddle/fluid/platform/device/gpu/rocm/rocm_helper.h b/paddle/fluid/platform/device/gpu/rocm/rocm_helper.h index a0f3fb0f73ba5e0100d471f8bd104aadb3932b5c..c0f6f173a798a2b1269d6a84c638dcbc6efec580 100644 --- a/paddle/fluid/platform/device/gpu/rocm/rocm_helper.h +++ b/paddle/fluid/platform/device/gpu/rocm/rocm_helper.h @@ -65,7 +65,7 @@ namespace platform { * } * } * -*/ + */ #define CUDA_KERNEL_LOOP_TYPE(i, num, index_type) \ int64_t __index__ = hipBlockIdx_x * hipBlockDim_x + hipThreadIdx_x; \ diff --git a/paddle/fluid/platform/device/ipu/ipu_device.cc b/paddle/fluid/platform/device/ipu/ipu_device.cc index 2d0381cb8b3ea64504668a150c38240a7ff44563..f6de526c90090c9d8bda3da177f6eabcf08b8d41 100644 --- a/paddle/fluid/platform/device/ipu/ipu_device.cc +++ b/paddle/fluid/platform/device/ipu/ipu_device.cc @@ -45,9 +45,10 @@ int GetNumDevices() { } int num_devices = popart::DeviceManager::createDeviceManager().enumerateDevices().size(); - PADDLE_ENFORCE_GT(num_devices, 0, platform::errors::Unavailable( - "Do not found any IPU devices, please " - "make sure Poplar sdk is enabled")); + PADDLE_ENFORCE_GT( + num_devices, 0, + platform::errors::Unavailable("Do not found any IPU devices, please " + "make sure Poplar sdk is enabled")); return num_devices; } diff --git a/paddle/fluid/platform/device/ipu/ipu_executor.cc b/paddle/fluid/platform/device/ipu/ipu_executor.cc index d490334ee33f52145b47e1e025ed29d9a0632f68..30c9bc2094a8a831d6515c15b4ff21c573b651a0 100644 --- a/paddle/fluid/platform/device/ipu/ipu_executor.cc +++ b/paddle/fluid/platform/device/ipu/ipu_executor.cc @@ -243,7 +243,8 @@ void Executor::AcquireDevice() { VLOG(10) << "Create IPU model device..."; std::map deviceOpts{ { - "numIPUs", std::to_string(ipu_strategy_->num_ipus), + "numIPUs", + std::to_string(ipu_strategy_->num_ipus), }, {"ipuVersion", "ipu2"}, }; @@ -254,7 +255,8 @@ void Executor::AcquireDevice() { VLOG(10) << "Create offline device..."; std::map deviceOpts{ { - "numIPUs", std::to_string(ipu_strategy_->num_ipus), + "numIPUs", + std::to_string(ipu_strategy_->num_ipus), }, {"ipuVersion", "ipu2"}, }; diff --git a/paddle/fluid/platform/device/ipu/ipu_info.h b/paddle/fluid/platform/device/ipu/ipu_info.h index fe7076e0b50b6e17f7bc71806bb8f7f9368dbd5b..06ef070ed65ea15fd47000f269d29ba69cadd7e8 100644 --- a/paddle/fluid/platform/device/ipu/ipu_info.h +++ b/paddle/fluid/platform/device/ipu/ipu_info.h @@ -13,6 +13,7 @@ limitations under the License. */ #ifdef PADDLE_WITH_IPU #include #include + #include "glog/logging.h" namespace paddle { diff --git a/paddle/fluid/platform/device/ipu/ipu_strategy.h b/paddle/fluid/platform/device/ipu/ipu_strategy.h index da08c76fb90d1313085cc2587e668423c62f6831..0e17a485afb01d19bf968926c0ab2603b6ac28cc 100644 --- a/paddle/fluid/platform/device/ipu/ipu_strategy.h +++ b/paddle/fluid/platform/device/ipu/ipu_strategy.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/platform/device/ipu/ipu_utils.h" #include "paddle/fluid/platform/enforce.h" @@ -143,10 +144,11 @@ class IpuStrategy { std::map> &options, // NOLINT const std::string &type_str) { auto it = options.find(key); - PADDLE_ENFORCE_NE(it, options.end(), platform::errors::InvalidArgument( - "Cannot find option: %s, type: %s " - "when setting IpuStrategy options", - key, type_str)); + PADDLE_ENFORCE_NE( + it, options.end(), + platform::errors::InvalidArgument("Cannot find option: %s, type: %s " + "when setting IpuStrategy options", + key, type_str)); it->second(value); } diff --git a/paddle/fluid/platform/device/ipu/popart_canonicalization/activation_ops.cc b/paddle/fluid/platform/device/ipu/popart_canonicalization/activation_ops.cc index 254e5665674246761482beeee344591a47fc9827..1d5fe8c329f116e74dbda65a88e0c7891ac03b40 100644 --- a/paddle/fluid/platform/device/ipu/popart_canonicalization/activation_ops.cc +++ b/paddle/fluid/platform/device/ipu/popart_canonicalization/activation_ops.cc @@ -57,14 +57,14 @@ Node *gelu_handler(Graph *graph, Node *node) { {{"value", std::vector{1.4142135623730951}}, {"dims", std::vector{1}}, {"dtype", GetOutputVarDType(node)}}); - auto zero_point_five = - CreateConst(graph, node, {}, {}, {{"value", std::vector{0.5}}, - {"dims", std::vector{1}}, - {"dtype", GetOutputVarDType(node)}}); - auto one = - CreateConst(graph, node, {}, {}, {{"value", std::vector{1}}, - {"dims", std::vector{1}}, - {"dtype", GetOutputVarDType(node)}}); + auto zero_point_five = CreateConst(graph, node, {}, {}, + {{"value", std::vector{0.5}}, + {"dims", std::vector{1}}, + {"dtype", GetOutputVarDType(node)}}); + auto one = CreateConst(graph, node, {}, {}, + {{"value", std::vector{1}}, + {"dims", std::vector{1}}, + {"dtype", GetOutputVarDType(node)}}); auto div = CreateBaseOp(graph, node, "popart_div", {GetInputVarNode("X", node), sqrt2->outputs[0]}, {}, {}); diff --git a/paddle/fluid/platform/device/ipu/popart_canonicalization/math_ops.cc b/paddle/fluid/platform/device/ipu/popart_canonicalization/math_ops.cc index af72f84c9d771cecc32d01fb6b4074adde49da57..9b91abc4a67aff742f73234bbeab00e1a073a820 100644 --- a/paddle/fluid/platform/device/ipu/popart_canonicalization/math_ops.cc +++ b/paddle/fluid/platform/device/ipu/popart_canonicalization/math_ops.cc @@ -44,9 +44,10 @@ Node *pow_handler(Graph *graph, Node *node) { MakeConstAttrMapFromValue(value_, {1}, GetOutputVarDType(node)); auto new_node_const = CreateConst(graph, node, {}, {}, attrs); - return CreateBaseOp(graph, node, "popart_pow", {GetInputVarNode("X", node), - new_node_const->outputs[0]}, - node->outputs); + return CreateBaseOp( + graph, node, "popart_pow", + {GetInputVarNode("X", node), new_node_const->outputs[0]}, + node->outputs); } } @@ -380,10 +381,10 @@ Node *cumsum_handler(Graph *graph, Node *node) { auto reverse = BOOST_GET_CONST(bool, op->GetAttr("reverse")); int64_t popart_reverse = 1 ? reverse : 0; auto axis = BOOST_GET_CONST(int, op->GetAttr("axis")); - auto axis_node = - CreateConst(graph, node, {}, {}, {{"value", std::vector{axis}}, - {"dims", std::vector{1}}, - {"dtype", ONNXDataType::INT64}}); + auto axis_node = CreateConst(graph, node, {}, {}, + {{"value", std::vector{axis}}, + {"dims", std::vector{1}}, + {"dtype", ONNXDataType::INT64}}); return CreateBaseOp( graph, node, "popart_cumsum", {GetInputVarNode("X", node), axis_node->outputs[0]}, diff --git a/paddle/fluid/platform/device/ipu/popart_canonicalization/nn_ops.cc b/paddle/fluid/platform/device/ipu/popart_canonicalization/nn_ops.cc index 2e9913f58efbba0bfbbe625fa4f490d836668b6e..bce6bac88e2046d292ee3f444c5ddfade7497534 100644 --- a/paddle/fluid/platform/device/ipu/popart_canonicalization/nn_ops.cc +++ b/paddle/fluid/platform/device/ipu/popart_canonicalization/nn_ops.cc @@ -35,20 +35,20 @@ Node *conv2d_handler(Graph *graph, Node *node) { auto stride_ = BOOST_GET_CONST(std::vector, op->GetAttr("strides")); auto stride = std::vector{stride_.begin(), stride_.end()}; if (!op->Input("Bias").empty()) { - return CreateConv( - graph, node, - { - GetInputVarNode("Input", node), GetInputVarNode("Filter", node), - GetInputVarNode("Bias", node), - }, - node->outputs, dilations, group_, {}, pads, stride); + return CreateConv(graph, node, + { + GetInputVarNode("Input", node), + GetInputVarNode("Filter", node), + GetInputVarNode("Bias", node), + }, + node->outputs, dilations, group_, {}, pads, stride); } else { - return CreateConv( - graph, node, - { - GetInputVarNode("Input", node), GetInputVarNode("Filter", node), - }, - node->outputs, dilations, group_, {}, pads, stride); + return CreateConv(graph, node, + { + GetInputVarNode("Input", node), + GetInputVarNode("Filter", node), + }, + node->outputs, dilations, group_, {}, pads, stride); } } @@ -148,15 +148,16 @@ Node *pool2d_handler(Graph *graph, Node *node) { auto dilations = std::vector{}; int64_t storage_order = 0; return CreateBaseOp(graph, node, "popart_maxpool", node->inputs, - node->outputs, { - {"num_outputs", num_outputs}, - {"kernel_shape", kernel_shape}, - {"ceil_mode", ceil_mode}, - {"dilations", dilations}, - {"pads", pads}, - {"storage_order", storage_order}, - {"strides", strides}, - }); + node->outputs, + { + {"num_outputs", num_outputs}, + {"kernel_shape", kernel_shape}, + {"ceil_mode", ceil_mode}, + {"dilations", dilations}, + {"pads", pads}, + {"storage_order", storage_order}, + {"strides", strides}, + }); } else if (pooling_type == "avg") { int64_t count_include_pad = 0; return CreateBaseOp(graph, node, "popart_averagepool", node->inputs, diff --git a/paddle/fluid/platform/device/ipu/popart_canonicalization/op_builder.cc b/paddle/fluid/platform/device/ipu/popart_canonicalization/op_builder.cc index 0525bb66f16181f0c2baff5c1ca1dfe5fddc39ea..b51d923bfcf5c1e81867e9fad3a55b2537d407ad 100644 --- a/paddle/fluid/platform/device/ipu/popart_canonicalization/op_builder.cc +++ b/paddle/fluid/platform/device/ipu/popart_canonicalization/op_builder.cc @@ -173,8 +173,9 @@ Node *CreateConv(Graph *graph, Node *node, const std::vector &inputs, Node *CreateSoftmaxOpset11(Graph *graph, Node *node, const std::vector &inputs, const std::vector &outputs, int64_t axis) { - PADDLE_ENFORCE_EQ(inputs.size(), 1, platform::errors::InvalidArgument( - "Softmax op only support one input")); + PADDLE_ENFORCE_EQ( + inputs.size(), 1, + platform::errors::InvalidArgument("Softmax op only support one input")); auto x_shape = inputs[0]->Var()->GetShape(); int x_rank = x_shape.size(); if (axis < 0) { diff --git a/paddle/fluid/platform/device/ipu/popart_canonicalization/search_ops.cc b/paddle/fluid/platform/device/ipu/popart_canonicalization/search_ops.cc index aec89a1cf0d8260bab53c0ed3427614b266bc285..77ce2f316691476a4b66f37efd61492dc947a9d9 100644 --- a/paddle/fluid/platform/device/ipu/popart_canonicalization/search_ops.cc +++ b/paddle/fluid/platform/device/ipu/popart_canonicalization/search_ops.cc @@ -69,10 +69,10 @@ Node *topk_handler(Graph *graph, Node *node) { var_k = GetInputVarNode("K", node); } else { auto k = BOOST_GET_CONST(int, op->GetAttr("k")); - auto *op_k = - CreateConst(graph, node, {}, {}, {{"value", std::vector{k}}, - {"dims", std::vector{1}}, - {"dtype", ONNXDataType::INT64}}); + auto *op_k = CreateConst(graph, node, {}, {}, + {{"value", std::vector{k}}, + {"dims", std::vector{1}}, + {"dtype", ONNXDataType::INT64}}); var_k = op_k->outputs[0]; } diff --git a/paddle/fluid/platform/device/ipu/popart_canonicalization/tensor_ops.cc b/paddle/fluid/platform/device/ipu/popart_canonicalization/tensor_ops.cc index 00926ee7a0b25f65f083ac3d5e53d16d73a64428..bf32744d5a54279c7e87889a66f98c5bd5f87fd1 100644 --- a/paddle/fluid/platform/device/ipu/popart_canonicalization/tensor_ops.cc +++ b/paddle/fluid/platform/device/ipu/popart_canonicalization/tensor_ops.cc @@ -61,7 +61,9 @@ Node *fill_constant_handler(Graph *graph, Node *node) { } return CreateConst(graph, node, node->inputs, node->outputs, AttributeMap{ - {"value", value}, {"dims", dims}, {"dtype", dtype}, + {"value", value}, + {"dims", dims}, + {"dtype", dtype}, }); } @@ -76,13 +78,14 @@ Node *gaussian_random_handler(Graph *graph, Node *node) { auto seed_ = BOOST_GET_CONST(int, op->GetAttr("seed")); auto seed = static_cast(seed_); return CreateBaseOp(graph, node, "popart_randomnormal", node->inputs, - node->outputs, { - {"shape", shape}, - {"dtype", dtype}, - {"mean", mean}, - {"scale", scale}, - {"seed", seed}, - }); + node->outputs, + { + {"shape", shape}, + {"dtype", dtype}, + {"mean", mean}, + {"scale", scale}, + {"seed", seed}, + }); } Node *uniform_random_handler(Graph *graph, Node *node) { @@ -96,13 +99,14 @@ Node *uniform_random_handler(Graph *graph, Node *node) { auto seed_ = BOOST_GET_CONST(int, op->GetAttr("seed")); auto seed = static_cast(seed_); return CreateBaseOp(graph, node, "popart_randomuniform", node->inputs, - node->outputs, { - {"shape", shape}, - {"dtype", dtype}, - {"high", high}, - {"low", low}, - {"seed", seed}, - }); + node->outputs, + { + {"shape", shape}, + {"dtype", dtype}, + {"high", high}, + {"low", low}, + {"seed", seed}, + }); } Node *transpose_handler(Graph *graph, Node *node) { @@ -204,32 +208,33 @@ Node *lookup_table_op_handler(Graph *graph, Node *node, if (padding_idx_ >= 0 && padding_idx_ < table_size_) { std::vector const_value_(emb_size_, 0); std::vector const_shape_{1, emb_size_}; - auto concat_const = - CreateConst(graph, node, {}, {}, {{"value", const_value_}, - {"dims", const_shape_}, - {"dtype", GetOutputVarDType(node)}}); - auto axes = - CreateConst(graph, node, {}, {}, {{"value", std::vector{0}}, - {"dims", std::vector{1}}, - {"dtype", ONNXDataType::INT64}}); - auto step = - CreateConst(graph, node, {}, {}, {{"value", std::vector{1}}, - {"dims", std::vector{1}}, - {"dtype", ONNXDataType::INT64}}); - - auto left_start = - CreateConst(graph, node, {}, {}, {{"value", std::vector{0}}, - {"dims", std::vector{1}}, - {"dtype", ONNXDataType::INT64}}); + auto concat_const = CreateConst(graph, node, {}, {}, + {{"value", const_value_}, + {"dims", const_shape_}, + {"dtype", GetOutputVarDType(node)}}); + auto axes = CreateConst(graph, node, {}, {}, + {{"value", std::vector{0}}, + {"dims", std::vector{1}}, + {"dtype", ONNXDataType::INT64}}); + auto step = CreateConst(graph, node, {}, {}, + {{"value", std::vector{1}}, + {"dims", std::vector{1}}, + {"dtype", ONNXDataType::INT64}}); + + auto left_start = CreateConst(graph, node, {}, {}, + {{"value", std::vector{0}}, + {"dims", std::vector{1}}, + {"dtype", ONNXDataType::INT64}}); auto left_end = CreateConst(graph, node, {}, {}, {{"value", std::vector{padding_idx_}}, {"dims", std::vector{1}}, {"dtype", ONNXDataType::INT64}}); - auto right_start = CreateConst( - graph, node, {}, {}, {{"value", std::vector{padding_idx_ + 1}}, - {"dims", std::vector{1}}, - {"dtype", ONNXDataType::INT64}}); + auto right_start = + CreateConst(graph, node, {}, {}, + {{"value", std::vector{padding_idx_ + 1}}, + {"dims", std::vector{1}}, + {"dtype", ONNXDataType::INT64}}); auto right_end = CreateConst(graph, node, {}, {}, {{"value", std::vector{table_size_}}, {"dims", std::vector{1}}, @@ -471,7 +476,9 @@ Node *assign_value_handler(Graph *graph, Node *node) { } return CreateConst(graph, node, node->inputs, node->outputs, AttributeMap{ - {"value", values}, {"dims", dims}, {"dtype", dtype}, + {"value", values}, + {"dims", dims}, + {"dtype", dtype}, }); } @@ -529,10 +536,10 @@ Node *one_hot_handler(Graph *graph, Node *node) { {{"value", std::vector{depth}}, {"dims", std::vector{1}}, {"dtype", ONNXDataType::INT64}}); - auto value_tensor = - CreateConst(graph, node, {}, {}, {{"value", std::vector{0, 1}}, - {"dims", std::vector{2}}, - {"dtype", ONNXDataType::FLOAT}}); + auto value_tensor = CreateConst(graph, node, {}, {}, + {{"value", std::vector{0, 1}}, + {"dims", std::vector{2}}, + {"dtype", ONNXDataType::FLOAT}}); return CreateBaseOp(graph, node, "popart_onehot", {GetInputVarNode("X", node), depth_tensor->outputs[0], value_tensor->outputs[0]}, @@ -550,21 +557,21 @@ Node *one_hot_v2_handler(Graph *graph, Node *node) { PADDLE_THROW(platform::errors::Unimplemented( "Do not support allow_out_of_range=True")); } else { - auto depth_tensor = - CreateConst(graph, node, {}, {}, {{"value", std::vector{depth}}, - {"dims", std::vector{1}}, - {"dtype", ONNXDataType::INT32}}); + auto depth_tensor = CreateConst(graph, node, {}, {}, + {{"value", std::vector{depth}}, + {"dims", std::vector{1}}, + {"dtype", ONNXDataType::INT32}}); Node *value_tensor = nullptr; if (GetOutputVarNode("Out", node)->Var()->GetDataType() == VarType::FP16) { - value_tensor = - CreateConst(graph, node, {}, {}, {{"value", std::vector{0, 1}}, - {"dims", std::vector{2}}, - {"dtype", ONNXDataType::FLOAT16}}); + value_tensor = CreateConst(graph, node, {}, {}, + {{"value", std::vector{0, 1}}, + {"dims", std::vector{2}}, + {"dtype", ONNXDataType::FLOAT16}}); } else { - value_tensor = - CreateConst(graph, node, {}, {}, {{"value", std::vector{0, 1}}, - {"dims", std::vector{2}}, - {"dtype", ONNXDataType::FLOAT}}); + value_tensor = CreateConst(graph, node, {}, {}, + {{"value", std::vector{0, 1}}, + {"dims", std::vector{2}}, + {"dtype", ONNXDataType::FLOAT}}); } return CreateBaseOp(graph, node, "popart_onehot", diff --git a/paddle/fluid/platform/device/mlu/cncl_helper.h b/paddle/fluid/platform/device/mlu/cncl_helper.h index 2f9bed014264175f5d5545964191fbc5848f5a09..634e420d5ce53abdd72c0b1ef5737276949b35ee 100644 --- a/paddle/fluid/platform/device/mlu/cncl_helper.h +++ b/paddle/fluid/platform/device/mlu/cncl_helper.h @@ -16,8 +16,8 @@ limitations under the License. */ #ifdef PADDLE_WITH_CNCL #include - #include + #include #include #include // NOLINT diff --git a/paddle/fluid/platform/device/mlu/device_context.h b/paddle/fluid/platform/device/mlu/device_context.h index 120916b4f5c56c1f288392bebde1e88a9d863030..d607b1e12f5a77d01ce6227ec81a97d568d8e8c9 100644 --- a/paddle/fluid/platform/device/mlu/device_context.h +++ b/paddle/fluid/platform/device/mlu/device_context.h @@ -12,6 +12,7 @@ limitations under the License. */ #ifdef PADDLE_WITH_MLU #include + #include "paddle/fluid/platform/device/mlu/enforce.h" #include "paddle/fluid/platform/device/mlu/mlu_stream.h" #include "paddle/fluid/platform/device_context.h" diff --git a/paddle/fluid/platform/device/mlu/device_context_test.cc b/paddle/fluid/platform/device/mlu/device_context_test.cc index 5caaa9dec1e4bab6bb0faac1d299f4f1db0ab477..41f79c7092ea404d4318eb2fa450f822bc1c7dde 100644 --- a/paddle/fluid/platform/device/mlu/device_context_test.cc +++ b/paddle/fluid/platform/device/mlu/device_context_test.cc @@ -20,9 +20,9 @@ limitations under the License. */ TEST(Device, Init) { using paddle::platform::DeviceContext; + using paddle::platform::MLUContext; using paddle::platform::MLUDeviceContext; using paddle::platform::MLUPlace; - using paddle::platform::MLUContext; int count = paddle::platform::GetMLUDeviceCount(); for (int i = 0; i < count; i++) { @@ -34,9 +34,9 @@ TEST(Device, Init) { } TEST(Device, MLUDeviceContext) { + using paddle::mluCnnlHandle; using paddle::platform::MLUDeviceContext; using paddle::platform::MLUPlace; - using paddle::mluCnnlHandle; int count = paddle::platform::GetMLUDeviceCount(); for (int i = 0; i < count; i++) { @@ -48,9 +48,9 @@ TEST(Device, MLUDeviceContext) { } TEST(Device, MLUStream) { + using paddle::mluStream; using paddle::platform::MLUDeviceContext; using paddle::platform::MLUPlace; - using paddle::mluStream; int count = paddle::platform::GetMLUDeviceCount(); for (int i = 0; i < count; i++) { @@ -62,11 +62,11 @@ TEST(Device, MLUStream) { } TEST(Device, DeviceContextPool) { + using paddle::platform::CPUPlace; using paddle::platform::DeviceContextPool; using paddle::platform::MLUDeviceContext; - using paddle::platform::Place; - using paddle::platform::CPUPlace; using paddle::platform::MLUPlace; + using paddle::platform::Place; DeviceContextPool& pool = DeviceContextPool::Instance(); auto cpu_dev_ctx1 = pool.Get(CPUPlace()); diff --git a/paddle/fluid/platform/device/mlu/mlu_collective_helper.cc b/paddle/fluid/platform/device/mlu/mlu_collective_helper.cc index 7708267c1bc7213e5f07a791b4e378b8e9a54cab..4051caac1c800f7a34e5acc257b2d3eccc6fc7fe 100644 --- a/paddle/fluid/platform/device/mlu/mlu_collective_helper.cc +++ b/paddle/fluid/platform/device/mlu/mlu_collective_helper.cc @@ -14,6 +14,7 @@ limitations under the License. */ #if defined(PADDLE_WITH_CNCL) #include + #include "paddle/fluid/platform/collective_helper.h" #include "paddle/fluid/platform/device/mlu/enforce.h" diff --git a/paddle/fluid/platform/device/mlu/mlu_info.cc b/paddle/fluid/platform/device/mlu/mlu_info.cc index 7cad99bf5d22df39590d94bd56571d914d2b0193..e3672707210fb602c9de42ac29237e5c3c69c088 100644 --- a/paddle/fluid/platform/device/mlu/mlu_info.cc +++ b/paddle/fluid/platform/device/mlu/mlu_info.cc @@ -13,8 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/device/mlu/mlu_info.h" + #include #include + #include "gflags/gflags.h" #include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/platform/device/mlu/enforce.h" @@ -187,8 +189,9 @@ static size_t MLUAllocSize(bool realloc) { size_t flag_mb = realloc ? FLAGS_reallocate_gpu_memory_in_mb : FLAGS_initial_gpu_memory_in_mb; size_t alloc_bytes = - (flag_mb > 0ul ? flag_mb << 20 : available_to_alloc * - FLAGS_fraction_of_gpu_memory_to_use); + (flag_mb > 0ul + ? flag_mb << 20 + : available_to_alloc * FLAGS_fraction_of_gpu_memory_to_use); PADDLE_ENFORCE_GE( available_to_alloc, alloc_bytes, platform::errors::ResourceExhausted("Not enough available MLU memory.")); diff --git a/paddle/fluid/platform/device/mlu/mlu_stream.cc b/paddle/fluid/platform/device/mlu/mlu_stream.cc index 7a27a49250a1ee9e58a2f76ce902b167e7aeb027..f570cc77e5a975993e4f8dfcaed6e3b6a4d94aaf 100644 --- a/paddle/fluid/platform/device/mlu/mlu_stream.cc +++ b/paddle/fluid/platform/device/mlu/mlu_stream.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/device/mlu/mlu_stream.h" + #include "paddle/fluid/platform/device/mlu/device_context.h" namespace paddle { diff --git a/paddle/fluid/platform/device/npu/ascend_npu_info.cc b/paddle/fluid/platform/device/npu/ascend_npu_info.cc index c100b2d0a1740aca35f4ef51ee4f924ca8ee7ed1..a9204ac3fca50a0d6b6623e3b4ed8bdc50b4844a 100644 --- a/paddle/fluid/platform/device/npu/ascend_npu_info.cc +++ b/paddle/fluid/platform/device/npu/ascend_npu_info.cc @@ -12,7 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/device/npu/ascend_npu_info.h" + #include + #include "acl/acl_rt.h" namespace paddle { diff --git a/paddle/fluid/platform/device/npu/dynload/hccl.h b/paddle/fluid/platform/device/npu/dynload/hccl.h index 3d7587bfa266b99fc2731c42a90eaa2f6230a100..ae140dd295067fb8f1777b0371524085e643d080 100644 --- a/paddle/fluid/platform/device/npu/dynload/hccl.h +++ b/paddle/fluid/platform/device/npu/dynload/hccl.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include + #include // NOLINT #include "paddle/fluid/platform/dynload/dynamic_loader.h" diff --git a/paddle/fluid/platform/device/npu/enforce_npu.h b/paddle/fluid/platform/device/npu/enforce_npu.h index 3887ee4866af8e469356f46c4b7212eb59f4c7d8..243926868631d790f4ce200266a4d53cebee4913 100644 --- a/paddle/fluid/platform/device/npu/enforce_npu.h +++ b/paddle/fluid/platform/device/npu/enforce_npu.h @@ -17,10 +17,9 @@ limitations under the License. */ #ifdef PADDLE_WITH_ASCEND_CL #include -#include "paddle/fluid/platform/enforce.h" - #include "acl/acl.h" #include "hccl/hccl_types.h" +#include "paddle/fluid/platform/enforce.h" namespace paddle { namespace platform { diff --git a/paddle/fluid/platform/device/npu/hccl_helper.h b/paddle/fluid/platform/device/npu/hccl_helper.h index 134ec04030d75f5ab98bd9789b8b5fe87341333f..107fe5989ddbae50a3b87181558b8deed33c74df 100644 --- a/paddle/fluid/platform/device/npu/hccl_helper.h +++ b/paddle/fluid/platform/device/npu/hccl_helper.h @@ -17,6 +17,7 @@ #ifdef PADDLE_WITH_ASCEND_CL #include + #include #include #include // NOLINT @@ -24,11 +25,10 @@ #include #include -#include "paddle/fluid/platform/device/npu/dynload/hccl.h" -#include "paddle/fluid/platform/device/npu/enforce_npu.h" - #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/platform/collective_helper.h" +#include "paddle/fluid/platform/device/npu/dynload/hccl.h" +#include "paddle/fluid/platform/device/npu/enforce_npu.h" #include "paddle/fluid/platform/float16.h" #define HCCL_ID_VARNAME "HCCLID" diff --git a/paddle/fluid/platform/device/npu/npu_collective_helper.cc b/paddle/fluid/platform/device/npu/npu_collective_helper.cc index cdec3519a23f38c1699166fe58c8ff974f01515f..77528fe19fcb44a257b602bdef5b7186772abf61 100644 --- a/paddle/fluid/platform/device/npu/npu_collective_helper.cc +++ b/paddle/fluid/platform/device/npu/npu_collective_helper.cc @@ -14,6 +14,7 @@ #if defined(PADDLE_WITH_ASCEND_CL) #include + #include "paddle/fluid/platform/collective_helper.h" #include "paddle/fluid/platform/device/npu/enforce_npu.h" diff --git a/paddle/fluid/platform/device/npu/npu_info.cc b/paddle/fluid/platform/device/npu/npu_info.cc index b5516944b750e9871e7200d43dcecce069f504ff..2688c88f5577310f48815dfa4d8d7ef84fbae7e1 100644 --- a/paddle/fluid/platform/device/npu/npu_info.cc +++ b/paddle/fluid/platform/device/npu/npu_info.cc @@ -13,12 +13,12 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/device/npu/npu_info.h" + #include #include #include #include "gflags/gflags.h" - #include "paddle/fluid/platform/lock_guard_ptr.h" #include "paddle/fluid/platform/macros.h" #include "paddle/fluid/platform/monitor.h" @@ -153,8 +153,9 @@ static size_t NPUAllocSize(bool realloc) { size_t flag_mb = realloc ? FLAGS_reallocate_gpu_memory_in_mb : FLAGS_initial_gpu_memory_in_mb; size_t alloc_bytes = - (flag_mb > 0ul ? flag_mb << 20 : available_to_alloc * - FLAGS_fraction_of_gpu_memory_to_use); + (flag_mb > 0ul + ? flag_mb << 20 + : available_to_alloc * FLAGS_fraction_of_gpu_memory_to_use); PADDLE_ENFORCE_GE( available_to_alloc, alloc_bytes, platform::errors::ResourceExhausted("Not enough available NPU memory.")); diff --git a/paddle/fluid/platform/device/npu/npu_op_runner.cc b/paddle/fluid/platform/device/npu/npu_op_runner.cc index 72169ae303b4c985069163812487128e56bb3f61..d38443acca3a3ef057014fc9796c482c1f891050 100644 --- a/paddle/fluid/platform/device/npu/npu_op_runner.cc +++ b/paddle/fluid/platform/device/npu/npu_op_runner.cc @@ -23,7 +23,6 @@ limitations under the License. */ #include "acl/acl.h" #include "acl/acl_op_compiler.h" - #include "paddle/fluid/framework/framework.pb.h" DECLARE_string(npu_precision_mode); diff --git a/paddle/fluid/platform/device/npu/npu_resource_pool.cc b/paddle/fluid/platform/device/npu/npu_resource_pool.cc index d837e90c3c42c31028b4dc2edd32079a5229ad4e..e7c302289dbfef06505e4c04eb9fa558f175ce4b 100644 --- a/paddle/fluid/platform/device/npu/npu_resource_pool.cc +++ b/paddle/fluid/platform/device/npu/npu_resource_pool.cc @@ -14,6 +14,7 @@ #ifdef PADDLE_WITH_ASCEND_CL #include "paddle/fluid/platform/device/npu/npu_resource_pool.h" + #include "paddle/fluid/platform/device/npu/npu_info.h" namespace paddle { diff --git a/paddle/fluid/platform/device/npu/npu_stream.cc b/paddle/fluid/platform/device/npu/npu_stream.cc index 0b15a0d937e825a6043276e3929489a4988736b2..55a73146815c9a6c33dcfa04b56bd3922f0a0af7 100644 --- a/paddle/fluid/platform/device/npu/npu_stream.cc +++ b/paddle/fluid/platform/device/npu/npu_stream.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/device/npu/npu_stream.h" + #include "paddle/fluid/platform/enforce.h" namespace paddle { diff --git a/paddle/fluid/platform/device/xpu/bkcl_helper.h b/paddle/fluid/platform/device/xpu/bkcl_helper.h index 24fd8b5faa4e9c850e9ed081548a0b9da61252f1..a7a3e4f060529bbfa94985346a40bbc36b3d1b15 100644 --- a/paddle/fluid/platform/device/xpu/bkcl_helper.h +++ b/paddle/fluid/platform/device/xpu/bkcl_helper.h @@ -17,6 +17,7 @@ #pragma once #include + #include #include #include // NOLINT @@ -217,7 +218,7 @@ class BKCLCommunicator { *bkcl_all_reduce *parallelly. So create a new bkcl comm for sync_batch_norm_op. And these *codes should be polished with a unified bkcl management. - */ + */ BKCLContextMap *GetSyncBatchNormCtx( framework::Scope *scope, const std::vector &places) { auto *bkcl_id_var = scope->FindVar(BKCL_ID_VARNAME); diff --git a/paddle/fluid/platform/device/xpu/enforce_xpu.h b/paddle/fluid/platform/device/xpu/enforce_xpu.h index c55d91c301550945a0f0c73ac00f2de38d1e8f05..77d14aa712e7018c51113c0a1eb957373fcc6689 100644 --- a/paddle/fluid/platform/device/xpu/enforce_xpu.h +++ b/paddle/fluid/platform/device/xpu/enforce_xpu.h @@ -15,7 +15,6 @@ limitations under the License. */ #pragma once #include "paddle/fluid/platform/device/xpu/xpu_header.h" - #include "paddle/phi/backends/xpu/enforce_xpu.h" namespace paddle { diff --git a/paddle/fluid/platform/device/xpu/tests/enforce_xpu_test.cc b/paddle/fluid/platform/device/xpu/tests/enforce_xpu_test.cc index 8cba98f3fb352883fe76acab767a492631dc0f33..0b528c3999e0767376681da747b7ccc715635a83 100644 --- a/paddle/fluid/platform/device/xpu/tests/enforce_xpu_test.cc +++ b/paddle/fluid/platform/device/xpu/tests/enforce_xpu_test.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/device/xpu/enforce_xpu.h" + #include "gtest/gtest.h" template diff --git a/paddle/fluid/platform/device/xpu/xpu_info.cc b/paddle/fluid/platform/device/xpu/xpu_info.cc index cdd7ee7f806e932b4d1041575fb5432c81c42865..dbc8ed4a51aaf7ac4dec20dab6f4e16df9327035 100644 --- a/paddle/fluid/platform/device/xpu/xpu_info.cc +++ b/paddle/fluid/platform/device/xpu/xpu_info.cc @@ -13,14 +13,13 @@ limitations under the License. */ #include #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/fluid/platform/device/device_wrapper.h" #include "paddle/fluid/platform/device/xpu/enforce_xpu.h" #include "paddle/fluid/platform/device/xpu/xpu_header.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/place.h" - #include "paddle/phi/backends/xpu/xpu_info.h" namespace paddle { diff --git a/paddle/fluid/platform/device/xpu/xpu_info.h b/paddle/fluid/platform/device/xpu/xpu_info.h index 38b4defadc6c3064eb47af2a48509e1e3339d6e4..2dd0f3275309e0b91ec0d04d8900ee10eafe16f1 100644 --- a/paddle/fluid/platform/device/xpu/xpu_info.h +++ b/paddle/fluid/platform/device/xpu/xpu_info.h @@ -12,6 +12,7 @@ limitations under the License. */ #ifdef PADDLE_WITH_XPU #include + #include "paddle/fluid/platform/place.h" #include "paddle/phi/backends/xpu/xpu_info.h" #include "xpu/runtime.h" diff --git a/paddle/fluid/platform/device/xpu/xpu_op_list.cc b/paddle/fluid/platform/device/xpu/xpu_op_list.cc index 073851433620130a3c3c6d256a4d6ca3b3f74555..8ace4d1a32c50d25983d7a9afe21ac6aa2d85e48 100644 --- a/paddle/fluid/platform/device/xpu/xpu_op_list.cc +++ b/paddle/fluid/platform/device/xpu/xpu_op_list.cc @@ -9,6 +9,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifdef PADDLE_WITH_XPU +#include "paddle/fluid/platform/device/xpu/xpu_op_list.h" + #include #include #include @@ -17,7 +19,6 @@ limitations under the License. */ #include "paddle/fluid/platform/device/xpu/xpu2_op_list.h" #include "paddle/fluid/platform/device/xpu/xpu_info.h" #include "paddle/fluid/platform/device/xpu/xpu_op_kpfirst_list.h" -#include "paddle/fluid/platform/device/xpu/xpu_op_list.h" namespace paddle { namespace platform { diff --git a/paddle/fluid/platform/device_code.cc b/paddle/fluid/platform/device_code.cc index a4226dabf9d52465ba935ce1d631a9254ad27172..4ee32ad5a03cdf536ebd97de282ed48215fc3b28 100644 --- a/paddle/fluid/platform/device_code.cc +++ b/paddle/fluid/platform/device_code.cc @@ -12,12 +12,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/platform/device_code.h" + #include + #include #include #include -#include "paddle/fluid/platform/device_code.h" #include "paddle/fluid/platform/enforce.h" DECLARE_string(cuda_dir); diff --git a/paddle/fluid/platform/device_code_test.cc b/paddle/fluid/platform/device_code_test.cc index 7da8c56138543588732996525cdfcace48745054..cb2649686ec0284f7face355c02fe2d1be1dbc93 100644 --- a/paddle/fluid/platform/device_code_test.cc +++ b/paddle/fluid/platform/device_code_test.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/device_code.h" + #include + #include "gtest/gtest.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/platform/init.h" diff --git a/paddle/fluid/platform/device_context.cc b/paddle/fluid/platform/device_context.cc index 09a29c3429cba5ce71da7138097bded7572913f5..0bd606257f541593ed48d780851abca1ff338875 100644 --- a/paddle/fluid/platform/device_context.cc +++ b/paddle/fluid/platform/device_context.cc @@ -12,9 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/device_context.h" + #include #include #include + #include "paddle/fluid/platform/place.h" #include "paddle/fluid/platform/stream/cuda_stream.h" #include "paddle/phi/backends/gpu/gpu_context.h" diff --git a/paddle/fluid/platform/device_context.h b/paddle/fluid/platform/device_context.h index a63d41405f1b2dac733d419e954d74ba35f63252..d0dae706ba5728bcd1911248b6492779259ffa6a 100644 --- a/paddle/fluid/platform/device_context.h +++ b/paddle/fluid/platform/device_context.h @@ -21,13 +21,12 @@ limitations under the License. */ #include #include +#include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/platform/device/gpu/gpu_types.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/backends/custom/custom_context.h" #include "paddle/phi/backends/gpu/gpu_decls.h" #include "paddle/phi/core/device_context.h" - -#include "paddle/fluid/memory/malloc.h" #ifdef PADDLE_WITH_CUDA #include "paddle/fluid/platform/device/gpu/gpu_helper.h" #include "paddle/fluid/platform/dynload/cublas.h" diff --git a/paddle/fluid/platform/device_context_test.cu b/paddle/fluid/platform/device_context_test.cu index 08a04a9565af7fe9f058a2a05a65ab678f4bf7eb..2db29dc11ada05b8392bc8bcaacfa6562734f333 100644 --- a/paddle/fluid/platform/device_context_test.cu +++ b/paddle/fluid/platform/device_context_test.cu @@ -11,18 +11,17 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/platform/device_context.h" - #include #include "glog/logging.h" #include "gtest/gtest.h" #include "paddle/fluid/memory/allocation/allocator_facade.h" +#include "paddle/fluid/platform/device_context.h" TEST(Device, Init) { - using paddle::platform::DeviceContext; using paddle::platform::CUDADeviceContext; using paddle::platform::CUDAPlace; + using paddle::platform::DeviceContext; int count = paddle::platform::GetGPUDeviceCount(); for (int i = 0; i < count; i++) { @@ -94,11 +93,11 @@ TEST(Device, CUDADeviceContext) { } TEST(Device, DeviceContextPool) { - using paddle::platform::DeviceContextPool; - using paddle::platform::CUDADeviceContext; - using paddle::platform::Place; using paddle::platform::CPUPlace; + using paddle::platform::CUDADeviceContext; using paddle::platform::CUDAPlace; + using paddle::platform::DeviceContextPool; + using paddle::platform::Place; DeviceContextPool& pool = DeviceContextPool::Instance(); auto cpu_dev_ctx1 = pool.Get(CPUPlace()); diff --git a/paddle/fluid/platform/device_context_xpu_test.cc b/paddle/fluid/platform/device_context_xpu_test.cc index 3de2e3957a990a254ffb762f996876a122a865bc..50cb0f98d334fb3d058272bdd26caf8df1fbbc5f 100644 --- a/paddle/fluid/platform/device_context_xpu_test.cc +++ b/paddle/fluid/platform/device_context_xpu_test.cc @@ -11,12 +11,11 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/fluid/platform/device_context.h" - #include #include "glog/logging.h" #include "gtest/gtest.h" +#include "paddle/fluid/platform/device_context.h" TEST(Device, Init) { using paddle::platform::DeviceContext; @@ -33,10 +32,10 @@ TEST(Device, Init) { } TEST(Device, DeviceContextPool) { + using paddle::platform::CPUPlace; using paddle::platform::DeviceContextPool; - using paddle::platform::XPUDeviceContext; using paddle::platform::Place; - using paddle::platform::CPUPlace; + using paddle::platform::XPUDeviceContext; using paddle::platform::XPUPlace; DeviceContextPool& pool = DeviceContextPool::Instance(); diff --git a/paddle/fluid/platform/device_event.h b/paddle/fluid/platform/device_event.h index 463329d32c936153ecce30691bb08c374a58f1dd..82d93dee3989f82cdbdc33293b4713978e0fc349 100644 --- a/paddle/fluid/platform/device_event.h +++ b/paddle/fluid/platform/device_event.h @@ -23,8 +23,8 @@ * for USE_PASS from pass_library. */ -using ::paddle::platform::kCUDA; using ::paddle::platform::kCPU; +using ::paddle::platform::kCUDA; USE_EVENT(kCPU) USE_EVENT_WAIT(kCPU, kCPU) diff --git a/paddle/fluid/platform/device_event_base.cc b/paddle/fluid/platform/device_event_base.cc index 67fad3857f2c142870ad08a14a82210a76a48cb9..374de7d923f306b89ccb92c68927a6946656866a 100644 --- a/paddle/fluid/platform/device_event_base.cc +++ b/paddle/fluid/platform/device_event_base.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/platform/device_event_base.h" + #include "paddle/fluid/platform/device_event_cpu.h" #include "paddle/fluid/platform/event.h" diff --git a/paddle/fluid/platform/device_event_base.h b/paddle/fluid/platform/device_event_base.h index 8fe5ef9fcb107bb1c36999f024f5fe5d506e4604..4e751aa6d133a8a3b06c2818683fc28fe1477f1c 100644 --- a/paddle/fluid/platform/device_event_base.h +++ b/paddle/fluid/platform/device_event_base.h @@ -13,6 +13,7 @@ // limitations under the License. #pragma once #include + #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/platform/device_event_cpu.h b/paddle/fluid/platform/device_event_cpu.h index 6e2bf4c7ad1356dee34e4f0c279202787a951918..1620dffdabd51773717e208de3a8dc127e68ae11 100644 --- a/paddle/fluid/platform/device_event_cpu.h +++ b/paddle/fluid/platform/device_event_cpu.h @@ -16,6 +16,7 @@ #include #include #include + #include "paddle/fluid/platform/device_event_base.h" namespace paddle { diff --git a/paddle/fluid/platform/device_event_gpu.cc b/paddle/fluid/platform/device_event_gpu.cc index f42ccc5a1db54efd70660beecd98bbda1a11dc41..f176d1a0d5dbd64651533f4b63decf6528f37630 100644 --- a/paddle/fluid/platform/device_event_gpu.cc +++ b/paddle/fluid/platform/device_event_gpu.cc @@ -101,8 +101,8 @@ void EventResetCUDA(const DeviceEvent* event) { } // namespace platform } // namespace paddle -using ::paddle::platform::kCUDA; using ::paddle::platform::kCPU; +using ::paddle::platform::kCUDA; REGISTER_EVENT_CREATE_FUNCTION(kCUDA, paddle::platform::DeviceEventCreateCUDA) REGISTER_EVENT_RECORD_FUNCTION(kCUDA, paddle::platform::DeviceEventRecordCUDA) REGISTER_EVENT_QUERY_FUNCTION(kCUDA, paddle::platform::DeviceEventQueryCUDA) diff --git a/paddle/fluid/platform/device_event_test.cc b/paddle/fluid/platform/device_event_test.cc index d9f744b26256b1f00bd256319a5ab606fe7a0b4c..92fe7c02bd0bd6e267ce269f0ad5f3bd8b888bb7 100644 --- a/paddle/fluid/platform/device_event_test.cc +++ b/paddle/fluid/platform/device_event_test.cc @@ -13,15 +13,16 @@ // limitations under the License. #include "paddle/fluid/platform/device_event.h" + #include "glog/logging.h" #include "gtest/gtest.h" #include "paddle/fluid/platform/place.h" -using ::paddle::platform::kCUDA; using ::paddle::platform::kCPU; +using ::paddle::platform::kCUDA; -using paddle::platform::DeviceEvent; using paddle::platform::DeviceContextPool; +using paddle::platform::DeviceEvent; #ifdef PADDLE_WITH_CUDA #include diff --git a/paddle/fluid/platform/device_tracer.cc b/paddle/fluid/platform/device_tracer.cc index 73847ce24aa72d926a9f5d28c59b2280625ca4c0..fa345ed31cbb280508d0f2af0c6d138d16bb1a94 100644 --- a/paddle/fluid/platform/device_tracer.cc +++ b/paddle/fluid/platform/device_tracer.cc @@ -12,6 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/platform/device_tracer.h" + #include #include #include @@ -20,7 +22,6 @@ limitations under the License. */ #include // NOLINT #include "glog/logging.h" -#include "paddle/fluid/platform/device_tracer.h" DECLARE_bool(enable_host_event_recorder_hook); @@ -255,7 +256,9 @@ void CUPTIAPI bufferCompleted(CUcontext ctx, uint32_t streamId, uint8_t *buffer, } break; } - default: { break; } + default: { + break; + } } } else if (status == CUPTI_ERROR_MAX_LIMIT_REACHED) { // Seems not an error in this case. diff --git a/paddle/fluid/platform/dynload/cublas.h b/paddle/fluid/platform/dynload/cublas.h index d7d43cecc25dd080462f892bc0a3bada1338874c..496b253dff5b3d91d282b83d3fd4ccfda147e432 100644 --- a/paddle/fluid/platform/dynload/cublas.h +++ b/paddle/fluid/platform/dynload/cublas.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include // NOLINT #include diff --git a/paddle/fluid/platform/dynload/cublasLt.h b/paddle/fluid/platform/dynload/cublasLt.h index 5157cfdad2e5939afb1b66b8c5ac80a4556669b6..3a1d28072c591c872c928c89a9c72332792445bd 100644 --- a/paddle/fluid/platform/dynload/cublasLt.h +++ b/paddle/fluid/platform/dynload/cublasLt.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include + #include // NOLINT #include diff --git a/paddle/fluid/platform/dynload/cuda_driver.cc b/paddle/fluid/platform/dynload/cuda_driver.cc index a0f9647f0893490bf12960d9674599a7bb7962b1..c6851594b803bf511f2f4b050168ebfb506f9236 100644 --- a/paddle/fluid/platform/dynload/cuda_driver.cc +++ b/paddle/fluid/platform/dynload/cuda_driver.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/dynload/cuda_driver.h" + #include "paddle/phi/backends/dynload/cuda_driver.h" namespace paddle { diff --git a/paddle/fluid/platform/dynload/cuda_driver.h b/paddle/fluid/platform/dynload/cuda_driver.h index f5550e9f9fe39e3e4213cc8a53fe789c65264437..b696ffc1a3be863704f5bf60b6f63667685c0b92 100644 --- a/paddle/fluid/platform/dynload/cuda_driver.h +++ b/paddle/fluid/platform/dynload/cuda_driver.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include // NOLINT #include "paddle/phi/backends/dynload/cuda_driver.h" diff --git a/paddle/fluid/platform/dynload/cudnn.cc b/paddle/fluid/platform/dynload/cudnn.cc index 553792d3bbf25e02d53c0162616999e160d4c6be..05cacb74c8673f08e4a2ecc56efb38fdd2c30275 100644 --- a/paddle/fluid/platform/dynload/cudnn.cc +++ b/paddle/fluid/platform/dynload/cudnn.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/dynload/cudnn.h" + #include "paddle/phi/backends/dynload/cudnn.h" namespace paddle { diff --git a/paddle/fluid/platform/dynload/cudnn.h b/paddle/fluid/platform/dynload/cudnn.h index bf4bb08a696ed868e15d0a7c8b34f19a83914fa0..9af1e8065c49dcbc580f39d88dc0d4aba91bd8ea 100644 --- a/paddle/fluid/platform/dynload/cudnn.h +++ b/paddle/fluid/platform/dynload/cudnn.h @@ -16,6 +16,7 @@ limitations under the License. */ #ifdef PADDLE_WITH_CUDA #include #include + #include // NOLINT #include "paddle/phi/backends/dynload/cudnn.h" diff --git a/paddle/fluid/platform/dynload/cufft.cc b/paddle/fluid/platform/dynload/cufft.cc index 1996ab16167f15c1f4a565e16246eed897555eec..6a06c4bdb6ac4745e6cbbcadf84ee172ead4752a 100644 --- a/paddle/fluid/platform/dynload/cufft.cc +++ b/paddle/fluid/platform/dynload/cufft.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/dynload/cufft.h" + #include "paddle/phi/backends/dynload/cufft.h" namespace paddle { diff --git a/paddle/fluid/platform/dynload/cufft.h b/paddle/fluid/platform/dynload/cufft.h index 6c3a0992d758db44c7939ca94a613cb3606afc1c..d79603a5a01fcba290e65a086318909faff1aab7 100644 --- a/paddle/fluid/platform/dynload/cufft.h +++ b/paddle/fluid/platform/dynload/cufft.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include // NOLINT #include "paddle/phi/backends/dynload/cufft.h" diff --git a/paddle/fluid/platform/dynload/cupti.h b/paddle/fluid/platform/dynload/cupti.h index 854e5a7b9f04a63e43e4e910c26d4e592651c125..8e08785f20925c49df2b1bdfa346a78c8967826a 100644 --- a/paddle/fluid/platform/dynload/cupti.h +++ b/paddle/fluid/platform/dynload/cupti.h @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include + #include // NOLINT #include "paddle/phi/backends/dynload/cupti.h" diff --git a/paddle/fluid/platform/dynload/curand.h b/paddle/fluid/platform/dynload/curand.h index 1fdd9240284dc86dd9441fd387ce97c7e10371dd..f4065a196d3c41868bad8054a6081ac852964fc2 100644 --- a/paddle/fluid/platform/dynload/curand.h +++ b/paddle/fluid/platform/dynload/curand.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include // NOLINT #include "paddle/phi/backends/dynload/curand.h" diff --git a/paddle/fluid/platform/dynload/cusolver.h b/paddle/fluid/platform/dynload/cusolver.h index 212c350ebb28816e50add6a328742e4239c7451a..854de23150cad7f108e72b175791bc57ef3854f8 100644 --- a/paddle/fluid/platform/dynload/cusolver.h +++ b/paddle/fluid/platform/dynload/cusolver.h @@ -15,6 +15,7 @@ limitations under the License. */ #include #include + #include // NOLINT #include "paddle/phi/backends/dynload/cusolver.h" diff --git a/paddle/fluid/platform/dynload/cusparse.h b/paddle/fluid/platform/dynload/cusparse.h index b4b93521678291f32790ab3b5b6ce02d5090774f..925852bb4158be1234ae20924bfe91c448326c55 100644 --- a/paddle/fluid/platform/dynload/cusparse.h +++ b/paddle/fluid/platform/dynload/cusparse.h @@ -15,6 +15,7 @@ limitations under the License. */ #include #include + #include // NOLINT #include "paddle/phi/backends/dynload/cusparse.h" diff --git a/paddle/fluid/platform/dynload/dynamic_loader.cc b/paddle/fluid/platform/dynload/dynamic_loader.cc index 5ce63b244efde5dd14bd5f07a2fe2c2ae33587c2..2f24e1b87dabad3dcacb0af7619d167ad8a6b79e 100644 --- a/paddle/fluid/platform/dynload/dynamic_loader.cc +++ b/paddle/fluid/platform/dynload/dynamic_loader.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include #include + #include "gflags/gflags.h" #include "paddle/phi/backends/dynload/dynamic_loader.h" diff --git a/paddle/fluid/platform/dynload/hiprtc.cc b/paddle/fluid/platform/dynload/hiprtc.cc index 6c4a4bfd0dedc65990ccef87039c2e153d5c6cf4..d9bb3fd2c4214f3042af22958f5e2125eb608beb 100644 --- a/paddle/fluid/platform/dynload/hiprtc.cc +++ b/paddle/fluid/platform/dynload/hiprtc.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/dynload/hiprtc.h" + #include "paddle/phi/backends/dynload/hiprtc.h" namespace paddle { diff --git a/paddle/fluid/platform/dynload/hiprtc.h b/paddle/fluid/platform/dynload/hiprtc.h index 851dadbac63d2fc373fd1c0232ab9c1d691a2eef..f27d5d808f77bab8fb7243fffeac5a7093c0f7b9 100644 --- a/paddle/fluid/platform/dynload/hiprtc.h +++ b/paddle/fluid/platform/dynload/hiprtc.h @@ -15,7 +15,9 @@ limitations under the License. */ #pragma once #include + #include // NOLINT + #include "paddle/phi/backends/dynload/hiprtc.h" namespace paddle { diff --git a/paddle/fluid/platform/dynload/miopen.cc b/paddle/fluid/platform/dynload/miopen.cc index 9660188b68d4fef1071a10becc63ad9bc7a67be3..15012531b4c9f62c98c8b951b170fb435a96eee2 100644 --- a/paddle/fluid/platform/dynload/miopen.cc +++ b/paddle/fluid/platform/dynload/miopen.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/dynload/miopen.h" + #include "paddle/phi/backends/dynload/cudnn.h" namespace paddle { diff --git a/paddle/fluid/platform/dynload/miopen.h b/paddle/fluid/platform/dynload/miopen.h index b99cd5ebb6e15b254c683d79ef204c208bc5e5fd..20b92b170511ccb919fef2c8a21b94611fd36d6f 100644 --- a/paddle/fluid/platform/dynload/miopen.h +++ b/paddle/fluid/platform/dynload/miopen.h @@ -14,10 +14,11 @@ limitations under the License. */ #pragma once #include - #include #include + #include // NOLINT + #include "paddle/phi/backends/dynload/miopen.h" namespace paddle { diff --git a/paddle/fluid/platform/dynload/mklml.h b/paddle/fluid/platform/dynload/mklml.h index 1c7d0c17a0fc84b2314ec3200e1a6e1f8ce8a5c7..78cae9a08215356595d0d022e8d420d8e569f2e7 100644 --- a/paddle/fluid/platform/dynload/mklml.h +++ b/paddle/fluid/platform/dynload/mklml.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include // NOLINT #include "paddle/phi/backends/dynload/mklml.h" diff --git a/paddle/fluid/platform/dynload/mklrt.h b/paddle/fluid/platform/dynload/mklrt.h index 334b98a1c3d5ab9442dfd2ca6b7c5d7055e94559..e1a2bedfa8e2c0bf72d682fa2aa903263d27d110 100644 --- a/paddle/fluid/platform/dynload/mklrt.h +++ b/paddle/fluid/platform/dynload/mklrt.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include // NOLINT #include "paddle/phi/backends/dynload/dynamic_loader.h" diff --git a/paddle/fluid/platform/dynload/nccl.h b/paddle/fluid/platform/dynload/nccl.h index a38d1d4272e397b748c7e3c9848930279212bb0e..c2052719dd56c364a96e16fc6e2652366f0cb7ef 100644 --- a/paddle/fluid/platform/dynload/nccl.h +++ b/paddle/fluid/platform/dynload/nccl.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include // NOLINT #include "paddle/phi/backends/dynload/nccl.h" diff --git a/paddle/fluid/platform/dynload/nvjpeg.h b/paddle/fluid/platform/dynload/nvjpeg.h index 8aaf672fe67b9f0a18d6b79db559505b5da0c821..026a3b6488606021d21e4a340ffe3fcb4b1ef623 100644 --- a/paddle/fluid/platform/dynload/nvjpeg.h +++ b/paddle/fluid/platform/dynload/nvjpeg.h @@ -12,6 +12,7 @@ limitations under the License. */ #ifdef PADDLE_WITH_CUDA #include + #include // NOLINT #include "paddle/phi/backends/dynload/nvjpeg.h" diff --git a/paddle/fluid/platform/dynload/nvrtc.cc b/paddle/fluid/platform/dynload/nvrtc.cc index a032299827742623ecd11a60b5d37856aa1af077..242aa912ad838fa755efbde5412d48ab3046ab7e 100644 --- a/paddle/fluid/platform/dynload/nvrtc.cc +++ b/paddle/fluid/platform/dynload/nvrtc.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/dynload/nvrtc.h" + #include "paddle/phi/backends/dynload/nvrtc.h" namespace paddle { diff --git a/paddle/fluid/platform/dynload/nvrtc.h b/paddle/fluid/platform/dynload/nvrtc.h index 5ca8860c5acbecac775b147702c26a610d0fe77a..e03235e116f252ed3b6868fef1cfcc555ada5768 100644 --- a/paddle/fluid/platform/dynload/nvrtc.h +++ b/paddle/fluid/platform/dynload/nvrtc.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include // NOLINT #include "paddle/phi/backends/dynload/nvrtc.h" diff --git a/paddle/fluid/platform/dynload/nvtx.h b/paddle/fluid/platform/dynload/nvtx.h index 3f974eca1d00bebe016e4518441c555983a37c41..c3dc9e31df354fe13798ee55b1e5a7e5afcb1625 100644 --- a/paddle/fluid/platform/dynload/nvtx.h +++ b/paddle/fluid/platform/dynload/nvtx.h @@ -15,6 +15,7 @@ limitations under the License. */ #ifndef _WIN32 #include #include + #include // NOLINT #include "paddle/phi/backends/dynload/nvtx.h" diff --git a/paddle/fluid/platform/dynload/rccl.h b/paddle/fluid/platform/dynload/rccl.h index 7bb4992c89cb9b65eeb97d0563fefaaa2a19cd99..2f874bb59f59366fd559c4d70fca2ce4d4562211 100644 --- a/paddle/fluid/platform/dynload/rccl.h +++ b/paddle/fluid/platform/dynload/rccl.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include // NOLINT + #include "paddle/phi/backends/dynload/rccl.h" namespace paddle { diff --git a/paddle/fluid/platform/dynload/rocblas.h b/paddle/fluid/platform/dynload/rocblas.h index 04f4fdd9506da75b4523ae26f3ea429bd4f76306..5cec6fb48798b790f3daf2433305cf79434afa3c 100644 --- a/paddle/fluid/platform/dynload/rocblas.h +++ b/paddle/fluid/platform/dynload/rocblas.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include // NOLINT #include diff --git a/paddle/fluid/platform/dynload/rocm_driver.cc b/paddle/fluid/platform/dynload/rocm_driver.cc index 088129f3f8d02e3258cc6f01f2815ed025e0bc17..4fa20c5c4bbb8c8a737d470fbb84b24b9445e20c 100644 --- a/paddle/fluid/platform/dynload/rocm_driver.cc +++ b/paddle/fluid/platform/dynload/rocm_driver.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/dynload/rocm_driver.h" + #include "paddle/phi/backends/dynload/rocm_driver.h" namespace paddle { diff --git a/paddle/fluid/platform/dynload/rocm_driver.h b/paddle/fluid/platform/dynload/rocm_driver.h index 5a902239fefd418d25597f8075f880e92f22456c..5c8e18611c40afdfbb73aaab44031aed7d756871 100644 --- a/paddle/fluid/platform/dynload/rocm_driver.h +++ b/paddle/fluid/platform/dynload/rocm_driver.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include // NOLINT #include "paddle/phi/backends/dynload/rocm_driver.h" diff --git a/paddle/fluid/platform/dynload/tensorrt.cc b/paddle/fluid/platform/dynload/tensorrt.cc index 8153877b7bbb892a5c108316f7fe28510fc64b79..8d700faac0c1485860cfb49f26a1ae37b155357f 100644 --- a/paddle/fluid/platform/dynload/tensorrt.cc +++ b/paddle/fluid/platform/dynload/tensorrt.cc @@ -13,6 +13,7 @@ limitations under the License. */ #include "paddle/fluid/platform/dynload/tensorrt.h" + #include namespace paddle { diff --git a/paddle/fluid/platform/enforce.h b/paddle/fluid/platform/enforce.h index 772a7750fe90d323045628f49c06cadf7d831dd2..1106eef455957ef53d78bdebb0f5893dc51f9195 100644 --- a/paddle/fluid/platform/enforce.h +++ b/paddle/fluid/platform/enforce.h @@ -36,6 +36,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/platform/external_error.pb.h" #endif // PADDLE_WITH_CUDA @@ -77,6 +78,7 @@ limitations under the License. */ #include "paddle/phi/backends/dynload/cusolver.h" #if !defined(__APPLE__) && defined(PADDLE_WITH_NCCL) #include + #include "paddle/phi/backends/dynload/nccl.h" #endif // __APPLE__ #endif // PADDLE_WITH_CUDA @@ -88,6 +90,7 @@ limitations under the License. */ #include "paddle/phi/backends/dynload/rocblas.h" #if !defined(__APPLE__) && defined(PADDLE_WITH_RCCL) #include // NOLINT + #include "paddle/phi/backends/dynload/rccl.h" #endif // __APPLE__ #endif // PADDLE_WITH_HIP diff --git a/paddle/fluid/platform/enforce_test.cc b/paddle/fluid/platform/enforce_test.cc index b9e423929916992fc718df495327e90b89f45a9c..771c4853f6f249a2772f43d89ef5fbb2c722519a 100644 --- a/paddle/fluid/platform/enforce_test.cc +++ b/paddle/fluid/platform/enforce_test.cc @@ -63,19 +63,22 @@ TEST(ENFORCE, FAILED) { TEST(ENFORCE, NO_ARG_OK) { int a = 2; int b = 2; - PADDLE_ENFORCE_EQ(a, b, paddle::platform::errors::Unavailable( - "PADDLE_ENFORCE_EQ tests failed.")); + PADDLE_ENFORCE_EQ( + a, b, + paddle::platform::errors::Unavailable("PADDLE_ENFORCE_EQ tests failed.")); // test enforce with extra message. - PADDLE_ENFORCE_EQ(a, b, paddle::platform::errors::Unavailable( - "Some %s wrong in PADDLE_ENFORCE_EQ.", "info")); + PADDLE_ENFORCE_EQ(a, b, + paddle::platform::errors::Unavailable( + "Some %s wrong in PADDLE_ENFORCE_EQ.", "info")); } TEST(ENFORCE_EQ, NO_EXTRA_MSG_FAIL) { int a = 2; bool caught_exception = false; try { - PADDLE_ENFORCE_EQ(a, 1 + 3, paddle::platform::errors::InvalidArgument( - "The result is not equal correct result.")); + PADDLE_ENFORCE_EQ(a, 1 + 3, + paddle::platform::errors::InvalidArgument( + "The result is not equal correct result.")); } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; std::string ex_msg = error.what(); @@ -89,8 +92,9 @@ TEST(ENFORCE_EQ, EXTRA_MSG_FAIL) { int a = 2; bool caught_exception = false; try { - PADDLE_ENFORCE_EQ(a, 1 + 3, paddle::platform::errors::InvalidArgument( - "The result is not equal correct result.")); + PADDLE_ENFORCE_EQ(a, 1 + 3, + paddle::platform::errors::InvalidArgument( + "The result is not equal correct result.")); } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; std::string ex_msg = error.what(); @@ -102,10 +106,12 @@ TEST(ENFORCE_EQ, EXTRA_MSG_FAIL) { } TEST(ENFORCE_NE, OK) { - PADDLE_ENFORCE_NE(1, 2, paddle::platform::errors::Unavailable( - "PADDLE_ENFORCE_NE tests failed.")); - PADDLE_ENFORCE_NE(1.0, 2UL, paddle::platform::errors::Unavailable( - "PADDLE_ENFORCE_NE tests failed.")); + PADDLE_ENFORCE_NE( + 1, 2, + paddle::platform::errors::Unavailable("PADDLE_ENFORCE_NE tests failed.")); + PADDLE_ENFORCE_NE( + 1.0, 2UL, + paddle::platform::errors::Unavailable("PADDLE_ENFORCE_NE tests failed.")); } TEST(ENFORCE_NE, FAIL) { bool caught_exception = false; @@ -125,14 +131,16 @@ TEST(ENFORCE_NE, FAIL) { } TEST(ENFORCE_GT, OK) { - PADDLE_ENFORCE_GT(2, 1, paddle::platform::errors::Unavailable( - "PADDLE_ENFORCE_GT tests failed.")); + PADDLE_ENFORCE_GT( + 2, 1, + paddle::platform::errors::Unavailable("PADDLE_ENFORCE_GT tests failed.")); } TEST(ENFORCE_GT, FAIL) { bool caught_exception = false; try { - PADDLE_ENFORCE_GT(1, 2, paddle::platform::errors::InvalidArgument( - "Expected 1 > 2, but received 1:1 <= 2:2.")); + PADDLE_ENFORCE_GT(1, 2, + paddle::platform::errors::InvalidArgument( + "Expected 1 > 2, but received 1:1 <= 2:2.")); } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; std::string ex_msg = error.what(); @@ -143,18 +151,22 @@ TEST(ENFORCE_GT, FAIL) { } TEST(ENFORCE_GE, OK) { - PADDLE_ENFORCE_GE(2, 2, paddle::platform::errors::Unavailable( - "PADDLE_ENFORCE_GE tests failed.")); - PADDLE_ENFORCE_GE(3, 2, paddle::platform::errors::Unavailable( - "PADDLE_ENFORCE_GE tests failed.")); - PADDLE_ENFORCE_GE(3.21, 2.0, paddle::platform::errors::Unavailable( - "PADDLE_ENFORCE_GE tests failed.")); + PADDLE_ENFORCE_GE( + 2, 2, + paddle::platform::errors::Unavailable("PADDLE_ENFORCE_GE tests failed.")); + PADDLE_ENFORCE_GE( + 3, 2, + paddle::platform::errors::Unavailable("PADDLE_ENFORCE_GE tests failed.")); + PADDLE_ENFORCE_GE( + 3.21, 2.0, + paddle::platform::errors::Unavailable("PADDLE_ENFORCE_GE tests failed.")); } TEST(ENFORCE_GE, FAIL) { bool caught_exception = false; try { - PADDLE_ENFORCE_GE(1, 2, paddle::platform::errors::InvalidArgument( - "Expected 1 >= 2, but received 1:1 < 2:2.")); + PADDLE_ENFORCE_GE(1, 2, + paddle::platform::errors::InvalidArgument( + "Expected 1 >= 2, but received 1:1 < 2:2.")); } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; std::string ex_msg = error.what(); @@ -165,22 +177,28 @@ TEST(ENFORCE_GE, FAIL) { } TEST(ENFORCE_LE, OK) { - PADDLE_ENFORCE_LE(1, 1, paddle::platform::errors::Unavailable( - "PADDLE_ENFORCE_LE tests failed.")); - PADDLE_ENFORCE_LE(1UL, 1UL, paddle::platform::errors::Unavailable( - "PADDLE_ENFORCE_LE tests failed.")); - PADDLE_ENFORCE_LE(2, 3, paddle::platform::errors::Unavailable( - "PADDLE_ENFORCE_LE tests failed.")); - PADDLE_ENFORCE_LE(2UL, 3UL, paddle::platform::errors::Unavailable( - "PADDLE_ENFORCE_LE tests failed.")); - PADDLE_ENFORCE_LE(2.0, 3.2, paddle::platform::errors::Unavailable( - "PADDLE_ENFORCE_LE tests failed.")); + PADDLE_ENFORCE_LE( + 1, 1, + paddle::platform::errors::Unavailable("PADDLE_ENFORCE_LE tests failed.")); + PADDLE_ENFORCE_LE( + 1UL, 1UL, + paddle::platform::errors::Unavailable("PADDLE_ENFORCE_LE tests failed.")); + PADDLE_ENFORCE_LE( + 2, 3, + paddle::platform::errors::Unavailable("PADDLE_ENFORCE_LE tests failed.")); + PADDLE_ENFORCE_LE( + 2UL, 3UL, + paddle::platform::errors::Unavailable("PADDLE_ENFORCE_LE tests failed.")); + PADDLE_ENFORCE_LE( + 2.0, 3.2, + paddle::platform::errors::Unavailable("PADDLE_ENFORCE_LE tests failed.")); } TEST(ENFORCE_LE, FAIL) { bool caught_exception = false; try { - PADDLE_ENFORCE_GT(1, 2, paddle::platform::errors::InvalidArgument( - "Expected 1 > 2, but received 1:1 <= 2:2.")); + PADDLE_ENFORCE_GT(1, 2, + paddle::platform::errors::InvalidArgument( + "Expected 1 > 2, but received 1:1 <= 2:2.")); } catch (paddle::platform::EnforceNotMet& error) { caught_exception = true; std::string ex_msg = error.what(); @@ -191,12 +209,15 @@ TEST(ENFORCE_LE, FAIL) { } TEST(ENFORCE_LT, OK) { - PADDLE_ENFORCE_LT(3, 10, paddle::platform::errors::Unavailable( - "PADDLE_ENFORCE_LT tests failed.")); - PADDLE_ENFORCE_LT(2UL, 3UL, paddle::platform::errors::Unavailable( - "PADDLE_ENFORCE_LT tests failed.")); - PADDLE_ENFORCE_LT(2, 3, paddle::platform::errors::Unavailable( - "PADDLE_ENFORCE_LT tests failed.")); + PADDLE_ENFORCE_LT( + 3, 10, + paddle::platform::errors::Unavailable("PADDLE_ENFORCE_LT tests failed.")); + PADDLE_ENFORCE_LT( + 2UL, 3UL, + paddle::platform::errors::Unavailable("PADDLE_ENFORCE_LT tests failed.")); + PADDLE_ENFORCE_LT( + 2, 3, + paddle::platform::errors::Unavailable("PADDLE_ENFORCE_LT tests failed.")); } TEST(ENFORCE_LT, FAIL) { bool caught_exception = false; @@ -263,16 +284,18 @@ std::ostream& operator<<(std::ostream& os, const Dims& d) { TEST(ENFORCE_USER_DEFINED_CLASS, EQ) { Dims a{{1, 2, 3, 4}}, b{{1, 2, 3, 4}}; - PADDLE_ENFORCE_EQ(a, b, paddle::platform::errors::Unavailable( - "PADDLE_ENFORCE_EQ tests failed.")); + PADDLE_ENFORCE_EQ( + a, b, + paddle::platform::errors::Unavailable("PADDLE_ENFORCE_EQ tests failed.")); } TEST(ENFORCE_USER_DEFINED_CLASS, NE) { Dims a{{1, 2, 3, 4}}, b{{5, 6, 7, 8}}; bool caught_exception = false; try { - PADDLE_ENFORCE_EQ(a, b, paddle::platform::errors::Unavailable( - "PADDLE_ENFORCE_EQ tests failed.")); + PADDLE_ENFORCE_EQ(a, b, + paddle::platform::errors::Unavailable( + "PADDLE_ENFORCE_EQ tests failed.")); } catch (paddle::platform::EnforceNotMet&) { caught_exception = true; } @@ -481,10 +504,12 @@ TEST(enforce, cannot_to_string_type) { "int can be converted to string"); CannotToStringType obj1(3), obj2(4), obj3(3); - PADDLE_ENFORCE_NE(obj1, obj2, paddle::platform::errors::InvalidArgument( - "Object 1 is not equal to Object 2")); - PADDLE_ENFORCE_EQ(obj1, obj3, paddle::platform::errors::InvalidArgument( - "Object 1 is equal to Object 3")); + PADDLE_ENFORCE_NE(obj1, obj2, + paddle::platform::errors::InvalidArgument( + "Object 1 is not equal to Object 2")); + PADDLE_ENFORCE_EQ(obj1, obj3, + paddle::platform::errors::InvalidArgument( + "Object 1 is equal to Object 3")); std::string msg = "Compare obj1 with obj2"; try { diff --git a/paddle/fluid/platform/errors.h b/paddle/fluid/platform/errors.h index 57f5b3a7c93743aa1262fda134064eabdc983aa3..758af3e2d9137ec96a071817f530ebcedd727c97 100644 --- a/paddle/fluid/platform/errors.h +++ b/paddle/fluid/platform/errors.h @@ -18,5 +18,5 @@ namespace paddle { namespace platform { namespace errors = ::phi::errors; using error = ::phi::ErrorCode; -} -} +} // namespace platform +} // namespace paddle diff --git a/paddle/fluid/platform/errors_test.cc b/paddle/fluid/platform/errors_test.cc index 712b67a654c401aff71182cdd1590f802980aabd..8b11c1d2d2492c2b57cfde600055a1cbfd58c091 100644 --- a/paddle/fluid/platform/errors_test.cc +++ b/paddle/fluid/platform/errors_test.cc @@ -12,11 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/platform/errors.h" + #include #include "gtest/gtest.h" #include "paddle/fluid/platform/enforce.h" -#include "paddle/fluid/platform/errors.h" using namespace paddle::platform::errors; // NOLINT diff --git a/paddle/fluid/platform/fast_divmod.h b/paddle/fluid/platform/fast_divmod.h index bef551078b332888c412f7558a208fb0f52b434c..f2a150c301216b120692cd414559e269e9a5b2f6 100644 --- a/paddle/fluid/platform/fast_divmod.h +++ b/paddle/fluid/platform/fast_divmod.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/phi/kernels/funcs/aligned_vector.h" #define INT_BITS 32 diff --git a/paddle/fluid/platform/flags.h b/paddle/fluid/platform/flags.h index b9d78c2e9dc3951d3d79bf60496aa04c15afbf5d..0a38d61293978f1d5e086b2086a76e6a20e75244 100644 --- a/paddle/fluid/platform/flags.h +++ b/paddle/fluid/platform/flags.h @@ -18,6 +18,7 @@ #include #include #include + #include "gflags/gflags.h" #include "paddle/fluid/platform/macros.h" #include "paddle/fluid/platform/variant.h" diff --git a/paddle/fluid/platform/float16_test.cu b/paddle/fluid/platform/float16_test.cu index 2c00854e082ebdb79515141a2a8133bceedc408c..dc7fdc6b443d93d62e90738a3535c0523ba8c12a 100644 --- a/paddle/fluid/platform/float16_test.cu +++ b/paddle/fluid/platform/float16_test.cu @@ -14,6 +14,7 @@ limitations under the License. */ #define GLOG_NO_ABBREVIATED_SEVERITIES // msvc conflict logging with windows.h #include #include + #include #include diff --git a/paddle/fluid/platform/gen_comm_id_helper.cc b/paddle/fluid/platform/gen_comm_id_helper.cc index bbec743d26f3b7ccf9ed9f049f3100dc25f50bad..45ca4a6f27765d979eb03b19d3a68cc81426811b 100644 --- a/paddle/fluid/platform/gen_comm_id_helper.cc +++ b/paddle/fluid/platform/gen_comm_id_helper.cc @@ -22,6 +22,7 @@ limitations under the License. */ #include #include #include + #include #include #include // NOLINT diff --git a/paddle/fluid/platform/init_test.cc b/paddle/fluid/platform/init_test.cc index 5301dd307590b25d457d658b4468998fb71137b0..bc5bd274bf8a785b6844ccc485033f3293798746 100644 --- a/paddle/fluid/platform/init_test.cc +++ b/paddle/fluid/platform/init_test.cc @@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/init.h" + #include "gtest/gtest.h" #include "paddle/fluid/platform/device_context.h" #ifdef PADDLE_WITH_MLU diff --git a/paddle/fluid/platform/lock_guard_ptr.h b/paddle/fluid/platform/lock_guard_ptr.h index bff24e74a7070b31d6385b2d5924bdc62d7219c9..66d6e446d3f1631d1ed74d52e05de78c9eeb3021 100644 --- a/paddle/fluid/platform/lock_guard_ptr.h +++ b/paddle/fluid/platform/lock_guard_ptr.h @@ -14,6 +14,7 @@ #pragma once #include + #include #include // NOLINT namespace paddle { diff --git a/paddle/fluid/platform/mkldnn_reuse.h b/paddle/fluid/platform/mkldnn_reuse.h index 5476d244f6035b9160d69b8ed14f51e2cc554f7a..382f96e83bfce5e53a4e7bf69c74f1655d2a9dda 100644 --- a/paddle/fluid/platform/mkldnn_reuse.h +++ b/paddle/fluid/platform/mkldnn_reuse.h @@ -1061,16 +1061,18 @@ static void SetDstMemoryQuantized( const size_t dst_dims = dst_tz.size(); MKLDNNMemoryFormat dst_fmt; - PADDLE_ENFORCE_LE(dst_dims, 5, platform::errors::InvalidArgument( - "Dst memory for quantization can not have " - "dims > 5. But received dst_dims is %d.", - dst_dims)); + PADDLE_ENFORCE_LE(dst_dims, 5, + platform::errors::InvalidArgument( + "Dst memory for quantization can not have " + "dims > 5. But received dst_dims is %d.", + dst_dims)); dst_fmt = platform::MKLDNNFormatForSize(dst_dims, output_format); - auto tmp_dst_md = platform::MKLDNNMemDesc( - {dst_tz}, paddle::framework::ToMKLDNNDataType( - framework::DataTypeTrait::DataType()), - dst_fmt); + auto tmp_dst_md = + platform::MKLDNNMemDesc({dst_tz}, + paddle::framework::ToMKLDNNDataType( + framework::DataTypeTrait::DataType()), + dst_fmt); dst_md.reset(new dnnl::memory::desc(tmp_dst_md)); dst_memory.reset( new dnnl::memory(*dst_md, engine, to_void_cast(output_data))); diff --git a/paddle/fluid/platform/monitor.h b/paddle/fluid/platform/monitor.h index dc9abaf36d8250f0cfe82b3a37b6d3759826f475..e7612f6dcb6cde82c1a513170b800992f74a3527 100644 --- a/paddle/fluid/platform/monitor.h +++ b/paddle/fluid/platform/monitor.h @@ -15,6 +15,7 @@ #pragma once #include + #include #include #include // NOLINT diff --git a/paddle/fluid/platform/os_info.cc b/paddle/fluid/platform/os_info.cc index 36dd7891d5518681140a86215cb6f0792ee1bdd7..694f701b5ad9b31809806f4b66f7c7517b693bac 100644 --- a/paddle/fluid/platform/os_info.cc +++ b/paddle/fluid/platform/os_info.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/os_info.h" + #include #include #include diff --git a/paddle/fluid/platform/os_info_test.cc b/paddle/fluid/platform/os_info_test.cc index b3311f1d19e6304a0b232cd936397559224e9b96..149da6ba27aead88979c62ec92cb0bea34c4c5da 100644 --- a/paddle/fluid/platform/os_info_test.cc +++ b/paddle/fluid/platform/os_info_test.cc @@ -12,13 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "paddle/fluid/platform/os_info.h" + #include + #include "gtest/gtest.h" TEST(ThreadInfo, TestThreadIdUtils) { - using paddle::platform::GetCurrentThreadStdId; - using paddle::platform::GetCurrentThreadId; using paddle::platform::GetAllThreadIds; + using paddle::platform::GetCurrentThreadId; + using paddle::platform::GetCurrentThreadStdId; EXPECT_EQ(std::hash()(std::this_thread::get_id()), GetCurrentThreadId().std_tid); auto ids = GetAllThreadIds(); @@ -26,10 +28,10 @@ TEST(ThreadInfo, TestThreadIdUtils) { } TEST(ThreadInfo, TestThreadNameUtils) { - using paddle::platform::GetCurrentThreadStdId; + using paddle::platform::GetAllThreadNames; using paddle::platform::GetCurrentThreadName; + using paddle::platform::GetCurrentThreadStdId; using paddle::platform::SetCurrentThreadName; - using paddle::platform::GetAllThreadNames; SetCurrentThreadName("MainThread"); EXPECT_FALSE(SetCurrentThreadName("MainThread")); auto names = GetAllThreadNames(); diff --git a/paddle/fluid/platform/profiler.cc b/paddle/fluid/platform/profiler.cc index 75abf36e676d06321e9d2eefb3d03bea5cafcaf0..c573650f1791fdab6e77d267c29aec6ac0091504 100644 --- a/paddle/fluid/platform/profiler.cc +++ b/paddle/fluid/platform/profiler.cc @@ -12,6 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/platform/profiler.h" + #include // NOLINT #include #include @@ -20,7 +22,6 @@ limitations under the License. */ #include "paddle/fluid/platform/device_tracer.h" #include "paddle/fluid/platform/enforce.h" -#include "paddle/fluid/platform/profiler.h" #include "paddle/fluid/platform/profiler/common_event.h" #include "paddle/fluid/platform/profiler/host_event_recorder.h" #include "paddle/fluid/platform/profiler/host_tracer.h" diff --git a/paddle/fluid/platform/profiler/chrometracing_logger.cc b/paddle/fluid/platform/profiler/chrometracing_logger.cc index 4ee95a530fb43fa5fe13c60f49a3c6b2d48cc74f..f728a820bd73cd5c2fe8d5db25a16675d3f0e82a 100644 --- a/paddle/fluid/platform/profiler/chrometracing_logger.cc +++ b/paddle/fluid/platform/profiler/chrometracing_logger.cc @@ -12,15 +12,15 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/platform/profiler/chrometracing_logger.h" + #include #include #include #include "glog/logging.h" - #include "paddle/fluid/platform/device/gpu/gpu_info.h" #include "paddle/fluid/platform/enforce.h" -#include "paddle/fluid/platform/profiler/chrometracing_logger.h" #include "paddle/fluid/platform/profiler/event_node.h" #include "paddle/fluid/platform/profiler/utils.h" @@ -304,9 +304,10 @@ void ChromeTracingLogger::HandleTypeKernel( blocks_per_sm = static_cast(kernel_info.grid_x * kernel_info.grid_y * kernel_info.grid_z) / device_property.multiProcessorCount; - warps_per_sm = blocks_per_sm * (kernel_info.block_x * kernel_info.block_y * - kernel_info.block_z) / - threads_per_warp; + warps_per_sm = + blocks_per_sm * + (kernel_info.block_x * kernel_info.block_y * kernel_info.block_z) / + threads_per_warp; occupancy = CalculateEstOccupancy( device_node.DeviceId(), kernel_info.registers_per_thread, kernel_info.static_shared_memory, kernel_info.dynamic_shared_memory, diff --git a/paddle/fluid/platform/profiler/chrometracing_logger.h b/paddle/fluid/platform/profiler/chrometracing_logger.h index 8977ab748c63a3b38bbc6e633cf9ff857bf15ae2..12d98d1ef0c6360caece3b803bb81ab467269b1a 100644 --- a/paddle/fluid/platform/profiler/chrometracing_logger.h +++ b/paddle/fluid/platform/profiler/chrometracing_logger.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/platform/profiler/output_logger.h" namespace paddle { diff --git a/paddle/fluid/platform/profiler/common_event.h b/paddle/fluid/platform/profiler/common_event.h index cfdc3be110a5b0886ae7d7b4ed24b89cd2eb35d8..8fe3b1505230615885cfee9e6a04db9ce0e0bb24 100644 --- a/paddle/fluid/platform/profiler/common_event.h +++ b/paddle/fluid/platform/profiler/common_event.h @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/fluid/platform/event.h" // import EventRole, TODO(TIEXING): remove later #include "paddle/fluid/platform/profiler/trace_event.h" diff --git a/paddle/fluid/platform/profiler/cpu_utilization.cc b/paddle/fluid/platform/profiler/cpu_utilization.cc index d507153d3f5b47ef072f9da0276073448127fb9c..4319841c8a93bf6fd951fc3c6e7cbeb9630a69f1 100644 --- a/paddle/fluid/platform/profiler/cpu_utilization.cc +++ b/paddle/fluid/platform/profiler/cpu_utilization.cc @@ -54,12 +54,13 @@ void CpuUtilization::RecordBeginTimeInfo() { if (stat_file != nullptr) { char temp_str[200]; uint64_t temp_lu; - int retval = fscanf( - stat_file, "%s %" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 - "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64, - temp_str, &system_tms_start_.tms_utime, &nice_time_start_, - &system_tms_start_.tms_stime, &idle_start_, &iowait_start_, &irq_start_, - &softirq_start_, &steal_start_, &temp_lu, &temp_lu); + int retval = + fscanf(stat_file, + "%s %" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 + "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64, + temp_str, &system_tms_start_.tms_utime, &nice_time_start_, + &system_tms_start_.tms_stime, &idle_start_, &iowait_start_, + &irq_start_, &softirq_start_, &steal_start_, &temp_lu, &temp_lu); if (retval != 11) { LOG(WARNING) << "Failed to read cpu utilization information at record beginning." @@ -87,12 +88,13 @@ void CpuUtilization::RecordEndTimeInfo() { if (stat_file != nullptr) { char temp_str[200]; uint64_t temp_lu; - int retval = fscanf( - stat_file, "%s %" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 - "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64, - temp_str, &system_tms_end_.tms_utime, &nice_time_end_, - &system_tms_end_.tms_stime, &idle_end_, &iowait_end_, &irq_end_, - &softirq_end_, &steal_end_, &temp_lu, &temp_lu); + int retval = + fscanf(stat_file, + "%s %" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 + "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64, + temp_str, &system_tms_end_.tms_utime, &nice_time_end_, + &system_tms_end_.tms_stime, &idle_end_, &iowait_end_, &irq_end_, + &softirq_end_, &steal_end_, &temp_lu, &temp_lu); if (retval != 11) { LOG(WARNING) diff --git a/paddle/fluid/platform/profiler/cpu_utilization.h b/paddle/fluid/platform/profiler/cpu_utilization.h index 7b05a6302cdb0628ad526b3fc6ae18fcb8df619b..aa25ae5a43c10e6c039c3452e2339c104118f521 100644 --- a/paddle/fluid/platform/profiler/cpu_utilization.h +++ b/paddle/fluid/platform/profiler/cpu_utilization.h @@ -15,8 +15,10 @@ #pragma once #include + #include #include + #include "glog/logging.h" #ifdef _MSC_VER #include diff --git a/paddle/fluid/platform/profiler/cuda_tracer.cc b/paddle/fluid/platform/profiler/cuda_tracer.cc index 2d3e354dc271a0241a9b63005aa29970d1548109..9e32f7bbf19ee1ca4084e817971915d629386be1 100644 --- a/paddle/fluid/platform/profiler/cuda_tracer.cc +++ b/paddle/fluid/platform/profiler/cuda_tracer.cc @@ -13,8 +13,10 @@ // limitations under the License. #include "paddle/fluid/platform/profiler/cuda_tracer.h" + #include #include + #include "glog/logging.h" #include "paddle/fluid/framework/new_executor/workqueue/workqueue_utils.h" #include "paddle/fluid/platform/os_info.h" diff --git a/paddle/fluid/platform/profiler/cuda_tracer.h b/paddle/fluid/platform/profiler/cuda_tracer.h index 20a60521266a2b32e01508a59981956870ee09dc..36c5ab4eb55468d10ed40ff52a3cdb9d841634cb 100644 --- a/paddle/fluid/platform/profiler/cuda_tracer.h +++ b/paddle/fluid/platform/profiler/cuda_tracer.h @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/fluid/platform/dynload/cupti.h" #include "paddle/fluid/platform/macros.h" #include "paddle/fluid/platform/profiler/tracer_base.h" diff --git a/paddle/fluid/platform/profiler/cupti_data_process.cc b/paddle/fluid/platform/profiler/cupti_data_process.cc index da12dccb74924fd27dee3047d29636341f7c47a2..7cb8b597dcdd06c66c8b48c46a8d2a2946ef83d0 100644 --- a/paddle/fluid/platform/profiler/cupti_data_process.cc +++ b/paddle/fluid/platform/profiler/cupti_data_process.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/platform/profiler/cupti_data_process.h" + #include + #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/os_info.h" diff --git a/paddle/fluid/platform/profiler/cupti_data_process.h b/paddle/fluid/platform/profiler/cupti_data_process.h index 01b2e72ade4e2e0d8061bad6cbcfa539a7dd8275..7b800464734567ddba4d97f225786168373d404e 100644 --- a/paddle/fluid/platform/profiler/cupti_data_process.h +++ b/paddle/fluid/platform/profiler/cupti_data_process.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/platform/dynload/cupti.h" #include "paddle/fluid/platform/profiler/trace_event_collector.h" diff --git a/paddle/fluid/platform/profiler/dump/deserialization_reader.cc b/paddle/fluid/platform/profiler/dump/deserialization_reader.cc index de3411579d3e9f72959a26e0e870e079e08913e8..82363fcff63491637a3ca16312e1f5d519f7f955 100644 --- a/paddle/fluid/platform/profiler/dump/deserialization_reader.cc +++ b/paddle/fluid/platform/profiler/dump/deserialization_reader.cc @@ -9,7 +9,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/profiler/dump/deserialization_reader.h" + #include + #include "paddle/fluid/platform/profiler/extra_info.h" namespace paddle { diff --git a/paddle/fluid/platform/profiler/dump/serialization_logger.cc b/paddle/fluid/platform/profiler/dump/serialization_logger.cc index 73021f4362af5df52129dac394de94e59f6e5f3b..b8afe2af0e77625cf30394de5f7ece1a24115d68 100644 --- a/paddle/fluid/platform/profiler/dump/serialization_logger.cc +++ b/paddle/fluid/platform/profiler/dump/serialization_logger.cc @@ -9,9 +9,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "glog/logging.h" - #include "paddle/fluid/platform/profiler/dump/serialization_logger.h" + +#include "glog/logging.h" #include "paddle/fluid/platform/profiler/event_node.h" #include "paddle/fluid/platform/profiler/extra_info.h" #include "paddle/fluid/platform/profiler/utils.h" diff --git a/paddle/fluid/platform/profiler/dump/test_serialization_logger.cc b/paddle/fluid/platform/profiler/dump/test_serialization_logger.cc index d294bfee58c2b5327ed709a795e756144ae1f3c1..5253ecc505dbb4dd3a39390027b56b7423c8ac58 100644 --- a/paddle/fluid/platform/profiler/dump/test_serialization_logger.cc +++ b/paddle/fluid/platform/profiler/dump/test_serialization_logger.cc @@ -13,26 +13,25 @@ // limitations under the License. #include "gtest/gtest.h" - #include "paddle/fluid/platform/profiler/dump/deserialization_reader.h" #include "paddle/fluid/platform/profiler/dump/serialization_logger.h" #include "paddle/fluid/platform/profiler/event_node.h" #include "paddle/fluid/platform/profiler/event_python.h" -using paddle::platform::SerializationLogger; -using paddle::platform::DeserializationReader; -using paddle::platform::NodeTrees; -using paddle::platform::HostTraceEventNode; using paddle::platform::CudaRuntimeTraceEventNode; +using paddle::platform::DeserializationReader; +using paddle::platform::DeviceTraceEvent; using paddle::platform::DeviceTraceEventNode; using paddle::platform::HostTraceEvent; -using paddle::platform::RuntimeTraceEvent; -using paddle::platform::DeviceTraceEvent; -using paddle::platform::TracerEventType; +using paddle::platform::HostTraceEventNode; using paddle::platform::KernelEventInfo; using paddle::platform::MemcpyEventInfo; using paddle::platform::MemsetEventInfo; +using paddle::platform::NodeTrees; using paddle::platform::ProfilerResult; +using paddle::platform::RuntimeTraceEvent; +using paddle::platform::SerializationLogger; +using paddle::platform::TracerEventType; TEST(SerializationLoggerTest, dump_case0) { std::list host_events; diff --git a/paddle/fluid/platform/profiler/event_node.cc b/paddle/fluid/platform/profiler/event_node.cc index b909fb5f25aa7b4098d809af8993a85e51e73f84..e1af63ad8909c7ec536271ca5c1bb3fc0695dfdb 100644 --- a/paddle/fluid/platform/profiler/event_node.cc +++ b/paddle/fluid/platform/profiler/event_node.cc @@ -12,6 +12,7 @@ limitations under the License. */ #include "paddle/fluid/platform/profiler/event_node.h" #include + #include #include #include diff --git a/paddle/fluid/platform/profiler/event_python.cc b/paddle/fluid/platform/profiler/event_python.cc index 5c42c8e8bf61ebcd798ed4203fbeb7eb0c47f621..abde62c6b1444d9abbd4c2a1a06b8c7a4d955c8b 100644 --- a/paddle/fluid/platform/profiler/event_python.cc +++ b/paddle/fluid/platform/profiler/event_python.cc @@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/profiler/event_python.h" + #include "paddle/fluid/platform/profiler/chrometracing_logger.h" #include "paddle/fluid/platform/profiler/dump/deserialization_reader.h" #include "paddle/fluid/platform/profiler/dump/serialization_logger.h" diff --git a/paddle/fluid/platform/profiler/event_tracing.h b/paddle/fluid/platform/profiler/event_tracing.h index fcaba9a43ca9385ab38e440f7b8659298a02ef05..fd81c15f92ad787818e308354e717c8b65a0fe8d 100644 --- a/paddle/fluid/platform/profiler/event_tracing.h +++ b/paddle/fluid/platform/profiler/event_tracing.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/platform/event.h" #include "paddle/fluid/platform/profiler/trace_event.h" @@ -70,10 +71,11 @@ class RecordEvent { * @param level: Used to filter events, works like glog VLOG(level). * RecordEvent will works if HostTraceLevel >= level. */ - explicit RecordEvent(const char* name, const TracerEventType type = - TracerEventType::UserDefined, - uint32_t level = kDefaultTraceLevel, - const EventRole role = EventRole::kOrdinary); + explicit RecordEvent( + const char* name, + const TracerEventType type = TracerEventType::UserDefined, + uint32_t level = kDefaultTraceLevel, + const EventRole role = EventRole::kOrdinary); RecordEvent(const std::string& name, const std::string& attr, const TracerEventType type = TracerEventType::UserDefined, diff --git a/paddle/fluid/platform/profiler/host_event_recorder.h b/paddle/fluid/platform/profiler/host_event_recorder.h index afd4135246556624cb022243e0e98b5ad9f9f6da..1359c3b85a0964367b1d8bb8a6c9bfffca4d7f64 100644 --- a/paddle/fluid/platform/profiler/host_event_recorder.h +++ b/paddle/fluid/platform/profiler/host_event_recorder.h @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/fluid/framework/new_executor/workqueue/thread_data_registry.h" #include "paddle/fluid/platform/macros.h" #include "paddle/fluid/platform/os_info.h" @@ -58,7 +59,7 @@ class EventContainer { public: // Record an event template - void Record(Args &&... args) { + void Record(Args &&...args) { DoRecord(ContainsStdString(), std::forward(args)...); } @@ -112,7 +113,7 @@ class EventContainer { // Record an event with string arguments template - void DoRecord(std::true_type, Args &&... args) { + void DoRecord(std::true_type, Args &&...args) { auto *storage = GetEventStorage(); std::function allocator = [this](size_t size) { return GetStrBufFromArena(size); @@ -122,7 +123,7 @@ class EventContainer { // Record an event without any string argument template - void DoRecord(std::false_type, Args &&... args) { + void DoRecord(std::false_type, Args &&...args) { auto *storage = GetEventStorage(); new (storage) EventType(std::forward(args)...); } @@ -199,7 +200,7 @@ class ThreadEventRecorder { public: // Forward call to EventContainer::Record template - void RecordEvent(Args &&... args) { + void RecordEvent(Args &&...args) { base_evt_cntr_.Record(std::forward(args)...); } @@ -237,7 +238,7 @@ class HostEventRecorder { // Do your best to avoid using 'std::string' as the argument type. // It will cause deep-copy to harm performance. template - void RecordEvent(Args &&... args) { + void RecordEvent(Args &&...args) { GetThreadLocalRecorder()->RecordEvent(std::forward(args)...); } diff --git a/paddle/fluid/platform/profiler/host_tracer.cc b/paddle/fluid/platform/profiler/host_tracer.cc index b7eb53331b793a74ff265947e381ef6d5d03d3da..8a36a3a8bab44e89f76b6ee6ce4aa565febd7807 100644 --- a/paddle/fluid/platform/profiler/host_tracer.cc +++ b/paddle/fluid/platform/profiler/host_tracer.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/platform/profiler/host_tracer.h" + #include "glog/logging.h" #include "paddle/fluid/platform/flags.h" #include "paddle/fluid/platform/profiler/common_event.h" diff --git a/paddle/fluid/platform/profiler/mlu/cnpapi_data_process.cc b/paddle/fluid/platform/profiler/mlu/cnpapi_data_process.cc index 36abf77279d061f72a47fae32d5cd54c4f03a160..7afdb5eb2a352667dd18d2f6f4ecdf2cf3def698 100644 --- a/paddle/fluid/platform/profiler/mlu/cnpapi_data_process.cc +++ b/paddle/fluid/platform/profiler/mlu/cnpapi_data_process.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/fluid/platform/profiler/mlu/cnpapi_data_process.h" + #include + #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/os_info.h" diff --git a/paddle/fluid/platform/profiler/mlu/mlu_tracer.cc b/paddle/fluid/platform/profiler/mlu/mlu_tracer.cc index 2d719a8bbfdcb1a16aefbaa1711eb8fbfaab8fbd..bbaafa3faa60a52efaf868276b055df5a0636a51 100644 --- a/paddle/fluid/platform/profiler/mlu/mlu_tracer.cc +++ b/paddle/fluid/platform/profiler/mlu/mlu_tracer.cc @@ -13,8 +13,10 @@ // limitations under the License. #include "paddle/fluid/platform/profiler/mlu/mlu_tracer.h" + #include #include + #include "glog/logging.h" #include "paddle/fluid/framework/new_executor/workqueue/workqueue_utils.h" #include "paddle/fluid/platform/os_info.h" diff --git a/paddle/fluid/platform/profiler/profiler.cc b/paddle/fluid/platform/profiler/profiler.cc index a417eda1509e5c2ede86e01cb18feaf263efcaef..8bcf856c01ab63495c84e1dad69c438c89500cce 100644 --- a/paddle/fluid/platform/profiler/profiler.cc +++ b/paddle/fluid/platform/profiler/profiler.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/platform/profiler/profiler.h" + #include "glog/logging.h" #ifdef PADDLE_WITH_CUDA #include diff --git a/paddle/fluid/platform/profiler/profiler.h b/paddle/fluid/platform/profiler/profiler.h index ea346a4fb748def7a2b0a7678880b30e4673fe66..65a3bcc02d857289a7d2a40e6f3cfa2d31154f01 100644 --- a/paddle/fluid/platform/profiler/profiler.h +++ b/paddle/fluid/platform/profiler/profiler.h @@ -20,6 +20,7 @@ #include #include #include + #include "paddle/fluid/platform/macros.h" #include "paddle/fluid/platform/profiler/cpu_utilization.h" #include "paddle/fluid/platform/profiler/event_node.h" diff --git a/paddle/fluid/platform/profiler/profiler_test.cc b/paddle/fluid/platform/profiler/profiler_test.cc index f2c867ffff21790719e3e70f9a9e9c86168f2a37..1f1fbcb71ecd5f9a7206aa24b1add4bc229e1d80 100644 --- a/paddle/fluid/platform/profiler/profiler_test.cc +++ b/paddle/fluid/platform/profiler/profiler_test.cc @@ -14,6 +14,7 @@ #include #include + #include "glog/logging.h" #include "gtest/gtest.h" #ifdef PADDLE_WITH_CUDA @@ -27,11 +28,11 @@ #include "paddle/fluid/platform/profiler/profiler.h" TEST(ProfilerTest, TestHostTracer) { - using paddle::platform::ProfilerOptions; using paddle::platform::Profiler; + using paddle::platform::ProfilerOptions; + using paddle::platform::ProfilerResult; using paddle::platform::RecordInstantEvent; using paddle::platform::TracerEventType; - using paddle::platform::ProfilerResult; ProfilerOptions options; options.trace_level = 2; options.trace_switch = 3; @@ -58,8 +59,8 @@ TEST(ProfilerTest, TestHostTracer) { } TEST(ProfilerTest, TestCudaTracer) { - using paddle::platform::ProfilerOptions; using paddle::platform::Profiler; + using paddle::platform::ProfilerOptions; using paddle::platform::ProfilerResult; ProfilerOptions options; options.trace_level = 0; diff --git a/paddle/fluid/platform/profiler/test_event_node.cc b/paddle/fluid/platform/profiler/test_event_node.cc index b8d1306ad076c0d6b7c90affb678d9d80151af59..23ad917b57d0eb477bc4664fbb2f7b91bb8caea5 100644 --- a/paddle/fluid/platform/profiler/test_event_node.cc +++ b/paddle/fluid/platform/profiler/test_event_node.cc @@ -13,22 +13,21 @@ // limitations under the License. #include "gtest/gtest.h" - #include "paddle/fluid/platform/profiler/chrometracing_logger.h" #include "paddle/fluid/platform/profiler/event_node.h" using paddle::platform::ChromeTracingLogger; -using paddle::platform::NodeTrees; -using paddle::platform::HostTraceEventNode; using paddle::platform::CudaRuntimeTraceEventNode; +using paddle::platform::DeviceTraceEvent; using paddle::platform::DeviceTraceEventNode; using paddle::platform::HostTraceEvent; -using paddle::platform::RuntimeTraceEvent; -using paddle::platform::DeviceTraceEvent; -using paddle::platform::TracerEventType; +using paddle::platform::HostTraceEventNode; using paddle::platform::KernelEventInfo; using paddle::platform::MemcpyEventInfo; using paddle::platform::MemsetEventInfo; +using paddle::platform::NodeTrees; +using paddle::platform::RuntimeTraceEvent; +using paddle::platform::TracerEventType; TEST(NodeTreesTest, LogMe_case0) { std::list host_events; std::list runtime_events; @@ -194,8 +193,10 @@ TEST(NodeTreesTest, HandleTrees_case0) { } std::function host_event_node_handle( [&](HostTraceEventNode* a) { logger.LogHostTraceEventNode(*a); }); - std::function runtime_event_node_handle([&]( - CudaRuntimeTraceEventNode* a) { logger.LogRuntimeTraceEventNode(*a); }); + std::function runtime_event_node_handle( + [&](CudaRuntimeTraceEventNode* a) { + logger.LogRuntimeTraceEventNode(*a); + }); std::function device_event_node_handle( [&](DeviceTraceEventNode* a) { logger.LogDeviceTraceEventNode(*a); }); tree.HandleTrees(host_event_node_handle, runtime_event_node_handle, diff --git a/paddle/fluid/platform/profiler/trace_event_collector.h b/paddle/fluid/platform/profiler/trace_event_collector.h index 5f2bc9dc90db9858ca9bff5d23843482922f637c..d1593bc1bfcd79c1174e9d0927d753424f4912d2 100644 --- a/paddle/fluid/platform/profiler/trace_event_collector.h +++ b/paddle/fluid/platform/profiler/trace_event_collector.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include "paddle/fluid/platform/profiler/trace_event.h" namespace paddle { diff --git a/paddle/fluid/platform/profiler/utils.h b/paddle/fluid/platform/profiler/utils.h index 06d1636c4617cae087f9a551b9e1d5afea33b6a4..433fd0b825a11cbf7555ca686465c5d71cc6271a 100644 --- a/paddle/fluid/platform/profiler/utils.h +++ b/paddle/fluid/platform/profiler/utils.h @@ -15,6 +15,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/platform/dynload/cupti.h" #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/os_info.h" @@ -26,8 +27,9 @@ template std::string string_format(const std::string& format, Args... args) { int size_s = std::snprintf(nullptr, 0, format.c_str(), args...) + 1; // Extra space for '\0' - PADDLE_ENFORCE_GE(size_s, 0, platform::errors::Fatal( - "Error during profiler data formatting.")); + PADDLE_ENFORCE_GE( + size_s, 0, + platform::errors::Fatal("Error during profiler data formatting.")); auto size = static_cast(size_s); auto buf = std::make_unique(size); std::snprintf(buf.get(), size, format.c_str(), args...); diff --git a/paddle/fluid/platform/profiler_helper.h b/paddle/fluid/platform/profiler_helper.h index f64e05504aa3f9f53089e62a14348ab6c1535eee..ae856044f8fc55fe022ecb3903cde0c0fae9fee8 100644 --- a/paddle/fluid/platform/profiler_helper.h +++ b/paddle/fluid/platform/profiler_helper.h @@ -390,8 +390,8 @@ void SetEvent(bool merge_thread, const Event &analyze_event, index++; } if (split_pos == -1 && !main_thread_event_name.count(rit->name())) { - event_name = "thread" + std::to_string(rit->thread_id()) + "::" + - rit->name(); + event_name = "thread" + std::to_string(rit->thread_id()) + + "::" + rit->name(); } else { if (!main_thread_event_name.count(rit->name())) { event_name = diff --git a/paddle/fluid/platform/profiler_test.cc b/paddle/fluid/platform/profiler_test.cc index e9f84a49246f77bf2b03d85f837a56f9ad8c4924..18d4b4dc83478e60ce7bb23ca8b60b05b1051ce8 100644 --- a/paddle/fluid/platform/profiler_test.cc +++ b/paddle/fluid/platform/profiler_test.cc @@ -36,24 +36,24 @@ TEST(Event, CpuElapsedTime) { TEST(RecordEvent, RecordEvent) { using paddle::platform::Event; + using paddle::platform::EventRole; + using paddle::platform::EventSortingKey; using paddle::platform::EventType; - using paddle::platform::RecordEvent; - using paddle::platform::PushEvent; using paddle::platform::PopEvent; using paddle::platform::ProfilerState; - using paddle::platform::EventSortingKey; - using paddle::platform::EventRole; + using paddle::platform::PushEvent; + using paddle::platform::RecordEvent; ProfilerState state = ProfilerState::kCPU; EnableProfiler(state); /* Usage 1: - * PushEvent(evt_name); - * ... - * code to be analyzed - * ... - * PopEvent(evt_name); - */ + * PushEvent(evt_name); + * ... + * code to be analyzed + * ... + * PopEvent(evt_name); + */ LOG(INFO) << "Usage 1: PushEvent & PopEvent"; for (int loop = 0; loop < 3; ++loop) { for (int i = 1; i < 5; ++i) { diff --git a/paddle/fluid/platform/resource_pool.h b/paddle/fluid/platform/resource_pool.h index f01d006d5b273b9c569223dec151595daef4cede..737001a50abbf1d710310e87b5e118f3ba59f93a 100644 --- a/paddle/fluid/platform/resource_pool.h +++ b/paddle/fluid/platform/resource_pool.h @@ -20,6 +20,7 @@ #include #include #include + #include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/macros.h" diff --git a/paddle/fluid/platform/stream/cuda_stream.cc b/paddle/fluid/platform/stream/cuda_stream.cc index e3e735d03aba13eea2bcb50fe7cb1c7574a21b78..d7f60e4019d2e2ae13208606c554e5ef36171cc0 100644 --- a/paddle/fluid/platform/stream/cuda_stream.cc +++ b/paddle/fluid/platform/stream/cuda_stream.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/platform/stream/cuda_stream.h" + #include "paddle/fluid/platform/cuda_device_guard.h" #include "paddle/fluid/platform/device/gpu/gpu_types.h" #include "paddle/fluid/platform/device_context.h" diff --git a/paddle/fluid/platform/stream_callback_manager.cc b/paddle/fluid/platform/stream_callback_manager.cc index 6fa326d57bc676283a99905d269ee4e27277e5cc..bb9a405798b633d9707c80a76ed8111e84b419ab 100644 --- a/paddle/fluid/platform/stream_callback_manager.cc +++ b/paddle/fluid/platform/stream_callback_manager.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/platform/stream_callback_manager.h" + #include "paddle/fluid/platform/device/device_wrapper.h" namespace paddle { diff --git a/paddle/fluid/platform/transform.h b/paddle/fluid/platform/transform.h index 6f714a677033bb87d1a221f62baffa1112726571..32c759d01026c5bebbb23490b26ad215ee6e0842 100644 --- a/paddle/fluid/platform/transform.h +++ b/paddle/fluid/platform/transform.h @@ -25,6 +25,7 @@ limitations under the License. */ #if defined(__NVCC__) || defined(__HIPCC__) #include #include + #include "paddle/fluid/platform/details/cuda_transform_iterator_cast.h" #endif diff --git a/paddle/fluid/platform/transform_test.cu b/paddle/fluid/platform/transform_test.cu index 2e7b8b402f69ac5b8c074e0dcf74b759b3ea8ab1..1caa2e87707722ad1396371e482c68872c974b39 100644 --- a/paddle/fluid/platform/transform_test.cu +++ b/paddle/fluid/platform/transform_test.cu @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include + #include "paddle/fluid/memory/allocation/allocator_facade.h" #include "paddle/fluid/memory/memcpy.h" #include "paddle/fluid/memory/memory.h" @@ -38,10 +39,10 @@ class Multiply { using paddle::memory::Alloc; using paddle::memory::Copy; -using paddle::platform::CPUPlace; -using paddle::platform::CUDAPlace; using paddle::platform::CPUDeviceContext; +using paddle::platform::CPUPlace; using paddle::platform::CUDADeviceContext; +using paddle::platform::CUDAPlace; using paddle::platform::Transform; diff --git a/paddle/fluid/pybind/ascend_wrapper_py.cc b/paddle/fluid/pybind/ascend_wrapper_py.cc index fdf3a12a81fb29127790968830695b8741c3ec19..8c1eb2c1b9003f19aab869c5e4a6169e30cf37e8 100644 --- a/paddle/fluid/pybind/ascend_wrapper_py.cc +++ b/paddle/fluid/pybind/ascend_wrapper_py.cc @@ -26,11 +26,13 @@ limitations under the License. */ #include #include #include + #include #include #include #include #include + #include "paddle/fluid/framework/fleet/ascend_wrapper.h" #include "paddle/fluid/platform/device/npu/ascend_npu_info.h" #include "paddle/fluid/platform/enforce.h" @@ -78,8 +80,9 @@ ge::Status ge_initialize( py::gil_scoped_release release; auto init_options = convert_map(options); ge::Status res = ge::GEInitialize(init_options); - PADDLE_ENFORCE_EQ(res, ge::SUCCESS, platform::errors::Fatal( - "ge initialize not success:%d", res)); + PADDLE_ENFORCE_EQ( + res, ge::SUCCESS, + platform::errors::Fatal("ge initialize not success:%d", res)); py::gil_scoped_acquire acquire; return res; } @@ -253,7 +256,7 @@ void BindAscendGraph(py::module *m) { return std::unique_ptr( new ge::Session(convert_map(options))); })) - .def("add_graph", (ge::Status (Session::*)(uint32_t, const Graph &)) & + .def("add_graph", (ge::Status(Session::*)(uint32_t, const Graph &)) & Session::AddGraph) .def("add_graph", [](Session &ss, uint32_t index, const Graph &graph, @@ -261,14 +264,15 @@ void BindAscendGraph(py::module *m) { return ss.AddGraph(index, graph, convert_map(options)); }) .def("remove_graph", &Session::RemoveGraph) - .def("run_graph", - [](Session &ss, uint32_t graphId, - const std::vector &inputs) -> py::tuple { - std::vector outputs; - ge::Status res = ss.RunGraph(graphId, inputs, outputs); - return py::make_tuple(outputs, res); - }, - py::call_guard()) + .def( + "run_graph", + [](Session &ss, uint32_t graphId, + const std::vector &inputs) -> py::tuple { + std::vector outputs; + ge::Status res = ss.RunGraph(graphId, inputs, outputs); + return py::make_tuple(outputs, res); + }, + py::call_guard()) .def("build_graph", &Session::BuildGraph) .def("run_graph_async", &Session::RunGraphAsync) #ifdef PADDLE_WITH_ASCEND_STRING @@ -385,7 +389,7 @@ void BindAscendGraph(py::module *m) { }) #ifdef PADDLE_WITH_ASCEND_STRING .def("get_input_desc", - (TensorDesc (Operator::*)(uint32_t) const) & Operator::GetInputDesc) + (TensorDesc(Operator::*)(uint32_t) const) & Operator::GetInputDesc) .def("get_input_desc", [](Operator &op, const std::string &name) { return op.GetInputDescByName(name.c_str()); @@ -420,7 +424,7 @@ void BindAscendGraph(py::module *m) { return op.GetOutputDescByName(name.c_str()); }) .def("get_output_desc", - (TensorDesc (Operator::*)(uint32_t) const) & Operator::GetOutputDesc) + (TensorDesc(Operator::*)(uint32_t) const) & Operator::GetOutputDesc) .def("update_output_desc", static_cast(&Operator::UpdateOutputDesc)) @@ -779,19 +783,18 @@ void BindAscendGraph(py::module *m) { .def("get_tensor_desc", &Tensor::GetTensorDesc) // .def("set_data", (graphStatus(Tensor::*)(std::vector &&)) & // Tensor::SetData) - .def("set_data", (graphStatus (Tensor::*)(const std::vector &)) & + .def("set_data", (graphStatus(Tensor::*)(const std::vector &)) & Tensor::SetData) .def("set_data", - (graphStatus (Tensor::*)(const uint8_t *, size_t)) & Tensor::SetData) + (graphStatus(Tensor::*)(const uint8_t *, size_t)) & Tensor::SetData) #ifdef PADDLE_WITH_ASCEND_STRING - .def("set_data", - (graphStatus (Tensor::*)(const char *)) & Tensor::SetData) + .def("set_data", (graphStatus(Tensor::*)(const char *)) & Tensor::SetData) #else .def("set_data", (graphStatus (Tensor::*)(const std::string &)) & Tensor::SetData) #endif .def("set_data", - (graphStatus (Tensor::*)(const std::vector &)) & + (graphStatus(Tensor::*)(const std::vector &)) & Tensor::SetData) .def("get_data", @@ -813,8 +816,9 @@ void BindAscendGraph(py::module *m) { .def(py::init(), py::arg("shape"), py::arg("format") = FORMAT_ND, py::arg("dt") = DT_FLOAT) .def(py::init()) - .def("update", (void (TensorDesc::*)(const Shape &, Format, DataType)) & - TensorDesc::Update, + .def("update", + (void(TensorDesc::*)(const Shape &, Format, DataType)) & + TensorDesc::Update, py::arg("shape"), py::arg("format") = FORMAT_ND, py::arg("dt") = DT_FLOAT) .def("set_shape", &TensorDesc::SetShape) diff --git a/paddle/fluid/pybind/bind_cost_model.cc b/paddle/fluid/pybind/bind_cost_model.cc index a4a40f1fd02c9d2cb6d2fcdadfb53ca1936c6418..ef2fe0dd3d4466cbf45f88c1a27f6ecc32fd0218 100644 --- a/paddle/fluid/pybind/bind_cost_model.cc +++ b/paddle/fluid/pybind/bind_cost_model.cc @@ -15,6 +15,7 @@ #include "paddle/fluid/pybind/bind_cost_model.h" #include + #include "paddle/fluid/framework/ir/cost_model.h" #include "paddle/fluid/framework/program_desc.h" diff --git a/paddle/fluid/pybind/bind_fleet_executor.cc b/paddle/fluid/pybind/bind_fleet_executor.cc index 8491d1e224930939212ed20019f5c78ca1c43f67..6bd032037443ef535a7c6fb8e29a80ed0ea13627 100644 --- a/paddle/fluid/pybind/bind_fleet_executor.cc +++ b/paddle/fluid/pybind/bind_fleet_executor.cc @@ -13,10 +13,13 @@ // limitations under the License. #include "paddle/fluid/pybind/bind_fleet_executor.h" + #include #include + #include #include + #include "paddle/fluid/distributed/fleet_executor/dist_model.h" #include "paddle/fluid/distributed/fleet_executor/dist_model_tensor_wrapper.h" #include "paddle/fluid/distributed/fleet_executor/fleet_executor.h" @@ -62,13 +65,13 @@ struct npy_format_descriptor { namespace paddle { namespace pybind { -using paddle::distributed::FleetExecutor; -using paddle::distributed::TaskNode; -using paddle::distributed::DistModelConfig; using paddle::distributed::DistModel; +using paddle::distributed::DistModelConfig; using paddle::distributed::DistModelDataBuf; -using paddle::distributed::DistModelTensor; using paddle::distributed::DistModelDataType; +using paddle::distributed::DistModelTensor; +using paddle::distributed::FleetExecutor; +using paddle::distributed::TaskNode; using paddle::framework::OpDesc; using paddle::framework::ProgramDesc; @@ -217,33 +220,34 @@ void BindFleetExecutor(py::module* m) { .def("reset", &DistModelDataBufReset) .def("reset", &DistModelDataBufReset) .def("length", &DistModelDataBuf::length) - .def("tolist", [](DistModelDataBuf& self, - const std::string& dtype) -> py::list { - py::list l; - if (dtype == "int32") { - auto* data = static_cast(self.data()); - auto size = self.length() / sizeof(int32_t); - l = py::cast(std::vector(data, data + size)); - } else if (dtype == "int64") { - auto* data = static_cast(self.data()); - auto size = self.length() / sizeof(int64_t); - l = py::cast(std::vector(data, data + size)); - } else if (dtype == "float32") { - auto* data = static_cast(self.data()); - auto size = self.length() / sizeof(float); - l = py::cast(std::vector(data, data + size)); - } else if (dtype == "float16") { - auto* data = static_cast(self.data()); - auto size = self.length() / sizeof(paddle::platform::float16); - l = py::cast( - std::vector(data, data + size)); - } else { - PADDLE_THROW(platform::errors::Unimplemented( - "Unsupported data type. Now only supports INT32, INT64, " - "FLOAT16 and FLOAT32.")); - } - return l; - }); + .def("tolist", + [](DistModelDataBuf& self, const std::string& dtype) -> py::list { + py::list l; + if (dtype == "int32") { + auto* data = static_cast(self.data()); + auto size = self.length() / sizeof(int32_t); + l = py::cast(std::vector(data, data + size)); + } else if (dtype == "int64") { + auto* data = static_cast(self.data()); + auto size = self.length() / sizeof(int64_t); + l = py::cast(std::vector(data, data + size)); + } else if (dtype == "float32") { + auto* data = static_cast(self.data()); + auto size = self.length() / sizeof(float); + l = py::cast(std::vector(data, data + size)); + } else if (dtype == "float16") { + auto* data = + static_cast(self.data()); + auto size = self.length() / sizeof(paddle::platform::float16); + l = py::cast( + std::vector(data, data + size)); + } else { + PADDLE_THROW(platform::errors::Unimplemented( + "Unsupported data type. Now only supports INT32, INT64, " + "FLOAT16 and FLOAT32.")); + } + return l; + }); py::class_(*m, "DistModelTensor") .def(py::init<>()) diff --git a/paddle/fluid/pybind/communication.cc b/paddle/fluid/pybind/communication.cc index aef02d65b4dbd22df05cb3fa0156588c9f6f412b..418804df02879a5b6d20bd965280bc33b1a2f4c8 100644 --- a/paddle/fluid/pybind/communication.cc +++ b/paddle/fluid/pybind/communication.cc @@ -12,16 +12,18 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include "paddle/fluid/pybind/communication.h" + #include #include #include #include #include + #include #include #include "paddle/fluid/distributed/store/tcp_store.h" -#include "paddle/fluid/pybind/communication.h" namespace py = pybind11; @@ -35,22 +37,24 @@ void BindTCPStore(py::module *m) { py::class_>( *m, "Store") .def(py::init<>()) - .def("set", - [](distributed::Store &self, const std::string &key, - const std::string &value) { - std::vector data(value.begin(), value.end()); - self.set(key, data); - }, - py::arg("key"), py::arg("value"), - py::call_guard()) - .def("get", - [](distributed::Store &self, - const std::string &key) -> py::bytes { - auto data = self.get(key); - return py::bytes(reinterpret_cast(data.data()), - data.size()); - }, - py::arg("key"), py::call_guard()) + .def( + "set", + [](distributed::Store &self, const std::string &key, + const std::string &value) { + std::vector data(value.begin(), value.end()); + self.set(key, data); + }, + py::arg("key"), py::arg("value"), + py::call_guard()) + .def( + "get", + [](distributed::Store &self, + const std::string &key) -> py::bytes { + auto data = self.get(key); + return py::bytes(reinterpret_cast(data.data()), + data.size()); + }, + py::arg("key"), py::call_guard()) .def("add", &distributed::Store::add, py::call_guard()) .def("wait", &distributed::Store::wait, diff --git a/paddle/fluid/pybind/communicator_py.cc b/paddle/fluid/pybind/communicator_py.cc index 723d7f3197230aa5218b19bebdf97bb9a7167e75..0cb5aa6ef70231e57fec32be0a8b64dcd0bd07ec 100644 --- a/paddle/fluid/pybind/communicator_py.cc +++ b/paddle/fluid/pybind/communicator_py.cc @@ -15,16 +15,17 @@ limitations under the License. */ #include "paddle/fluid/pybind/communicator_py.h" #include + #include #include #include #include -#include "paddle/fluid/framework/program_desc.h" -#include "pybind11/pybind11.h" +#include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/operators/distributed/communicator.h" #include "paddle/fluid/operators/distributed/large_scale_kv.h" #include "paddle/fluid/operators/distributed/ps/service/communicator/communicator_common.h" +#include "pybind11/pybind11.h" namespace py = pybind11; diff --git a/paddle/fluid/pybind/compatible.cc b/paddle/fluid/pybind/compatible.cc index cfe87a86cf0e559e9e0ef314b5ba475571f08e3e..013d0cc0c60682ab9b2d477528618af09d888242 100644 --- a/paddle/fluid/pybind/compatible.cc +++ b/paddle/fluid/pybind/compatible.cc @@ -13,23 +13,25 @@ // limitations under the License. #include "paddle/fluid/pybind/compatible.h" + #include #include + #include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/pybind/pybind_boost_headers.h" namespace py = pybind11; -using paddle::framework::compatible::OpAttrVariantT; -using paddle::framework::compatible::OpUpdateInfo; using paddle::framework::compatible::OpAttrInfo; -using paddle::framework::compatible::OpInputOutputInfo; +using paddle::framework::compatible::OpAttrVariantT; using paddle::framework::compatible::OpBugfixInfo; -using paddle::framework::compatible::OpUpdateType; -using paddle::framework::compatible::OpUpdateBase; -using paddle::framework::compatible::OpVersionDesc; using paddle::framework::compatible::OpCheckpoint; +using paddle::framework::compatible::OpInputOutputInfo; +using paddle::framework::compatible::OpUpdateBase; +using paddle::framework::compatible::OpUpdateInfo; +using paddle::framework::compatible::OpUpdateType; using paddle::framework::compatible::OpVersion; +using paddle::framework::compatible::OpVersionDesc; namespace paddle { namespace pybind { diff --git a/paddle/fluid/pybind/const_value.cc b/paddle/fluid/pybind/const_value.cc index 8b48d0b4e44ca8d2e0ca63c4eb8742dfd6d53271..89a3904d0003fe9175d6ff79d4b788370d886b86 100644 --- a/paddle/fluid/pybind/const_value.cc +++ b/paddle/fluid/pybind/const_value.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/pybind/const_value.h" + #include "paddle/fluid/framework/ir/node.h" #include "paddle/fluid/framework/op_proto_maker.h" #include "paddle/fluid/framework/operator.h" diff --git a/paddle/fluid/pybind/crypto.cc b/paddle/fluid/pybind/crypto.cc index 8fbf395bf18a6522941983eb1fa35c963d775b63..07a9e4021cee78760bef22ef7b583bd5e75300aa 100644 --- a/paddle/fluid/pybind/crypto.cc +++ b/paddle/fluid/pybind/crypto.cc @@ -97,11 +97,12 @@ void BindAESCipher(py::module* m) { void BindCipherFactory(py::module* m) { py::class_(*m, "CipherFactory") .def(py::init<>()) - .def_static("create_cipher", - [](const std::string& config_file) { - return CipherFactory::CreateCipher(config_file); - }, - py::arg("config_file") = std::string()); + .def_static( + "create_cipher", + [](const std::string& config_file) { + return CipherFactory::CreateCipher(config_file); + }, + py::arg("config_file") = std::string()); } void BindCipherUtils(py::module* m) { diff --git a/paddle/fluid/pybind/cuda_streams_py.cc b/paddle/fluid/pybind/cuda_streams_py.cc index 64c145c94f99d110f0110847021898bed3a69d9e..54080d5e096155cd5dbf3bba92fbeb2efb418f6e 100644 --- a/paddle/fluid/pybind/cuda_streams_py.cc +++ b/paddle/fluid/pybind/cuda_streams_py.cc @@ -12,13 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/pybind/cuda_streams_py.h" + #include #include #include "paddle/fluid/platform/device_event_base.h" #include "paddle/fluid/platform/event.h" #include "paddle/fluid/platform/stream/cuda_stream.h" -#include "paddle/fluid/pybind/cuda_streams_py.h" namespace py = pybind11; @@ -28,29 +29,31 @@ void BindCudaStream(py::module *m_ptr) { auto &m = *m_ptr; // Bind Methods - m.def("_get_current_stream", - [](int deviceId) { + m.def( + "_get_current_stream", + [](int deviceId) { #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) - return paddle::platform::stream::get_current_stream(deviceId); + return paddle::platform::stream::get_current_stream(deviceId); #else - PADDLE_THROW(platform::errors::Unavailable( - "Paddle is not compiled with CUDA. Cannot visit cuda current" - "stream.")); + PADDLE_THROW(platform::errors::Unavailable( + "Paddle is not compiled with CUDA. Cannot visit cuda current" + "stream.")); #endif - }, - py::return_value_policy::reference); + }, + py::return_value_policy::reference); - m.def("_set_current_stream", - [](paddle::platform::stream::CUDAStream &stream) { + m.def( + "_set_current_stream", + [](paddle::platform::stream::CUDAStream &stream) { #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) - return paddle::platform::stream::set_current_stream(&stream); + return paddle::platform::stream::set_current_stream(&stream); #else - PADDLE_THROW(platform::errors::Unavailable( - "Paddle is not compiled with CUDA. Cannot set cuda current " - "stream.")); + PADDLE_THROW(platform::errors::Unavailable( + "Paddle is not compiled with CUDA. Cannot set cuda current " + "stream.")); #endif - }, - py::return_value_policy::reference); + }, + py::return_value_policy::reference); m.def("_device_synchronize", [](int device_id) { #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) @@ -94,12 +97,13 @@ void BindCudaStream(py::module *m_ptr) { )DOC") #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) - .def("wait_event", - [](paddle::platform::stream::CUDAStream &self, - paddle::platform::CudaEvent &event) { - self.WaitEvent(event.GetRawCudaEvent()); - }, - R"DOC( + .def( + "wait_event", + [](paddle::platform::stream::CUDAStream &self, + paddle::platform::CudaEvent &event) { + self.WaitEvent(event.GetRawCudaEvent()); + }, + R"DOC( Makes all future work submitted to stream wait for all work captured in event. Parameters: @@ -115,15 +119,16 @@ void BindCudaStream(py::module *m_ptr) { s.wait_event(event) )DOC") - .def("wait_stream", - [](paddle::platform::stream::CUDAStream &self, - paddle::platform::stream::CUDAStream &stream) { - paddle::platform::CudaEvent event; - event.Record(stream.raw_stream()); - - self.WaitEvent(event.GetRawCudaEvent()); - }, - R"DOC( + .def( + "wait_stream", + [](paddle::platform::stream::CUDAStream &self, + paddle::platform::stream::CUDAStream &stream) { + paddle::platform::CudaEvent event; + event.Record(stream.raw_stream()); + + self.WaitEvent(event.GetRawCudaEvent()); + }, + R"DOC( Synchronizes with the given stream. Parameters: @@ -139,11 +144,12 @@ void BindCudaStream(py::module *m_ptr) { s1.wait_stream(s2) )DOC") - .def("query", - [](paddle::platform::stream::CUDAStream &self) { - return self.Query(); - }, - R"DOC( + .def( + "query", + [](paddle::platform::stream::CUDAStream &self) { + return self.Query(); + }, + R"DOC( Return the status whether if all operations in stream have completed. Returns: A boolean value. @@ -157,11 +163,12 @@ void BindCudaStream(py::module *m_ptr) { is_done = s.query() )DOC") - .def("synchronize", - [](paddle::platform::stream::CUDAStream &self) { - self.Synchronize(); - }, - R"DOC( + .def( + "synchronize", + [](paddle::platform::stream::CUDAStream &self) { + self.Synchronize(); + }, + R"DOC( Waits for stream tasks to complete. Examples: @@ -173,16 +180,17 @@ void BindCudaStream(py::module *m_ptr) { s.synchronize() )DOC") - .def("record_event", - [](paddle::platform::stream::CUDAStream &self, - paddle::platform::CudaEvent *event) { - if (event == nullptr) { - event = new paddle::platform::CudaEvent(); - } - event->Record(self.raw_stream()); - return event; - }, - R"DOC( + .def( + "record_event", + [](paddle::platform::stream::CUDAStream &self, + paddle::platform::CudaEvent *event) { + if (event == nullptr) { + event = new paddle::platform::CudaEvent(); + } + event->Record(self.raw_stream()); + return event; + }, + R"DOC( Record a CUDA event in the stream. Parameters: @@ -201,7 +209,7 @@ void BindCudaStream(py::module *m_ptr) { event = s.record_event() )DOC", - py::arg("event") = nullptr) + py::arg("event") = nullptr) .def_property_readonly( "cuda_stream", [](paddle::platform::stream::CUDAStream &self) { @@ -225,32 +233,33 @@ void BindCudaStream(py::module *m_ptr) { )DOC") #endif - .def("__init__", - [](paddle::platform::stream::CUDAStream &self, - platform::CUDAPlace *device, int priority) { + .def( + "__init__", + [](paddle::platform::stream::CUDAStream &self, + platform::CUDAPlace *device, int priority) { #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) - if (priority != 1 && priority != 2) { - PADDLE_THROW(platform::errors::InvalidArgument( - "Priority should be 1(high) or 2(normal) ")); - } - auto prio = paddle::platform::stream::Priority(priority); - auto stream_flag = - paddle::platform::stream::StreamFlag::kStreamNonBlocking; - - if (device == nullptr) { - int curr_device_id = platform::GetCurrentDeviceId(); - auto device_tmp = platform::CUDAPlace(curr_device_id); - device = &device_tmp; - } - - new (&self) paddle::platform::stream::CUDAStream(*device, prio, - stream_flag); + if (priority != 1 && priority != 2) { + PADDLE_THROW(platform::errors::InvalidArgument( + "Priority should be 1(high) or 2(normal) ")); + } + auto prio = paddle::platform::stream::Priority(priority); + auto stream_flag = + paddle::platform::stream::StreamFlag::kStreamNonBlocking; + + if (device == nullptr) { + int curr_device_id = platform::GetCurrentDeviceId(); + auto device_tmp = platform::CUDAPlace(curr_device_id); + device = &device_tmp; + } + + new (&self) paddle::platform::stream::CUDAStream(*device, prio, + stream_flag); #else PADDLE_THROW(platform::errors::Unavailable( "Class CUDAStream can only be initialized on the GPU platform.")); #endif - }, - py::arg("device") = nullptr, py::arg("priority") = 2) + }, + py::arg("device") = nullptr, py::arg("priority") = 2) .def( "__init__", [](paddle::platform::stream::CUDAStream &self, int device, @@ -315,15 +324,16 @@ void BindCudaStream(py::module *m_ptr) { )DOC") #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) - .def("record", - [](paddle::platform::CudaEvent &self, - paddle::platform::stream::CUDAStream *stream) { - if (stream == nullptr) { - stream = paddle::platform::stream::get_current_stream(-1); - } - self.Record(stream->raw_stream()); - }, - R"DOC( + .def( + "record", + [](paddle::platform::CudaEvent &self, + paddle::platform::stream::CUDAStream *stream) { + if (stream == nullptr) { + stream = paddle::platform::stream::get_current_stream(-1); + } + self.Record(stream->raw_stream()); + }, + R"DOC( Records the event in the given stream. Parameters: @@ -338,10 +348,11 @@ void BindCudaStream(py::module *m_ptr) { event.record() )DOC", - py::arg("stream") = nullptr) - .def("query", - [](paddle::platform::CudaEvent &self) { return self.Query(); }, - R"DOC( + py::arg("stream") = nullptr) + .def( + "query", + [](paddle::platform::CudaEvent &self) { return self.Query(); }, + R"DOC( Queries the event's status. Returns: A boolean which indicates all work currently captured by the event has been completed. @@ -355,8 +366,9 @@ void BindCudaStream(py::module *m_ptr) { is_done = event.query() )DOC") - .def("synchronize", - [](paddle::platform::CudaEvent &self) { self.Synchronize(); }, R"DOC( + .def( + "synchronize", + [](paddle::platform::CudaEvent &self) { self.Synchronize(); }, R"DOC( Waits for an event to complete. Examples: @@ -369,22 +381,23 @@ void BindCudaStream(py::module *m_ptr) { )DOC") #endif - .def("__init__", - [](paddle::platform::CudaEvent &self, bool enable_timing, - bool blocking, bool interprocess) { + .def( + "__init__", + [](paddle::platform::CudaEvent &self, bool enable_timing, + bool blocking, bool interprocess) { #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) - unsigned int flags = platform::GenerateDeviceEventFlag( - enable_timing, blocking, interprocess); - new (&self) paddle::platform::CudaEvent(flags); + unsigned int flags = platform::GenerateDeviceEventFlag( + enable_timing, blocking, interprocess); + new (&self) paddle::platform::CudaEvent(flags); #else - PADDLE_THROW(platform::errors::Unavailable( - "Class CUDAEvent can only be initialized on the GPU " - "platform.")); + PADDLE_THROW(platform::errors::Unavailable( + "Class CUDAEvent can only be initialized on the GPU " + "platform.")); #endif - }, - py::arg("enable_timing") = false, py::arg("blocking") = false, - py::arg("interprocess") = false); + }, + py::arg("enable_timing") = false, py::arg("blocking") = false, + py::arg("interprocess") = false); } } // namespace pybind diff --git a/paddle/fluid/pybind/data_set_py.cc b/paddle/fluid/pybind/data_set_py.cc index 5e2274cb65138513b4cad9d0e81c0a1318e24f7f..700bd458a58eb09d3cded6ad60a4a1e72092e808 100644 --- a/paddle/fluid/pybind/data_set_py.cc +++ b/paddle/fluid/pybind/data_set_py.cc @@ -24,6 +24,7 @@ limitations under the License. */ #include #include #include + #include "google/protobuf/io/zero_copy_stream_impl.h" #include "google/protobuf/text_format.h" #include "paddle/fluid/framework/async_executor.h" diff --git a/paddle/fluid/pybind/distributed_py.cc b/paddle/fluid/pybind/distributed_py.cc index 6636fc8aca51dd2e0594bdbcda576998bdd4b307..3d1a81da6f382a921082cd415fedcaa2a10ed4ed 100644 --- a/paddle/fluid/pybind/distributed_py.cc +++ b/paddle/fluid/pybind/distributed_py.cc @@ -109,132 +109,141 @@ void BindDistributed(py::module *m) { .def("rank", &distributed::ProcessGroup::GetRank) .def("size", &distributed::ProcessGroup::GetSize) .def("name", &distributed::ProcessGroup::GetBackendName) - .def("allreduce", - [](distributed::ProcessGroup &self, py::handle py_tensor, - distributed::ReduceOp op) { - auto tensor = CastPyArg2Tensor(py_tensor.ptr(), 0); - distributed::AllreduceOptions opts; - opts.reduce_op = op; - auto dense = - std::dynamic_pointer_cast(tensor.impl()); - std::vector tensors = {*dense}; - return self.AllReduce(tensors, tensors, opts); - }, - py::arg("tensor"), py::arg("op") = distributed::ReduceOp::SUM, - py::call_guard()) - - .def("broadcast", - [](distributed::ProcessGroup &self, py::handle py_tensor, - int source_rank) { - auto tensor = CastPyArg2Tensor(py_tensor.ptr(), 0); - distributed::BroadcastOptions opts; - opts.source_rank = source_rank; - auto dense = - std::dynamic_pointer_cast(tensor.impl()); - std::vector tensors = {*dense}; - return self.Broadcast(tensors, tensors, opts); - }, - py::arg("tensor"), py::arg("source_rank"), - py::call_guard()) - - .def("barrier", - [](distributed::ProcessGroup &self, std::vector place_ids) { - distributed::BarrierOptions opts; - opts.place_ids = place_ids; - return self.Barrier(opts); - }, - py::arg("place_ids") = std::vector{}, - py::call_guard()) - - .def("send", - [](distributed::ProcessGroup &self, py::handle py_tensor, - int dst) { - auto tensor = CastPyArg2Tensor(py_tensor.ptr(), 0); - auto dense = - std::dynamic_pointer_cast(tensor.impl()); - std::vector tensors = {*dense}; - return self.Send(tensors, dst); - }, - py::arg("tensor"), py::arg("dst"), - py::call_guard()) - - .def("recv", - [](distributed::ProcessGroup &self, py::handle py_tensor, - int src) { - auto tensor = CastPyArg2Tensor(py_tensor.ptr(), 0); - auto dense = - std::dynamic_pointer_cast(tensor.impl()); - std::vector tensors = {*dense}; - return self.Recv(tensors, src); - }, - py::arg("tensor"), py::arg("src"), - py::call_guard()) - - .def("all_gather", - [](distributed::ProcessGroup &self, py::handle py_in_tensor, - py::handle py_out_tensor) { - auto in_tensor = CastPyArg2Tensor(py_in_tensor.ptr(), 0); - auto out_tensor = CastPyArg2Tensor(py_out_tensor.ptr(), 0); - auto in_dense = std::dynamic_pointer_cast( - in_tensor.impl()); - auto out_dense = std::dynamic_pointer_cast( - out_tensor.impl()); - std::vector in_tensors = {*in_dense}; - std::vector out_tensors = {*out_dense}; - return self.AllGather(in_tensors, out_tensors); - }, - py::arg("in"), py::arg("out"), - py::call_guard()) - - .def("alltoall", - [](distributed::ProcessGroup &self, py::handle py_in_tensor, - py::handle py_out_tensor) { - auto in_tensor = CastPyArg2Tensor(py_in_tensor.ptr(), 0); - auto out_tensor = CastPyArg2Tensor(py_out_tensor.ptr(), 0); - auto in_dense = std::dynamic_pointer_cast( - in_tensor.impl()); - auto out_dense = std::dynamic_pointer_cast( - out_tensor.impl()); - std::vector in_tensors = {*in_dense}; - std::vector out_tensors = {*out_dense}; - return self.AllToAll(in_tensors, out_tensors); - }, - py::arg("in"), py::arg("out"), - py::call_guard()) - - .def("reduce", - [](distributed::ProcessGroup &self, py::handle py_in_tensor, - int dst, distributed::ReduceOp op) { - auto in_tensor = CastPyArg2Tensor(py_in_tensor.ptr(), 0); - distributed::ReduceOptions opts; - opts.reduce_op = op; - opts.root_rank = dst; - auto dense = std::dynamic_pointer_cast( - in_tensor.impl()); - std::vector tensors = {*dense}; - return self.Reduce(tensors, tensors, opts); - }, - py::arg("tensor"), py::arg("dst"), - py::arg("op") = distributed::ReduceOp::SUM, - py::call_guard()) - - .def("scatter", - [](distributed::ProcessGroup &self, py::handle py_in_tensor, - py::handle py_out_tensor, int src) { - auto in_tensor = CastPyArg2Tensor(py_in_tensor.ptr(), 0); - auto out_tensor = CastPyArg2Tensor(py_out_tensor.ptr(), 0); - distributed::ScatterOptions opts; - opts.root_rank = src; - auto in_dense = std::dynamic_pointer_cast( - in_tensor.impl()); - auto out_dense = std::dynamic_pointer_cast( - out_tensor.impl()); - std::vector in_tensors = {*in_dense}; - std::vector out_tensors = {*out_dense}; - return self.Scatter(in_tensors, out_tensors, opts); - }, - py::arg("in"), py::arg("out"), py::arg("src"), - py::call_guard()); + .def( + "allreduce", + [](distributed::ProcessGroup &self, py::handle py_tensor, + distributed::ReduceOp op) { + auto tensor = CastPyArg2Tensor(py_tensor.ptr(), 0); + distributed::AllreduceOptions opts; + opts.reduce_op = op; + auto dense = + std::dynamic_pointer_cast(tensor.impl()); + std::vector tensors = {*dense}; + return self.AllReduce(tensors, tensors, opts); + }, + py::arg("tensor"), py::arg("op") = distributed::ReduceOp::SUM, + py::call_guard()) + + .def( + "broadcast", + [](distributed::ProcessGroup &self, py::handle py_tensor, + int source_rank) { + auto tensor = CastPyArg2Tensor(py_tensor.ptr(), 0); + distributed::BroadcastOptions opts; + opts.source_rank = source_rank; + auto dense = + std::dynamic_pointer_cast(tensor.impl()); + std::vector tensors = {*dense}; + return self.Broadcast(tensors, tensors, opts); + }, + py::arg("tensor"), py::arg("source_rank"), + py::call_guard()) + + .def( + "barrier", + [](distributed::ProcessGroup &self, std::vector place_ids) { + distributed::BarrierOptions opts; + opts.place_ids = place_ids; + return self.Barrier(opts); + }, + py::arg("place_ids") = std::vector{}, + py::call_guard()) + + .def( + "send", + [](distributed::ProcessGroup &self, py::handle py_tensor, + int dst) { + auto tensor = CastPyArg2Tensor(py_tensor.ptr(), 0); + auto dense = + std::dynamic_pointer_cast(tensor.impl()); + std::vector tensors = {*dense}; + return self.Send(tensors, dst); + }, + py::arg("tensor"), py::arg("dst"), + py::call_guard()) + + .def( + "recv", + [](distributed::ProcessGroup &self, py::handle py_tensor, + int src) { + auto tensor = CastPyArg2Tensor(py_tensor.ptr(), 0); + auto dense = + std::dynamic_pointer_cast(tensor.impl()); + std::vector tensors = {*dense}; + return self.Recv(tensors, src); + }, + py::arg("tensor"), py::arg("src"), + py::call_guard()) + + .def( + "all_gather", + [](distributed::ProcessGroup &self, py::handle py_in_tensor, + py::handle py_out_tensor) { + auto in_tensor = CastPyArg2Tensor(py_in_tensor.ptr(), 0); + auto out_tensor = CastPyArg2Tensor(py_out_tensor.ptr(), 0); + auto in_dense = std::dynamic_pointer_cast( + in_tensor.impl()); + auto out_dense = std::dynamic_pointer_cast( + out_tensor.impl()); + std::vector in_tensors = {*in_dense}; + std::vector out_tensors = {*out_dense}; + return self.AllGather(in_tensors, out_tensors); + }, + py::arg("in"), py::arg("out"), + py::call_guard()) + + .def( + "alltoall", + [](distributed::ProcessGroup &self, py::handle py_in_tensor, + py::handle py_out_tensor) { + auto in_tensor = CastPyArg2Tensor(py_in_tensor.ptr(), 0); + auto out_tensor = CastPyArg2Tensor(py_out_tensor.ptr(), 0); + auto in_dense = std::dynamic_pointer_cast( + in_tensor.impl()); + auto out_dense = std::dynamic_pointer_cast( + out_tensor.impl()); + std::vector in_tensors = {*in_dense}; + std::vector out_tensors = {*out_dense}; + return self.AllToAll(in_tensors, out_tensors); + }, + py::arg("in"), py::arg("out"), + py::call_guard()) + + .def( + "reduce", + [](distributed::ProcessGroup &self, py::handle py_in_tensor, + int dst, distributed::ReduceOp op) { + auto in_tensor = CastPyArg2Tensor(py_in_tensor.ptr(), 0); + distributed::ReduceOptions opts; + opts.reduce_op = op; + opts.root_rank = dst; + auto dense = std::dynamic_pointer_cast( + in_tensor.impl()); + std::vector tensors = {*dense}; + return self.Reduce(tensors, tensors, opts); + }, + py::arg("tensor"), py::arg("dst"), + py::arg("op") = distributed::ReduceOp::SUM, + py::call_guard()) + + .def( + "scatter", + [](distributed::ProcessGroup &self, py::handle py_in_tensor, + py::handle py_out_tensor, int src) { + auto in_tensor = CastPyArg2Tensor(py_in_tensor.ptr(), 0); + auto out_tensor = CastPyArg2Tensor(py_out_tensor.ptr(), 0); + distributed::ScatterOptions opts; + opts.root_rank = src; + auto in_dense = std::dynamic_pointer_cast( + in_tensor.impl()); + auto out_dense = std::dynamic_pointer_cast( + out_tensor.impl()); + std::vector in_tensors = {*in_dense}; + std::vector out_tensors = {*out_dense}; + return self.Scatter(in_tensors, out_tensors, opts); + }, + py::arg("in"), py::arg("out"), py::arg("src"), + py::call_guard()); #if defined(PADDLE_WITH_NCCL) py::class_def("eager_assign_group_by_size", - [](py::handle py_tensors, std::vector is_sparse_gradient, - std::vector group_size_limits, - std::vector tensor_indices) { - auto tensors = CastPyArg2VectorOfTensor(py_tensors.ptr(), 0); - return distributed::Eager_AssignGroupBySize( - tensors, is_sparse_gradient, group_size_limits, tensor_indices); - }, - py::arg("tensors"), py::arg("is_sparse_gradient"), - py::arg("group_size_limits") = std::vector{25 * 1024 * 1024}, - py::arg("tensor_indices") = std::vector{}, - py::call_guard()); + m->def( + "eager_assign_group_by_size", + [](py::handle py_tensors, std::vector is_sparse_gradient, + std::vector group_size_limits, + std::vector tensor_indices) { + auto tensors = CastPyArg2VectorOfTensor(py_tensors.ptr(), 0); + return distributed::Eager_AssignGroupBySize( + tensors, is_sparse_gradient, group_size_limits, tensor_indices); + }, + py::arg("tensors"), py::arg("is_sparse_gradient"), + py::arg("group_size_limits") = std::vector{25 * 1024 * 1024}, + py::arg("tensor_indices") = std::vector{}, + py::call_guard()); py::class_>(*m, "EagerReducer", R"DOC()DOC") .def(py::init(&CreateEagerReducer)) - .def("prepare_for_backward", - [](distributed::EagerReducer &self, py::handle py_tensors) { - auto params = CastPyArg2VectorOfTensor(py_tensors.ptr(), 0); - self.PrepareForBackward(params); - }, - py::arg("tensors"), py::call_guard()); + .def( + "prepare_for_backward", + [](distributed::EagerReducer &self, py::handle py_tensors) { + auto params = CastPyArg2VectorOfTensor(py_tensors.ptr(), 0); + self.PrepareForBackward(params); + }, + py::arg("tensors"), py::call_guard()); } } // end namespace pybind diff --git a/paddle/fluid/pybind/eager.cc b/paddle/fluid/pybind/eager.cc index c1b26ee0b792dc3959cefcb16806aed5181895c6..f9325d1b9ca53f0a0569832fe47527520f84b830 100644 --- a/paddle/fluid/pybind/eager.cc +++ b/paddle/fluid/pybind/eager.cc @@ -9,6 +9,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // disable numpy compile error +#include "paddle/fluid/pybind/eager.h" + #include #include @@ -22,7 +24,6 @@ limitations under the License. */ #include "paddle/fluid/memory/allocation/allocator.h" #include "paddle/fluid/memory/memcpy.h" #include "paddle/fluid/platform/enforce.h" -#include "paddle/fluid/pybind/eager.h" #include "paddle/fluid/pybind/eager_utils.h" #include "paddle/phi/common/data_type.h" #include "paddle/phi/core/compat/convert_utils.h" @@ -488,45 +489,45 @@ void AutoInitStringTensorByStringTensor( } /** We should have init function with signature: - * 1. - * def __init__ () - * 2. - * def __init__ ( - * ** dtype: paddle::framework::proto::VarType::Type, - * ** dims: vector, - * ** name: std::string, - * ** type: paddle::framework::proto::VarType::LodTensor, - * ** persistable: bool) - * 3. (multi-place) - * (should have at least one parameter, one parameter equals to case 4, zero - * parameter equals to case 1) - * def __init__ ( - * ** value: ndarray, - * ** place: paddle::platform::Place, - * ** persistable: bool, - * ** zero_copy: bool, - * ** name: std::string, - * ** stop_gradient: bool) - * 4. - * def __init__ ( - * ** value: ndarray) - * 5. - * def __init__ ( - * ** tensor: Tensor) - * 6. (multi-place) - * (should have at least one parameter, one parameter equals to case 5, zero - * parameter equals to case 1.) - * def __init__ ( - * ** tensor: Tensor, - * ** place: paddle::platform::Place, - * ** name: std::string) - * 7. (multi-place) (should have at least one parameter, one parameter similar - * to case 5, zero parameter equals to case 1.) - * def __init__ ( - * ** tensor: FrameworkTensor, - * ** place: paddle::platform::Place, - * ** name: std::string) - * **/ + * 1. + * def __init__ () + * 2. + * def __init__ ( + * ** dtype: paddle::framework::proto::VarType::Type, + * ** dims: vector, + * ** name: std::string, + * ** type: paddle::framework::proto::VarType::LodTensor, + * ** persistable: bool) + * 3. (multi-place) + * (should have at least one parameter, one parameter equals to case 4, zero + * parameter equals to case 1) + * def __init__ ( + * ** value: ndarray, + * ** place: paddle::platform::Place, + * ** persistable: bool, + * ** zero_copy: bool, + * ** name: std::string, + * ** stop_gradient: bool) + * 4. + * def __init__ ( + * ** value: ndarray) + * 5. + * def __init__ ( + * ** tensor: Tensor) + * 6. (multi-place) + * (should have at least one parameter, one parameter equals to case 5, zero + * parameter equals to case 1.) + * def __init__ ( + * ** tensor: Tensor, + * ** place: paddle::platform::Place, + * ** name: std::string) + * 7. (multi-place) (should have at least one parameter, one parameter similar + * to case 5, zero parameter equals to case 1.) + * def __init__ ( + * ** tensor: FrameworkTensor, + * ** place: paddle::platform::Place, + * ** name: std::string) + * **/ int TensorInit(PyObject* self, PyObject* args, PyObject* kwargs) { EAGER_TRY // set a flag to record use kwargs or not @@ -828,37 +829,37 @@ int TensorInit(PyObject* self, PyObject* args, PyObject* kwargs) { } /** We should have init function with signature: - * 1. - * def __init__ () - * - * 2. - * def __init__ ( - * ** dims: vector, - * ** name: std::string) - * - * 3. - * (should have at least one parameter, one parameter equals to case 4, zero - * parameter equals to case 1) - * def __init__ ( - * ** value: ndarray, - * ** zero_copy: bool, - * ** name: std::string) - * - * 4. - * def __init__ ( - * ** value: ndarray) - * - * 5. - * def __init__ ( - * ** tensor: Tensor) - * - * 6. - * (should have at least one parameter, one parameter equals to case 5, zero - * parameter equals to case 1.) - * def __init__ ( - * ** tensor: Tensor, - * ** name: std::string) - * **/ + * 1. + * def __init__ () + * + * 2. + * def __init__ ( + * ** dims: vector, + * ** name: std::string) + * + * 3. + * (should have at least one parameter, one parameter equals to case 4, zero + * parameter equals to case 1) + * def __init__ ( + * ** value: ndarray, + * ** zero_copy: bool, + * ** name: std::string) + * + * 4. + * def __init__ ( + * ** value: ndarray) + * + * 5. + * def __init__ ( + * ** tensor: Tensor) + * + * 6. + * (should have at least one parameter, one parameter equals to case 5, zero + * parameter equals to case 1.) + * def __init__ ( + * ** tensor: Tensor, + * ** name: std::string) + * **/ int StringTensorInit(PyObject* self, PyObject* args, PyObject* kwargs) { // set a flag to record use kwargs or not bool flag_kwargs = false; @@ -916,8 +917,9 @@ int StringTensorInit(PyObject* self, PyObject* args, PyObject* kwargs) { // case 1 VLOG(6) << "Calling case1's string initializer."; EmptyStringTensorInitializer( - py_tensor_ptr, egr::Controller::Instance().GenerateUniqueName( - "generated_string_tensor"), + py_tensor_ptr, + egr::Controller::Instance().GenerateUniqueName( + "generated_string_tensor"), egr::Controller::Instance().GetExpectedPlace()); return 0; } else { diff --git a/paddle/fluid/pybind/eager.h b/paddle/fluid/pybind/eager.h index a3eac7ab47043bd69b35d1755af258921d496612..db2b438c3bd94b79bb65a02f40e403aa6762acfd 100644 --- a/paddle/fluid/pybind/eager.h +++ b/paddle/fluid/pybind/eager.h @@ -11,11 +11,11 @@ limitations under the License. */ #pragma once #include -#include "pybind11/pybind11.h" -#include "pybind11/stl.h" #include "paddle/fluid/eager/pylayer/py_layer_node.h" #include "paddle/phi/core/dense_tensor.h" +#include "pybind11/pybind11.h" +#include "pybind11/stl.h" namespace paddle { namespace pybind { diff --git a/paddle/fluid/pybind/eager_custom_python_api.h b/paddle/fluid/pybind/eager_custom_python_api.h index a3e996dbcbf6472ecbeb22593f563609275d50fe..df4920a5e690fc8e386ae2ed38ef9535deed7a7f 100644 --- a/paddle/fluid/pybind/eager_custom_python_api.h +++ b/paddle/fluid/pybind/eager_custom_python_api.h @@ -14,6 +14,7 @@ #pragma once #include + #include "paddle/phi/core/enforce.h" static PyObject *eager_api_run_program(PyObject *self, PyObject *args, diff --git a/paddle/fluid/pybind/eager_functions.cc b/paddle/fluid/pybind/eager_functions.cc index 628e808ef99acd6e97505f5cc5e4c4bfe6a7889f..c75ac0b52c52c4e20c3714fed764dc8152760620 100644 --- a/paddle/fluid/pybind/eager_functions.cc +++ b/paddle/fluid/pybind/eager_functions.cc @@ -20,9 +20,6 @@ typedef SSIZE_T ssize_t; #include #include -#include "pybind11/numpy.h" -#include "pybind11/pybind11.h" - #include "paddle/fluid/eager/accumulation/accumulation_node.h" #include "paddle/fluid/eager/api/all.h" #include "paddle/fluid/eager/autograd_meta.h" @@ -51,6 +48,8 @@ typedef SSIZE_T ssize_t; #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/sparse_coo_tensor.h" #include "paddle/phi/core/sparse_csr_tensor.h" +#include "pybind11/numpy.h" +#include "pybind11/pybind11.h" namespace paddle { namespace pybind { diff --git a/paddle/fluid/pybind/eager_method.cc b/paddle/fluid/pybind/eager_method.cc index 7831530bff03bf834b127aece0af8f75c8ea93c7..ab6b8edd52eae4f9e04821611b2cd34d00f54f1d 100644 --- a/paddle/fluid/pybind/eager_method.cc +++ b/paddle/fluid/pybind/eager_method.cc @@ -21,9 +21,6 @@ typedef SSIZE_T ssize_t; #include #include -#include "pybind11/numpy.h" -#include "pybind11/pybind11.h" - #include "paddle/fluid/eager/accumulation/accumulation_node.h" #include "paddle/fluid/eager/api/all.h" #include "paddle/fluid/eager/api/generated/fluid_generated/dygraph_forward_api.h" @@ -47,6 +44,8 @@ typedef SSIZE_T ssize_t; #include "paddle/phi/core/sparse_coo_tensor.h" #include "paddle/phi/core/sparse_csr_tensor.h" #include "pybind11/detail/internals.h" +#include "pybind11/numpy.h" +#include "pybind11/pybind11.h" #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #include "paddle/fluid/eager/api/generated/eager_generated/forwards/dygraph_functions.h" #include "paddle/fluid/framework/python_headers.h" @@ -1007,10 +1006,11 @@ static PyObject* tensor_method__setitem_eager_tensor(TensorObject* self, PADDLE_ENFORCE_EQ( egr::egr_utils_api::IsLeafTensor(self->tensor) && !egr::EagerUtils::autograd_meta(&self->tensor)->StopGradient(), - false, platform::errors::InvalidArgument( - "Leaf Tensor (%s) that doesn't stop gradient can't use " - "inplace strategy.", - self->tensor.name())); + false, + platform::errors::InvalidArgument( + "Leaf Tensor (%s) that doesn't stop gradient can't use " + "inplace strategy.", + self->tensor.name())); } paddle::experimental::Tensor value_tensor; @@ -1232,9 +1232,10 @@ static PyObject* tensor_register_reduce_hook(TensorObject* self, PyObject* args, "Only can register backward hook for leaf Tensor.")); PADDLE_ENFORCE_EQ( !egr::EagerUtils::unsafe_autograd_meta(self->tensor)->StopGradient(), - true, platform::errors::InvalidArgument( - "Cannot register backward hook on a Tensor that stop " - "gradient.")); + true, + platform::errors::InvalidArgument( + "Cannot register backward hook on a Tensor that stop " + "gradient.")); PADDLE_ENFORCE( grad_node.get() != nullptr, paddle::platform::errors::Fatal("Detected NULL grad_node," @@ -1667,8 +1668,8 @@ PyMethodDef variable_methods[] = { (PyCFunction)(void (*)(void))tensor_method__is_initialized, METH_VARARGS | METH_KEYWORDS, NULL}, {"_is_dense_tensor_hold_allocation", - (PyCFunction)( - void (*)(void))tensor_method__is_dense_tensor_hold_allocation, + (PyCFunction)(void (*)( + void))tensor_method__is_dense_tensor_hold_allocation, METH_VARARGS | METH_KEYWORDS, NULL}, {"_copy_to", (PyCFunction)(void (*)(void))tensor_method__copy_to, METH_VARARGS | METH_KEYWORDS, NULL}, @@ -1793,8 +1794,8 @@ PyMethodDef string_tensor_variable_methods[] = { (PyCFunction)(void (*)(void))tensor_method__is_initialized, METH_VARARGS | METH_KEYWORDS, NULL}, {"_is_string_tensor_hold_allocation", - (PyCFunction)( - void (*)(void))tensor_method__is_string_tensor_hold_allocation, + (PyCFunction)(void (*)( + void))tensor_method__is_string_tensor_hold_allocation, METH_VARARGS | METH_KEYWORDS, NULL}, // TODO(zhoushunjie): Need to add _copy_to, copy_ for StringTensor. {NULL, NULL, 0, NULL}}; diff --git a/paddle/fluid/pybind/eager_op_function_generator.cc b/paddle/fluid/pybind/eager_op_function_generator.cc index b546aa2d76bcd2264abde045d3d09d8c04a17762..f58f3ce94537ea8d0a851685777ab83c665c7a01 100644 --- a/paddle/fluid/pybind/eager_op_function_generator.cc +++ b/paddle/fluid/pybind/eager_op_function_generator.cc @@ -486,7 +486,8 @@ int main(int argc, char* argv[]) { "\"paddle/fluid/pybind/op_function_common.h\"", "\"paddle/fluid/eager/api/generated/fluid_generated/" "dygraph_forward_api.h\"", - "\"paddle/fluid/pybind/exception.h\"", ""}; + "\"paddle/fluid/pybind/exception.h\"", + ""}; std::ofstream out(argv[1], std::ios::out); diff --git a/paddle/fluid/pybind/eager_py_layer.cc b/paddle/fluid/pybind/eager_py_layer.cc index 47a5309d691f5863e60469f9b56649c7f0eded50..a0cef6388c13f2f328dfe2c64c6a4391875a55f3 100644 --- a/paddle/fluid/pybind/eager_py_layer.cc +++ b/paddle/fluid/pybind/eager_py_layer.cc @@ -16,8 +16,6 @@ limitations under the License. */ #include #pragma GCC diagnostic ignored "-Wattributes" -#include "pybind11/pytypes.h" - #include "paddle/fluid/eager/accumulation/accumulation_node.h" #include "paddle/fluid/eager/api/all.h" #include "paddle/fluid/eager/autograd_meta.h" @@ -34,6 +32,7 @@ limitations under the License. */ #include "paddle/phi/core/compat/convert_utils.h" #include "paddle/phi/core/dense_tensor.h" #include "pybind11/detail/internals.h" +#include "pybind11/pytypes.h" #pragma GCC diagnostic ignored "-Wwrite-strings" #pragma GCC diagnostic ignored "-Wmissing-field-initializers" @@ -323,10 +322,11 @@ PyObject* pylayer_method_apply(PyObject* cls, PyObject* args, egr::EagerUtils::autograd_meta(dirty_tensor); PADDLE_ENFORCE_EQ(!dirty_tensor_autograd_meta->StopGradient() && egr::egr_utils_api::IsLeafTensor(*dirty_tensor), - false, paddle::platform::errors::InvalidArgument( - "Leaf Var (%s) that doesn't stop gradient " - "can't use inplace strategy.", - dirty_tensor->name())); + false, + paddle::platform::errors::InvalidArgument( + "Leaf Var (%s) that doesn't stop gradient " + "can't use inplace strategy.", + dirty_tensor->name())); dirty_tensor->bump_inplace_version(); VLOG(3) << "Tensor(" << dirty_tensor->name() << ") uses Inplace Strategy."; @@ -466,16 +466,19 @@ PyMethodDef pylayer_methods[] = { METH_O, NULL}, {NULL, NULL, 0, NULL}}; -struct PyGetSetDef pylayer_properties[]{ - {"container", (getter)tensor_properties_get_container, - (setter)tensor_properties_set_container, nullptr, nullptr}, - {"non_differentiable", (getter)tensor_properties_get_non_differentiable, - (setter)tensor_properties_set_non_differentiable, nullptr, nullptr}, - {"dirty_tensors", (getter)tensor_properties_get_dirty_tensors, - (setter)tensor_properties_set_dirty_tensors, nullptr, nullptr}, - {"materialize_grads", nullptr, - (setter)tensor_properties_set_materialize_grads, nullptr, nullptr}, - {nullptr, nullptr, nullptr, nullptr, nullptr}}; +struct PyGetSetDef pylayer_properties[] { + {"container", (getter)tensor_properties_get_container, + (setter)tensor_properties_set_container, nullptr, nullptr}, + {"non_differentiable", (getter)tensor_properties_get_non_differentiable, + (setter)tensor_properties_set_non_differentiable, nullptr, nullptr}, + {"dirty_tensors", (getter)tensor_properties_get_dirty_tensors, + (setter)tensor_properties_set_dirty_tensors, nullptr, nullptr}, + {"materialize_grads", nullptr, + (setter)tensor_properties_set_materialize_grads, nullptr, nullptr}, + { + nullptr, nullptr, nullptr, nullptr, nullptr + } +}; void BindEagerPyLayer(PyObject* module) { auto heap_type = reinterpret_cast( diff --git a/paddle/fluid/pybind/eager_utils.cc b/paddle/fluid/pybind/eager_utils.cc index efa0fe2cb582eaff7d11e5fcfe2a460b2d8db0ea..9bcac35037d0476b75315874fca366b7d8caacdd 100644 --- a/paddle/fluid/pybind/eager_utils.cc +++ b/paddle/fluid/pybind/eager_utils.cc @@ -14,6 +14,9 @@ limitations under the License. */ #include #include +// clang-format will try to move eager_utils.h in front of other headers +// according to google c++ style, and that cause compiling problems. +// clang-format off #include "paddle/fluid/eager/api/all.h" #include "paddle/fluid/eager/autograd_meta.h" #include "paddle/fluid/framework/convert_utils.h" @@ -31,6 +34,7 @@ limitations under the License. */ #include "paddle/phi/common/data_type.h" #include "paddle/phi/core/compat/convert_utils.h" #include "paddle/phi/core/dense_tensor.h" +// clang-format on namespace paddle { namespace pybind { diff --git a/paddle/fluid/pybind/eager_utils.h b/paddle/fluid/pybind/eager_utils.h index 7f94f6c90e5a02d5fdea2a6d78475f6fca52bda3..beab99877bd798c563ae281c8f83c7513fd5b384 100644 --- a/paddle/fluid/pybind/eager_utils.h +++ b/paddle/fluid/pybind/eager_utils.h @@ -16,12 +16,12 @@ typedef SSIZE_T ssize_t; #endif #include + #include "paddle/phi/common/backend.h" #include "paddle/phi/common/data_type.h" #include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" #include "paddle/phi/core/dense_tensor.h" - #include "pybind11/pybind11.h" #include "pybind11/stl.h" namespace paddle { @@ -112,8 +112,9 @@ struct TupleTensorResult { PyObject* args, ssize_t arg_idx) { TupleTensorResult::Run(out, result, value_idx, args, arg_idx); if (N - 1 == value_idx) { - PyTuple_SET_ITEM(result, N - 1, ToPyObject(std::get(out), - value_idx, args, arg_idx)); + PyTuple_SET_ITEM( + result, N - 1, + ToPyObject(std::get(out), value_idx, args, arg_idx)); } else { PyTuple_SET_ITEM(result, N - 1, ToPyObject(std::get(out))); } diff --git a/paddle/fluid/pybind/exception.cc b/paddle/fluid/pybind/exception.cc index 4f25a6f1a5ca8d1a7926d148830934370e323e0f..934a9ef97fb15486d5dfa7cfe4d6c0c89b076d5c 100644 --- a/paddle/fluid/pybind/exception.cc +++ b/paddle/fluid/pybind/exception.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/pybind/exception.h" + #include "paddle/phi/api/ext/exception.h" namespace paddle { namespace pybind { diff --git a/paddle/fluid/pybind/fleet_py.cc b/paddle/fluid/pybind/fleet_py.cc index 4ffb513671c56598356a0311ecec15772dcc917d..25f2c91002844197e8faf30723584979240e30bf 100644 --- a/paddle/fluid/pybind/fleet_py.cc +++ b/paddle/fluid/pybind/fleet_py.cc @@ -18,8 +18,6 @@ limitations under the License. */ #undef _XOPEN_SOURCE #endif -#include "paddle/fluid/pybind/fleet_py.h" - #include #include #include @@ -35,17 +33,18 @@ limitations under the License. */ #include "paddle/fluid/distributed/ps/service/ps_service/graph_py_service.h" #include "paddle/fluid/distributed/ps/wrapper/fleet.h" #include "paddle/fluid/framework/fleet/heter_ps/graph_gpu_wrapper.h" +#include "paddle/fluid/pybind/fleet_py.h" namespace py = pybind11; using paddle::distributed::CommContext; using paddle::distributed::Communicator; +using paddle::distributed::FeatureNode; using paddle::distributed::FleetWrapper; -using paddle::distributed::HeterClient; -using paddle::distributed::GraphPyService; using paddle::distributed::GraphNode; -using paddle::distributed::GraphPyServer; using paddle::distributed::GraphPyClient; -using paddle::distributed::FeatureNode; +using paddle::distributed::GraphPyServer; +using paddle::distributed::GraphPyService; +using paddle::distributed::HeterClient; namespace paddle { namespace pybind { @@ -246,13 +245,13 @@ void BindGraphPyClient(py::module* m) { .def("bind_local_server", &GraphPyClient::bind_local_server); } -using paddle::distributed::TreeIndex; -using paddle::distributed::IndexWrapper; using paddle::distributed::IndexNode; +using paddle::distributed::IndexWrapper; +using paddle::distributed::TreeIndex; #ifdef PADDLE_WITH_HETERPS using paddle::framework::GraphGpuWrapper; -using paddle::framework::NeighborSampleResult; using paddle::framework::NeighborSampleQuery; +using paddle::framework::NeighborSampleResult; using paddle::framework::NodeQueryResult; #endif diff --git a/paddle/fluid/pybind/fleet_wrapper_py.cc b/paddle/fluid/pybind/fleet_wrapper_py.cc index af1c3da727d4178b8bab132fd9684aef48d445be..0e1d4cd76add2dccbafa7914d51b6a94a932423a 100644 --- a/paddle/fluid/pybind/fleet_wrapper_py.cc +++ b/paddle/fluid/pybind/fleet_wrapper_py.cc @@ -46,10 +46,10 @@ void BindFleetWrapper(py::module* m) { .def("push_dense", &framework::FleetWrapper::PushDenseVarsSync) .def("pull_dense", &framework::FleetWrapper::PullDenseVarsSync) .def("init_server", &framework::FleetWrapper::InitServer) - .def("run_server", (uint64_t (framework::FleetWrapper::*)(void)) & + .def("run_server", (uint64_t(framework::FleetWrapper::*)(void)) & framework::FleetWrapper::RunServer) - .def("run_server", (uint64_t (framework::FleetWrapper::*)( // NOLINT - const std::string&, uint32_t)) & // NOLINT + .def("run_server", (uint64_t(framework::FleetWrapper::*)( // NOLINT + const std::string&, uint32_t)) & // NOLINT framework::FleetWrapper::RunServer) .def("init_worker", &framework::FleetWrapper::InitWorker) .def("init_model", &framework::FleetWrapper::PushDenseParamSync) diff --git a/paddle/fluid/pybind/generator_py.cc b/paddle/fluid/pybind/generator_py.cc index 6bb85da8c466fdc657a295d1c5cd66b7b0739812..e456526f8441cb06841b630cc69a4ac72aa91fb2 100644 --- a/paddle/fluid/pybind/generator_py.cc +++ b/paddle/fluid/pybind/generator_py.cc @@ -8,9 +8,10 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/phi/core/generator.h" #include +#include "paddle/phi/core/generator.h" + #ifdef _POSIX_C_SOURCE #undef _POSIX_C_SOURCE #endif diff --git a/paddle/fluid/pybind/gloo_context_py.cc b/paddle/fluid/pybind/gloo_context_py.cc index 2314ceac76e5b6c7bc6a55f753f4c7eb839ccd0e..b4ee1bcd02bd7e569acd7cbb638e7d7fec8ed788 100644 --- a/paddle/fluid/pybind/gloo_context_py.cc +++ b/paddle/fluid/pybind/gloo_context_py.cc @@ -43,13 +43,14 @@ void BindGlooContext(py::module *m) { py::class_ gloo_parallel_strategy( *m, "GlooParallelStrategy", ""); gloo_parallel_strategy.def(py::init()) - .def_property("rank_num", - [](const platform::GlooParallelStrategy &self) { - return self.rank_num; - }, - [](platform::GlooParallelStrategy &self, int nranks) { - self.rank_num = nranks; - }) + .def_property( + "rank_num", + [](const platform::GlooParallelStrategy &self) { + return self.rank_num; + }, + [](platform::GlooParallelStrategy &self, int nranks) { + self.rank_num = nranks; + }) .def_property( "rank", [](const platform::GlooParallelStrategy &self) { return self.rank; }, @@ -62,20 +63,22 @@ void BindGlooContext(py::module *m) { [](platform::GlooParallelStrategy &self, const std::string &iface) { self.iface = iface; }) - .def_property("init_seconds", - [](const platform::GlooParallelStrategy &self) { - return self.init_seconds; - }, - [](platform::GlooParallelStrategy &self, int init_seconds) { - self.init_seconds = init_seconds; - }) - .def_property("run_seconds", - [](const platform::GlooParallelStrategy &self) { - return self.run_seconds; - }, - [](platform::GlooParallelStrategy &self, int run_seconds) { - self.run_seconds = run_seconds; - }) + .def_property( + "init_seconds", + [](const platform::GlooParallelStrategy &self) { + return self.init_seconds; + }, + [](platform::GlooParallelStrategy &self, int init_seconds) { + self.init_seconds = init_seconds; + }) + .def_property( + "run_seconds", + [](const platform::GlooParallelStrategy &self) { + return self.run_seconds; + }, + [](platform::GlooParallelStrategy &self, int run_seconds) { + self.run_seconds = run_seconds; + }) .def_property( "ip_address", [](const platform::GlooParallelStrategy &self) { @@ -83,13 +86,14 @@ void BindGlooContext(py::module *m) { }, [](platform::GlooParallelStrategy &self, const std::string &ip_address) { self.ip_address = ip_address; }) - .def_property("ip_port", - [](const platform::GlooParallelStrategy &self) { - return self.ip_port; - }, - [](platform::GlooParallelStrategy &self, int ip_port) { - self.ip_port = ip_port; - }); + .def_property( + "ip_port", + [](const platform::GlooParallelStrategy &self) { + return self.ip_port; + }, + [](platform::GlooParallelStrategy &self, int ip_port) { + self.ip_port = ip_port; + }); py::class_ gloo_ctx(*m, "GlooParallelContext"); gloo_ctx.def(py::init()) diff --git a/paddle/fluid/pybind/gloo_context_py.h b/paddle/fluid/pybind/gloo_context_py.h index 89bd183097b7541c33a797f27178bafb934bcd52..51f736ed060ceeea0b4e48ed133d1d898c4a9c19 100644 --- a/paddle/fluid/pybind/gloo_context_py.h +++ b/paddle/fluid/pybind/gloo_context_py.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "pybind11/pybind11.h" #include "pybind11/stl.h" diff --git a/paddle/fluid/pybind/imperative.cc b/paddle/fluid/pybind/imperative.cc index 954bac00ddbd71ea14cb07853f0315142167a196..3de6c64617ddd03c45f54aae757ad23468ad90f0 100644 --- a/paddle/fluid/pybind/imperative.cc +++ b/paddle/fluid/pybind/imperative.cc @@ -159,10 +159,9 @@ static const platform::Place PyObjectToPlace(const py::object &place_obj) { // only initialize varbase, but not its tensor. static void InitVarBaseOnly(imperative::VarBase *self, const std::string &name, bool persistable = false, int stop_gradient = -1) { - auto name_ = name == "" - ? imperative::GetCurrentTracer()->GenerateUniqueName( - "generated_tensor") - : name; + auto name_ = name == "" ? imperative::GetCurrentTracer()->GenerateUniqueName( + "generated_tensor") + : name; VLOG(5) << "Init Tensor as: / name: " << name_ << " / persistable: " << persistable @@ -274,10 +273,9 @@ static void InitVarBaseFromTensorWithArgDefault(imperative::VarBase *self, const std::string &name) { VLOG(4) << "Init VarBase"; auto place = imperative::GetCurrentTracer()->ExpectedPlace(); - auto name_ = name == "" - ? imperative::GetCurrentTracer()->GenerateUniqueName( - "generated_tensor") - : name; + auto name_ = name == "" ? imperative::GetCurrentTracer()->GenerateUniqueName( + "generated_tensor") + : name; new (self) imperative::VarBase(name_); self->SetPersistable(false); self->SetType(framework::proto::VarType::LOD_TENSOR); @@ -299,10 +297,9 @@ static void InitVarBaseFromTensorWithArg(imperative::VarBase *self, const P &place, const std::string &name) { VLOG(4) << "Init VarBase"; - auto name_ = name == "" - ? imperative::GetCurrentTracer()->GenerateUniqueName( - "generated_tensor") - : name; + auto name_ = name == "" ? imperative::GetCurrentTracer()->GenerateUniqueName( + "generated_tensor") + : name; new (self) imperative::VarBase(name_); self->SetPersistable(false); self->SetType(framework::proto::VarType::LOD_TENSOR); @@ -556,38 +553,39 @@ void BindImperative(py::module *m_ptr) { }, py::return_value_policy::take_ownership); - m.def("_array_to_share_memory_tensor", - [](py::object &obj) { - // 1. cast to python array - auto array = obj.cast(); - PADDLE_ENFORCE_NE( - string::Sprintf("%s", array.dtype()).compare("object"), 0, - platform::errors::InvalidArgument( - "Faild to convert input data to a regular ndarray.\n * " - "Usually this means the input data contains nested " - "lists with different lengths.\n * Check the reader " - "function passed to 'set_(sample/sample_list/batch)" - "_generator' to locate the data causes this issue.")); - // 2. construcct LoDTensor - framework::LoDTensor t; - SetTensorFromPyArray(&t, array, - platform::CPUPlace(), true); - // 3. allocate shared memory - void *data_ptr = t.data(); - size_t data_size = t.numel() * framework::DataTypeSize(t.dtype()); - auto shared_writer_holder = - memory::allocation::AllocateMemoryMapWriterAllocation(data_size); - // 4. maintain mmap fd set & backup ipc_name - const std::string &ipc_name = shared_writer_holder->ipc_name(); - memory::allocation::MemoryMapFdSet::Instance().Insert(ipc_name); - // 5. copy data & reset holder - memory::Copy(platform::CPUPlace(), shared_writer_holder->ptr(), - platform::CPUPlace(), data_ptr, data_size); - t.ResetHolder(shared_writer_holder); - - return t; - }, - py::return_value_policy::take_ownership); + m.def( + "_array_to_share_memory_tensor", + [](py::object &obj) { + // 1. cast to python array + auto array = obj.cast(); + PADDLE_ENFORCE_NE( + string::Sprintf("%s", array.dtype()).compare("object"), 0, + platform::errors::InvalidArgument( + "Faild to convert input data to a regular ndarray.\n * " + "Usually this means the input data contains nested " + "lists with different lengths.\n * Check the reader " + "function passed to 'set_(sample/sample_list/batch)" + "_generator' to locate the data causes this issue.")); + // 2. construcct LoDTensor + framework::LoDTensor t; + SetTensorFromPyArray(&t, array, + platform::CPUPlace(), true); + // 3. allocate shared memory + void *data_ptr = t.data(); + size_t data_size = t.numel() * framework::DataTypeSize(t.dtype()); + auto shared_writer_holder = + memory::allocation::AllocateMemoryMapWriterAllocation(data_size); + // 4. maintain mmap fd set & backup ipc_name + const std::string &ipc_name = shared_writer_holder->ipc_name(); + memory::allocation::MemoryMapFdSet::Instance().Insert(ipc_name); + // 5. copy data & reset holder + memory::Copy(platform::CPUPlace(), shared_writer_holder->ptr(), + platform::CPUPlace(), data_ptr, data_size); + t.ResetHolder(shared_writer_holder); + + return t; + }, + py::return_value_policy::take_ownership); m.def("_remove_tensor_list_mmap_fds", [](py::list &tensor_list) { for (size_t i = 0; i < tensor_list.size(); ++i) { @@ -1089,31 +1087,32 @@ void BindImperative(py::module *m_ptr) { self.Name())); return var->CurrentInplaceVersion(); }) - .def("_bump_inplace_version", - [](std::shared_ptr &self) { - // NOTE(liym27): _bump_inplace_version is only used for inplace - // operation - self->BumpInplaceVersion(); - }, - R"DOC( + .def( + "_bump_inplace_version", + [](std::shared_ptr &self) { + // NOTE(liym27): _bump_inplace_version is only used for inplace + // operation + self->BumpInplaceVersion(); + }, + R"DOC( **Notes**: **This API is ONLY available in Dygraph mode.** **This is a very low level API. Users should not use it directly. ** Bump the version whenever the Tensor is modified through an inplace operation. )DOC") - .def("numpy", + .def( + "numpy", - [](imperative::VarBase &self) -> py::array { - const auto &tensor = - self.MutableVar()->Get(); - PADDLE_ENFORCE_EQ( - tensor.IsInitialized(), true, - platform::errors::InvalidArgument( - "Tensor of %s is Empty, please check if it has no data.", - self.Name())); - return TensorToPyArray(tensor, true); - }, - R"DOC( + [](imperative::VarBase &self) -> py::array { + const auto &tensor = self.MutableVar()->Get(); + PADDLE_ENFORCE_EQ( + tensor.IsInitialized(), true, + platform::errors::InvalidArgument( + "Tensor of %s is Empty, please check if it has no data.", + self.Name())); + return TensorToPyArray(tensor, true); + }, + R"DOC( Returns a numpy array shows the value of current Tensor. Returns: @@ -1133,68 +1132,69 @@ void BindImperative(py::module *m_ptr) { x = linear(data) print(x.numpy()) )DOC") - .def("detach", - [](const imperative::VarBase - &self) -> std::shared_ptr { - PADDLE_ENFORCE_EQ( - self.Var().IsInitialized(), true, - platform::errors::InvalidArgument( - "Tensor %s has not been initialized!", self.Name())); + .def( + "detach", + [](const imperative::VarBase &self) + -> std::shared_ptr { + PADDLE_ENFORCE_EQ( + self.Var().IsInitialized(), true, + platform::errors::InvalidArgument( + "Tensor %s has not been initialized!", self.Name())); - PADDLE_ENFORCE_EQ( - self.Var().IsType() || - self.Var().IsType(), - true, - platform::errors::InvalidArgument( - "Type of Tensor[%s] must be LoDTensor or SelectedRows!", - self.Name())); + PADDLE_ENFORCE_EQ( + self.Var().IsType() || + self.Var().IsType(), + true, + platform::errors::InvalidArgument( + "Type of Tensor[%s] must be LoDTensor or SelectedRows!", + self.Name())); - auto detach_var = std::make_shared( - true, "detach_" + self.Name()); + auto detach_var = std::make_shared( + true, "detach_" + self.Name()); - detach_var->SetPersistable(self.Persistable()); - detach_var->SetType(self.Type()); - detach_var->SetDataType(self.DataType()); + detach_var->SetPersistable(self.Persistable()); + detach_var->SetType(self.Type()); + detach_var->SetDataType(self.DataType()); - if (self.Var().IsType()) { - const auto &origin_tensor = - self.Var().Get(); - PADDLE_ENFORCE_EQ( - origin_tensor.IsInitialized(), true, - platform::errors::InvalidArgument( - "Tensor %s has not been initialized!", self.Name())); - - auto *detach_tensor = - detach_var->MutableVar()->GetMutable(); - detach_tensor->ShareDataWith(origin_tensor); - // NOTE(liym27): Call ShareInplaceVersionCounterWith to share the - // same TensorInplaceVersion, which is used to check whether - // inplace - // operations are correct. - detach_tensor->ShareInplaceVersionCounterWith(origin_tensor); - } else { - const auto &origin_selected_rows = - self.Var().Get(); - PADDLE_ENFORCE_EQ( - origin_selected_rows.value().IsInitialized(), true, - platform::errors::InvalidArgument( - "Tensor %s has not been initialized!", self.Name())); - - auto *detach_selected_rows = - detach_var->MutableVar()->GetMutable(); - detach_selected_rows->set_height(origin_selected_rows.height()); - detach_selected_rows->set_rows(origin_selected_rows.rows()); - detach_selected_rows->mutable_value()->ShareDataWith( - origin_selected_rows.value()); - detach_selected_rows->mutable_value() - ->ShareInplaceVersionCounterWith( - origin_selected_rows.value()); - } - VLOG(3) << "The detached Tensor(" << detach_var->Name() - << ") share data with " << self.Name(); - return detach_var; - }, - py::return_value_policy::take_ownership, R"DOC( + if (self.Var().IsType()) { + const auto &origin_tensor = + self.Var().Get(); + PADDLE_ENFORCE_EQ( + origin_tensor.IsInitialized(), true, + platform::errors::InvalidArgument( + "Tensor %s has not been initialized!", self.Name())); + + auto *detach_tensor = + detach_var->MutableVar()->GetMutable(); + detach_tensor->ShareDataWith(origin_tensor); + // NOTE(liym27): Call ShareInplaceVersionCounterWith to share the + // same TensorInplaceVersion, which is used to check whether + // inplace + // operations are correct. + detach_tensor->ShareInplaceVersionCounterWith(origin_tensor); + } else { + const auto &origin_selected_rows = + self.Var().Get(); + PADDLE_ENFORCE_EQ( + origin_selected_rows.value().IsInitialized(), true, + platform::errors::InvalidArgument( + "Tensor %s has not been initialized!", self.Name())); + + auto *detach_selected_rows = + detach_var->MutableVar()->GetMutable(); + detach_selected_rows->set_height(origin_selected_rows.height()); + detach_selected_rows->set_rows(origin_selected_rows.rows()); + detach_selected_rows->mutable_value()->ShareDataWith( + origin_selected_rows.value()); + detach_selected_rows->mutable_value() + ->ShareInplaceVersionCounterWith( + origin_selected_rows.value()); + } + VLOG(3) << "The detached Tensor(" << detach_var->Name() + << ") share data with " << self.Name(); + return detach_var; + }, + py::return_value_policy::take_ownership, R"DOC( Returns a new Tensor, detached from the current graph. It will share data with origin Tensor and always doesn't have a Tensor copy. @@ -1256,23 +1256,23 @@ void BindImperative(py::module *m_ptr) { .def("_gradient_set_empty", &imperative::VarBase::_GradientSetEmpty, py::arg("set_is_empty") = true) .def("_is_gradient_set_empty", &imperative::VarBase::_IsGradientSetEmpty) - .def("clone", - [](std::shared_ptr &self) { - const auto &tensor = self->Var().Get(); - PADDLE_ENFORCE_EQ( - tensor.IsInitialized(), true, - platform::errors::InvalidArgument( - "%s has not been initialized", self->Name())); - auto tracer = imperative::GetCurrentTracer(); - auto new_var = std::make_shared( - true, tracer->GenerateUniqueName(self->Name() + "_clone")); - framework::AttributeMap attrs; - imperative::NameVarBaseMap ins = {{"X", {self}}}; - imperative::NameVarBaseMap outs = {{"Out", {new_var}}}; - tracer->TraceOp("assign", ins, outs, attrs); - return new_var; - }, - py::return_value_policy::copy, R"DOC( + .def( + "clone", + [](std::shared_ptr &self) { + const auto &tensor = self->Var().Get(); + PADDLE_ENFORCE_EQ(tensor.IsInitialized(), true, + platform::errors::InvalidArgument( + "%s has not been initialized", self->Name())); + auto tracer = imperative::GetCurrentTracer(); + auto new_var = std::make_shared( + true, tracer->GenerateUniqueName(self->Name() + "_clone")); + framework::AttributeMap attrs; + imperative::NameVarBaseMap ins = {{"X", {self}}}; + imperative::NameVarBaseMap outs = {{"Out", {new_var}}}; + tracer->TraceOp("assign", ins, outs, attrs); + return new_var; + }, + py::return_value_policy::copy, R"DOC( Returns a new Tensor, which is clone of origin Tensor, and it remains in the current graph. It will always have a Tensor copy. @@ -1305,11 +1305,12 @@ void BindImperative(py::module *m_ptr) { print(x.grad) # None )DOC") .def("_grad_name", &imperative::VarBase::GradVarName) - .def("_grad_value", - [](imperative::VarBase &self) { - return self.MutableGradVar()->Get(); - }, - py::return_value_policy::reference) + .def( + "_grad_value", + [](imperative::VarBase &self) { + return self.MutableGradVar()->Get(); + }, + py::return_value_policy::reference) .def("_set_grad_type", [](imperative::VarBase &self, framework::proto::VarType::Type type) { self.MutableGradVarBase()->SetType(type); @@ -1337,26 +1338,27 @@ void BindImperative(py::module *m_ptr) { } } }) - .def("_grad_ivar", - [](const imperative::VarBase &self) { - auto &grad_var = self.GradVarBase(); - - if (grad_var && grad_var->Var().IsInitialized()) { - auto *tensor = - grad_var->MutableVar()->IsType() - ? grad_var->MutableVar() - ->GetMutable() - : grad_var->MutableVar() - ->GetMutable() - ->mutable_value(); - - if (tensor->IsInitialized()) { - return grad_var; - } - } - return std::shared_ptr(nullptr); - }, - py::return_value_policy::copy) + .def( + "_grad_ivar", + [](const imperative::VarBase &self) { + auto &grad_var = self.GradVarBase(); + + if (grad_var && grad_var->Var().IsInitialized()) { + auto *tensor = + grad_var->MutableVar()->IsType() + ? grad_var->MutableVar() + ->GetMutable() + : grad_var->MutableVar() + ->GetMutable() + ->mutable_value(); + + if (tensor->IsInitialized()) { + return grad_var; + } + } + return std::shared_ptr(nullptr); + }, + py::return_value_policy::copy) .def("_set_grad_ivar", [](imperative::VarBase &self, imperative::VarBase &grad) { self.SetGradVarBase(grad); @@ -1365,13 +1367,14 @@ void BindImperative(py::module *m_ptr) { [](imperative::VarBase &self) { return self.Var().IsType(); }) - .def("_allreduce", - [](imperative::VarBase &self, - const imperative::ParallelStrategy &strategy) { - if (strategy.nranks_ > 1) { + .def( + "_allreduce", + [](imperative::VarBase &self, + const imperative::ParallelStrategy &strategy) { + if (strategy.nranks_ > 1) { #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) #if NCCL_VERSION_CODE >= 2212 - imperative::AllReduce(self.Var(), self.MutableVar(), strategy); + imperative::AllReduce(self.Var(), self.MutableVar(), strategy); #else if (!self.Var().IsType()) { imperative::AllReduce(self.Var(), self.MutableVar(), strategy); @@ -1388,9 +1391,9 @@ void BindImperative(py::module *m_ptr) { "Imperative allreduce is not supported when paddle is " "not compiled with NCCL.")); #endif // PADDLE_WITH_NCCL or PADDLE_WITH_RCCL - } - }, - py::call_guard()) + } + }, + py::call_guard()) .def("_register_grad_hook", [](imperative::VarBase &self, const py::handle &hook) { PADDLE_ENFORCE_EQ( @@ -1425,22 +1428,23 @@ void BindImperative(py::module *m_ptr) { std::make_shared>(py_func)); } }) - .def("_register_backward_hook", - [](imperative::VarBase &self, const py::handle &hook) { - PADDLE_ENFORCE_EQ( - self.IsLeaf(), true, - platform::errors::InvalidArgument( - "Only can register backward hook for leaf Tensor.")); - PADDLE_ENFORCE_EQ( - !self.OverridedStopGradient() && self.HasGradVar(), true, - platform::errors::InvalidArgument( - "Cannot register backward hook on a Tensor that stop " - "gradient or without gradient.")); - auto py_func = PyObjectCast>(hook.ptr()); - self.GradVarBase()->AddVoidHook( - std::make_shared>(py_func)); - }, - R"DOC( + .def( + "_register_backward_hook", + [](imperative::VarBase &self, const py::handle &hook) { + PADDLE_ENFORCE_EQ( + self.IsLeaf(), true, + platform::errors::InvalidArgument( + "Only can register backward hook for leaf Tensor.")); + PADDLE_ENFORCE_EQ( + !self.OverridedStopGradient() && self.HasGradVar(), true, + platform::errors::InvalidArgument( + "Cannot register backward hook on a Tensor that stop " + "gradient or without gradient.")); + auto py_func = PyObjectCast>(hook.ptr()); + self.GradVarBase()->AddVoidHook( + std::make_shared>(py_func)); + }, + R"DOC( Registers a backward hook for current Tensor. This hook will be called every time the gradient of current Tensor has been fully calculated. @@ -1461,17 +1465,18 @@ void BindImperative(py::module *m_ptr) { Returns: None )DOC") - .def("cpu", - [](const std::shared_ptr &self) { - if (platform::is_cpu_place(self->Place())) { - return self; - } else { - auto new_var = self->NewVarBase(platform::CPUPlace(), true); - new_var->SetOverridedStopGradient(self->OverridedStopGradient()); - return new_var; - } - }, - R"DOC( + .def( + "cpu", + [](const std::shared_ptr &self) { + if (platform::is_cpu_place(self->Place())) { + return self; + } else { + auto new_var = self->NewVarBase(platform::CPUPlace(), true); + new_var->SetOverridedStopGradient(self->OverridedStopGradient()); + return new_var; + } + }, + R"DOC( Returns a copy of this Tensor in CPU memory. If this Tensor is already in CPU memory, then no copy is performed and the original Tensor is returned. @@ -1487,24 +1492,25 @@ void BindImperative(py::module *m_ptr) { print(y.place) # CPUPlace )DOC") - .def("pin_memory", - [](const std::shared_ptr &self) { + .def( + "pin_memory", + [](const std::shared_ptr &self) { #if !defined(PADDLE_WITH_CUDA) && !defined(PADDLE_WITH_HIP) - PADDLE_THROW(platform::errors::PermissionDenied( - "Cannot copy this Tensor to pinned memory in CPU version " - "Paddle, " - "Please recompile or reinstall Paddle with CUDA support.")); + PADDLE_THROW(platform::errors::PermissionDenied( + "Cannot copy this Tensor to pinned memory in CPU version " + "Paddle, " + "Please recompile or reinstall Paddle with CUDA support.")); #endif - if (platform::is_cuda_pinned_place(self->Place())) { - return self; - } else { - auto new_var = - self->NewVarBase(platform::CUDAPinnedPlace(), true); - new_var->SetOverridedStopGradient(self->OverridedStopGradient()); - return new_var; - } - }, - R"DOC( + if (platform::is_cuda_pinned_place(self->Place())) { + return self; + } else { + auto new_var = + self->NewVarBase(platform::CUDAPinnedPlace(), true); + new_var->SetOverridedStopGradient(self->OverridedStopGradient()); + return new_var; + } + }, + R"DOC( Returns a copy of this Tensor in pin memory. If this Tensor is already in pin memory, then no copy is performed and the original Tensor is returned. @@ -1520,13 +1526,14 @@ void BindImperative(py::module *m_ptr) { print(y.place) # CUDAPinnedPlace )DOC") - .def("cuda", - [](const std::shared_ptr &self, - py::handle &handle, bool blocking) { + .def( + "cuda", + [](const std::shared_ptr &self, + py::handle &handle, bool blocking) { #if !defined(PADDLE_WITH_CUDA) && !defined(PADDLE_WITH_HIP) - PADDLE_THROW(platform::errors::PermissionDenied( - "Cannot copy this Tensor to GPU in CPU version Paddle, " - "Please recompile or reinstall Paddle with CUDA support.")); + PADDLE_THROW(platform::errors::PermissionDenied( + "Cannot copy this Tensor to GPU in CPU version Paddle, " + "Please recompile or reinstall Paddle with CUDA support.")); #else int device_count = platform::GetGPUDeviceCount(); int device_id = 0; @@ -1563,8 +1570,8 @@ void BindImperative(py::module *m_ptr) { return new_var; } #endif - }, - py::arg("device_id") = py::none(), py::arg("blocking") = true, R"DOC( + }, + py::arg("device_id") = py::none(), py::arg("blocking") = true, R"DOC( Returns a copy of this Tensor in GPU memory. If this Tensor is already in GPU memory and device_id is default, @@ -1592,49 +1599,51 @@ void BindImperative(py::module *m_ptr) { y = x.cuda(1) print(y.place) # CUDAPlace(1) )DOC") - .def("_share_memory", - [](const std::shared_ptr &self) { + .def( + "_share_memory", + [](const std::shared_ptr &self) { #ifndef _WIN32 - PADDLE_ENFORCE_EQ( - platform::is_cpu_place(self->Place()), true, - platform::errors::InvalidArgument( - "Sharing memory only support CPU Tensor currently")); - // 1. get LoDTensor - auto *t = self->MutableVar()->GetMutable(); - // 2. allocate shared memory - void *data_ptr = t->data(); - size_t data_size = - t->numel() * framework::SizeOfType( - framework::TransToProtoVarType(t->dtype())); - auto shared_writer_holder = - memory::allocation::AllocateMemoryMapWriterAllocation( - data_size); - // 3. maintain mmap fd set & backup ipc_name - const std::string &ipc_name = shared_writer_holder->ipc_name(); - memory::allocation::MemoryMapFdSet::Instance().Insert(ipc_name); - // 4. copy data & reset holder - memory::Copy(platform::CPUPlace(), shared_writer_holder->ptr(), - platform::CPUPlace(), data_ptr, data_size); - t->ResetHolder(shared_writer_holder); - return *t; + PADDLE_ENFORCE_EQ( + platform::is_cpu_place(self->Place()), true, + platform::errors::InvalidArgument( + "Sharing memory only support CPU Tensor currently")); + // 1. get LoDTensor + auto *t = self->MutableVar()->GetMutable(); + // 2. allocate shared memory + void *data_ptr = t->data(); + size_t data_size = + t->numel() * framework::SizeOfType( + framework::TransToProtoVarType(t->dtype())); + auto shared_writer_holder = + memory::allocation::AllocateMemoryMapWriterAllocation( + data_size); + // 3. maintain mmap fd set & backup ipc_name + const std::string &ipc_name = shared_writer_holder->ipc_name(); + memory::allocation::MemoryMapFdSet::Instance().Insert(ipc_name); + // 4. copy data & reset holder + memory::Copy(platform::CPUPlace(), shared_writer_holder->ptr(), + platform::CPUPlace(), data_ptr, data_size); + t->ResetHolder(shared_writer_holder); + return *t; #else PADDLE_THROW(platform::errors::PermissionDenied( "Sharing memory in Windows OS is not supported currently")); #endif - }, - py::return_value_policy::reference) + }, + py::return_value_policy::reference) #if defined(PADDLE_WITH_CUDA) - .def("_uva", - [](const std::shared_ptr &self, int device_id) { - PADDLE_ENFORCE_EQ(platform::is_cpu_place(self->Place()), true, - platform::errors::InvalidArgument( - "Unified virtual addressing only support " - "CPU Tensor currently.")); - auto *self_tensor = - self->MutableVar()->GetMutable(); - tensor_uva(self_tensor, device_id); - }, - py::arg("device_id") = 0, py::return_value_policy::reference, R"DOC( + .def( + "_uva", + [](const std::shared_ptr &self, int device_id) { + PADDLE_ENFORCE_EQ(platform::is_cpu_place(self->Place()), true, + platform::errors::InvalidArgument( + "Unified virtual addressing only support " + "CPU Tensor currently.")); + auto *self_tensor = + self->MutableVar()->GetMutable(); + tensor_uva(self_tensor, device_id); + }, + py::arg("device_id") = 0, py::return_value_policy::reference, R"DOC( Returns self tensor with the UVA(unified virtual addressing). Args: @@ -1651,86 +1660,94 @@ void BindImperative(py::module *m_ptr) { )DOC") #endif .def("copy_", &imperative::VarBase::CopyFrom) - .def("_copy_to", - [](const std::shared_ptr &self, - const platform::CPUPlace &place, bool blocking) { - auto new_var = self->NewVarBase(place, blocking); - // Note(zhiqiu): Since NewVarBase may use GpuCopyAsync to - // copy data from the tensor of self to the tensor of new varbase, - // we need to ensure that the varbase self is not destructed until - // the GpuCopyAsync is completed. Otherwise, the memory may be - // freed - // when varbase self is destructed. - // To do that, we increase the reference count of self by 1 and - // add a cuda event to wait the GpuCopyAsync's completion. - if (!blocking) { - IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); - } - return new_var; - }, - py::return_value_policy::copy) - .def("_copy_to", - [](const std::shared_ptr &self, - const platform::CUDAPinnedPlace &place, bool blocking) { - auto new_var = self->NewVarBase(place, blocking); - if (!blocking) { - IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); - } - return new_var; - }, - py::return_value_policy::copy) - .def("_copy_to", - [](const std::shared_ptr &self, - const platform::XPUPlace &place, bool blocking) { - auto new_var = self->NewVarBase(place, blocking); - if (!blocking) { - IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); - } - return new_var; - }, - py::return_value_policy::copy) - .def("_copy_to", - [](const std::shared_ptr &self, - const platform::CUDAPlace &place, bool blocking) { - auto new_var = self->NewVarBase(place, blocking); - if (!blocking) { - IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); - } - return new_var; - }, - py::return_value_policy::copy) - .def("_copy_to", - [](const std::shared_ptr &self, - const platform::NPUPlace &place, bool blocking) { - auto new_var = self->NewVarBase(place, blocking); - if (!blocking) { - IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); - } - return new_var; - }, - py::return_value_policy::copy) - .def("_copy_to", - [](const std::shared_ptr &self, - const platform::MLUPlace &place, bool blocking) { - auto new_var = self->NewVarBase(place, blocking); - if (!blocking) { - IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); - } - return new_var; - }, - py::return_value_policy::copy) - .def("_copy_to", - [](const std::shared_ptr &self, - const platform::Place &place, bool blocking) { - auto new_var = self->NewVarBase(place, blocking); - if (!blocking) { - IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); - } - return new_var; - }, - py::return_value_policy::copy) - .def("value", [](imperative::VarBase &self) { return self.MutableVar(); }, - py::return_value_policy::reference) + .def( + "_copy_to", + [](const std::shared_ptr &self, + const platform::CPUPlace &place, bool blocking) { + auto new_var = self->NewVarBase(place, blocking); + // Note(zhiqiu): Since NewVarBase may use GpuCopyAsync to + // copy data from the tensor of self to the tensor of new varbase, + // we need to ensure that the varbase self is not destructed until + // the GpuCopyAsync is completed. Otherwise, the memory may be + // freed + // when varbase self is destructed. + // To do that, we increase the reference count of self by 1 and + // add a cuda event to wait the GpuCopyAsync's completion. + if (!blocking) { + IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); + } + return new_var; + }, + py::return_value_policy::copy) + .def( + "_copy_to", + [](const std::shared_ptr &self, + const platform::CUDAPinnedPlace &place, bool blocking) { + auto new_var = self->NewVarBase(place, blocking); + if (!blocking) { + IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); + } + return new_var; + }, + py::return_value_policy::copy) + .def( + "_copy_to", + [](const std::shared_ptr &self, + const platform::XPUPlace &place, bool blocking) { + auto new_var = self->NewVarBase(place, blocking); + if (!blocking) { + IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); + } + return new_var; + }, + py::return_value_policy::copy) + .def( + "_copy_to", + [](const std::shared_ptr &self, + const platform::CUDAPlace &place, bool blocking) { + auto new_var = self->NewVarBase(place, blocking); + if (!blocking) { + IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); + } + return new_var; + }, + py::return_value_policy::copy) + .def( + "_copy_to", + [](const std::shared_ptr &self, + const platform::NPUPlace &place, bool blocking) { + auto new_var = self->NewVarBase(place, blocking); + if (!blocking) { + IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); + } + return new_var; + }, + py::return_value_policy::copy) + .def( + "_copy_to", + [](const std::shared_ptr &self, + const platform::MLUPlace &place, bool blocking) { + auto new_var = self->NewVarBase(place, blocking); + if (!blocking) { + IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); + } + return new_var; + }, + py::return_value_policy::copy) + .def( + "_copy_to", + [](const std::shared_ptr &self, + const platform::Place &place, bool blocking) { + auto new_var = self->NewVarBase(place, blocking); + if (!blocking) { + IncreaseVarbaseReferenceCountUntilCopyComplete(self, place); + } + return new_var; + }, + py::return_value_policy::copy) + .def( + "value", [](imperative::VarBase &self) { return self.MutableVar(); }, + py::return_value_policy::reference) .def("_clear", [](const std::shared_ptr &self) { auto *t = self->MutableVar()->GetMutable(); @@ -1842,39 +1859,28 @@ void BindImperative(py::module *m_ptr) { &imperative::VarBase::SetOverridedStopGradient) .def_property("persistable", &imperative::VarBase::Persistable, &imperative::VarBase::SetPersistable) - .def_property_readonly("shape", - [](imperative::VarBase &self) { - if (self.Var().IsType()) { - return phi::vectorize( - self.Var() - .Get() - .dims()); - } else if (self.Var() - .IsType()) { - return phi::vectorize( - self.Var() - .Get() - .value() - .dims()); - } else if (self.Var() - .IsType()) { - return std::vector{static_cast( - self.Var() - .Get() - .size())}; - } else if (self.Var() - .IsType()) { - return std::vector{static_cast( - self.Var() - .Get() - .size())}; - } else { - VLOG(2) << "It is meaningless to get shape of " - "variable type " - << GetTypeName(self); - return std::vector(); - } - }) + .def_property_readonly( + "shape", + [](imperative::VarBase &self) { + if (self.Var().IsType()) { + return phi::vectorize( + self.Var().Get().dims()); + } else if (self.Var().IsType()) { + return phi::vectorize( + self.Var().Get().value().dims()); + } else if (self.Var().IsType()) { + return std::vector{static_cast( + self.Var().Get().size())}; + } else if (self.Var().IsType()) { + return std::vector{ + static_cast(self.Var().Get().size())}; + } else { + VLOG(2) << "It is meaningless to get shape of " + "variable type " + << GetTypeName(self); + return std::vector(); + } + }) .def_property_readonly("is_leaf", &imperative::VarBase::IsLeaf, R"DOC( Whether a Tensor is leaf Tensor. @@ -2157,13 +2163,14 @@ void BindImperative(py::module *m_ptr) { [](imperative::ParallelStrategy &self, int nranks) { self.nranks_ = nranks; }) - .def_property("local_rank", - [](const imperative::ParallelStrategy &self) { - return self.local_rank_; - }, - [](imperative::ParallelStrategy &self, int local_rank) { - self.local_rank_ = local_rank; - }) + .def_property( + "local_rank", + [](const imperative::ParallelStrategy &self) { + return self.local_rank_; + }, + [](imperative::ParallelStrategy &self, int local_rank) { + self.local_rank_ = local_rank; + }) .def_property( "trainer_endpoints", [](const imperative::ParallelStrategy &self) { @@ -2172,12 +2179,14 @@ void BindImperative(py::module *m_ptr) { [](imperative::ParallelStrategy &self, std::vector eps) { self.trainer_endpoints_ = eps; }) - .def_property("current_endpoint", - [](const imperative::ParallelStrategy &self) { - return self.current_endpoint_; - }, - [](imperative::ParallelStrategy &self, - const std::string &ep) { self.current_endpoint_ = ep; }) + .def_property( + "current_endpoint", + [](const imperative::ParallelStrategy &self) { + return self.current_endpoint_; + }, + [](imperative::ParallelStrategy &self, const std::string &ep) { + self.current_endpoint_ = ep; + }) .def_property( "nrings", [](const imperative::ParallelStrategy &self) { return self.nrings_; }, @@ -2359,43 +2368,44 @@ void BindImperative(py::module *m_ptr) { }); #if defined(PADDLE_WITH_CUDA) - m.def("to_uva_tensor", - [](const py::object &obj, int device_id) { - const auto &tracer = imperative::GetCurrentTracer(); - auto new_tensor = std::shared_ptr( - new imperative::VarBase(tracer->GenerateUniqueName())); - auto array = obj.cast(); - if (py::isinstance>(array)) { - SetUVATensorFromPyArray(new_tensor, array, device_id); - } else if (py::isinstance>(array)) { - SetUVATensorFromPyArray(new_tensor, array, device_id); - } else if (py::isinstance>(array)) { - SetUVATensorFromPyArray(new_tensor, array, device_id); - } else if (py::isinstance>(array)) { - SetUVATensorFromPyArray(new_tensor, array, device_id); - } else if (py::isinstance>(array)) { - SetUVATensorFromPyArray(new_tensor, array, device_id); - } else if (py::isinstance>(array)) { - SetUVATensorFromPyArray(new_tensor, array, device_id); - } else if (py::isinstance>( - array)) { - SetUVATensorFromPyArray( - new_tensor, array, device_id); - } else if (py::isinstance>(array)) { - SetUVATensorFromPyArray(new_tensor, array, device_id); - } else { - // obj may be any type, obj.cast() may be failed, - // then the array.dtype will be string of unknown meaning. - PADDLE_THROW(platform::errors::InvalidArgument( - "Input object type error or incompatible array data type. " - "tensor.set() supports array with bool, float16, float32, " - "float64, int8, int16, int32, int64," - "please check your input or input array data type.")); - } - return new_tensor; - }, - py::arg("obj"), py::arg("device_id") = 0, - py::return_value_policy::reference, R"DOC( + m.def( + "to_uva_tensor", + [](const py::object &obj, int device_id) { + const auto &tracer = imperative::GetCurrentTracer(); + auto new_tensor = std::shared_ptr( + new imperative::VarBase(tracer->GenerateUniqueName())); + auto array = obj.cast(); + if (py::isinstance>(array)) { + SetUVATensorFromPyArray(new_tensor, array, device_id); + } else if (py::isinstance>(array)) { + SetUVATensorFromPyArray(new_tensor, array, device_id); + } else if (py::isinstance>(array)) { + SetUVATensorFromPyArray(new_tensor, array, device_id); + } else if (py::isinstance>(array)) { + SetUVATensorFromPyArray(new_tensor, array, device_id); + } else if (py::isinstance>(array)) { + SetUVATensorFromPyArray(new_tensor, array, device_id); + } else if (py::isinstance>(array)) { + SetUVATensorFromPyArray(new_tensor, array, device_id); + } else if (py::isinstance>( + array)) { + SetUVATensorFromPyArray(new_tensor, array, + device_id); + } else if (py::isinstance>(array)) { + SetUVATensorFromPyArray(new_tensor, array, device_id); + } else { + // obj may be any type, obj.cast() may be failed, + // then the array.dtype will be string of unknown meaning. + PADDLE_THROW(platform::errors::InvalidArgument( + "Input object type error or incompatible array data type. " + "tensor.set() supports array with bool, float16, float32, " + "float64, int8, int16, int32, int64," + "please check your input or input array data type.")); + } + return new_tensor; + }, + py::arg("obj"), py::arg("device_id") = 0, + py::return_value_policy::reference, R"DOC( Returns tensor with the UVA(unified virtual addressing) created from numpy array. Args: diff --git a/paddle/fluid/pybind/imperative.h b/paddle/fluid/pybind/imperative.h index 0e3e98512d60fa111c94f70bf43524c36463cc05..91b9294421529b4ce2cd6101569edd8002d597af 100644 --- a/paddle/fluid/pybind/imperative.h +++ b/paddle/fluid/pybind/imperative.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "pybind11/pybind11.h" #include "pybind11/stl.h" diff --git a/paddle/fluid/pybind/inference_api.cc b/paddle/fluid/pybind/inference_api.cc index d4c19364d4816052fe97b5f9d52871498933caf0..d6ffbf010016a997b258038f713c286cca4c340d 100644 --- a/paddle/fluid/pybind/inference_api.cc +++ b/paddle/fluid/pybind/inference_api.cc @@ -13,8 +13,10 @@ // limitations under the License. #include "paddle/fluid/pybind/inference_api.h" + #include #include + #include #include #include @@ -26,6 +28,7 @@ #include #include #include + #include "paddle/fluid/inference/api/analysis_predictor.h" #include "paddle/fluid/inference/api/helper.h" #include "paddle/fluid/inference/api/paddle_infer_contrib.h" @@ -75,8 +78,8 @@ using paddle::AnalysisPredictor; using paddle::NativeConfig; using paddle::NativePaddlePredictor; using paddle::PaddleBuf; -using paddle::PaddleDType; using paddle::PaddleDataLayout; +using paddle::PaddleDType; using paddle::PaddlePassBuilder; using paddle::PaddlePlace; using paddle::PaddlePredictor; @@ -379,13 +382,13 @@ void BindInferenceApi(py::module *m) { &paddle::CreatePaddlePredictor, py::arg("config")); m->def("create_paddle_predictor", &paddle::CreatePaddlePredictor, py::arg("config")); - m->def("create_predictor", [](const paddle_infer::Config &config) - -> std::unique_ptr { - auto pred = - std::unique_ptr( - new paddle_infer::Predictor(config)); - return pred; - }); + m->def("create_predictor", + [](const paddle_infer::Config &config) + -> std::unique_ptr { + auto pred = std::unique_ptr( + new paddle_infer::Predictor(config)); + return pred; + }); m->def("copy_tensor", &CopyPaddleInferTensor); m->def("paddle_dtype_size", &paddle::PaddleDtypeSize); m->def("paddle_tensor_to_bytes", &SerializePDTensorToBytes); @@ -578,11 +581,11 @@ void BindAnalysisConfig(py::module *m) { .def(py::init()) .def(py::init()) .def("summary", &AnalysisConfig::Summary) - .def("set_model", (void (AnalysisConfig::*)(const std::string &)) & - AnalysisConfig::SetModel) - .def("set_model", (void (AnalysisConfig::*)(const std::string &, - const std::string &)) & + .def("set_model", (void(AnalysisConfig::*)(const std::string &)) & AnalysisConfig::SetModel) + .def("set_model", + (void(AnalysisConfig::*)(const std::string &, const std::string &)) & + AnalysisConfig::SetModel) .def("set_prog_file", &AnalysisConfig::SetProgFile) .def("set_params_file", &AnalysisConfig::SetParamsFile) .def("model_dir", &AnalysisConfig::model_dir) @@ -716,11 +719,12 @@ void BindAnalysisConfig(py::module *m) { [](AnalysisConfig &self, const std::string &pass) { self.pass_builder()->DeletePass(pass); }) - .def("pass_builder", - [](AnalysisConfig &self) { - return dynamic_cast(self.pass_builder()); - }, - py::return_value_policy::reference) + .def( + "pass_builder", + [](AnalysisConfig &self) { + return dynamic_cast(self.pass_builder()); + }, + py::return_value_policy::reference) .def("nnadapter", &AnalysisConfig::NNAdapter) .def("set_dist_config", &AnalysisConfig::SetDistConfig) .def("dist_config", &AnalysisConfig::dist_config); diff --git a/paddle/fluid/pybind/io.cc b/paddle/fluid/pybind/io.cc index a7222abf45c50966b8edf546d4f0109ab8653a6c..c8806962421269f51f9f2b1db1308fc92936df38 100644 --- a/paddle/fluid/pybind/io.cc +++ b/paddle/fluid/pybind/io.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/pybind/io.h" + #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/selected_rows_utils.h" #include "paddle/fluid/platform/enforce.h" diff --git a/paddle/fluid/pybind/io.h b/paddle/fluid/pybind/io.h index 942c93deccf99f0913909b66766927046b1e5809..7f10306e919e9eabb16842ddda195914d407e027 100644 --- a/paddle/fluid/pybind/io.h +++ b/paddle/fluid/pybind/io.h @@ -20,6 +20,7 @@ typedef SSIZE_T ssize_t; #endif #include + #include "paddle/fluid/pybind/pybind_boost_headers.h" namespace paddle { diff --git a/paddle/fluid/pybind/ir.cc b/paddle/fluid/pybind/ir.cc index ecbacd37d5666b85d5ddaef595d106e2400b055c..ef005ee8b10fc8e69becc63868fe4813a6892079 100644 --- a/paddle/fluid/pybind/ir.cc +++ b/paddle/fluid/pybind/ir.cc @@ -13,12 +13,14 @@ // limitations under the License. #include "paddle/fluid/pybind/ir.h" + #include #include #include #include #include #include + #include "paddle/fluid/framework/ir/graph.h" #include "paddle/fluid/framework/ir/graph_helper.h" #include "paddle/fluid/framework/ir/graph_pattern_detector.h" @@ -31,18 +33,18 @@ #include "pybind11/stl.h" namespace py = pybind11; -using paddle::framework::ir::Graph; -using paddle::framework::ir::Node; -using paddle::framework::ir::NodeComp; -using paddle::framework::ir::GraphSafeRemoveNodes; -using paddle::framework::ir::HasCircle; -using paddle::framework::ir::GraphNum; -using paddle::framework::ir::TopologySortOperations; -using paddle::framework::ir::BuildOperationAdjList; using paddle::framework::OpDesc; using paddle::framework::ProgramDesc; using paddle::framework::Scope; using paddle::framework::VarDesc; +using paddle::framework::ir::BuildOperationAdjList; +using paddle::framework::ir::Graph; +using paddle::framework::ir::GraphNum; +using paddle::framework::ir::GraphSafeRemoveNodes; +using paddle::framework::ir::HasCircle; +using paddle::framework::ir::Node; +using paddle::framework::ir::NodeComp; +using paddle::framework::ir::TopologySortOperations; using pybind11::return_value_policy; namespace paddle { @@ -104,16 +106,18 @@ void BindGraph(py::module *m) { }) .def("erase", &Graph::Erase) .def("nodes", &Graph::Nodes, return_value_policy::reference) - .def("create_var_node", - [](Graph &self, VarDesc &var_desc) { - return self.CreateVarNode(&var_desc); - }, - return_value_policy::reference) - .def("create_op_node", - [](Graph &self, OpDesc &op_desc) { - return self.CreateOpNode(&op_desc); - }, - return_value_policy::reference) + .def( + "create_var_node", + [](Graph &self, VarDesc &var_desc) { + return self.CreateVarNode(&var_desc); + }, + return_value_policy::reference) + .def( + "create_op_node", + [](Graph &self, OpDesc &op_desc) { + return self.CreateOpNode(&op_desc); + }, + return_value_policy::reference) .def("create_control_dep_var", &Graph::CreateControlDepVar, return_value_policy::reference) .def("create_empty_node", &Graph::CreateEmptyNode, diff --git a/paddle/fluid/pybind/ir.h b/paddle/fluid/pybind/ir.h index 2cc1459bbe0fe8dc27f292999d01ed34211ed080..ad2d6aa11bfefde9e49ceb766266d09a66ffb9f1 100644 --- a/paddle/fluid/pybind/ir.h +++ b/paddle/fluid/pybind/ir.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/framework/ir/graph.h" namespace paddle { diff --git a/paddle/fluid/pybind/op_function_common.cc b/paddle/fluid/pybind/op_function_common.cc index 8b9b98eba126e0367bb73c7b19a75bdbfa06d99f..a3c6fa14765aa4c4e35160ecd53fee994ddc5972 100644 --- a/paddle/fluid/pybind/op_function_common.cc +++ b/paddle/fluid/pybind/op_function_common.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/pybind/op_function_common.h" + #include #include #include @@ -28,7 +30,6 @@ #include "paddle/fluid/imperative/tracer.h" #include "paddle/fluid/imperative/type_defs.h" #include "paddle/fluid/pybind/imperative.h" -#include "paddle/fluid/pybind/op_function_common.h" namespace py = pybind11; namespace paddle { diff --git a/paddle/fluid/pybind/protobuf.cc b/paddle/fluid/pybind/protobuf.cc index 66bf8c95179afbf9894f46a8847b4812fb3869b6..329b3b83337dcf07f68e77dbdcab4ae88ae0120a 100644 --- a/paddle/fluid/pybind/protobuf.cc +++ b/paddle/fluid/pybind/protobuf.cc @@ -76,11 +76,12 @@ void BindProgramDesc(pybind11::module *m) { platform::errors::InvalidArgument( "Failed to parse ProgramDesc from binary string.")); }) - .def("_set_version", - [](pd::ProgramDesc &self, int64_t version) { - return self.SetVersion(version); - }, - pybind11::arg("version") = pd::kCurProgramVersion) + .def( + "_set_version", + [](pd::ProgramDesc &self, int64_t version) { + return self.SetVersion(version); + }, + pybind11::arg("version") = pd::kCurProgramVersion) .def("_version", [](pd::ProgramDesc &self) -> int64_t { return self.Version(); }) .def("get_op_deps", [](const framework::ProgramDesc &program) { @@ -113,18 +114,20 @@ void BindBlockDesc(pybind11::module *m) { .def("_insert_op", &pd::BlockDesc::InsertOp, pybind11::return_value_policy::reference) .def("_remove_op", &pd::BlockDesc::RemoveOp) - .def("var", - [](pd::BlockDesc &self, pybind11::bytes byte_name) { - std::string name = byte_name; - return self.Var(name); - }, - pybind11::return_value_policy::reference) - .def("has_var", - [](pd::BlockDesc &self, pybind11::bytes byte_name) { - std::string name = byte_name; - return self.HasVar(name); - }, - pybind11::return_value_policy::reference) + .def( + "var", + [](pd::BlockDesc &self, pybind11::bytes byte_name) { + std::string name = byte_name; + return self.Var(name); + }, + pybind11::return_value_policy::reference) + .def( + "has_var", + [](pd::BlockDesc &self, pybind11::bytes byte_name) { + std::string name = byte_name; + return self.HasVar(name); + }, + pybind11::return_value_policy::reference) .def("_rename_var", [](pd::BlockDesc &self, const pybind11::bytes &byte_name, const pybind11::bytes &byte_name_new) { @@ -137,24 +140,27 @@ void BindBlockDesc(pybind11::module *m) { std::string name = byte_name; return self.HasVarRecursive(name); }) - .def("find_var", - [](pd::BlockDesc &self, pybind11::bytes byte_name) { - std::string name = byte_name; - return self.FindVar(name); - }, - pybind11::return_value_policy::reference) - .def("find_var_recursive", - [](pd::BlockDesc &self, pybind11::bytes byte_name) { - std::string name = byte_name; - return self.FindVarRecursive(name); - }, - pybind11::return_value_policy::reference) - .def("_remove_var", - [](pd::BlockDesc &self, pybind11::bytes byte_name) { - std::string name = byte_name; - return self.RemoveVar(name); - }, - pybind11::return_value_policy::reference) + .def( + "find_var", + [](pd::BlockDesc &self, pybind11::bytes byte_name) { + std::string name = byte_name; + return self.FindVar(name); + }, + pybind11::return_value_policy::reference) + .def( + "find_var_recursive", + [](pd::BlockDesc &self, pybind11::bytes byte_name) { + std::string name = byte_name; + return self.FindVarRecursive(name); + }, + pybind11::return_value_policy::reference) + .def( + "_remove_var", + [](pd::BlockDesc &self, pybind11::bytes byte_name) { + std::string name = byte_name; + return self.RemoveVar(name); + }, + pybind11::return_value_policy::reference) .def("all_vars", &pd::BlockDesc::AllVars, pybind11::return_value_policy::reference) .def("op_size", &pd::BlockDesc::OpSize) @@ -258,8 +264,9 @@ void BindOpDesc(pybind11::module *m) { pybind11::class_ op_desc(*m, "OpDesc", ""); op_desc - .def("__init__", [](pd::OpDesc &self) { new (&self) pd::OpDesc(); }, - pybind11::return_value_policy::reference) + .def( + "__init__", [](pd::OpDesc &self) { new (&self) pd::OpDesc(); }, + pybind11::return_value_policy::reference) .def("copy_from", &pd::OpDesc::CopyFrom) .def("type", &pd::OpDesc::Type) .def("set_type", &pd::OpDesc::SetType) @@ -304,8 +311,9 @@ void BindOpDesc(pybind11::module *m) { .def("infer_var_type", &pd::OpDesc::InferVarType) .def("set_is_target", &pd::OpDesc::SetIsTarget) .def("serialize_to_string", SerializeMessage) - .def("block", [](pd::OpDesc &self) { return self.Block(); }, - pybind11::return_value_policy::reference) + .def( + "block", [](pd::OpDesc &self) { return self.Block(); }, + pybind11::return_value_policy::reference) .def("id", &pd::OpDesc::Id) .def("original_id", &pd::OpDesc::OriginalId) .def("set_original_id", &pd::OpDesc::SetOriginalId) diff --git a/paddle/fluid/pybind/pybind.cc b/paddle/fluid/pybind/pybind.cc index d1c2b28dc80cf65a59f9869fbde434b4feb61095..cba7d036235161dda33b0d97cf616e97fe3aefaf 100644 --- a/paddle/fluid/pybind/pybind.cc +++ b/paddle/fluid/pybind/pybind.cc @@ -693,56 +693,56 @@ PYBIND11_MODULE(core_noavx, m) { m.def("_get_use_default_grad_op_desc_maker_ops", [] { return OpInfoMap::Instance().GetUseDefaultGradOpDescMakerOps(); }); - m.def("_get_all_register_op_kernels", - [](const std::string &lib) { - std::unordered_map> - all_kernels_info; - if (lib == "fluid" || lib == "all") { - auto &all_kernels = - paddle::framework::OperatorWithKernel::AllOpKernels(); - - for (auto &kernel_pair : all_kernels) { - auto op_type = kernel_pair.first; - std::vector kernel_types; - for (auto &info_pair : kernel_pair.second) { - paddle::framework::OpKernelType kernel_type = info_pair.first; - kernel_types.emplace_back( - paddle::framework::KernelTypeToString(kernel_type)); - } - all_kernels_info.emplace(op_type, kernel_types); + m.def( + "_get_all_register_op_kernels", + [](const std::string &lib) { + std::unordered_map> + all_kernels_info; + if (lib == "fluid" || lib == "all") { + auto &all_kernels = + paddle::framework::OperatorWithKernel::AllOpKernels(); + + for (auto &kernel_pair : all_kernels) { + auto op_type = kernel_pair.first; + std::vector kernel_types; + for (auto &info_pair : kernel_pair.second) { + paddle::framework::OpKernelType kernel_type = info_pair.first; + kernel_types.emplace_back( + paddle::framework::KernelTypeToString(kernel_type)); } + all_kernels_info.emplace(op_type, kernel_types); } - if (lib == "phi" || lib == "all") { - auto phi_kernels = phi::KernelFactory::Instance().kernels(); - for (auto &kernel_pair : phi_kernels) { - auto op_type = phi::TransToFluidOpName(kernel_pair.first); - std::vector kernel_types; - for (auto &info_pair : kernel_pair.second) { - framework::OpKernelType kernel_type = - framework::TransPhiKernelKeyToOpKernelType(info_pair.first); - auto kernel_type_str = - framework::KernelTypeToString(kernel_type); - if (all_kernels_info.count(op_type)) { - if (std::find(all_kernels_info[op_type].begin(), - all_kernels_info[op_type].end(), - kernel_type_str) == - all_kernels_info[op_type].end()) { - all_kernels_info[op_type].emplace_back(kernel_type_str); - } - } else { - kernel_types.emplace_back(kernel_type_str); + } + if (lib == "phi" || lib == "all") { + auto phi_kernels = phi::KernelFactory::Instance().kernels(); + for (auto &kernel_pair : phi_kernels) { + auto op_type = phi::TransToFluidOpName(kernel_pair.first); + std::vector kernel_types; + for (auto &info_pair : kernel_pair.second) { + framework::OpKernelType kernel_type = + framework::TransPhiKernelKeyToOpKernelType(info_pair.first); + auto kernel_type_str = framework::KernelTypeToString(kernel_type); + if (all_kernels_info.count(op_type)) { + if (std::find(all_kernels_info[op_type].begin(), + all_kernels_info[op_type].end(), + kernel_type_str) == + all_kernels_info[op_type].end()) { + all_kernels_info[op_type].emplace_back(kernel_type_str); } - } - if (!kernel_types.empty()) { - all_kernels_info.emplace(op_type, kernel_types); + } else { + kernel_types.emplace_back(kernel_type_str); } } + if (!kernel_types.empty()) { + all_kernels_info.emplace(op_type, kernel_types); + } } + } - return all_kernels_info; - }, - py::arg("lib") = "all", - R"DOC( + return all_kernels_info; + }, + py::arg("lib") = "all", + R"DOC( Return the registered kernels in paddle. Args: @@ -1011,9 +1011,10 @@ PYBIND11_MODULE(core_noavx, m) { t.set(np.ndarray([5, 30]), fluid.CPUPlace()) )DOC") - .def("shape", - [](framework::Tensor &self) { return vectorize(self.dims()); }, - R"DOC( + .def( + "shape", + [](framework::Tensor &self) { return vectorize(self.dims()); }, + R"DOC( Return the shape of Tensor. Returns: @@ -1101,20 +1102,21 @@ PYBIND11_MODULE(core_noavx, m) { // avoid misuse. // The discussion is here: // https://github.com/PaddlePaddle/Paddle/issues/10855 - .def("set_lod", - [](framework::Tensor &self, - const std::vector> &lod) { - // the input lod is offset-based level-of-detail info - LoD new_lod; - new_lod.reserve(lod.size()); - std::copy(lod.begin(), lod.end(), std::back_inserter(new_lod)); - PADDLE_ENFORCE_EQ( - CheckLoD(new_lod, vectorize(self.dims()).front()), true, - platform::errors::InvalidArgument( - "The provided LoD is invalid, the LoD is %s", new_lod)); - self.set_lod(new_lod); - }, - py::arg("lod"), R"DOC( + .def( + "set_lod", + [](framework::Tensor &self, + const std::vector> &lod) { + // the input lod is offset-based level-of-detail info + LoD new_lod; + new_lod.reserve(lod.size()); + std::copy(lod.begin(), lod.end(), std::back_inserter(new_lod)); + PADDLE_ENFORCE_EQ( + CheckLoD(new_lod, vectorize(self.dims()).front()), true, + platform::errors::InvalidArgument( + "The provided LoD is invalid, the LoD is %s", new_lod)); + self.set_lod(new_lod); + }, + py::arg("lod"), R"DOC( Set LoD of the Tensor. Args: @@ -1134,28 +1136,29 @@ PYBIND11_MODULE(core_noavx, m) { t.set_lod([[0, 2, 5]]) print(t.lod()) # [[0, 2, 5]] )DOC") - .def("set_recursive_sequence_lengths", - [](framework::Tensor &self, const std::vector> - &recursive_sequence_lengths) { - // the input recursive_sequence_lengths is length-based - // level-of-detail info - LoD new_lod; - new_lod.reserve(recursive_sequence_lengths.size()); - std::copy(recursive_sequence_lengths.begin(), - recursive_sequence_lengths.end(), - std::back_inserter(new_lod)); - LoD new_offset_lod = ConvertToOffsetBasedLoD(new_lod); - PADDLE_ENFORCE_EQ( - CheckLoD(new_offset_lod, vectorize(self.dims()).front()), true, - platform::errors::InvalidArgument( - "The provided recursive_sequence_lengths info is " - "invalid, " - "the LoD converted by recursive_sequence_lengths is " - "%s", - new_lod)); - self.set_lod(new_offset_lod); - }, - py::arg("recursive_sequence_lengths"), R"DOC( + .def( + "set_recursive_sequence_lengths", + [](framework::Tensor &self, const std::vector> + &recursive_sequence_lengths) { + // the input recursive_sequence_lengths is length-based + // level-of-detail info + LoD new_lod; + new_lod.reserve(recursive_sequence_lengths.size()); + std::copy(recursive_sequence_lengths.begin(), + recursive_sequence_lengths.end(), + std::back_inserter(new_lod)); + LoD new_offset_lod = ConvertToOffsetBasedLoD(new_lod); + PADDLE_ENFORCE_EQ( + CheckLoD(new_offset_lod, vectorize(self.dims()).front()), true, + platform::errors::InvalidArgument( + "The provided recursive_sequence_lengths info is " + "invalid, " + "the LoD converted by recursive_sequence_lengths is " + "%s", + new_lod)); + self.set_lod(new_offset_lod); + }, + py::arg("recursive_sequence_lengths"), R"DOC( Set LoD of the Tensor according to recursive sequence lengths. For example, if recursive_sequence_lengths=[[2, 3]], which means @@ -1180,16 +1183,17 @@ PYBIND11_MODULE(core_noavx, m) { print(t.recursive_sequence_lengths()) # [[2, 3]] print(t.lod()) # [[0, 2, 5]] )DOC") - .def("lod", - [](framework::Tensor &self) -> std::vector> { - // output the offset-based lod info - LoD lod = self.lod(); - std::vector> new_lod; - new_lod.reserve(lod.size()); - std::copy(lod.begin(), lod.end(), std::back_inserter(new_lod)); - return new_lod; - }, - R"DOC( + .def( + "lod", + [](framework::Tensor &self) -> std::vector> { + // output the offset-based lod info + LoD lod = self.lod(); + std::vector> new_lod; + new_lod.reserve(lod.size()); + std::copy(lod.begin(), lod.end(), std::back_inserter(new_lod)); + return new_lod; + }, + R"DOC( Return the LoD of the Tensor. Returns: @@ -1207,16 +1211,17 @@ PYBIND11_MODULE(core_noavx, m) { print(t.lod()) # [[0, 2, 5]] )DOC") // Set above comments of set_lod. - .def("recursive_sequence_lengths", - [](framework::Tensor &self) -> std::vector> { - // output the length-based lod info - LoD lod = phi::ConvertToLengthBasedLoD(self.lod()); - std::vector> new_lod; - new_lod.reserve(lod.size()); - std::copy(lod.begin(), lod.end(), std::back_inserter(new_lod)); - return new_lod; - }, - R"DOC( + .def( + "recursive_sequence_lengths", + [](framework::Tensor &self) -> std::vector> { + // output the length-based lod info + LoD lod = phi::ConvertToLengthBasedLoD(self.lod()); + std::vector> new_lod; + new_lod.reserve(lod.size()); + std::copy(lod.begin(), lod.end(), std::back_inserter(new_lod)); + return new_lod; + }, + R"DOC( Return the recursive sequence lengths corresponding to of the LodD of the Tensor. @@ -1234,13 +1239,14 @@ PYBIND11_MODULE(core_noavx, m) { t.set_recursive_sequence_lengths([[2, 3]]) print(t.recursive_sequence_lengths()) # [[2, 3]] )DOC") - .def("has_valid_recursive_sequence_lengths", - [](framework::Tensor &self) -> bool { - // Check that the lod info is valid and match the outermost - // dimension of the Tensor data - return CheckLoD(self.lod(), vectorize(self.dims()).front()); - }, - R"DOC( + .def( + "has_valid_recursive_sequence_lengths", + [](framework::Tensor &self) -> bool { + // Check that the lod info is valid and match the outermost + // dimension of the Tensor data + return CheckLoD(self.lod(), vectorize(self.dims()).front()); + }, + R"DOC( Check whether the LoD of the Tensor is valid. Returns: @@ -1624,9 +1630,10 @@ PYBIND11_MODULE(core_noavx, m) { const int64_t &height) { new (&instance) phi::SelectedRows(rows, height); }) - .def("get_tensor", - [](phi::SelectedRows &self) { return self.mutable_value(); }, - py::return_value_policy::reference) + .def( + "get_tensor", + [](phi::SelectedRows &self) { return self.mutable_value(); }, + py::return_value_policy::reference) .def("numel", [](phi::SelectedRows &self) -> int64_t { return self.value().numel(); @@ -1668,11 +1675,12 @@ All parameter, weight, gradient are variables in Paddle. }) .def("get_float", [](const Variable &var) -> float { return var.Get(); }) - .def("get_tensor", - [](Variable &self) -> LoDTensor * { - return self.GetMutable(); - }, - py::return_value_policy::reference) + .def( + "get_tensor", + [](Variable &self) -> LoDTensor * { + return self.GetMutable(); + }, + py::return_value_policy::reference) .def("get_bytes", [](Variable &self) { return py::bytes(*self.GetMutable()); @@ -1683,53 +1691,60 @@ All parameter, weight, gradient are variables in Paddle. }) .def("set_vocab", [](Variable &self, Vocab vocab) { *self.GetMutable() = vocab; }) - .def("get_string_tensor", - [](Variable &self) { return self.GetMutable(); }, - py::return_value_policy::reference) - .def("get_map_tensor", - [](Variable &self) { return self.GetMutable(); }, - py::return_value_policy::reference) - .def("get_lod_rank_table", - [](Variable &self) { return self.GetMutable(); }, - py::return_value_policy::reference) - .def("get_selected_rows", - [](Variable &self) -> phi::SelectedRows * { - return self.GetMutable(); - }, - py::return_value_policy::reference) - .def("get_lod_tensor_array", - [](Variable &self) { return self.GetMutable(); }, - py::return_value_policy::reference) - .def("get_fetch_list", - [](Variable &self) { return self.GetMutable(); }, - py::return_value_policy::reference) + .def( + "get_string_tensor", + [](Variable &self) { return self.GetMutable(); }, + py::return_value_policy::reference) + .def( + "get_map_tensor", + [](Variable &self) { return self.GetMutable(); }, + py::return_value_policy::reference) + .def( + "get_lod_rank_table", + [](Variable &self) { return self.GetMutable(); }, + py::return_value_policy::reference) + .def( + "get_selected_rows", + [](Variable &self) -> phi::SelectedRows * { + return self.GetMutable(); + }, + py::return_value_policy::reference) + .def( + "get_lod_tensor_array", + [](Variable &self) { return self.GetMutable(); }, + py::return_value_policy::reference) + .def( + "get_fetch_list", + [](Variable &self) { return self.GetMutable(); }, + py::return_value_policy::reference) #if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) - .def("get_communicator", - [](Variable &self) -> platform::Communicator * { - return self.GetMutable(); - }, - py::return_value_policy::reference) + .def( + "get_communicator", + [](Variable &self) -> platform::Communicator * { + return self.GetMutable(); + }, + py::return_value_policy::reference) #endif - .def("get_reader", - [](Variable &self) -> framework::ReaderHolder * { - PADDLE_ENFORCE_EQ( - self.IsType(), true, - platform::errors::InvalidArgument( - "The variable is not type of ReaderHolder.")); - return self.GetMutable(); - }, - py::return_value_policy::reference) - .def("get_scope", - [](Variable &self) -> Scope * { - auto scope_vec = - self.GetMutable>(); - PADDLE_ENFORCE_GT( - scope_vec->size(), 0, - platform::errors::InvalidArgument( - "The size of scope_vec should be greater than 0")); - return scope_vec->front(); - }, - py::return_value_policy::reference) + .def( + "get_reader", + [](Variable &self) -> framework::ReaderHolder * { + PADDLE_ENFORCE_EQ(self.IsType(), true, + platform::errors::InvalidArgument( + "The variable is not type of ReaderHolder.")); + return self.GetMutable(); + }, + py::return_value_policy::reference) + .def( + "get_scope", + [](Variable &self) -> Scope * { + auto scope_vec = self.GetMutable>(); + PADDLE_ENFORCE_GT( + scope_vec->size(), 0, + platform::errors::InvalidArgument( + "The size of scope_vec should be greater than 0")); + return scope_vec->front(); + }, + py::return_value_policy::reference) .def("set_scope", [](Variable &self, Scope &scope) { auto scope_vec = self.GetMutable>(); scope_vec->emplace_back(&scope); @@ -1762,12 +1777,13 @@ All parameter, weight, gradient are variables in Paddle. _Scope .def("_remove_from_pool", [](Scope &self) { ScopePool::Instance().Remove(&self); }) - .def("var", - [](Scope &self, const std::string &name) -> Variable * { - return self.Var(name); - }, - py::arg("name"), - R"DOC( + .def( + "var", + [](Scope &self, const std::string &name) -> Variable * { + return self.Var(name); + }, + py::arg("name"), + R"DOC( Find or create variable named :code:`name` in the current scope. If the variable named :code:`name` does not exist in the @@ -1780,7 +1796,7 @@ All parameter, weight, gradient are variables in Paddle. Returns: out (core.Variable): the found or created variable. )DOC", - py::return_value_policy::reference) + py::return_value_policy::reference) .def("find_var", &Scope::FindVar, py::arg("name"), R"DOC( Find variable named :code:`name` in the current scope or @@ -1806,33 +1822,35 @@ All parameter, weight, gradient are variables in Paddle. None )DOC", py::return_value_policy::reference) - .def("new_scope", [](Scope &self) -> Scope * { return &self.NewScope(); }, - R"DOC( + .def( + "new_scope", [](Scope &self) -> Scope * { return &self.NewScope(); }, + R"DOC( Create a new sub-scope of the current scope. Returns: out (core._Scope): the created sub-scope. )DOC", - py::return_value_policy::reference) + py::return_value_policy::reference) .def("drop_kids", &Scope::DropKids, R"DOC( Delete all sub-scopes of the current scope. )DOC") .def("_kids", &Scope::kids); - m.def("Scope", - []() -> Scope * { - auto *s = new Scope(); - ScopePool::Instance().Insert(std::unique_ptr(s)); - return s; - }, - R"DOC( + m.def( + "Scope", + []() -> Scope * { + auto *s = new Scope(); + ScopePool::Instance().Insert(std::unique_ptr(s)); + return s; + }, + R"DOC( Create a new scope. Returns: out (core._Scope): the created scope. )DOC", - py::return_value_policy::reference); + py::return_value_policy::reference); //! @note: Be careful! PyBind will return std::string as an unicode, not //! Python str. If you want a str object, you should cast them in Python. @@ -1919,11 +1937,12 @@ All parameter, weight, gradient are variables in Paddle. return std::make_tuple(ProgramDesc(pruned_desc), pruned_origin_block_id_map); }); - m.def("prune_backward", - [](const framework::ProgramDesc &program) { - return PruneBackward(program); - }, - R"DOC( + m.def( + "prune_backward", + [](const framework::ProgramDesc &program) { + return PruneBackward(program); + }, + R"DOC( Prune the backward part of a program, mostly called in program.clone(for_test=True). @@ -2790,8 +2809,8 @@ All parameter, weight, gradient are variables in Paddle. .def("outputs", [](const OperatorBase &op) -> std::map> { - return op.Outputs(); - }) + return op.Outputs(); + }) .def("output_vars", [](const OperatorBase &op) { return op.OutputVars(true); }) .def("inputs", [](const OperatorBase &op) { return op.Inputs(); }) @@ -2806,11 +2825,12 @@ All parameter, weight, gradient are variables in Paddle. py::class_>( m, "TrainerBase") - .def("get_worker_scope", - [](TrainerBase &self, int thread_id) -> Scope * { - return self.GetWorkerScope(thread_id); - }, - py::return_value_policy::reference) + .def( + "get_worker_scope", + [](TrainerBase &self, int thread_id) -> Scope * { + return self.GetWorkerScope(thread_id); + }, + py::return_value_policy::reference) .def("finalize", &TrainerBase::Finalize) .def("ResetDataset", &TrainerBase::ResetDataset); @@ -3010,21 +3030,23 @@ All parameter, weight, gradient are variables in Paddle. m.def("device_memory_stat_current_value", memory::DeviceMemoryStatCurrentValue); m.def("device_memory_stat_peak_value", memory::DeviceMemoryStatPeakValue); - m.def("run_cmd", - [](const std::string &cmd, int time_out = -1, - int sleep_inter = -1) -> const std::string { - return paddle::framework::shell_get_command_output(cmd, time_out, - sleep_inter); - }, - py::arg("cmd"), py::arg("time_out") = -1, py::arg("sleep_inter") = -1); - m.def("shell_execute_cmd", - [](const std::string &cmd, int time_out = 0, int sleep_inter = 0, - bool redirect_stderr = false) -> std::vector { - return paddle::framework::shell_execute_cmd( - cmd, time_out, sleep_inter, redirect_stderr); - }, - py::arg("cmd"), py::arg("time_out") = 0, py::arg("sleep_inter") = 0, - py::arg("redirect_stderr") = false); + m.def( + "run_cmd", + [](const std::string &cmd, int time_out = -1, + int sleep_inter = -1) -> const std::string { + return paddle::framework::shell_get_command_output(cmd, time_out, + sleep_inter); + }, + py::arg("cmd"), py::arg("time_out") = -1, py::arg("sleep_inter") = -1); + m.def( + "shell_execute_cmd", + [](const std::string &cmd, int time_out = 0, int sleep_inter = 0, + bool redirect_stderr = false) -> std::vector { + return paddle::framework::shell_execute_cmd(cmd, time_out, sleep_inter, + redirect_stderr); + }, + py::arg("cmd"), py::arg("time_out") = 0, py::arg("sleep_inter") = 0, + py::arg("redirect_stderr") = false); #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) m.def("is_float16_supported", [](const platform::CUDAPlace &place) -> bool { @@ -3092,9 +3114,10 @@ All parameter, weight, gradient are variables in Paddle. pylodtensorarray .def("__init__", [](LoDTensorArray &instance) { new (&instance) LoDTensorArray(); }) - .def("__getitem__", - [](LoDTensorArray &self, size_t i) { return &self.at(i); }, - py::return_value_policy::reference) + .def( + "__getitem__", + [](LoDTensorArray &self, size_t i) { return &self.at(i); }, + py::return_value_policy::reference) .def("__len__", [](LoDTensorArray &self) { return self.size(); }) .def("__setitem__", [](LoDTensorArray &self, size_t i, const LoDTensor &t) { @@ -3105,13 +3128,14 @@ All parameter, weight, gradient are variables in Paddle. self[i].ShareDataWith(t); self[i].set_lod(t.lod()); }) - .def("append", - [](LoDTensorArray &self, const LoDTensor &t) { - self.emplace_back(); - self.back().ShareDataWith(t); - self.back().set_lod(t.lod()); - }, - py::arg("tensor"), R"DOC( + .def( + "append", + [](LoDTensorArray &self, const LoDTensor &t) { + self.emplace_back(); + self.back().ShareDataWith(t); + self.back().set_lod(t.lod()); + }, + py::arg("tensor"), R"DOC( Append a LoDensor to LoDTensorArray. Args: @@ -3131,89 +3155,94 @@ All parameter, weight, gradient are variables in Paddle. t.set(np.ndarray([5, 30]), fluid.CPUPlace()) arr.append(t) )DOC") - .def("_move_to_list", - [](LoDTensorArray &self) -> py::list { - py::list res(self.size()); - for (size_t i = 0; i < self.size(); ++i) { - res[i] = py::cast(std::move(self[i])); - } - self.clear(); - return res; - }, - py::return_value_policy::take_ownership); + .def( + "_move_to_list", + [](LoDTensorArray &self) -> py::list { + py::list res(self.size()); + for (size_t i = 0; i < self.size(); ++i) { + res[i] = py::cast(std::move(self[i])); + } + self.clear(); + return res; + }, + py::return_value_policy::take_ownership); py::class_(m, "FetchList", R"DOC( FetchList is a vector of boost::variant. )DOC") - .def("_move_to_list", - [](FetchList &self) -> py::list { - py::list res(self.size()); - for (size_t i = 0; i < self.size(); ++i) { - if (data_is_lod_tensor(self[i])) { - auto &data = BOOST_GET(LoDTensor, self[i]); - res[i] = py::cast(std::move(data)); - } else { - auto &data = BOOST_GET(LoDTensorArray, self[i]); - py::list tmp(data.size()); - for (size_t j = 0; j < data.size(); ++j) { - tmp[j] = py::cast(std::move(data[j])); - } - res[i] = std::move(tmp); - } - } - self.clear(); - return res; - }, - py::return_value_policy::take_ownership) + .def( + "_move_to_list", + [](FetchList &self) -> py::list { + py::list res(self.size()); + for (size_t i = 0; i < self.size(); ++i) { + if (data_is_lod_tensor(self[i])) { + auto &data = BOOST_GET(LoDTensor, self[i]); + res[i] = py::cast(std::move(data)); + } else { + auto &data = BOOST_GET(LoDTensorArray, self[i]); + py::list tmp(data.size()); + for (size_t j = 0; j < data.size(); ++j) { + tmp[j] = py::cast(std::move(data[j])); + } + res[i] = std::move(tmp); + } + } + self.clear(); + return res; + }, + py::return_value_policy::take_ownership) - .def("append", - [](FetchList &self, const LoDTensor &t) { - self.emplace_back(); - auto &lod_tensor = BOOST_GET(LoDTensor, self.back()); - lod_tensor.ShareDataWith(t); - lod_tensor.set_lod(t.lod()); - }, - py::arg("var")) - - .def("append", - [](FetchList &self, const LoDTensorArray &t) { - self.emplace_back(); - auto &lod_tensor_array = BOOST_GET(LoDTensorArray, self.back()); - for (size_t i = 0; i < t.size(); ++i) { - lod_tensor_array[i].ShareDataWith(t[i]); - lod_tensor_array[i].set_lod(t[i].lod()); - } - }, - py::arg("var")); + .def( + "append", + [](FetchList &self, const LoDTensor &t) { + self.emplace_back(); + auto &lod_tensor = BOOST_GET(LoDTensor, self.back()); + lod_tensor.ShareDataWith(t); + lod_tensor.set_lod(t.lod()); + }, + py::arg("var")) + + .def( + "append", + [](FetchList &self, const LoDTensorArray &t) { + self.emplace_back(); + auto &lod_tensor_array = BOOST_GET(LoDTensorArray, self.back()); + for (size_t i = 0; i < t.size(); ++i) { + lod_tensor_array[i].ShareDataWith(t[i]); + lod_tensor_array[i].set_lod(t[i].lod()); + } + }, + py::arg("var")); py::class_(m, "FetchUnmergedList", R"DOC( FetchUnmergedList is 2-D array of FetchType(boost::variant(LoDTensor, LoDTensorArray)). )DOC") - .def("_move_to_list", - [](FetchUnmergedList &self) -> py::list { - py::list res(self.size()); - for (size_t i = 0; i < self.size(); ++i) { - py::list tmp(self[i].size()); - for (size_t j = 0; j < self[i].size(); ++j) { - if (data_is_lod_tensor(self[i][j])) { - auto &var = BOOST_GET(LoDTensor, self[i][j]); - tmp[j] = py::cast(std::move(var)); - } else { - auto &var = BOOST_GET(LoDTensorArray, self[i][j]); - py::list tmp_array(var.size()); - for (size_t k = 0; k < var.size(); ++k) { - tmp_array[k] = std::move(var[k]); - } - tmp[j] = std::move(tmp_array); - } - } - res[i] = std::move(tmp); - self[i].clear(); - } - self.clear(); - return res; - }, - py::return_value_policy::take_ownership); + .def( + "_move_to_list", + [](FetchUnmergedList &self) -> py::list { + py::list res(self.size()); + for (size_t i = 0; i < self.size(); ++i) { + py::list tmp(self[i].size()); + for (size_t j = 0; j < self[i].size(); ++j) { + if (data_is_lod_tensor(self[i][j])) { + auto &var = BOOST_GET(LoDTensor, self[i][j]); + tmp[j] = py::cast(std::move(var)); + } else { + auto &var = BOOST_GET(LoDTensorArray, self[i][j]); + py::list tmp_array(var.size()); + for (size_t k = 0; k < var.size(); ++k) { + tmp_array[k] = std::move(var[k]); + } + tmp[j] = std::move(tmp_array); + } + } + res[i] = std::move(tmp); + self[i].clear(); + } + self.clear(); + return res; + }, + py::return_value_policy::take_ownership); m.def("op_support_gpu", OpSupportGPU); #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) @@ -3227,11 +3256,12 @@ All parameter, weight, gradient are variables in Paddle. } platform::EmptyCache(); }); - m.def("get_device_properties", - [](int id) -> const gpuDeviceProp & { - return platform::GetDeviceProperties(id); - }, - py::return_value_policy::copy); + m.def( + "get_device_properties", + [](int id) -> const gpuDeviceProp & { + return platform::GetDeviceProperties(id); + }, + py::return_value_policy::copy); py::class_(m, "_gpuDeviceProperties") .def_property_readonly( @@ -3409,15 +3439,16 @@ All parameter, weight, gradient are variables in Paddle. profiler->Prepare(); }) .def("start", &paddle::platform::Profiler::Start) - .def("stop", - [](paddle::platform::Profiler *profiler) { - platform::DisableHostEventRecorder(); - auto result = profiler->Stop(); - framework::StaticGraphExecutorPerfStatistics( - result->GetNodeTrees()); - return result; - }, - py::return_value_policy::automatic_reference); + .def( + "stop", + [](paddle::platform::Profiler *profiler) { + platform::DisableHostEventRecorder(); + auto result = profiler->Stop(); + framework::StaticGraphExecutorPerfStatistics( + result->GetNodeTrees()); + return result; + }, + py::return_value_policy::automatic_reference); py::class_(m, "ProfilerOptions") .def(py::init<>()) @@ -3666,11 +3697,12 @@ All parameter, weight, gradient are variables in Paddle. }, R"DOC(This config that the this is distributed training with parameter server )DOC") - .def_property("_dry_run", - [](const ExecutionStrategy &self) { return self.dry_run_; }, - [](ExecutionStrategy &self, bool dry_run) { - self.dry_run_ = dry_run; - }); + .def_property( + "_dry_run", + [](const ExecutionStrategy &self) { return self.dry_run_; }, + [](ExecutionStrategy &self, bool dry_run) { + self.dry_run_ = dry_run; + }); exec_strategy.def_property( "use_experimental_executor", @@ -3918,11 +3950,12 @@ All parameter, weight, gradient are variables in Paddle. const std::vector &trainers_endpoints) { self.trainers_endpoints_ = trainers_endpoints; }) - .def_property("trainer_id", - [](const BuildStrategy &self) { return self.trainer_id_; }, - [](BuildStrategy &self, int trainer_id) { - self.trainer_id_ = trainer_id; - }) + .def_property( + "trainer_id", + [](const BuildStrategy &self) { return self.trainer_id_; }, + [](BuildStrategy &self, int trainer_id) { + self.trainer_id_ = trainer_id; + }) .def_property( "nccl_comm_num", [](const BuildStrategy &self) { return self.nccl_comm_num_; }, @@ -3935,20 +3968,22 @@ All parameter, weight, gradient are variables in Paddle. [](BuildStrategy &self, int bkcl_comm_num) { self.bkcl_comm_num_ = bkcl_comm_num; }) - .def_property("use_hierarchical_allreduce", - [](const BuildStrategy &self) { - return self.use_hierarchical_allreduce_; - }, - [](BuildStrategy &self, bool use) { - self.use_hierarchical_allreduce_ = use; - }) - .def_property("hierarchical_allreduce_inter_nranks", - [](const BuildStrategy &self) { - return self.hierarchical_allreduce_inter_nranks_; - }, - [](BuildStrategy &self, int nranks) { - self.hierarchical_allreduce_inter_nranks_ = nranks; - }) + .def_property( + "use_hierarchical_allreduce", + [](const BuildStrategy &self) { + return self.use_hierarchical_allreduce_; + }, + [](BuildStrategy &self, bool use) { + self.use_hierarchical_allreduce_ = use; + }) + .def_property( + "hierarchical_allreduce_inter_nranks", + [](const BuildStrategy &self) { + return self.hierarchical_allreduce_inter_nranks_; + }, + [](BuildStrategy &self, int nranks) { + self.hierarchical_allreduce_inter_nranks_ = nranks; + }) .def_property( "fuse_elewise_add_act_ops", @@ -4107,19 +4142,20 @@ All parameter, weight, gradient are variables in Paddle. build_strategy = static.BuildStrategy() build_strategy.fuse_relu_depthwise_conv = True )DOC") - .def_property("fuse_broadcast_ops", - [](const BuildStrategy &self) { - return self.fuse_broadcast_ops_ == true || - self.fuse_broadcast_ops_ == paddle::none; - }, - [](BuildStrategy &self, bool b) { - PADDLE_ENFORCE_NE(self.IsFinalized(), true, - platform::errors::PreconditionNotMet( - "BuildStrategy has been finlaized, " - "cannot be configured again.")); - self.fuse_broadcast_ops_ = b; - }, - R"DOC((bool, optional): fuse_broadcast_op indicates whether + .def_property( + "fuse_broadcast_ops", + [](const BuildStrategy &self) { + return self.fuse_broadcast_ops_ == true || + self.fuse_broadcast_ops_ == paddle::none; + }, + [](BuildStrategy &self, bool b) { + PADDLE_ENFORCE_NE(self.IsFinalized(), true, + platform::errors::PreconditionNotMet( + "BuildStrategy has been finlaized, " + "cannot be configured again.")); + self.fuse_broadcast_ops_ = b; + }, + R"DOC((bool, optional): fuse_broadcast_op indicates whether to fuse the broadcast ops. Note that, in Reduce mode, fusing broadcast ops may make the program faster. Because fusing broadcast OP equals delaying the execution of all @@ -4137,18 +4173,19 @@ All parameter, weight, gradient are variables in Paddle. build_strategy = static.BuildStrategy() build_strategy.fuse_broadcast_ops = True )DOC") - .def_property("fuse_all_optimizer_ops", - [](const BuildStrategy &self) { - return self.fuse_all_optimizer_ops_ == true || - self.fuse_all_optimizer_ops_ == paddle::none; - }, - [](BuildStrategy &self, bool b) { - PADDLE_ENFORCE_NE(self.IsFinalized(), true, - platform::errors::PreconditionNotMet( - "BuildStrategy has been finlaized, " - "cannot be configured again.")); - self.fuse_all_optimizer_ops_ = b; - }) + .def_property( + "fuse_all_optimizer_ops", + [](const BuildStrategy &self) { + return self.fuse_all_optimizer_ops_ == true || + self.fuse_all_optimizer_ops_ == paddle::none; + }, + [](BuildStrategy &self, bool b) { + PADDLE_ENFORCE_NE(self.IsFinalized(), true, + platform::errors::PreconditionNotMet( + "BuildStrategy has been finlaized, " + "cannot be configured again.")); + self.fuse_all_optimizer_ops_ = b; + }) .def_property( "sync_batch_norm", [](const BuildStrategy &self) { return self.sync_batch_norm_; }, @@ -4231,9 +4268,10 @@ All parameter, weight, gradient are variables in Paddle. self.is_distribution_ = b; #endif }) - .def_property("async_mode", - [](const BuildStrategy &self) { return self.async_mode_; }, - [](BuildStrategy &self, bool b) { self.async_mode_ = b; }) + .def_property( + "async_mode", + [](const BuildStrategy &self) { return self.async_mode_; }, + [](BuildStrategy &self, bool b) { self.async_mode_ = b; }) .def_property( "enable_inplace", [](const BuildStrategy &self) { return self.enable_inplace_; }, @@ -4249,13 +4287,14 @@ All parameter, weight, gradient are variables in Paddle. self.fuse_all_reduce_ops_ == paddle::none; }, [](BuildStrategy &self, bool b) { self.fuse_all_reduce_ops_ = b; }) - .def_property("enable_backward_optimizer_op_deps", - [](const BuildStrategy &self) { - return self.enable_backward_optimizer_op_deps_; - }, - [](BuildStrategy &self, bool b) { - self.enable_backward_optimizer_op_deps_ = b; - }) + .def_property( + "enable_backward_optimizer_op_deps", + [](const BuildStrategy &self) { + return self.enable_backward_optimizer_op_deps_; + }, + [](BuildStrategy &self, bool b) { + self.enable_backward_optimizer_op_deps_ = b; + }) .def_property( "cache_runtime_context", [](const BuildStrategy &self) { return self.cache_runtime_context_; }, @@ -4275,24 +4314,26 @@ All parameter, weight, gradient are variables in Paddle. [](BuildStrategy &self, bool fix_op_run_order) { self.fix_op_run_order_ = fix_op_run_order; }) - .def_property("allow_cuda_graph_capture", - [](const BuildStrategy &self) { - return self.allow_cuda_graph_capture_; - }, - [](BuildStrategy &self, bool allow_cuda_graph_capture) { - self.allow_cuda_graph_capture_ = allow_cuda_graph_capture; - }) + .def_property( + "allow_cuda_graph_capture", + [](const BuildStrategy &self) { + return self.allow_cuda_graph_capture_; + }, + [](BuildStrategy &self, bool allow_cuda_graph_capture) { + self.allow_cuda_graph_capture_ = allow_cuda_graph_capture; + }) .def("_copy", [](const BuildStrategy &self) { auto new_bs = self; new_bs.ClearFinalized(); return new_bs; }) - .def("_finalize_strategy_and_create_passes", - [](BuildStrategy &self) -> std::shared_ptr { - return self.CreatePassesFromStrategy(true); - }, - R"DOC(Allow user to customized passes. Normally model-specific + .def( + "_finalize_strategy_and_create_passes", + [](BuildStrategy &self) -> std::shared_ptr { + return self.CreatePassesFromStrategy(true); + }, + R"DOC(Allow user to customized passes. Normally model-specific optimization passes should be defined in this way. BuildStrategy cannot be updated after being finalized.)DOC"); @@ -4310,11 +4351,12 @@ All parameter, weight, gradient are variables in Paddle. // We still cannot get local_scope from this vector, since the element // of vec will be freed by Python GC. We can only return Scope* // one by one and mark them as reference. - .def("local_scopes", - [](ParallelExecutor &self) -> std::vector * { - return &self.GetLocalScopes(); - }, - py::return_value_policy::reference) + .def( + "local_scopes", + [](ParallelExecutor &self) -> std::vector * { + return &self.GetLocalScopes(); + }, + py::return_value_policy::reference) .def("drop_local_exe_scopes", &ParallelExecutor::DropLocalExeScopes) .def("_need_create_local_exe_scopes", &ParallelExecutor::NeedCreateLocalExeScope) @@ -4346,12 +4388,13 @@ All parameter, weight, gradient are variables in Paddle. std::unique_ptr>( m, "IpuBackend") // manage IpuBackend in C++ - .def("get_instance", - []() { - return std::unique_ptr( - platform::ipu::IpuBackend::GetInstance()); - }, - py::return_value_policy::reference) + .def( + "get_instance", + []() { + return std::unique_ptr( + platform::ipu::IpuBackend::GetInstance()); + }, + py::return_value_policy::reference) .def("weights_to_host", &platform::ipu::IpuBackend::WeightsToHost) .def("detach", &platform::ipu::IpuBackend::Detach) .def("reset", &platform::ipu::IpuBackend::Reset) diff --git a/paddle/fluid/pybind/reader_py.cc b/paddle/fluid/pybind/reader_py.cc index e0aab0dd06ecbbaff9b870a3b6497da2279ebd12..3e779ba41c0ebb943d302be8476b99fbc1128f2e 100644 --- a/paddle/fluid/pybind/reader_py.cc +++ b/paddle/fluid/pybind/reader_py.cc @@ -13,12 +13,14 @@ // limitations under the License. #include "paddle/fluid/pybind/reader_py.h" + #include #include #include #include #include #include + #include "Python.h" #include "boost/optional.hpp" #include "gflags/gflags.h" @@ -337,32 +339,33 @@ void BindMultiDeviceReader(py::module *module, const char *reader_name) { py::call_guard()) .def("read_next_list", &ReaderType::ReadNextList, py::call_guard()) - .def("read_next_var_list", - [](ReaderType &self) { - auto result_list = self.ReadNextList(); - auto &tensor_list = result_list[0]; - std::vector> var_list; - var_list.reserve(tensor_list.size()); - auto func = [](framework::LoDTensor &lod_tensor) { - std::string act_name = - imperative::GetCurrentTracer()->GenerateUniqueName( - "generated_var"); - auto new_var = std::make_shared(act_name); - new_var->SetPersistable(false); - new_var->SetType(framework::proto::VarType::LOD_TENSOR); - new_var->SetDataType( - framework::TransToProtoVarType(lod_tensor.dtype())); - auto *tensor = - new_var->MutableVar()->GetMutable(); - *tensor = std::move(lod_tensor); - return new_var; - }; - for (auto &tensor : tensor_list) { - var_list.emplace_back(func(tensor)); - } - return var_list; - }, - py::call_guard()) + .def( + "read_next_var_list", + [](ReaderType &self) { + auto result_list = self.ReadNextList(); + auto &tensor_list = result_list[0]; + std::vector> var_list; + var_list.reserve(tensor_list.size()); + auto func = [](framework::LoDTensor &lod_tensor) { + std::string act_name = + imperative::GetCurrentTracer()->GenerateUniqueName( + "generated_var"); + auto new_var = std::make_shared(act_name); + new_var->SetPersistable(false); + new_var->SetType(framework::proto::VarType::LOD_TENSOR); + new_var->SetDataType( + framework::TransToProtoVarType(lod_tensor.dtype())); + auto *tensor = + new_var->MutableVar()->GetMutable(); + *tensor = std::move(lod_tensor); + return new_var; + }; + for (auto &tensor : tensor_list) { + var_list.emplace_back(func(tensor)); + } + return var_list; + }, + py::call_guard()) .def("reset", &ReaderType::Reset, py::call_guard()) .def("shutdown", &ReaderType::Shutdown, @@ -372,34 +375,35 @@ void BindMultiDeviceReader(py::module *module, const char *reader_name) { void BindReader(py::module *module) { auto &m = *module; - m.def("diff_tensor_shape", [](const framework::LoDTensor &tensor, - const framework::VarDesc &var_desc, - size_t num_places) -> py::object { - auto diff = DiffTensorShapeWithVarDesc(tensor, var_desc, num_places); - if (diff) { - return py::cast(std::move(diff.get())); - } else { - return py::cast(nullptr); - } - }); - - m.def("init_lod_tensor_blocking_queue", - [](framework::Variable &var, size_t capacity, - bool is_ordered) -> py::object { - VLOG(1) << "init_lod_tensor_blocking_queue"; - if (is_ordered) { - auto *holder = var.GetMutable< - reader::OrderedMultiDeviceLoDTensorBlockingQueueHolder>(); - holder->InitOnce(capacity, FLAGS_reader_queue_speed_test_mode); - return py::cast(holder->GetQueue()); - } else { - auto *holder = - var.GetMutable(); - holder->InitOnce(capacity, FLAGS_reader_queue_speed_test_mode); - return py::cast(holder->GetQueue()); - } - }, - py::return_value_policy::copy); + m.def( + "diff_tensor_shape", + [](const framework::LoDTensor &tensor, const framework::VarDesc &var_desc, + size_t num_places) -> py::object { + auto diff = DiffTensorShapeWithVarDesc(tensor, var_desc, num_places); + if (diff) { + return py::cast(std::move(diff.get())); + } else { + return py::cast(nullptr); + } + }); + + m.def( + "init_lod_tensor_blocking_queue", + [](framework::Variable &var, size_t capacity, + bool is_ordered) -> py::object { + VLOG(1) << "init_lod_tensor_blocking_queue"; + if (is_ordered) { + auto *holder = var.GetMutable< + reader::OrderedMultiDeviceLoDTensorBlockingQueueHolder>(); + holder->InitOnce(capacity, FLAGS_reader_queue_speed_test_mode); + return py::cast(holder->GetQueue()); + } else { + auto *holder = var.GetMutable(); + holder->InitOnce(capacity, FLAGS_reader_queue_speed_test_mode); + return py::cast(holder->GetQueue()); + } + }, + py::return_value_policy::copy); py::class_(m, "Reader", "") .def("start", &framework::ReaderHolder::Start) @@ -408,12 +412,13 @@ void BindReader(py::module *module) { py::class_>( m, "LoDTensorBlockingQueue", "") - .def("push", - [](reader::LoDTensorBlockingQueue &self, - const std::vector &lod_tensor_vec) { - return self.Push(lod_tensor_vec); - }, - py::call_guard()) + .def( + "push", + [](reader::LoDTensorBlockingQueue &self, + const std::vector &lod_tensor_vec) { + return self.Push(lod_tensor_vec); + }, + py::call_guard()) .def("size", &reader::LoDTensorBlockingQueue::Size) .def("capacity", &reader::LoDTensorBlockingQueue::Cap) .def("close", &reader::LoDTensorBlockingQueue::Close) @@ -424,12 +429,13 @@ void BindReader(py::module *module) { py::class_>( m, "OrderedMultiDeviceLoDTensorBlockingQueue", "") - .def("push", - [](reader::OrderedMultiDeviceLoDTensorBlockingQueue &self, - const std::vector &lod_tensor_vec) { - return self.Push(lod_tensor_vec); - }, - py::call_guard()) + .def( + "push", + [](reader::OrderedMultiDeviceLoDTensorBlockingQueue &self, + const std::vector &lod_tensor_vec) { + return self.Push(lod_tensor_vec); + }, + py::call_guard()) .def("size", &reader::OrderedMultiDeviceLoDTensorBlockingQueue::Size) .def("capacity", &reader::OrderedMultiDeviceLoDTensorBlockingQueue::Cap) .def("close", &reader::OrderedMultiDeviceLoDTensorBlockingQueue::Close) @@ -444,19 +450,20 @@ void BindReader(py::module *module) { BindMultiDeviceReader( module, "OrderedMultiDeviceFeedReader"); - m.def("create_py_reader", - [](const std::shared_ptr &queue, - const std::vector &names, - const std::vector> &shapes, - const std::vector &dtypes, - const std::vector &need_check_feed, - const std::vector &dst_places, - bool use_double_buffer, bool drop_last, bool pin_memory) { - return new MultiDeviceFeedReader( - queue, names, shapes, dtypes, need_check_feed, dst_places, - use_double_buffer, drop_last, pin_memory); - }, - py::return_value_policy::take_ownership); + m.def( + "create_py_reader", + [](const std::shared_ptr &queue, + const std::vector &names, + const std::vector> &shapes, + const std::vector &dtypes, + const std::vector &need_check_feed, + const std::vector &dst_places, bool use_double_buffer, + bool drop_last, bool pin_memory) { + return new MultiDeviceFeedReader( + queue, names, shapes, dtypes, need_check_feed, dst_places, + use_double_buffer, drop_last, pin_memory); + }, + py::return_value_policy::take_ownership); m.def( "create_py_reader", diff --git a/paddle/fluid/pybind/slice_utils.h b/paddle/fluid/pybind/slice_utils.h index add332abd30eaaad1772a0b8e326ea0ae6c27e8b..109f3e5705b60176637675d248aea856766c797c 100644 --- a/paddle/fluid/pybind/slice_utils.h +++ b/paddle/fluid/pybind/slice_utils.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/scope_guard.h" #include "paddle/fluid/operators/utils.h" diff --git a/paddle/fluid/pybind/tensor_py.h b/paddle/fluid/pybind/tensor_py.h index 63b36bd917390d25f34fcc3d63266a6d41d6b570..ed7ce64032b0ef00406cf4a62a677d753ce7b31d 100644 --- a/paddle/fluid/pybind/tensor_py.h +++ b/paddle/fluid/pybind/tensor_py.h @@ -15,12 +15,14 @@ limitations under the License. */ #pragma once #include + #include #include #include #include #include #include + #include "paddle/fluid/framework/data_type.h" #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/memory/memcpy.h" diff --git a/paddle/fluid/pybind/uva_utils.h b/paddle/fluid/pybind/uva_utils.h index 94f55769b7356ee0dbc90a90fb1a40ae73b057fe..3ea3d7ee1a7422896c90edca6722bc42969567a7 100644 --- a/paddle/fluid/pybind/uva_utils.h +++ b/paddle/fluid/pybind/uva_utils.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/fluid/operators/utils.h" #include "paddle/phi/common/data_type.h" #include "paddle/phi/core/compat/convert_utils.h" diff --git a/paddle/fluid/string/pretty_log.h b/paddle/fluid/string/pretty_log.h index 45fe89e8b5b14ef7afe7ccb4806b025f0a5eac39..d161b2a912fcaa5bf31f03b28efa84fddad950da 100644 --- a/paddle/fluid/string/pretty_log.h +++ b/paddle/fluid/string/pretty_log.h @@ -17,6 +17,6 @@ #include #include #include -#include "gflags/gflags.h" +#include "gflags/gflags.h" #include "paddle/utils/string/pretty_log.h" diff --git a/paddle/infrt/api/infrt_api.cc b/paddle/infrt/api/infrt_api.cc index f0bf46567a5bfc9ef86b35b14f1b8d1802cf8dfe..2f4bbd5df352c55f3846061fdef9d5334f5d550a 100644 --- a/paddle/infrt/api/infrt_api.cc +++ b/paddle/infrt/api/infrt_api.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// clang-format off #include "paddle/infrt/api/infrt_api.h" #include @@ -61,6 +62,7 @@ #include "paddle/infrt/dialect/tensorrt/trt_op_teller_pass.h" #include "paddle/infrt/dialect/tensorrt/trt_type_convert_pass.h" #endif +// clang-format on using namespace infrt::host_context; // NOLINT using namespace infrt::tensor; // NOLINT diff --git a/paddle/infrt/backends/host/phi_context.h b/paddle/infrt/backends/host/phi_context.h index 2af1fab10082126b3c281213f38cdebca7af69a9..880d1f03d87666ac05ba329c5ed72dd04d89a895 100644 --- a/paddle/infrt/backends/host/phi_context.h +++ b/paddle/infrt/backends/host/phi_context.h @@ -35,12 +35,12 @@ class CpuPhiContext : public ::phi::CPUContext { class GpuPhiContext : public ::phi::GPUContext { public: using Base = ::phi::GPUContext; - using ::phi::GPUContext::SetStream; - using ::phi::GPUContext::SetEigenDevice; using ::phi::GPUContext::SetBlasHandle; using ::phi::GPUContext::SetDnnHandle; + using ::phi::GPUContext::SetEigenDevice; using ::phi::GPUContext::SetSolverHandle; using ::phi::GPUContext::SetSparseHandle; + using ::phi::GPUContext::SetStream; }; } // namespace backends diff --git a/paddle/infrt/backends/tensorrt/plugin/pool_op_plugin.cu b/paddle/infrt/backends/tensorrt/plugin/pool_op_plugin.cu index 5a53777c8e30f98e1089f153156a49b1b8c6b7e6..f3e2fe35074a6722b269034d054a9bafc682349e 100644 --- a/paddle/infrt/backends/tensorrt/plugin/pool_op_plugin.cu +++ b/paddle/infrt/backends/tensorrt/plugin/pool_op_plugin.cu @@ -199,8 +199,8 @@ bool PoolPlugin::isOutputBroadcastAcrossBatch(int32_t outputIndex, return false; } -bool PoolPlugin::canBroadcastInputAcrossBatch(int32_t inputIndex) const - noexcept { +bool PoolPlugin::canBroadcastInputAcrossBatch( + int32_t inputIndex) const noexcept { return false; } diff --git a/paddle/infrt/backends/tensorrt/plugin/pool_op_plugin.h b/paddle/infrt/backends/tensorrt/plugin/pool_op_plugin.h index 0da1d15845330aafe0b02ae8a999439aedb12634..34189f95438bfd256fa3c79d79cc92e0ba6b8f82 100644 --- a/paddle/infrt/backends/tensorrt/plugin/pool_op_plugin.h +++ b/paddle/infrt/backends/tensorrt/plugin/pool_op_plugin.h @@ -114,10 +114,10 @@ class PoolPlugin : public nvinfer1::IPluginV2IOExt { char const* getPluginNamespace() const noexcept override; // IPluginV2Ext methods - nvinfer1::DataType getOutputDataType(int32_t index, - nvinfer1::DataType const* inputTypes, - int32_t nbInputs) const - noexcept override; + nvinfer1::DataType getOutputDataType( + int32_t index, + nvinfer1::DataType const* inputTypes, + int32_t nbInputs) const noexcept override; bool isOutputBroadcastAcrossBatch(int32_t outputIndex, bool const* inputIsBroadcasted, int32_t nbInputs) const noexcept override; diff --git a/paddle/infrt/backends/tensorrt/test_trt_engine.cc b/paddle/infrt/backends/tensorrt/test_trt_engine.cc index 89dd3b0dc7abf48102b48f16fb974b3c902fe049..7e081362f9c621bb9666c265bf4e827b799b830e 100644 --- a/paddle/infrt/backends/tensorrt/test_trt_engine.cc +++ b/paddle/infrt/backends/tensorrt/test_trt_engine.cc @@ -12,13 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include #include #include #include #include +#include + #include "paddle/fluid/inference/tensorrt/plugin/split_op_plugin.h" #include "paddle/fluid/inference/tensorrt/plugin/trt_plugin.h" #include "paddle/fluid/memory/allocation/allocator_facade.h" diff --git a/paddle/infrt/backends/tensorrt/trt_engine.cc b/paddle/infrt/backends/tensorrt/trt_engine.cc index a2d4954618986e66fccbc8cb67faf612e975a596..a539078e4af4de8a4dd4eafdc74b5c9139c71e9f 100644 --- a/paddle/infrt/backends/tensorrt/trt_engine.cc +++ b/paddle/infrt/backends/tensorrt/trt_engine.cc @@ -18,6 +18,7 @@ #include #include #include + #include "paddle/phi/backends/dynload/tensorrt.h" #include "paddle/phi/backends/gpu/gpu_info.h" #include "paddle/phi/core/ddim.h" diff --git a/paddle/infrt/backends/tensorrt/trt_engine.h b/paddle/infrt/backends/tensorrt/trt_engine.h index 41d11a711170921da4fc9beae37e57e811dee769..44f36a84cb5dcd77c6e5413244d3205bf5c612cd 100644 --- a/paddle/infrt/backends/tensorrt/trt_engine.h +++ b/paddle/infrt/backends/tensorrt/trt_engine.h @@ -17,6 +17,7 @@ #include #include + #include "paddle/infrt/backends/tensorrt/trt_options.h" #include "paddle/infrt/backends/tensorrt/trt_utils.h" #include "paddle/phi/backends/dynload/tensorrt.h" diff --git a/paddle/infrt/backends/tensorrt/trt_options.h b/paddle/infrt/backends/tensorrt/trt_options.h index d5190f5e6220e682c3d3a3ab564e381a3180caff..b4e36da2058ed65506fc3066693dff8e5acd24dd 100644 --- a/paddle/infrt/backends/tensorrt/trt_options.h +++ b/paddle/infrt/backends/tensorrt/trt_options.h @@ -15,12 +15,12 @@ #pragma once +#include + #include #include #include -#include - namespace infrt { namespace backends { namespace tensorrt { diff --git a/paddle/infrt/common/global.h b/paddle/infrt/common/global.h index e6586cb3a3c603ed352b360a45c3cce879978657..2d7735d525244dc2453a68ee12e9272b2bbeaa06 100644 --- a/paddle/infrt/common/global.h +++ b/paddle/infrt/common/global.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/infrt/tensor/dense_host_tensor.h" namespace infrt { diff --git a/paddle/infrt/common/memory.h b/paddle/infrt/common/memory.h index 678529b8b785cd2511734e8abb14127eb7514254..643b21477615dd7519c06cf80c045e93f8633e83 100644 --- a/paddle/infrt/common/memory.h +++ b/paddle/infrt/common/memory.h @@ -15,9 +15,9 @@ #pragma once #include -#include #include +#include #include "paddle/infrt/common/macros.h" #include "paddle/infrt/common/target.h" diff --git a/paddle/infrt/dialect/dense_tensor.h b/paddle/infrt/dialect/dense_tensor.h index 7fbd1e8a4efe1e9dc1d022beb7673ee8a59c7e36..8dec818a80a2728005bcade381cd3417f0407288 100644 --- a/paddle/infrt/dialect/dense_tensor.h +++ b/paddle/infrt/dialect/dense_tensor.h @@ -13,6 +13,8 @@ // limitations under the License. #pragma once + +// clang-format off #include #include #include @@ -25,3 +27,4 @@ #define GET_OP_CLASSES #include "paddle/infrt/dialect/dense_tensor.hpp.inc" +// clang-format on diff --git a/paddle/infrt/dialect/diagnostic_utils.cc b/paddle/infrt/dialect/diagnostic_utils.cc index 4151001067ecb4519148cc819e9233d454ba38b0..8785ce69b8e8f4291cd482fb3ede2eb8db6359d4 100644 --- a/paddle/infrt/dialect/diagnostic_utils.cc +++ b/paddle/infrt/dialect/diagnostic_utils.cc @@ -15,6 +15,7 @@ #include "paddle/infrt/dialect/diagnostic_utils.h" #include + #include namespace infrt { diff --git a/paddle/infrt/dialect/infrt/ir/infrt_dialect.cc b/paddle/infrt/dialect/infrt/ir/infrt_dialect.cc index c4f20cb4d35c54d3e5b9eaf9fa378907f8872567..0e3a10270cde2dba2bcf2d8c314e37bb5da4b72a 100644 --- a/paddle/infrt/dialect/infrt/ir/infrt_dialect.cc +++ b/paddle/infrt/dialect/infrt/ir/infrt_dialect.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// clang-format off #include "paddle/infrt/dialect/infrt/ir/infrt_dialect.h" #include @@ -60,6 +61,7 @@ void InfrtDialect::initialize() { #include "paddle/infrt/dialect/infrt/ir/test_kernels.cpp.inc" >(); } +// clang-format on /// Parse a type registered to this dialect. mlir::Type InfrtDialect::parseType(::mlir::DialectAsmParser &parser) const { diff --git a/paddle/infrt/dialect/infrt/ir/infrt_dialect.h b/paddle/infrt/dialect/infrt/ir/infrt_dialect.h index e2e9b9348eb46da737d72757680a4fdf4aee5282..5a7c45b3205476026ad6b10ae3c3896ad545134e 100644 --- a/paddle/infrt/dialect/infrt/ir/infrt_dialect.h +++ b/paddle/infrt/dialect/infrt/ir/infrt_dialect.h @@ -23,8 +23,8 @@ #include #include #include -#include "paddle/infrt/dialect/infrt/common/types.h" +#include "paddle/infrt/dialect/infrt/common/types.h" #include "paddle/infrt/dialect/infrt/ir/infrt_opsDialect.h.inc" #define GET_TYPEDEF_CLASSES #include "paddle/infrt/dialect/infrt/ir/infrt_opsTypes.h.inc" diff --git a/paddle/infrt/dialect/infrt/pass/infrt_op_fuse_pass.cc b/paddle/infrt/dialect/infrt/pass/infrt_op_fuse_pass.cc index 63be5ca9095638bee8f39df35ab1b51f3085afac..309e0f8b94040f2275309856b96f7ceac4e674f1 100644 --- a/paddle/infrt/dialect/infrt/pass/infrt_op_fuse_pass.cc +++ b/paddle/infrt/dialect/infrt/pass/infrt_op_fuse_pass.cc @@ -15,6 +15,7 @@ #include "paddle/infrt/dialect/infrt/pass/infrt_op_fuse_pass.h" #include + #include "paddle/infrt/dialect/infrt/ir/infrt_dialect.h" #include "paddle/infrt/dialect/pd/ir/pd_ops.h" namespace { diff --git a/paddle/infrt/dialect/init_dialects.cc b/paddle/infrt/dialect/init_dialects.cc index 8da34bd404be62c1935d0b2a8e51282f82907eb1..c204f9ea6266967b5f95230108346b04dce3f51f 100644 --- a/paddle/infrt/dialect/init_dialects.cc +++ b/paddle/infrt/dialect/init_dialects.cc @@ -19,12 +19,10 @@ #include "paddle/infrt/dialect/dense_tensor.h" #include "paddle/infrt/dialect/infrt/ir/basic_kernels.h" #include "paddle/infrt/dialect/infrt/ir/infrt_dialect.h" - #include "paddle/infrt/dialect/pd/ir/pd_ops.h" #include "paddle/infrt/dialect/phi/ir/infrt_phi_tensor.h" #include "paddle/infrt/dialect/phi/ir/phi_base.h" #include "paddle/infrt/dialect/phi/ir/phi_kernels.h" - #include "paddle/infrt/dialect/tensor_shape.h" #include "paddle/infrt/dialect/tensorrt/trt_ops.h" diff --git a/paddle/infrt/dialect/mlir_loader.cc b/paddle/infrt/dialect/mlir_loader.cc index 19b8cba12df8687a907534ada30cdecc1321a3c2..ab533a25c4173cebe821d6b4ac04325aaf9c588a 100644 --- a/paddle/infrt/dialect/mlir_loader.cc +++ b/paddle/infrt/dialect/mlir_loader.cc @@ -20,10 +20,10 @@ #include #include #include -#include #include #include +#include #include #include diff --git a/paddle/infrt/dialect/mlir_loader.h b/paddle/infrt/dialect/mlir_loader.h index 5e50ad9e5a27176a1bea32356b0cf343140bb441..b4faba8068e4462d660e0fb3c7edf070fb63047e 100644 --- a/paddle/infrt/dialect/mlir_loader.h +++ b/paddle/infrt/dialect/mlir_loader.h @@ -16,9 +16,9 @@ #include #include -#include #include +#include namespace infrt { namespace dialect { diff --git a/paddle/infrt/dialect/opt.cc b/paddle/infrt/dialect/opt.cc index 2006530958f0b5223edfcee87a5895e101f0e240..e57666ffca08079430ef3296c1d10d213a89bebe 100644 --- a/paddle/infrt/dialect/opt.cc +++ b/paddle/infrt/dialect/opt.cc @@ -14,6 +14,7 @@ #include #include + #include "paddle/infrt/dialect/init_dialects.h" int main(int argc, char **argv) { diff --git a/paddle/infrt/dialect/pd/pass/pd_op_fuse_pass.cc b/paddle/infrt/dialect/pd/pass/pd_op_fuse_pass.cc index 8bdf957db27d8c2b20025931a76826628feddbdd..c9247abe695ae8c143a794a6e1b3a1b85b73ebed 100644 --- a/paddle/infrt/dialect/pd/pass/pd_op_fuse_pass.cc +++ b/paddle/infrt/dialect/pd/pass/pd_op_fuse_pass.cc @@ -14,6 +14,7 @@ #include "paddle/infrt/dialect/pd/pass/pd_op_fuse_pass.h" // NOLINT #include + #include "paddle/infrt/dialect/pd/ir/pd_ops.h" namespace { diff --git a/paddle/infrt/dialect/phi/ir/infrt_phi_tensor.h b/paddle/infrt/dialect/phi/ir/infrt_phi_tensor.h index 9a92558daab0376d430fe04b853a810cf42b6e85..f7358db5bf356f735a2b1d5a8178738cfe117e42 100644 --- a/paddle/infrt/dialect/phi/ir/infrt_phi_tensor.h +++ b/paddle/infrt/dialect/phi/ir/infrt_phi_tensor.h @@ -14,6 +14,7 @@ #pragma once +// clang-format off #include #include #include @@ -37,3 +38,4 @@ // NOLINT #define GET_OP_CLASSES #include "paddle/infrt/dialect/phi/ir/infrt_phi_tensor.h.inc" +// clang-format on diff --git a/paddle/infrt/dialect/phi/ir/phi_base.cc b/paddle/infrt/dialect/phi/ir/phi_base.cc index 1bd6068d3fb961f3f35456f220d76c416614e49f..39a23529ac3d100ec3d336fb6be9ea7a2a891727 100644 --- a/paddle/infrt/dialect/phi/ir/phi_base.cc +++ b/paddle/infrt/dialect/phi/ir/phi_base.cc @@ -21,6 +21,7 @@ #include #include #include + #include "paddle/infrt/common/global.h" #include "paddle/infrt/dialect/phi/ir/infrt_phi_base.cpp.inc" #include "paddle/infrt/dialect/phi/ir/infrt_phi_baseDialect.cpp.inc" diff --git a/paddle/infrt/dialect/phi/ir/phi_base.h b/paddle/infrt/dialect/phi/ir/phi_base.h index 64cd08cc05ed42fe8d53b8c5b8a5bc994bae8824..2cbdef5af906e4f04e9864c0ca717eb39ace7b9b 100644 --- a/paddle/infrt/dialect/phi/ir/phi_base.h +++ b/paddle/infrt/dialect/phi/ir/phi_base.h @@ -18,8 +18,8 @@ #include #include -#include "paddle/infrt/dialect/infrt/common/types.h" +#include "paddle/infrt/dialect/infrt/common/types.h" #include "paddle/infrt/dialect/phi/ir/infrt_phi_baseDialect.h.inc" #define GET_OP_CLASSES diff --git a/paddle/infrt/dialect/phi/ir/phi_kernels.cc b/paddle/infrt/dialect/phi/ir/phi_kernels.cc index c7a837b83fc24095982f50fe5c1720e13723fbdb..69c3f9633911792b906373b84bcb69969cbf5899 100644 --- a/paddle/infrt/dialect/phi/ir/phi_kernels.cc +++ b/paddle/infrt/dialect/phi/ir/phi_kernels.cc @@ -13,12 +13,12 @@ // limitations under the License. #include "paddle/infrt/dialect/phi/ir/phi_kernels.h" + #include #include "paddle/infrt/dialect/phi/ir/phi_gpu_kernelsDialect.cpp.inc" #define GET_OP_CLASSES #include "paddle/infrt/dialect/phi/ir/phi_cpu_kernels.cpp.inc" // NOLINT - #include "paddle/infrt/dialect/phi/ir/phi_cpu_kernelsDialect.cpp.inc" #define GET_OP_CLASSES #include "paddle/infrt/dialect/phi/ir/phi_gpu_kernels.cpp.inc" // NOLINT diff --git a/paddle/infrt/dialect/phi/ir/phi_kernels.h b/paddle/infrt/dialect/phi/ir/phi_kernels.h index 4f8b41852cc67e32c510c247e907092046731452..9321ebb148f8634d9945c509fc3f125dcbbbc075 100644 --- a/paddle/infrt/dialect/phi/ir/phi_kernels.h +++ b/paddle/infrt/dialect/phi/ir/phi_kernels.h @@ -32,11 +32,9 @@ #include "paddle/infrt/dialect/dense_tensor.h" #include "paddle/infrt/dialect/infrt/ir/infrt_dialect.h" #include "paddle/infrt/dialect/phi/ir/phi_base.h" - #include "paddle/infrt/dialect/phi/ir/phi_cpu_kernelsDialect.h.inc" #define GET_OP_CLASSES #include "paddle/infrt/dialect/phi/ir/phi_cpu_kernels.h.inc" - #include "paddle/infrt/dialect/phi/ir/phi_gpu_kernelsDialect.h.inc" #define GET_OP_CLASSES #include "paddle/infrt/dialect/phi/ir/phi_gpu_kernels.h.inc" diff --git a/paddle/infrt/dialect/phi/pass/kernel_op_desc.cc b/paddle/infrt/dialect/phi/pass/kernel_op_desc.cc index 9425a290142da8ea8ce50e3658b52291f5cf0fa3..ff870a06752e51448048f1c83e9dd5fcb550478a 100644 --- a/paddle/infrt/dialect/phi/pass/kernel_op_desc.cc +++ b/paddle/infrt/dialect/phi/pass/kernel_op_desc.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/infrt/dialect/phi/pass/kernel_op_desc.h" + #include + #include "paddle/infrt/dialect/phi/data_type.h" #include "paddle/phi/core/type_defs.h" #include "paddle/phi/kernels/declarations.h" diff --git a/paddle/infrt/dialect/phi/pass/kernel_op_desc.h b/paddle/infrt/dialect/phi/pass/kernel_op_desc.h index cdc8f7cbff553687bed63d165b18c4bc8efdb807..4385d3c941727e81c8705540a1ec6bd3c57ad292 100644 --- a/paddle/infrt/dialect/phi/pass/kernel_op_desc.h +++ b/paddle/infrt/dialect/phi/pass/kernel_op_desc.h @@ -16,6 +16,7 @@ #include #include + #include "paddle/infrt/dialect/infrt/common/types.h" namespace infrt { diff --git a/paddle/infrt/dialect/phi/pass/kernel_op_desc_test.cc b/paddle/infrt/dialect/phi/pass/kernel_op_desc_test.cc index bd5f0799a60d5d3925e1e1265997820c37b438e6..24af0ea437875c50428134c693c9269d40d8edb6 100644 --- a/paddle/infrt/dialect/phi/pass/kernel_op_desc_test.cc +++ b/paddle/infrt/dialect/phi/pass/kernel_op_desc_test.cc @@ -12,12 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +// clang-format off #include #include #include #include "paddle/infrt/dialect/phi/pass/kernel_op_desc.h" #include "paddle/phi/kernels/declarations.h" +// clang-format on namespace infrt { diff --git a/paddle/infrt/dialect/phi/pass/phi_op_convert_pass.cc b/paddle/infrt/dialect/phi/pass/phi_op_convert_pass.cc index 862c9ae4ee5afb87e1cc8f31b44071fb35e078b4..f4de56b42a683110edea4a7a2e36e9880fe89f86 100644 --- a/paddle/infrt/dialect/phi/pass/phi_op_convert_pass.cc +++ b/paddle/infrt/dialect/phi/pass/phi_op_convert_pass.cc @@ -20,6 +20,7 @@ #include #include #include + #include #include #include diff --git a/paddle/infrt/dialect/phi/pass/phi_op_convert_pass.h b/paddle/infrt/dialect/phi/pass/phi_op_convert_pass.h index a0e74426a409743d539752e30ac068117407058b..9748e1679d3f1b291f7075d8fea16ada5af71b58 100644 --- a/paddle/infrt/dialect/phi/pass/phi_op_convert_pass.h +++ b/paddle/infrt/dialect/phi/pass/phi_op_convert_pass.h @@ -14,6 +14,7 @@ #pragma once #include + #include "paddle/infrt/dialect/infrt/common/types.h" namespace infrt { diff --git a/paddle/infrt/dialect/phi/pass/proto_arg_map_context.h b/paddle/infrt/dialect/phi/pass/proto_arg_map_context.h index 7cb2651ccf6a27670f05ab067f637342e71d6af8..30bde83cd8199c9d1de404e4b5c77abd680deb3d 100644 --- a/paddle/infrt/dialect/phi/pass/proto_arg_map_context.h +++ b/paddle/infrt/dialect/phi/pass/proto_arg_map_context.h @@ -15,7 +15,9 @@ limitations under the License. */ #pragma once #include + #include + #include "paddle/infrt/dialect/pd/common/pd_ops_info.h" #include "paddle/phi/core/compat/arg_map_context.h" diff --git a/paddle/infrt/dialect/phi/phi_exec.cc b/paddle/infrt/dialect/phi/phi_exec.cc index a2808a00cb67da582ce4fc8b995772725d79e47e..0aae8cc93377d40f549eccd7a5c153efcd376d9b 100644 --- a/paddle/infrt/dialect/phi/phi_exec.cc +++ b/paddle/infrt/dialect/phi/phi_exec.cc @@ -41,7 +41,9 @@ bool parse_inputs(int argc, *params_file_name = argv[2]; return true; } - default: { return false; } + default: { + return false; + } } } diff --git a/paddle/infrt/dialect/print_ir.cc b/paddle/infrt/dialect/print_ir.cc index b118a5f7a9caf42f4aa63dd0222e7a2647addac5..a240cebe736552dd48d91c7d196efe0bafe935c4 100644 --- a/paddle/infrt/dialect/print_ir.cc +++ b/paddle/infrt/dialect/print_ir.cc @@ -28,6 +28,7 @@ #include #include #include + #include #include "paddle/infrt/common/global.h" @@ -74,8 +75,8 @@ void printOperation(mlir::Operation *op, int indent) { if (!op->getAttrs().empty()) { printIndent(indent) << op->getAttrs().size() << " attributes:\n"; for (mlir::NamedAttribute attr : op->getAttrs()) { - printIndent(indent + 1) << "- {" << attr.getName() << " : " - << attr.getValue() << "}\n"; + printIndent(indent + 1) + << "- {" << attr.getName() << " : " << attr.getValue() << "}\n"; } } diff --git a/paddle/infrt/dialect/tensor_shape.cc b/paddle/infrt/dialect/tensor_shape.cc index 92c03818264ee7c44626042dd1de53b66bb8c54b..9a825224f1d30117bb2afc34221657d984e08c64 100644 --- a/paddle/infrt/dialect/tensor_shape.cc +++ b/paddle/infrt/dialect/tensor_shape.cc @@ -66,5 +66,4 @@ void TensorShapeDialect::printType(mlir::Type type, #define GET_OP_CLASSES #include "paddle/infrt/dialect/tensor_shape.cpp.inc" // NOLINT - #include "paddle/infrt/dialect/tensor_shape_dialect.cpp.inc" diff --git a/paddle/infrt/dialect/tensorrt/convert.h b/paddle/infrt/dialect/tensorrt/convert.h index 2a242ca285ba8cf3e9e4257950c6137fb9e5d225..2dcd86486f51d3692e1fa8bce94dbf0ca792a1d1 100644 --- a/paddle/infrt/dialect/tensorrt/convert.h +++ b/paddle/infrt/dialect/tensorrt/convert.h @@ -20,6 +20,7 @@ #include #include #include + #include "paddle/infrt/dialect/infrt/common/types.h" #include "paddle/infrt/dialect/infrt/ir/infrt_dialect.h" #include "paddle/infrt/dialect/pd/ir/pd_ops.h" diff --git a/paddle/infrt/dialect/tensorrt/trt_exec.cc b/paddle/infrt/dialect/tensorrt/trt_exec.cc index dcb84ceb50edf91956664d21c4ad804e0aac0281..899e71f1c990f298232c27dbc739bf4c43bf57c7 100644 --- a/paddle/infrt/dialect/tensorrt/trt_exec.cc +++ b/paddle/infrt/dialect/tensorrt/trt_exec.cc @@ -11,10 +11,14 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + +// clang-format off #include #include + #include #include + #include "paddle/infrt/common/global.h" #include "paddle/infrt/dialect/infrt/pass/infrt_weights_unfold_pass.h" #include "paddle/infrt/dialect/mlir_loader.h" @@ -44,6 +48,7 @@ #endif #include +// clang-format on int main(int argc, char** argv) { static llvm::cl::opt input_file( diff --git a/paddle/infrt/dialect/tensorrt/trt_graph_fuse_pass.cc b/paddle/infrt/dialect/tensorrt/trt_graph_fuse_pass.cc index bbe9a76e87b00592284892a8187b4be1391a7cf5..7109fc772ec8623363bf43cca0e5069397adbeba 100644 --- a/paddle/infrt/dialect/tensorrt/trt_graph_fuse_pass.cc +++ b/paddle/infrt/dialect/tensorrt/trt_graph_fuse_pass.cc @@ -18,6 +18,7 @@ #include #include #include + #include #include #include diff --git a/paddle/infrt/dialect/tensorrt/trt_graph_split_pass.cc b/paddle/infrt/dialect/tensorrt/trt_graph_split_pass.cc index d5ce871edd1a3ab8b30450bda239158ee43d28e7..d74fe3e5e9c2f2baf67636b5880f67d6fb65cd35 100644 --- a/paddle/infrt/dialect/tensorrt/trt_graph_split_pass.cc +++ b/paddle/infrt/dialect/tensorrt/trt_graph_split_pass.cc @@ -15,6 +15,7 @@ #include "paddle/infrt/dialect/tensorrt/trt_graph_split_pass.h" #include + #include "paddle/infrt/dialect/pd/ir/pd_ops.h" namespace infrt { diff --git a/paddle/infrt/dialect/tensorrt/trt_op_teller_pass.cc b/paddle/infrt/dialect/tensorrt/trt_op_teller_pass.cc index d7b917385cf1472c430cea613e0d4d0658a90f22..35b869fb307880a585162413c38d6e4ef180136c 100644 --- a/paddle/infrt/dialect/tensorrt/trt_op_teller_pass.cc +++ b/paddle/infrt/dialect/tensorrt/trt_op_teller_pass.cc @@ -16,6 +16,7 @@ #include #include + #include "paddle/infrt/dialect/dense_tensor.h" #include "paddle/infrt/dialect/infrt/ir/basic_kernels.h" #include "paddle/infrt/dialect/infrt/ir/infrt_dialect.h" diff --git a/paddle/infrt/dialect/tensorrt/trt_ops.cc b/paddle/infrt/dialect/tensorrt/trt_ops.cc index 415a78a6967ab6fd4e2a38380d09a5d5c64b1c2f..161fbbbcc65a564b835ced615aa92ff8eec6ced9 100644 --- a/paddle/infrt/dialect/tensorrt/trt_ops.cc +++ b/paddle/infrt/dialect/tensorrt/trt_ops.cc @@ -11,6 +11,8 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. + +// clang-format off #include "paddle/infrt/dialect/tensorrt/trt_ops.h" #include #include @@ -24,6 +26,7 @@ #include "paddle/infrt/dialect/dense_tensor.h" #include "paddle/infrt/dialect/infrt/ir/infrt_dialect.h" #include "paddle/infrt/dialect/phi/ir/phi_base.h" +// clang-format on namespace infrt { namespace trt { diff --git a/paddle/infrt/dialect/tensorrt/trt_ops.h b/paddle/infrt/dialect/tensorrt/trt_ops.h index 76768037dbdb3072976d9f6cf0cdfb4f7956bdd4..e851c26c43c8cf32b658fffae203e2dea32209f0 100644 --- a/paddle/infrt/dialect/tensorrt/trt_ops.h +++ b/paddle/infrt/dialect/tensorrt/trt_ops.h @@ -28,6 +28,7 @@ #include #include #include + #include "paddle/infrt/dialect/infrt/ir/basic_kernels.h" #include "paddle/infrt/dialect/infrt/ir/infrt_dialect.h" #include "paddle/infrt/dialect/pd/ir/pd_ops.h" diff --git a/paddle/infrt/dialect/tensorrt/trt_type_convert_pass.cc b/paddle/infrt/dialect/tensorrt/trt_type_convert_pass.cc index 35c81d0230161b27f3a1564e953a09f122841b33..1cb7c4155b9878aa715004d48747489c1f1e1cec 100644 --- a/paddle/infrt/dialect/tensorrt/trt_type_convert_pass.cc +++ b/paddle/infrt/dialect/tensorrt/trt_type_convert_pass.cc @@ -15,6 +15,7 @@ #include "paddle/infrt/dialect/tensorrt/trt_type_convert_pass.h" #include + #include #include "llvm/ADT/StringRef.h" diff --git a/paddle/infrt/host_context/core_runtime.cc b/paddle/infrt/host_context/core_runtime.cc index e3917bd07d24248becb013e2d6ef6546608285f9..3dbb0b41c9fb84b9f6a1b68dd31c4f94bbd37394 100644 --- a/paddle/infrt/host_context/core_runtime.cc +++ b/paddle/infrt/host_context/core_runtime.cc @@ -14,9 +14,8 @@ #include "paddle/infrt/host_context/core_runtime.h" -#include - #include +#include #include #include "paddle/infrt/host_context/kernel_registry.h" diff --git a/paddle/infrt/host_context/core_runtime.h b/paddle/infrt/host_context/core_runtime.h index acb6a66cac630f695afbdcc527d7b397973aa84f..585369e249b22b851299c886e894344db40db7ba 100644 --- a/paddle/infrt/host_context/core_runtime.h +++ b/paddle/infrt/host_context/core_runtime.h @@ -46,7 +46,7 @@ class CoreRuntime : public std::enable_shared_from_this { //! Get the results of the execution. llvm::SmallVector // - GetResults(llvm::ArrayRef arg_names); + GetResults(llvm::ArrayRef arg_names); std::shared_ptr getptr() { return std::shared_ptr(this); diff --git a/paddle/infrt/host_context/kernel_registry.cc b/paddle/infrt/host_context/kernel_registry.cc index 5693e973a3f9894cdabb9eb4bc837d840638213e..2518056ba9d2998a8f6a8e8a8aebb1171a4b7465 100644 --- a/paddle/infrt/host_context/kernel_registry.cc +++ b/paddle/infrt/host_context/kernel_registry.cc @@ -39,8 +39,8 @@ const std::vector &KernelRegistry::GetAttrNameList( void KernelRegistry::AddKernel(const std::string &key, KernelImplementation fn, const std::vector &attr_order) { - CHECK(!impl_->data.count(key)) << "kernel [" << key - << "] is registered twice"; + CHECK(!impl_->data.count(key)) + << "kernel [" << key << "] is registered twice"; impl_->data.emplace( key, std::make_pair([fn]() { return fn; }, std::move(attr_order))); } @@ -48,8 +48,8 @@ void KernelRegistry::AddKernel(const std::string &key, void KernelRegistry::AddKernel(const std::string &key, KernelLauncher fn, const std::vector &attr_order) { - CHECK(!impl_->data.count(key)) << "kernel [" << key - << "] is registered twice"; + CHECK(!impl_->data.count(key)) + << "kernel [" << key << "] is registered twice"; impl_->data.emplace(key, std::make_pair(std::move(fn), std::move(attr_order))); } diff --git a/paddle/infrt/host_context/mlir_exec.cc b/paddle/infrt/host_context/mlir_exec.cc index 6ad51a02bda29432970bc389e1d77e7ecf6e6c0a..1ae7cdc742afdb26641723fc9ac4a077ae27b1b3 100644 --- a/paddle/infrt/host_context/mlir_exec.cc +++ b/paddle/infrt/host_context/mlir_exec.cc @@ -14,6 +14,7 @@ #include #include + #include #include diff --git a/paddle/infrt/host_context/mlir_program_executor.h b/paddle/infrt/host_context/mlir_program_executor.h index c2ccb90640b21bcfb675a707d6cb60cf5028ab36..7808c460457aaa2f915c0879e5105a5e66724dbe 100644 --- a/paddle/infrt/host_context/mlir_program_executor.h +++ b/paddle/infrt/host_context/mlir_program_executor.h @@ -19,10 +19,10 @@ #include #include #include -#include #include #include +#include #include "paddle/infrt/host_context/core_runtime.h" #include "paddle/infrt/host_context/kernel_registry.h" diff --git a/paddle/infrt/host_context/mlir_to_runtime_translate.cc b/paddle/infrt/host_context/mlir_to_runtime_translate.cc index 05bb28b7c56137f19d0c6a4159a07bfc77e053e1..9292e593a708fbf31b21719c3fd2771c5683e3fd 100644 --- a/paddle/infrt/host_context/mlir_to_runtime_translate.cc +++ b/paddle/infrt/host_context/mlir_to_runtime_translate.cc @@ -14,6 +14,7 @@ #include "paddle/infrt/host_context/mlir_to_runtime_translate.h" +#include #include #include #include @@ -23,7 +24,6 @@ #include #include -#include #include #include #include @@ -591,8 +591,8 @@ bool MlirToRuntimeTranslator::EmitCallOp(mlir::Operation* op, { // lookup the callee function auto it = table.find(callee_name.getValue().str()); - CHECK(it != table.end()) << "can't find function [" - << callee_name.getValue().str() << "]"; + CHECK(it != table.end()) + << "can't find function [" << callee_name.getValue().str() << "]"; auto* function = impl_->cur_op->CreateFunctionExecutable(it->second, &impl_->func_defs); impl_->cur_op->AppendAttribute(new Value(function)); diff --git a/paddle/infrt/host_context/op_executable.cc b/paddle/infrt/host_context/op_executable.cc index 4d588a9c2b523c6941fe1ed36ba8473307005930..b53dc0545c72fdee065f0b84a42a964a381ad619 100644 --- a/paddle/infrt/host_context/op_executable.cc +++ b/paddle/infrt/host_context/op_executable.cc @@ -15,6 +15,7 @@ #include "paddle/infrt/host_context/op_executable.h" #include + #include #include diff --git a/paddle/infrt/host_context/op_executable.h b/paddle/infrt/host_context/op_executable.h index 550f6ab6349ed2f3f503ea7b0b425f7dbc1aea2c..b80b99fd41405caa80147497ebd057bd79572829 100644 --- a/paddle/infrt/host_context/op_executable.h +++ b/paddle/infrt/host_context/op_executable.h @@ -16,6 +16,7 @@ #include #include #include + #include #include #include diff --git a/paddle/infrt/host_context/paddle_mlir.h b/paddle/infrt/host_context/paddle_mlir.h index 57bdc1b48578b25c6723d83cc58839d1b843231c..629181cca3d6ec85bb454397593e71c38f541a47 100644 --- a/paddle/infrt/host_context/paddle_mlir.h +++ b/paddle/infrt/host_context/paddle_mlir.h @@ -20,6 +20,7 @@ #include #include #include + #include #include #include diff --git a/paddle/infrt/host_context/paddle_mlir_converter.cc b/paddle/infrt/host_context/paddle_mlir_converter.cc index a2808a00cb67da582ce4fc8b995772725d79e47e..0aae8cc93377d40f549eccd7a5c153efcd376d9b 100644 --- a/paddle/infrt/host_context/paddle_mlir_converter.cc +++ b/paddle/infrt/host_context/paddle_mlir_converter.cc @@ -41,7 +41,9 @@ bool parse_inputs(int argc, *params_file_name = argv[2]; return true; } - default: { return false; } + default: { + return false; + } } } diff --git a/paddle/infrt/host_context/symbol_table.h b/paddle/infrt/host_context/symbol_table.h index 805215a78ce0d09b5d4a155d302e5525ea08d524..8c79c78c690e82290a70e2cb386ee731c4804093 100644 --- a/paddle/infrt/host_context/symbol_table.h +++ b/paddle/infrt/host_context/symbol_table.h @@ -14,9 +14,8 @@ #pragma once -#include - #include +#include #include "paddle/infrt/host_context/value.h" diff --git a/paddle/infrt/host_context/value.h b/paddle/infrt/host_context/value.h index 1834cb4c0db056939013e2f202a5a0b3e0908cdb..af785c13349fda2aa9f7dc48249ae1f7ef9b05e0 100644 --- a/paddle/infrt/host_context/value.h +++ b/paddle/infrt/host_context/value.h @@ -159,15 +159,15 @@ class Value : public common::Object { template const T& get() const { - CHECK(data.template is()) << "typeid: " << data.index() - << " != " << ValueVariantType::IndexOf; + CHECK(data.template is()) + << "typeid: " << data.index() << " != " << ValueVariantType::IndexOf; return data.get(); } template T& get() { - CHECK(data.template is()) << "typeid: " << data.index() - << " != " << ValueVariantType::IndexOf; + CHECK(data.template is()) + << "typeid: " << data.index() << " != " << ValueVariantType::IndexOf; return data.get(); } diff --git a/paddle/infrt/kernel/phi/dense_tensor_kernels.cc b/paddle/infrt/kernel/phi/dense_tensor_kernels.cc index 95e25b243f3abcd87eda08764c1cd1994f370deb..8c49f47e7d8739b9e27e1eb24ce509e3a4472685 100644 --- a/paddle/infrt/kernel/phi/dense_tensor_kernels.cc +++ b/paddle/infrt/kernel/phi/dense_tensor_kernels.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/infrt/kernel/phi/dense_tensor_kernels.h" + #include + #include "llvm/Support/ErrorHandling.h" #include "paddle/infrt/backends/host/phi_allocator.h" #include "paddle/infrt/common/string.h" diff --git a/paddle/infrt/kernel/phi/infershaped/infershaped_kernel_launcher.cc b/paddle/infrt/kernel/phi/infershaped/infershaped_kernel_launcher.cc index 2e40261f27386717deee886494ef047c2f7166d7..cb9640451f9b28e37443e3356399b47fcf28be5c 100644 --- a/paddle/infrt/kernel/phi/infershaped/infershaped_kernel_launcher.cc +++ b/paddle/infrt/kernel/phi/infershaped/infershaped_kernel_launcher.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/infrt/kernel/phi/infershaped/infershaped_kernel_launcher.h" + #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/meta_tensor.h" diff --git a/paddle/infrt/kernel/phi/infershaped/infershaped_utils.h b/paddle/infrt/kernel/phi/infershaped/infershaped_utils.h index 277c4ad6b7afcf1d205687bf2e7084af91653836..531d77ba952aa5384bcf84e6c2e2cefe2e3c7b99 100644 --- a/paddle/infrt/kernel/phi/infershaped/infershaped_utils.h +++ b/paddle/infrt/kernel/phi/infershaped/infershaped_utils.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/infrt/tensor/dense_host_tensor.h" #include "paddle/phi/core/dense_tensor.h" diff --git a/paddle/infrt/kernel/phi/infershaped/phi_kernel_launcher.h b/paddle/infrt/kernel/phi/infershaped/phi_kernel_launcher.h index d87027847202bc12fd6d55712961946cf18a29a7..bac25e0f437d86af18e1bbaf32175d3f13631714 100644 --- a/paddle/infrt/kernel/phi/infershaped/phi_kernel_launcher.h +++ b/paddle/infrt/kernel/phi/infershaped/phi_kernel_launcher.h @@ -14,6 +14,7 @@ #pragma once #include + #include #include "paddle/infrt/backends/host/phi_context.h" diff --git a/paddle/infrt/kernel/tensorrt/trt_kernels.cc b/paddle/infrt/kernel/tensorrt/trt_kernels.cc index c0f5ebb4a7657619aea82ef40ee5602a5b90f5d0..0ea68f2e835f76459b5aff3b476b5d786e5c69b2 100644 --- a/paddle/infrt/kernel/tensorrt/trt_kernels.cc +++ b/paddle/infrt/kernel/tensorrt/trt_kernels.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// clang-format off #include "paddle/infrt/kernel/tensorrt/trt_kernels.h" #include #include @@ -36,6 +37,7 @@ #include "paddle/infrt/host_context/symbol_table.h" #include "paddle/phi/common/place.h" #include "paddle/phi/core/dense_tensor.h" +// clang-format on namespace infrt { namespace kernel { diff --git a/paddle/infrt/kernel/tensorrt/trt_kernels.h b/paddle/infrt/kernel/tensorrt/trt_kernels.h index bf23bd45c13415782e29dfd45713fea3a2a0acb0..bf41c124a299baea0342cc0ca9851e8b754340a7 100644 --- a/paddle/infrt/kernel/tensorrt/trt_kernels.h +++ b/paddle/infrt/kernel/tensorrt/trt_kernels.h @@ -19,7 +19,6 @@ #include #include "mlir/IR/Operation.h" - #include "paddle/infrt/backends/tensorrt/trt_engine.h" #include "paddle/phi/backends/gpu/gpu_context.h" diff --git a/paddle/infrt/kernel/test_kernels.cc b/paddle/infrt/kernel/test_kernels.cc index bcf475d1bc09dab8be1b7a23359e1eb935ee02e0..e00afa4b7901ae77c2b22626c3aae3f508f3c022 100644 --- a/paddle/infrt/kernel/test_kernels.cc +++ b/paddle/infrt/kernel/test_kernels.cc @@ -92,11 +92,11 @@ class BenchmarkStats { std::sort(run_times_walltime_.begin(), run_times_walltime_.end()); std::sort(run_times_cpu_.begin(), run_times_cpu_.end()); - auto percentile = []( - double p, const std::vector &run_times) { - assert(p >= 0.0 && p <= 1.0); - return run_times[run_times.size() * p]; - }; + auto percentile = + [](double p, const std::vector &run_times) { + assert(p >= 0.0 && p <= 1.0); + return run_times[run_times.size() * p]; + }; // BM: prefix is added to make grepping results from lit output easier. std::string prefix; diff --git a/paddle/infrt/paddle/scope.h b/paddle/infrt/paddle/scope.h index 4ebf846374c6fed58217a8774b99c794f34979e2..1f81d0914dfc6b5ed5c2b76ffe0a4670d0daf298 100644 --- a/paddle/infrt/paddle/scope.h +++ b/paddle/infrt/paddle/scope.h @@ -13,10 +13,9 @@ // limitations under the License. #pragma once -#include - #include #include +#include #include #include "paddle/infrt/common/macros.h" diff --git a/paddle/infrt/support/type_traits.h b/paddle/infrt/support/type_traits.h index 341dabb7c1c4a69800fd114bc481dd9a4b082ba7..33a42fe37eaa66045acaaaa8b8b4e70d3755434f 100644 --- a/paddle/infrt/support/type_traits.h +++ b/paddle/infrt/support/type_traits.h @@ -115,7 +115,8 @@ struct nonesuch { template class Op, + template + class Op, class... Args> struct detector : std::false_type { using value_t = std::false_type; diff --git a/paddle/infrt/tests/models/test_abs.cc b/paddle/infrt/tests/models/test_abs.cc index 89bbe78ffe27a13eabb45dd6e7b75ae49a618a5f..aa5a2c6945b47a823064e0182406c7f384c42688 100644 --- a/paddle/infrt/tests/models/test_abs.cc +++ b/paddle/infrt/tests/models/test_abs.cc @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +// clang-format off #include #include #include @@ -49,6 +50,7 @@ #include "paddle/infrt/dialect/phi/ir/infrt_phi_tensor.h" #include "paddle/infrt/dialect/phi/ir/phi_base.h" #include "paddle/infrt/dialect/phi/ir/phi_kernels.h" +// clang-format on static llvm::cl::list cl_shared_libs( // NOLINT "shared_libs", diff --git a/paddle/phi/api/ext/op_meta_info.h b/paddle/phi/api/ext/op_meta_info.h index a9475db800816c569eaad306803f89b6b3a8fad9..fa19714dde7dba98d24b33c25ff07617f0d934a5 100644 --- a/paddle/phi/api/ext/op_meta_info.h +++ b/paddle/phi/api/ext/op_meta_info.h @@ -317,25 +317,24 @@ using InferShapeFunc = std::vector> (*)( const std::vector>>& vec_input_shapes, const std::vector& attrs); -#define PD_SPECIALIZE_InferShapeCallHelper_FOR_SHAPE(input_type) \ - template \ - struct InferShapeCallHelper { \ - template \ - static Return InferShape( \ - const std::vector>& input_shapes, \ - const std::vector>>& \ - vec_input_shapes, \ - const std::vector& attrs, \ - const PreviousArgs&... pargs) { \ - input_type arg = input_shapes[in_idx]; \ - return InferShapeCallHelper::template InferShape( \ - input_shapes, vec_input_shapes, attrs, pargs..., arg); \ - } \ +#define PD_SPECIALIZE_InferShapeCallHelper_FOR_SHAPE(input_type) \ + template \ + struct InferShapeCallHelper { \ + template \ + static Return InferShape( \ + const std::vector>& input_shapes, \ + const std::vector>>& \ + vec_input_shapes, \ + const std::vector& attrs, \ + const PreviousArgs&... pargs) { \ + input_type arg = input_shapes[in_idx]; \ + return InferShapeCallHelper:: \ + template InferShape( \ + input_shapes, vec_input_shapes, attrs, pargs..., arg); \ + } \ } #define PD_SPECIALIZE_InferShapeCallHelper_FOR_SHAPES(input_type) \ @@ -397,10 +396,8 @@ struct InferShapeFuncImpl { const std::vector>& input_shapes, const std::vector>>& vec_input_shapes, const std::vector& attrs) { - return InferShapeCallHelper>::template InferShape<0, - 0, - 0>( - input_shapes, vec_input_shapes, attrs); + return InferShapeCallHelper>:: + template InferShape<0, 0, 0>(input_shapes, vec_input_shapes, attrs); } private: @@ -482,20 +479,19 @@ using InferDtypeFunc = std::vector (*)( } \ } -#define PD_SPECIALIZE_InferDtypeCallHelper_FOR_DTYPES(input_type) \ - template \ - struct InferDtypeCallHelper { \ - template \ - static Return InferDtype( \ - const std::vector& input_dtypes, \ - const std::vector>& vec_input_dtypes, \ - const PreviousArgs&... pargs) { \ - input_type arg = vec_input_dtypes[vec_in_idx]; \ - return InferDtypeCallHelper::template InferDtype( \ - input_dtypes, vec_input_dtypes, pargs..., arg); \ - } \ +#define PD_SPECIALIZE_InferDtypeCallHelper_FOR_DTYPES(input_type) \ + template \ + struct InferDtypeCallHelper { \ + template \ + static Return InferDtype( \ + const std::vector& input_dtypes, \ + const std::vector>& vec_input_dtypes, \ + const PreviousArgs&... pargs) { \ + input_type arg = vec_input_dtypes[vec_in_idx]; \ + return InferDtypeCallHelper:: \ + template InferDtype( \ + input_dtypes, vec_input_dtypes, pargs..., arg); \ + } \ } template diff --git a/paddle/phi/api/lib/api_custom_impl.cc b/paddle/phi/api/lib/api_custom_impl.cc index 3ef7763d57e8b84ace86325b43aefe1c334488d8..5ca7f2b51edd2a4f769d2b3f309c00236b599e6e 100644 --- a/paddle/phi/api/lib/api_custom_impl.cc +++ b/paddle/phi/api/lib/api_custom_impl.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include "paddle/phi/api/lib/api_custom_impl.h" +#include "glog/logging.h" #include "paddle/phi/api/lib/api_gen_utils.h" #include "paddle/phi/api/lib/data_transform.h" #include "paddle/phi/api/lib/kernel_dispatch.h" @@ -28,8 +29,6 @@ limitations under the License. */ #include "paddle/phi/infermeta/nullary.h" #include "paddle/phi/infermeta/unary.h" -#include "glog/logging.h" - namespace paddle { namespace experimental { diff --git a/paddle/phi/api/lib/backend_set.h b/paddle/phi/api/lib/backend_set.h index 2aa4f969221d9c0f8936e7fc7c3a41cc04a63454..93f8f05b74b75290430fda723423ce121725f722 100644 --- a/paddle/phi/api/lib/backend_set.h +++ b/paddle/phi/api/lib/backend_set.h @@ -32,8 +32,9 @@ class BackendSet final { public: constexpr BackendSet() : bitset_(0) {} explicit constexpr BackendSet(Backend b) - : bitset_(b == Backend::UNDEFINED ? 0 : 1ULL << (static_cast(b) - - 1)) {} + : bitset_(b == Backend::UNDEFINED + ? 0 + : 1ULL << (static_cast(b) - 1)) {} inline uint64_t bitset() const { return bitset_; } diff --git a/paddle/phi/api/lib/data_transform.cc b/paddle/phi/api/lib/data_transform.cc index 12f7b8bba58705d58deffc3a6492ebbdc983bb43..4803616812cd01f76142542b8a52cd672bbfe5da 100644 --- a/paddle/phi/api/lib/data_transform.cc +++ b/paddle/phi/api/lib/data_transform.cc @@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +// clang-format off #include "paddle/phi/api/lib/data_transform.h" #include "paddle/phi/api/lib/kernel_dispatch.h" @@ -23,6 +24,7 @@ limitations under the License. */ #include "paddle/phi/kernels/transfer_layout_kernel.h" #include "paddle/fluid/framework/tensor_util.h" +// clang-format on namespace paddle { namespace experimental { diff --git a/paddle/phi/api/lib/sparse_api_custom_impl.cc b/paddle/phi/api/lib/sparse_api_custom_impl.cc index 71ba8eaae2d3653ebb8d5c7db5cf74e4bb901e6a..0b93c96e7f81d9afd1a22e6ce786c96ae3e84beb 100644 --- a/paddle/phi/api/lib/sparse_api_custom_impl.cc +++ b/paddle/phi/api/lib/sparse_api_custom_impl.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/phi/api/lib/sparse_api_custom_impl.h" #include + #include "glog/logging.h" #include "paddle/phi/api/lib/kernel_dispatch.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/api/lib/tensor.cc b/paddle/phi/api/lib/tensor.cc index a340c0fed10d871efc8bb018741d03afce1fd00f..74364d5ab03733fb212f0bffd80df046a5e847a5 100644 --- a/paddle/phi/api/lib/tensor.cc +++ b/paddle/phi/api/lib/tensor.cc @@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +// clang-format off #include "paddle/phi/api/include/tensor.h" #include @@ -34,6 +35,7 @@ limitations under the License. */ #include "paddle/phi/core/tensor_utils.h" #include "paddle/fluid/platform/stream/cuda_stream.h" +// clang-format off namespace paddle { namespace experimental { diff --git a/paddle/phi/api/lib/tensor_copy.cc b/paddle/phi/api/lib/tensor_copy.cc index 85de3601fd96add0405124e56e16beaa23e9b3bf..5f8c2ed71e9395508eaac787d86be70345471312 100644 --- a/paddle/phi/api/lib/tensor_copy.cc +++ b/paddle/phi/api/lib/tensor_copy.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/api/lib/tensor_copy.h" + #include "paddle/phi/api/lib/api_gen_utils.h" #include "paddle/phi/api/lib/kernel_dispatch.h" #include "paddle/phi/core/compat/convert_utils.h" diff --git a/paddle/phi/api/lib/tensor_method.cc b/paddle/phi/api/lib/tensor_method.cc index 5285392b4a6ac8cc67de57f0a5eaec2dbdd61bd0..fbeeb3332eadb9cf6319d1442fcf99746e7422d7 100644 --- a/paddle/phi/api/lib/tensor_method.cc +++ b/paddle/phi/api/lib/tensor_method.cc @@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +// clang-format off #include "paddle/phi/api/include/tensor.h" #include "paddle/phi/common/int_array.h" @@ -22,6 +23,7 @@ limitations under the License. */ #include "paddle/phi/api/lib/api_gen_utils.h" #include "paddle/phi/api/lib/kernel_dispatch.h" #include "paddle/phi/infermeta/unary.h" +// clang-format off namespace paddle { namespace experimental { diff --git a/paddle/phi/api/lib/utils/tensor_utils.h b/paddle/phi/api/lib/utils/tensor_utils.h index 36a0901bbe980694924e22907ca1fab1bcbb7224..f930f5b11f64fe2fba73258ae23fe3fd273711d3 100644 --- a/paddle/phi/api/lib/utils/tensor_utils.h +++ b/paddle/phi/api/lib/utils/tensor_utils.h @@ -18,7 +18,6 @@ limitations under the License. */ #include "paddle/fluid/framework/lod_tensor.h" #include "paddle/fluid/framework/variable.h" - #include "paddle/phi/api/lib/utils/allocator.h" #include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" diff --git a/paddle/phi/backends/callback_manager.cc b/paddle/phi/backends/callback_manager.cc index 4a958ef73bfc67d73bcf73f7d50d224beb6b8ae4..295f70fc65cd7f8930b95d1597d377630bef43ca 100644 --- a/paddle/phi/backends/callback_manager.cc +++ b/paddle/phi/backends/callback_manager.cc @@ -13,11 +13,12 @@ // limitations under the License. #include "paddle/phi/backends/callback_manager.h" -#include "paddle/fluid/platform/device/device_wrapper.h" -#include "paddle/fluid/platform/enforce.h" #include +#include "paddle/fluid/platform/device/device_wrapper.h" +#include "paddle/fluid/platform/enforce.h" + namespace phi { CallbackManager::CallbackManager(stream::Stream *stream) diff --git a/paddle/phi/backends/custom/custom_context.h b/paddle/phi/backends/custom/custom_context.h index 37b0ee21219b59a0a79d748f6cd4ab0bc289440b..57be8534fa95499a26d914feaa42d872ced86873 100644 --- a/paddle/phi/backends/custom/custom_context.h +++ b/paddle/phi/backends/custom/custom_context.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/phi/common/place.h" #include "paddle/phi/core/device_context.h" diff --git a/paddle/phi/backends/custom/custom_device_test.cc b/paddle/phi/backends/custom/custom_device_test.cc index 53b88f9b4ac7904b04e3786aae02719ce06f9204..51fa74b4dc5f36caf139e50f6635c50aedef925c 100644 --- a/paddle/phi/backends/custom/custom_device_test.cc +++ b/paddle/phi/backends/custom/custom_device_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include #include "paddle/fluid/framework/tensor.h" diff --git a/paddle/phi/backends/device_base.cc b/paddle/phi/backends/device_base.cc index b72c6efd51f2c23d7bdb3f2d72eafc868e26c43f..e57653702c538af4ce6301407907f04a9c759ba3 100644 --- a/paddle/phi/backends/device_base.cc +++ b/paddle/phi/backends/device_base.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/backends/device_base.h" + #include "gflags/gflags.h" #include "glog/logging.h" #include "paddle/phi/core/enforce.h" @@ -214,8 +215,9 @@ size_t DeviceInterface::AllocSize(size_t dev_id, bool realloc) { size_t flag_mb = realloc ? FLAGS_reallocate_gpu_memory_in_mb : FLAGS_initial_gpu_memory_in_mb; size_t alloc_bytes = - (flag_mb > 0ul ? flag_mb << 20 : available_to_alloc * - FLAGS_fraction_of_gpu_memory_to_use); + (flag_mb > 0ul + ? flag_mb << 20 + : available_to_alloc * FLAGS_fraction_of_gpu_memory_to_use); PADDLE_ENFORCE_GE(available_to_alloc, alloc_bytes, phi::errors::ResourceExhausted( diff --git a/paddle/phi/backends/device_ext.h b/paddle/phi/backends/device_ext.h index 749d8d323b62d1cfd7429f0f2b20da94de8e956f..ff58f4f35fd3277458cb920bf081d643e85f6193 100644 --- a/paddle/phi/backends/device_ext.h +++ b/paddle/phi/backends/device_ext.h @@ -34,7 +34,9 @@ typedef enum { C_INTERNAL_ERROR // plugin error } C_Status; -typedef struct C_Device_st { int id; } * C_Device; +typedef struct C_Device_st { + int id; +} * C_Device; typedef struct C_Stream_st* C_Stream; diff --git a/paddle/phi/backends/device_manager.h b/paddle/phi/backends/device_manager.h index 18d51687ef121c29e3a51021e9b9a58923ddb40d..56d99ba43bdd155d06f00e8f5413e5d79433d2cd 100644 --- a/paddle/phi/backends/device_manager.h +++ b/paddle/phi/backends/device_manager.h @@ -19,11 +19,10 @@ #include "paddle/phi/backends/device_base.h" #include "paddle/phi/backends/device_ext.h" +#include "paddle/phi/backends/dynload/port.h" #include "paddle/phi/backends/event.h" #include "paddle/phi/backends/stream.h" #include "paddle/phi/common/place.h" - -#include "paddle/phi/backends/dynload/port.h" #include "paddle/phi/core/utils/rw_lock.h" namespace phi { diff --git a/paddle/phi/backends/dynload/cublas.h b/paddle/phi/backends/dynload/cublas.h index ee0696fb4b2180bd56da93e35dc2f47c0e67de31..308ae2accef14613de3597b6d458ff05b99f183e 100644 --- a/paddle/phi/backends/dynload/cublas.h +++ b/paddle/phi/backends/dynload/cublas.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include // NOLINT #include diff --git a/paddle/phi/backends/dynload/cublasLt.h b/paddle/phi/backends/dynload/cublasLt.h index 4c7ac9c3f21c45a301dc947f32471f364ec12439..1e2a20ebdf4407cb5392e58dc36fbdb7747c30c8 100644 --- a/paddle/phi/backends/dynload/cublasLt.h +++ b/paddle/phi/backends/dynload/cublasLt.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include + #include // NOLINT #include diff --git a/paddle/phi/backends/dynload/cuda_driver.h b/paddle/phi/backends/dynload/cuda_driver.h index f4ea70a81b91fa329b2aad1448cc7a6b1f652b81..f743a33a1866fab7a968719f88041f15bf75884c 100644 --- a/paddle/phi/backends/dynload/cuda_driver.h +++ b/paddle/phi/backends/dynload/cuda_driver.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include // NOLINT #include "paddle/phi/backends/dynload/dynamic_loader.h" diff --git a/paddle/phi/backends/dynload/cudnn.cc b/paddle/phi/backends/dynload/cudnn.cc index 02d626d5f98f9fc0c260a55c846031634b68e144..8aa3b623273d77c2e50a68227e7d0e63bc9dc73e 100644 --- a/paddle/phi/backends/dynload/cudnn.cc +++ b/paddle/phi/backends/dynload/cudnn.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/backends/dynload/cudnn.h" + #include "paddle/fluid/platform/enforce.h" namespace phi { diff --git a/paddle/phi/backends/dynload/cudnn.h b/paddle/phi/backends/dynload/cudnn.h index a3afb98e3e636bbf78b944008bacc8c08caf38c5..7b9004308e95b3be3b0ace2699b8fed7d616bac5 100644 --- a/paddle/phi/backends/dynload/cudnn.h +++ b/paddle/phi/backends/dynload/cudnn.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #ifdef PADDLE_WITH_CUDA #include + #include // NOLINT #include "paddle/phi/backends/dynload/dynamic_loader.h" diff --git a/paddle/phi/backends/dynload/cufft.cc b/paddle/phi/backends/dynload/cufft.cc index 596a68c1ed6aad96942ddd2b5eee82b8102e2444..5a7080032d28d1690ce9208c72943058dcfca710 100644 --- a/paddle/phi/backends/dynload/cufft.cc +++ b/paddle/phi/backends/dynload/cufft.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/backends/dynload/cufft.h" + #include "paddle/fluid/platform/enforce.h" namespace phi { diff --git a/paddle/phi/backends/dynload/cufft.h b/paddle/phi/backends/dynload/cufft.h index 4697e335477ec668ebba66bd1aff5f083f2d3a7a..a27d7c3ab1eeec9da81cd5e320763e4d19aca5ed 100644 --- a/paddle/phi/backends/dynload/cufft.h +++ b/paddle/phi/backends/dynload/cufft.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include + #include // NOLINT #include "paddle/phi/backends/dynload/dynamic_loader.h" diff --git a/paddle/phi/backends/dynload/cupti.h b/paddle/phi/backends/dynload/cupti.h index a526fbfd926393701e2ebb076fa9208810d2be26..22e21b78f4f2e6806fe1f5db6b34a6188566ea31 100644 --- a/paddle/phi/backends/dynload/cupti.h +++ b/paddle/phi/backends/dynload/cupti.h @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include + #include // NOLINT #include "paddle/phi/backends/dynload/dynamic_loader.h" diff --git a/paddle/phi/backends/dynload/curand.h b/paddle/phi/backends/dynload/curand.h index 875403b03bb8171e7ccf0bde78a62bfe728bddb1..f3c4496dc4d399796f89328d3a0117490462c558 100644 --- a/paddle/phi/backends/dynload/curand.h +++ b/paddle/phi/backends/dynload/curand.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include // NOLINT #include "paddle/phi/backends/dynload/dynamic_loader.h" diff --git a/paddle/phi/backends/dynload/cusolver.h b/paddle/phi/backends/dynload/cusolver.h index 40e5f183dc0350967ee0b23d2a6128ce02e7bd8b..1354e310554804ea5d7402cb0cd62431365e285e 100644 --- a/paddle/phi/backends/dynload/cusolver.h +++ b/paddle/phi/backends/dynload/cusolver.h @@ -15,6 +15,7 @@ limitations under the License. */ #include #include + #include // NOLINT #include "paddle/phi/backends/dynload/dynamic_loader.h" diff --git a/paddle/phi/backends/dynload/cusparse.h b/paddle/phi/backends/dynload/cusparse.h index 8f7d54d55dbc49e567a602dc22ce693355e68d1a..a7e305f98d49a9d2c6a0030e9803af78458c931e 100644 --- a/paddle/phi/backends/dynload/cusparse.h +++ b/paddle/phi/backends/dynload/cusparse.h @@ -15,6 +15,7 @@ limitations under the License. */ #include #include + #include // NOLINT #include "paddle/phi/backends/dynload/dynamic_loader.h" diff --git a/paddle/phi/backends/dynload/hiprand.h b/paddle/phi/backends/dynload/hiprand.h index ccaf02d93047a42774a7b64b8ec1a03c9ee9bd97..3e9502dd94d911b0cc1329b9e7c09dad59435b26 100644 --- a/paddle/phi/backends/dynload/hiprand.h +++ b/paddle/phi/backends/dynload/hiprand.h @@ -16,9 +16,9 @@ limitations under the License. */ #include #include // NOLINT -#include "paddle/phi/backends/dynload/port.h" #include "paddle/phi/backends/dynload/dynamic_loader.h" +#include "paddle/phi/backends/dynload/port.h" namespace phi { namespace dynload { diff --git a/paddle/phi/backends/dynload/hiprtc.h b/paddle/phi/backends/dynload/hiprtc.h index 0404aad559394affbd26cf8c942e446186cf7b71..75dd88f87bd3aa9f1aea12ec8c8c68aff4f978ba 100644 --- a/paddle/phi/backends/dynload/hiprtc.h +++ b/paddle/phi/backends/dynload/hiprtc.h @@ -15,7 +15,9 @@ limitations under the License. */ #pragma once #include + #include // NOLINT + #include "paddle/phi/backends/dynload/dynamic_loader.h" #include "paddle/phi/backends/dynload/port.h" diff --git a/paddle/phi/backends/dynload/lapack.cc b/paddle/phi/backends/dynload/lapack.cc index bb03beabd4ffcb58badd68b613a0ac093a144406..9719da97751465de86333cb8d3cecf73c8e0014d 100644 --- a/paddle/phi/backends/dynload/lapack.cc +++ b/paddle/phi/backends/dynload/lapack.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/backends/dynload/lapack.h" + #include namespace phi { diff --git a/paddle/phi/backends/dynload/lapack.h b/paddle/phi/backends/dynload/lapack.h index c81c66c69282fac3c8bbf4ef5e30c50c8592b1b0..f0e1e9ad7a4c0009203d170a45ee792b51bbac11 100644 --- a/paddle/phi/backends/dynload/lapack.h +++ b/paddle/phi/backends/dynload/lapack.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/fluid/platform/complex.h" #include "paddle/phi/backends/dynload/dynamic_loader.h" #include "paddle/phi/backends/dynload/port.h" diff --git a/paddle/phi/backends/dynload/miopen.cc b/paddle/phi/backends/dynload/miopen.cc index e7916873ccfde7e1e5d0933045c9b44557f2f07a..9c58da1d6ff1ae05fdc3056b46567ab1c64e202e 100644 --- a/paddle/phi/backends/dynload/miopen.cc +++ b/paddle/phi/backends/dynload/miopen.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/backends/dynload/miopen.h" + #include "paddle/fluid/platform/enforce.h" namespace phi { diff --git a/paddle/phi/backends/dynload/miopen.h b/paddle/phi/backends/dynload/miopen.h index eb14bfe8ec543129aa68f779ea0734599dd4e05a..eeaf8028ec312402427fd9c23467a3a0996973a1 100644 --- a/paddle/phi/backends/dynload/miopen.h +++ b/paddle/phi/backends/dynload/miopen.h @@ -14,10 +14,11 @@ limitations under the License. */ #pragma once #include - #include #include + #include // NOLINT + #include "paddle/phi/backends/dynload/dynamic_loader.h" #include "paddle/phi/backends/dynload/port.h" diff --git a/paddle/phi/backends/dynload/mklml.h b/paddle/phi/backends/dynload/mklml.h index 5f5520a831eb163a3ee05cdd6ce86bd724057d3b..0f0c31f8064dffe6065c78c3d68c1bcf3bb592a0 100644 --- a/paddle/phi/backends/dynload/mklml.h +++ b/paddle/phi/backends/dynload/mklml.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include // NOLINT #include "paddle/phi/backends/dynload/dynamic_loader.h" diff --git a/paddle/phi/backends/dynload/mklrt.h b/paddle/phi/backends/dynload/mklrt.h index 8638d83d025bd6e6c8fafa6b32974fe65259d32d..0267fb69a5932cccc3d8d0161dd3ea63912066f5 100644 --- a/paddle/phi/backends/dynload/mklrt.h +++ b/paddle/phi/backends/dynload/mklrt.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include // NOLINT #include "paddle/phi/backends/dynload/dynamic_loader.h" diff --git a/paddle/phi/backends/dynload/nccl.h b/paddle/phi/backends/dynload/nccl.h index b04ef0f0651eb2c9f404603a81de564801e3dec1..6c73c562caa69701baf91839b27d07cd1b381d00 100644 --- a/paddle/phi/backends/dynload/nccl.h +++ b/paddle/phi/backends/dynload/nccl.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include // NOLINT #include "paddle/phi/backends/dynload/dynamic_loader.h" diff --git a/paddle/phi/backends/dynload/nvjpeg.h b/paddle/phi/backends/dynload/nvjpeg.h index 13bb8a5698f152a0371cd0270645f559c6482f00..6e71e6b582c059830152eca5c14c24699bc35c3a 100644 --- a/paddle/phi/backends/dynload/nvjpeg.h +++ b/paddle/phi/backends/dynload/nvjpeg.h @@ -12,6 +12,7 @@ limitations under the License. */ #ifdef PADDLE_WITH_CUDA #include + #include // NOLINT #include "paddle/phi/backends/dynload/dynamic_loader.h" diff --git a/paddle/phi/backends/dynload/nvrtc.h b/paddle/phi/backends/dynload/nvrtc.h index 516ca7686d253c690b5d496b4286b6ea25911e2e..9244e9487b2505a05466c89c9746182b7734dac9 100644 --- a/paddle/phi/backends/dynload/nvrtc.h +++ b/paddle/phi/backends/dynload/nvrtc.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include // NOLINT #include "paddle/phi/backends/dynload/dynamic_loader.h" diff --git a/paddle/phi/backends/dynload/nvtx.h b/paddle/phi/backends/dynload/nvtx.h index e9fd32668dc809296d9ed3f33e976161daf55a92..a9a166b289e3320c27f93d21a5a1daf2dfec821a 100644 --- a/paddle/phi/backends/dynload/nvtx.h +++ b/paddle/phi/backends/dynload/nvtx.h @@ -15,6 +15,7 @@ limitations under the License. */ #ifndef _WIN32 #include #include + #include // NOLINT #include "paddle/phi/backends/dynload/dynamic_loader.h" diff --git a/paddle/phi/backends/dynload/port.h b/paddle/phi/backends/dynload/port.h index 981e5f5af644eed10c4e7612c96ba242f5c2f286..d380993c9b67ae85b7fdc2aff7a0fa2af87fcbc7 100644 --- a/paddle/phi/backends/dynload/port.h +++ b/paddle/phi/backends/dynload/port.h @@ -28,6 +28,7 @@ #include // dladdr #include #include + #include // std::accumulate #else #ifndef NOMINMAX @@ -40,6 +41,7 @@ #include #include #include + #include // std::accumulate in msvc #ifndef S_ISDIR // windows port for sys/stat.h #define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR) diff --git a/paddle/phi/backends/dynload/rccl.h b/paddle/phi/backends/dynload/rccl.h index 4472684962832ebbd2d97c05faea419f23edafd0..2da35dc2df2db32cbe911e2a3302cafbc92e848e 100644 --- a/paddle/phi/backends/dynload/rccl.h +++ b/paddle/phi/backends/dynload/rccl.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include // NOLINT + #include "paddle/phi/backends/dynload/dynamic_loader.h" #include "paddle/phi/backends/dynload/port.h" diff --git a/paddle/phi/backends/dynload/rocblas.h b/paddle/phi/backends/dynload/rocblas.h index 18061b192e465655975ed2d4c52e9ff4151a6bfb..a9804b3d82a7de4c5c1c5fabc12de902640cb7d6 100644 --- a/paddle/phi/backends/dynload/rocblas.h +++ b/paddle/phi/backends/dynload/rocblas.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include // NOLINT #include diff --git a/paddle/phi/backends/dynload/rocm_driver.h b/paddle/phi/backends/dynload/rocm_driver.h index 59e35b787a5994f09641ad9ffcafbe8f4150222f..4e456db44c90403c4d1bce8e32faec5ecbbda831 100644 --- a/paddle/phi/backends/dynload/rocm_driver.h +++ b/paddle/phi/backends/dynload/rocm_driver.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include // NOLINT #include "paddle/phi/backends/dynload/dynamic_loader.h" diff --git a/paddle/phi/backends/dynload/tensorrt.cc b/paddle/phi/backends/dynload/tensorrt.cc index cc3b4e014608839e9196c4966f2ef53a96089d9a..45525701020250f8e1b060613284cf98d1a0bbf6 100644 --- a/paddle/phi/backends/dynload/tensorrt.cc +++ b/paddle/phi/backends/dynload/tensorrt.cc @@ -13,6 +13,7 @@ limitations under the License. */ #include "paddle/phi/backends/dynload/tensorrt.h" + #include namespace phi { diff --git a/paddle/phi/backends/event.cc b/paddle/phi/backends/event.cc index a474536f865c16e9f808f49a2e24b26f102c75d1..43077d280f360aa65baec850a4f0fac31cf53a4d 100644 --- a/paddle/phi/backends/event.cc +++ b/paddle/phi/backends/event.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/backends/event.h" + #include "paddle/fluid/platform/device/device_wrapper.h" #include "paddle/phi/backends/device_guard.h" #include "paddle/phi/backends/stream.h" diff --git a/paddle/phi/backends/gpu/cuda/cuda_helper.h b/paddle/phi/backends/gpu/cuda/cuda_helper.h index 08670832c775f5bba61c3b03f111fee8f9048f8a..c62addfd257ab961803f4bccf33f689db3ffa90f 100644 --- a/paddle/phi/backends/gpu/cuda/cuda_helper.h +++ b/paddle/phi/backends/gpu/cuda/cuda_helper.h @@ -60,7 +60,7 @@ namespace gpu { * } * } * -*/ + */ #define CUDA_KERNEL_LOOP_TYPE(i, num, index_type) \ int64_t __index__ = blockIdx.x * blockDim.x + threadIdx.x; \ diff --git a/paddle/phi/backends/gpu/gpu_context.cc b/paddle/phi/backends/gpu/gpu_context.cc index e8c264b884fe3105dcab540846639f433b647fda..f51f287ee4a0848fc41901daeccbdac07eff270a 100644 --- a/paddle/phi/backends/gpu/gpu_context.cc +++ b/paddle/phi/backends/gpu/gpu_context.cc @@ -23,7 +23,6 @@ limitations under the License. */ #include #include "glog/logging.h" - #include "paddle/phi/api/ext/exception.h" #include "paddle/phi/backends/gpu/gpu_decls.h" #include "paddle/phi/backends/gpu/gpu_info.h" diff --git a/paddle/phi/backends/gpu/gpu_context.h b/paddle/phi/backends/gpu/gpu_context.h index db9f287041dfb3a98efc6ae4edc2ce2e7a2d7a8f..5246155131dbeace56d9eff26fb51e0139e2732a 100644 --- a/paddle/phi/backends/gpu/gpu_context.h +++ b/paddle/phi/backends/gpu/gpu_context.h @@ -18,6 +18,7 @@ limitations under the License. */ #include #include #include + #include "paddle/phi/backends/gpu/forwards.h" #include "paddle/phi/backends/gpu/gpu_decls.h" #include "paddle/phi/backends/gpu/gpu_helper.h" diff --git a/paddle/phi/backends/gpu/gpu_info.h b/paddle/phi/backends/gpu/gpu_info.h index 443830acf47932db89e6b5a553a8ca32db01ea86..323565c000a1c38cc0cefa2746845a7b276972e6 100644 --- a/paddle/phi/backends/gpu/gpu_info.h +++ b/paddle/phi/backends/gpu/gpu_info.h @@ -14,6 +14,7 @@ limitations under the License. */ #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) #include + #include #include #include diff --git a/paddle/phi/backends/gpu/gpu_launch_config.h b/paddle/phi/backends/gpu/gpu_launch_config.h index 888b44632ea28076dd6623a727f8f73e20361608..2dd1431ff58bb4ed09e08d925206561432c81a44 100644 --- a/paddle/phi/backends/gpu/gpu_launch_config.h +++ b/paddle/phi/backends/gpu/gpu_launch_config.h @@ -25,9 +25,11 @@ #endif #include + #include #include #include + #include "paddle/phi/backends/gpu/gpu_context.h" #include "paddle/phi/core/enforce.h" @@ -95,9 +97,9 @@ struct GpuLaunchConfig { }; /* According to NVIDIA, if number of threads per block is 64/128/256/512, - * cuda performs better. And number of blocks should be greater (at least - * 2x~4x) than number of SMs. Hence, SM count is took into account within - * this function to determine the right number of threads per block. */ + * cuda performs better. And number of blocks should be greater (at least + * 2x~4x) than number of SMs. Hence, SM count is took into account within + * this function to determine the right number of threads per block. */ inline GpuLaunchConfig GetGpuLaunchConfig1D(const phi::GPUContext& context, int64_t numel, int vec_size = 1) { diff --git a/paddle/phi/backends/gpu/gpu_resources.h b/paddle/phi/backends/gpu/gpu_resources.h index 07ccb6215409ace02eff84aedb460aba1e14f884..7bec5eebf5886f4caefed1a21acc2f6435b3968d 100644 --- a/paddle/phi/backends/gpu/gpu_resources.h +++ b/paddle/phi/backends/gpu/gpu_resources.h @@ -14,6 +14,7 @@ #pragma once #include + #include "paddle/phi/backends/gpu/gpu_decls.h" #include "paddle/phi/common/place.h" diff --git a/paddle/phi/backends/gpu/rocm/rocm_helper.h b/paddle/phi/backends/gpu/rocm/rocm_helper.h index 2d75b6ea4cb7109a4ac262143d50ebbc5de5d329..14e9ca660bdf90362053111801c885c809e69475 100644 --- a/paddle/phi/backends/gpu/rocm/rocm_helper.h +++ b/paddle/phi/backends/gpu/rocm/rocm_helper.h @@ -60,7 +60,7 @@ namespace gpu { * } * } * -*/ + */ #define CUDA_KERNEL_LOOP_TYPE(i, num, index_type) \ int64_t __index__ = hipBlockIdx_x * hipBlockDim_x + hipThreadIdx_x; \ diff --git a/paddle/phi/backends/gpu/rocm/rocm_info.cc b/paddle/phi/backends/gpu/rocm/rocm_info.cc index 23e58d34b25725c048a39244d27f0afd0a917e0f..b89d5a3c1624fca814f0fd2ef438944076b1de9c 100644 --- a/paddle/phi/backends/gpu/rocm/rocm_info.cc +++ b/paddle/phi/backends/gpu/rocm/rocm_info.cc @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "paddle/phi/backends/gpu/gpu_info.h" // TODO(phi): remove fluid headers. diff --git a/paddle/phi/backends/stream.cc b/paddle/phi/backends/stream.cc index 30939f31fcc3c80931cf627451f46cb620dc21df..f8b15bdbd9e633ff49694664194d8abc6a17744e 100644 --- a/paddle/phi/backends/stream.cc +++ b/paddle/phi/backends/stream.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/backends/stream.h" + #include "paddle/fluid/platform/device/device_wrapper.h" #include "paddle/phi/backends/device_guard.h" #include "paddle/phi/backends/event.h" diff --git a/paddle/phi/backends/xpu/enforce_xpu.h b/paddle/phi/backends/xpu/enforce_xpu.h index 29b048ead852dd91788316c2284b438d7dcbd61c..30095e3a0074a18c41161ce41ba2b117a8874e02 100644 --- a/paddle/phi/backends/xpu/enforce_xpu.h +++ b/paddle/phi/backends/xpu/enforce_xpu.h @@ -14,11 +14,10 @@ limitations under the License. */ #pragma once +#include "paddle/fluid/platform/enforce.h" #include "paddle/phi/backends/xpu/xpu_header.h" #include "xpu/bkcl.h" -#include "paddle/fluid/platform/enforce.h" - namespace phi { namespace backends { namespace xpu { diff --git a/paddle/phi/backends/xpu/xpu_context.cc b/paddle/phi/backends/xpu/xpu_context.cc index 7cc9eb44bc48886d2f8c6ecb45977685251f279f..dbff88c0a2709dfd80fd81c63ce27d0ca90fa571 100644 --- a/paddle/phi/backends/xpu/xpu_context.cc +++ b/paddle/phi/backends/xpu/xpu_context.cc @@ -18,7 +18,6 @@ #include "paddle/phi/api/ext/exception.h" #include "paddle/phi/common/place.h" - #include "xpu/runtime.h" #include "xpu/runtime_ex.h" #include "xpu/xdnn.h" @@ -86,8 +85,8 @@ struct XPUContext::Impl { void Init() { owned_ = true; backends::xpu::XPUDeviceGuard guard(place_.GetDeviceId()); - LOG_FIRST_N(WARNING, 1) << "Please NOTE: xpu device: " - << static_cast(place_.device); + LOG_FIRST_N(WARNING, 1) + << "Please NOTE: xpu device: " << static_cast(place_.device); context_ = xpu::create_context(); xpu_version_ = backends::xpu::get_xpu_version(place_.device); SetL3Cache(); diff --git a/paddle/phi/backends/xpu/xpu_context.h b/paddle/phi/backends/xpu/xpu_context.h index b87489c567cabea137850163879ed00d151f60cb..d39b3c9cc1ff77be6d2a07751784088addc0154c 100644 --- a/paddle/phi/backends/xpu/xpu_context.h +++ b/paddle/phi/backends/xpu/xpu_context.h @@ -15,12 +15,12 @@ limitations under the License. */ #pragma once #include -#include "paddle/phi/backends/xpu/forwards.h" -#include "paddle/phi/common/place.h" -#include "paddle/phi/core/device_context.h" +#include "paddle/phi/backends/xpu/forwards.h" #include "paddle/phi/backends/xpu/xpu_header.h" #include "paddle/phi/backends/xpu/xpu_info.h" +#include "paddle/phi/common/place.h" +#include "paddle/phi/core/device_context.h" namespace xpu = baidu::xpu::api; diff --git a/paddle/phi/backends/xpu/xpu_header.h b/paddle/phi/backends/xpu/xpu_header.h index 5337f78c64207aa2148fbbbd4f9c213fe165369e..1fe6f6d07796fa60245865906370922a57d3dd2a 100644 --- a/paddle/phi/backends/xpu/xpu_header.h +++ b/paddle/phi/backends/xpu/xpu_header.h @@ -22,7 +22,6 @@ limitations under the License. */ #include "paddle/fluid/platform/enforce.h" #include "paddle/phi/common/bfloat16.h" #include "paddle/phi/common/float16.h" - #include "xpu/runtime.h" #include "xpu/runtime_ex.h" #include "xpu/xdnn.h" diff --git a/paddle/phi/backends/xpu/xpu_info.h b/paddle/phi/backends/xpu/xpu_info.h index b1056cdc4b14bf4abe80984563027f60eda1b283..9d5f073eaa8e62841c63b48fa32648ba0452c6a3 100644 --- a/paddle/phi/backends/xpu/xpu_info.h +++ b/paddle/phi/backends/xpu/xpu_info.h @@ -12,6 +12,7 @@ limitations under the License. */ #include #include + #include "paddle/phi/common/place.h" namespace phi { diff --git a/paddle/phi/common/data_type.h b/paddle/phi/common/data_type.h index 1792cb9370673bdbcaeeae2d1fccb5cd871e7e19..ef9b42504829859f23a379ecc3d7b43d2fef6acd 100644 --- a/paddle/phi/common/data_type.h +++ b/paddle/phi/common/data_type.h @@ -14,11 +14,10 @@ limitations under the License. */ #pragma once +#include "paddle/phi/api/ext/exception.h" #include "paddle/phi/common/bfloat16.h" #include "paddle/phi/common/complex.h" #include "paddle/phi/common/float16.h" - -#include "paddle/phi/api/ext/exception.h" #include "paddle/phi/common/pstring.h" namespace paddle { diff --git a/paddle/phi/common/int_array.cc b/paddle/phi/common/int_array.cc index daed2b6625a9e2837d84cbbd7762740302f425a1..81701ee010ca29e5e31af7a05bc424a4225544c9 100644 --- a/paddle/phi/common/int_array.cc +++ b/paddle/phi/common/int_array.cc @@ -14,9 +14,8 @@ limitations under the License. */ #include "paddle/phi/common/int_array.h" -#include "paddle/phi/common/place.h" - #include "paddle/fluid/framework/tensor_util.h" +#include "paddle/phi/common/place.h" namespace paddle { namespace experimental { diff --git a/paddle/phi/common/place.cc b/paddle/phi/common/place.cc index 667d0a32b93da3f6b82a21f93c14927cb7db81d0..c15a17651b18bebbde14ad213ff79f83165aa3bf 100644 --- a/paddle/phi/common/place.cc +++ b/paddle/phi/common/place.cc @@ -19,7 +19,6 @@ limitations under the License. */ #include #include "glog/logging.h" - #include "paddle/phi/api/ext/exception.h" namespace phi { diff --git a/paddle/phi/common/scalar.cc b/paddle/phi/common/scalar.cc index 41f1c9541823dbecc83ddc73540cae7255dc0199..2954af086ac4c4ea45a416e94d46a30a63533d2e 100644 --- a/paddle/phi/common/scalar.cc +++ b/paddle/phi/common/scalar.cc @@ -14,11 +14,10 @@ limitations under the License. */ #include "paddle/phi/common/scalar.h" -#include "paddle/phi/common/place.h" -#include "paddle/phi/core/enforce.h" - #include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/platform/place.h" +#include "paddle/phi/common/place.h" +#include "paddle/phi/core/enforce.h" namespace paddle { namespace experimental { diff --git a/paddle/phi/core/compat/op_utils.h b/paddle/phi/core/compat/op_utils.h index 8eb6524e79c0f7b3e3551f898544aef2348a28be..ae3b8924ece696de7ad0c48faf8144d64d014264 100644 --- a/paddle/phi/core/compat/op_utils.h +++ b/paddle/phi/core/compat/op_utils.h @@ -18,7 +18,6 @@ limitations under the License. */ #include #include "glog/logging.h" - #include "paddle/phi/core/compat/arg_map_context.h" #include "paddle/phi/core/enforce.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/phi/core/ddim.h b/paddle/phi/core/ddim.h index dd13081ddafffab4557f03fd722d0d31021fb1db..794d7051aee58e4fc63c40f2d7dd361ed6b834ba 100644 --- a/paddle/phi/core/ddim.h +++ b/paddle/phi/core/ddim.h @@ -238,10 +238,10 @@ int arity(const DDim& ddim); std::ostream& operator<<(std::ostream&, const DDim&); /** -* \brief Flatten dim to 3d -* e.g., DDim d = mak_ddim({1, 2, 3, 4, 5, 6}) -* flatten_to_3d(d, 2, 4); ===> {1*2, 3*4, 5*6} ===> {2, 12, 30} -*/ + * \brief Flatten dim to 3d + * e.g., DDim d = mak_ddim({1, 2, 3, 4, 5, 6}) + * flatten_to_3d(d, 2, 4); ===> {1*2, 3*4, 5*6} ===> {2, 12, 30} + */ DDim flatten_to_3d(const DDim& src, int num_row_dims, int num_col_dims); // Reshape a tensor to a matrix. The matrix's first dimension(column length) diff --git a/paddle/phi/core/dense_tensor.h b/paddle/phi/core/dense_tensor.h index 06d3e435bc110f51f2391b6f5b6f3f17a94bf1c9..09098705b11e44a1acad18e1e16d22a7bef6f741 100644 --- a/paddle/phi/core/dense_tensor.h +++ b/paddle/phi/core/dense_tensor.h @@ -20,7 +20,7 @@ limitations under the License. */ #include "paddle/phi/core/tensor_meta.h" /* @jim19930609: Move to MKLDNN_Tensor in the future - */ + */ #ifdef PADDLE_WITH_MKLDNN #include "dnnl.hpp" #endif diff --git a/paddle/phi/core/dense_tensor_impl.cc b/paddle/phi/core/dense_tensor_impl.cc index 8c97b6bf223fbd4ec23819cbd190d7fb3412c187..a59b910b7e0069e79bf710c367c322927805b2cd 100644 --- a/paddle/phi/core/dense_tensor_impl.cc +++ b/paddle/phi/core/dense_tensor_impl.cc @@ -12,15 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/phi/core/dense_tensor.h" - +#include "paddle/fluid/memory/malloc.h" #include "paddle/phi/common/bfloat16.h" #include "paddle/phi/common/complex.h" #include "paddle/phi/common/float16.h" - #include "paddle/phi/core/compat/convert_utils.h" - -#include "paddle/fluid/memory/malloc.h" +#include "paddle/phi/core/dense_tensor.h" #ifdef PADDLE_WITH_MKLDNN #include "paddle/fluid/platform/mkldnn_utils.h" diff --git a/paddle/phi/core/device_context.cc b/paddle/phi/core/device_context.cc index 0f5f22b5bd1f47f4a27bd769bd24e968aea5581b..ce57f4f627baad260ee0634a166f674d0cd19f09 100644 --- a/paddle/phi/core/device_context.cc +++ b/paddle/phi/core/device_context.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/core/device_context.h" + #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/enforce.h" #include "paddle/phi/core/selected_rows.h" diff --git a/paddle/phi/core/device_context.h b/paddle/phi/core/device_context.h index d7c2c777ca6328d072316de99ab27a5f1c13fa14..45e4fbf64dc04383e74b2c38f5b69766c91111ad 100644 --- a/paddle/phi/core/device_context.h +++ b/paddle/phi/core/device_context.h @@ -75,17 +75,17 @@ class PADDLE_API DeviceContext { void SetHostAllocator(const Allocator*); /** - * @brief Set the zero-size Allocator object. - * - * @param allocator - */ + * @brief Set the zero-size Allocator object. + * + * @param allocator + */ void SetZeroAllocator(const Allocator*); /** - * @brief Set the zero-size Allocator object. - * - * @param allocator - */ + * @brief Set the zero-size Allocator object. + * + * @param allocator + */ void SetPinnedAllocator(const Allocator*); /** @@ -135,10 +135,10 @@ class PADDLE_API DeviceContext { virtual void Wait() const {} /** - * @brief Set the generator for special op. - * - * @param Generator - */ + * @brief Set the generator for special op. + * + * @param Generator + */ void SetGenerator(Generator*); /** * @brief Get the generator object. @@ -148,10 +148,10 @@ class PADDLE_API DeviceContext { Generator* GetGenerator() const; /** - * @brief Set the host generator for special op. - * - * @param Generator - */ + * @brief Set the host generator for special op. + * + * @param Generator + */ void SetHostGenerator(Generator*); /** * @brief Get the host generator object. diff --git a/paddle/phi/core/enforce.cc b/paddle/phi/core/enforce.cc index ae6b0135b3222effa7207c3fc28d4af6cbf1a7be..91e0316ff75589ef748c619d9b683fc2dfb56bfc 100644 --- a/paddle/phi/core/enforce.cc +++ b/paddle/phi/core/enforce.cc @@ -14,13 +14,12 @@ limitations under the License. */ #include "paddle/phi/core/enforce.h" +#include #include #include #include #include -#include - // is not suitable to be placed in the header file, // it will introduce a large number of unnecessary includes, and these type // declarations that depend on boost are also not suitable for the phi header diff --git a/paddle/phi/core/hostdevice.h b/paddle/phi/core/hostdevice.h index 0869df143235fcd937d75e7dba908c4efbd7ee95..decebbe66a5381a0d0e3b2ed94c9649013fbc7de 100644 --- a/paddle/phi/core/hostdevice.h +++ b/paddle/phi/core/hostdevice.h @@ -20,6 +20,7 @@ #if defined(__xpu__) #include + #include "xpu/kernel/cluster_header.h" #include "xpu/kernel/debug.h" #include "xpu/kernel/math.h" diff --git a/paddle/phi/core/kernel_factory.cc b/paddle/phi/core/kernel_factory.cc index d479147f06ba186a04d985fc3e974837fbc55fbd..d864544e10dd8da43f3f922a69f01f30409f17f3 100644 --- a/paddle/phi/core/kernel_factory.cc +++ b/paddle/phi/core/kernel_factory.cc @@ -15,7 +15,6 @@ #include "paddle/phi/core/kernel_factory.h" #include "glog/logging.h" - #include "paddle/phi/core/enforce.h" namespace phi { diff --git a/paddle/phi/core/kernel_registry.h b/paddle/phi/core/kernel_registry.h index 41e1e2b53a9e9fd94a99b32e19841376ae8180c2..65f655d50375cbd320d6222d5c86d6a542e9009e 100644 --- a/paddle/phi/core/kernel_registry.h +++ b/paddle/phi/core/kernel_registry.h @@ -22,13 +22,12 @@ #include #include "paddle/phi/core/custom_kernel.h" +#include "paddle/phi/core/enforce.h" #include "paddle/phi/core/kernel_factory.h" #include "paddle/phi/core/kernel_utils.h" #include "paddle/phi/core/macros.h" #include "paddle/phi/core/type_defs.h" -#include "paddle/phi/core/enforce.h" - namespace phi { #define BACKEND(arg__) phi::Backend::arg__ @@ -58,16 +57,13 @@ struct KernelArgsParseFunctor { for (auto arg_type : args_type) { if (arg_type == std::type_index(typeid(const CPUContext&)) #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) - || - arg_type == std::type_index(typeid(const GPUContext&))) { + || arg_type == std::type_index(typeid(const GPUContext&))) { #elif defined(PADDLE_WITH_XPU) - || - arg_type == std::type_index(typeid(const XPUContext&))) { + || arg_type == std::type_index(typeid(const XPUContext&))) { #elif defined(PADDLE_WITH_CUSTOM_DEVICE) - || - arg_type == std::type_index(typeid(const CustomContext&))) { + || arg_type == std::type_index(typeid(const CustomContext&))) { #else - ) { + ) { #endif // do nothing, skip context arg now } else if (arg_type == std::type_index(typeid(const DenseTensor&))) { @@ -420,93 +416,93 @@ struct KernelRegistrar { PD_CONCATENATE(_PD_KERNEL_INSTANTIATION_, N) \ (meta_kernel_fn, backend, context, __VA_ARGS__) -#define _PD_KERNEL_INSTANTIATION_1( \ - meta_kernel_fn, backend, context, cpp_dtype) \ - template decltype( \ - meta_kernel_fn) meta_kernel_fn -#define _PD_KERNEL_INSTANTIATION_2( \ - meta_kernel_fn, backend, context, cpp_dtype, ...) \ - template decltype( \ - meta_kernel_fn) meta_kernel_fn; \ - PD_EXPAND(_PD_KERNEL_INSTANTIATION_1( \ +#define _PD_KERNEL_INSTANTIATION_1( \ + meta_kernel_fn, backend, context, cpp_dtype) \ + template decltype(meta_kernel_fn) \ + meta_kernel_fn +#define _PD_KERNEL_INSTANTIATION_2( \ + meta_kernel_fn, backend, context, cpp_dtype, ...) \ + template decltype(meta_kernel_fn) \ + meta_kernel_fn; \ + PD_EXPAND(_PD_KERNEL_INSTANTIATION_1( \ meta_kernel_fn, backend, context, __VA_ARGS__)) -#define _PD_KERNEL_INSTANTIATION_3( \ - meta_kernel_fn, backend, context, cpp_dtype, ...) \ - template decltype( \ - meta_kernel_fn) meta_kernel_fn; \ - PD_EXPAND(_PD_KERNEL_INSTANTIATION_2( \ +#define _PD_KERNEL_INSTANTIATION_3( \ + meta_kernel_fn, backend, context, cpp_dtype, ...) \ + template decltype(meta_kernel_fn) \ + meta_kernel_fn; \ + PD_EXPAND(_PD_KERNEL_INSTANTIATION_2( \ meta_kernel_fn, backend, context, __VA_ARGS__)) -#define _PD_KERNEL_INSTANTIATION_4( \ - meta_kernel_fn, backend, context, cpp_dtype, ...) \ - template decltype( \ - meta_kernel_fn) meta_kernel_fn; \ - PD_EXPAND(_PD_KERNEL_INSTANTIATION_3( \ +#define _PD_KERNEL_INSTANTIATION_4( \ + meta_kernel_fn, backend, context, cpp_dtype, ...) \ + template decltype(meta_kernel_fn) \ + meta_kernel_fn; \ + PD_EXPAND(_PD_KERNEL_INSTANTIATION_3( \ meta_kernel_fn, backend, context, __VA_ARGS__)) -#define _PD_KERNEL_INSTANTIATION_5( \ - meta_kernel_fn, backend, context, cpp_dtype, ...) \ - template decltype( \ - meta_kernel_fn) meta_kernel_fn; \ - PD_EXPAND(_PD_KERNEL_INSTANTIATION_4( \ +#define _PD_KERNEL_INSTANTIATION_5( \ + meta_kernel_fn, backend, context, cpp_dtype, ...) \ + template decltype(meta_kernel_fn) \ + meta_kernel_fn; \ + PD_EXPAND(_PD_KERNEL_INSTANTIATION_4( \ meta_kernel_fn, backend, context, __VA_ARGS__)) -#define _PD_KERNEL_INSTANTIATION_6( \ - meta_kernel_fn, backend, context, cpp_dtype, ...) \ - template decltype( \ - meta_kernel_fn) meta_kernel_fn; \ - PD_EXPAND(_PD_KERNEL_INSTANTIATION_5( \ +#define _PD_KERNEL_INSTANTIATION_6( \ + meta_kernel_fn, backend, context, cpp_dtype, ...) \ + template decltype(meta_kernel_fn) \ + meta_kernel_fn; \ + PD_EXPAND(_PD_KERNEL_INSTANTIATION_5( \ meta_kernel_fn, backend, context, __VA_ARGS__)) -#define _PD_KERNEL_INSTANTIATION_7( \ - meta_kernel_fn, backend, context, cpp_dtype, ...) \ - template decltype( \ - meta_kernel_fn) meta_kernel_fn; \ - PD_EXPAND(_PD_KERNEL_INSTANTIATION_6( \ +#define _PD_KERNEL_INSTANTIATION_7( \ + meta_kernel_fn, backend, context, cpp_dtype, ...) \ + template decltype(meta_kernel_fn) \ + meta_kernel_fn; \ + PD_EXPAND(_PD_KERNEL_INSTANTIATION_6( \ meta_kernel_fn, backend, context, __VA_ARGS__)) -#define _PD_KERNEL_INSTANTIATION_8( \ - meta_kernel_fn, backend, context, cpp_dtype, ...) \ - template decltype( \ - meta_kernel_fn) meta_kernel_fn; \ - PD_EXPAND(_PD_KERNEL_INSTANTIATION_7( \ +#define _PD_KERNEL_INSTANTIATION_8( \ + meta_kernel_fn, backend, context, cpp_dtype, ...) \ + template decltype(meta_kernel_fn) \ + meta_kernel_fn; \ + PD_EXPAND(_PD_KERNEL_INSTANTIATION_7( \ meta_kernel_fn, backend, context, __VA_ARGS__)) -#define _PD_KERNEL_INSTANTIATION_9( \ - meta_kernel_fn, backend, context, cpp_dtype, ...) \ - template decltype( \ - meta_kernel_fn) meta_kernel_fn; \ - PD_EXPAND(_PD_KERNEL_INSTANTIATION_8( \ +#define _PD_KERNEL_INSTANTIATION_9( \ + meta_kernel_fn, backend, context, cpp_dtype, ...) \ + template decltype(meta_kernel_fn) \ + meta_kernel_fn; \ + PD_EXPAND(_PD_KERNEL_INSTANTIATION_8( \ meta_kernel_fn, backend, context, __VA_ARGS__)) -#define _PD_KERNEL_INSTANTIATION_10( \ - meta_kernel_fn, backend, context, cpp_dtype, ...) \ - template decltype( \ - meta_kernel_fn) meta_kernel_fn; \ - PD_EXPAND(_PD_KERNEL_INSTANTIATION_9( \ +#define _PD_KERNEL_INSTANTIATION_10( \ + meta_kernel_fn, backend, context, cpp_dtype, ...) \ + template decltype(meta_kernel_fn) \ + meta_kernel_fn; \ + PD_EXPAND(_PD_KERNEL_INSTANTIATION_9( \ meta_kernel_fn, backend, context, __VA_ARGS__)) -#define _PD_KERNEL_INSTANTIATION_11( \ - meta_kernel_fn, backend, context, cpp_dtype, ...) \ - template decltype( \ - meta_kernel_fn) meta_kernel_fn; \ - PD_EXPAND(_PD_KERNEL_INSTANTIATION_10( \ +#define _PD_KERNEL_INSTANTIATION_11( \ + meta_kernel_fn, backend, context, cpp_dtype, ...) \ + template decltype(meta_kernel_fn) \ + meta_kernel_fn; \ + PD_EXPAND(_PD_KERNEL_INSTANTIATION_10( \ meta_kernel_fn, backend, context, __VA_ARGS__)) -#define _PD_KERNEL_INSTANTIATION_12( \ - meta_kernel_fn, backend, context, cpp_dtype, ...) \ - template decltype( \ - meta_kernel_fn) meta_kernel_fn; \ - PD_EXPAND(_PD_KERNEL_INSTANTIATION_11( \ +#define _PD_KERNEL_INSTANTIATION_12( \ + meta_kernel_fn, backend, context, cpp_dtype, ...) \ + template decltype(meta_kernel_fn) \ + meta_kernel_fn; \ + PD_EXPAND(_PD_KERNEL_INSTANTIATION_11( \ meta_kernel_fn, backend, context, __VA_ARGS__)) -#define _PD_KERNEL_INSTANTIATION_13( \ - meta_kernel_fn, backend, context, cpp_dtype, ...) \ - template decltype( \ - meta_kernel_fn) meta_kernel_fn; \ - PD_EXPAND(_PD_KERNEL_INSTANTIATION_12( \ +#define _PD_KERNEL_INSTANTIATION_13( \ + meta_kernel_fn, backend, context, cpp_dtype, ...) \ + template decltype(meta_kernel_fn) \ + meta_kernel_fn; \ + PD_EXPAND(_PD_KERNEL_INSTANTIATION_12( \ meta_kernel_fn, backend, context, __VA_ARGS__)) -#define _PD_KERNEL_INSTANTIATION_14( \ - meta_kernel_fn, backend, context, cpp_dtype, ...) \ - template decltype( \ - meta_kernel_fn) meta_kernel_fn; \ - PD_EXPAND(_PD_KERNEL_INSTANTIATION_13( \ +#define _PD_KERNEL_INSTANTIATION_14( \ + meta_kernel_fn, backend, context, cpp_dtype, ...) \ + template decltype(meta_kernel_fn) \ + meta_kernel_fn; \ + PD_EXPAND(_PD_KERNEL_INSTANTIATION_13( \ meta_kernel_fn, backend, context, __VA_ARGS__)) -#define _PD_KERNEL_INSTANTIATION_15( \ - meta_kernel_fn, backend, context, cpp_dtype, ...) \ - template decltype( \ - meta_kernel_fn) meta_kernel_fn; \ - PD_EXPAND(_PD_KERNEL_INSTANTIATION_14( \ +#define _PD_KERNEL_INSTANTIATION_15( \ + meta_kernel_fn, backend, context, cpp_dtype, ...) \ + template decltype(meta_kernel_fn) \ + meta_kernel_fn; \ + PD_EXPAND(_PD_KERNEL_INSTANTIATION_14( \ meta_kernel_fn, backend, context, __VA_ARGS__)) #define PD_KERNEL_REGISTRAR_INIT(reg_type, \ @@ -569,8 +565,8 @@ struct KernelRegistrar { #backend, \ DATALAYOUT(layout), \ ::paddle::experimental::CppTypeToDataType::Type(), \ - ::phi::KernelArgsParseFunctor)>::Parse, \ + ::phi::KernelArgsParseFunctor< \ + decltype(&meta_kernel_fn)>::Parse, \ args_def_fn, \ PHI_KERNEL(meta_kernel_fn), \ PHI_VARIADIC_KERNEL(meta_kernel_fn)); \ @@ -592,8 +588,8 @@ struct KernelRegistrar { #backend, \ DATALAYOUT(layout), \ ::paddle::experimental::CppTypeToDataType::Type(), \ - ::phi::KernelArgsParseFunctor)>::Parse, \ + ::phi::KernelArgsParseFunctor< \ + decltype(&meta_kernel_fn)>::Parse, \ args_def_fn, \ PHI_KERNEL(meta_kernel_fn), \ PHI_VARIADIC_KERNEL(meta_kernel_fn)); \ @@ -623,8 +619,8 @@ struct KernelRegistrar { #backend, \ DATALAYOUT(layout), \ ::paddle::experimental::CppTypeToDataType::Type(), \ - ::phi::KernelArgsParseFunctor)>::Parse, \ + ::phi::KernelArgsParseFunctor< \ + decltype(&meta_kernel_fn)>::Parse, \ args_def_fn, \ PHI_KERNEL(meta_kernel_fn), \ PHI_VARIADIC_KERNEL(meta_kernel_fn)); \ @@ -654,8 +650,8 @@ struct KernelRegistrar { #backend, \ DATALAYOUT(layout), \ ::paddle::experimental::CppTypeToDataType::Type(), \ - ::phi::KernelArgsParseFunctor)>::Parse, \ + ::phi::KernelArgsParseFunctor< \ + decltype(&meta_kernel_fn)>::Parse, \ args_def_fn, \ PHI_KERNEL(meta_kernel_fn), \ PHI_VARIADIC_KERNEL(meta_kernel_fn)); \ @@ -685,8 +681,8 @@ struct KernelRegistrar { #backend, \ DATALAYOUT(layout), \ ::paddle::experimental::CppTypeToDataType::Type(), \ - ::phi::KernelArgsParseFunctor)>::Parse, \ + ::phi::KernelArgsParseFunctor< \ + decltype(&meta_kernel_fn)>::Parse, \ args_def_fn, \ PHI_KERNEL(meta_kernel_fn), \ PHI_VARIADIC_KERNEL(meta_kernel_fn)); \ @@ -716,8 +712,8 @@ struct KernelRegistrar { #backend, \ DATALAYOUT(layout), \ ::paddle::experimental::CppTypeToDataType::Type(), \ - ::phi::KernelArgsParseFunctor)>::Parse, \ + ::phi::KernelArgsParseFunctor< \ + decltype(&meta_kernel_fn)>::Parse, \ args_def_fn, \ PHI_KERNEL(meta_kernel_fn), \ PHI_VARIADIC_KERNEL(meta_kernel_fn)); \ @@ -747,8 +743,8 @@ struct KernelRegistrar { #backend, \ DATALAYOUT(layout), \ ::paddle::experimental::CppTypeToDataType::Type(), \ - ::phi::KernelArgsParseFunctor)>::Parse, \ + ::phi::KernelArgsParseFunctor< \ + decltype(&meta_kernel_fn)>::Parse, \ args_def_fn, \ PHI_KERNEL(meta_kernel_fn), \ PHI_VARIADIC_KERNEL(meta_kernel_fn)); \ @@ -778,8 +774,8 @@ struct KernelRegistrar { #backend, \ DATALAYOUT(layout), \ ::paddle::experimental::CppTypeToDataType::Type(), \ - ::phi::KernelArgsParseFunctor)>::Parse, \ + ::phi::KernelArgsParseFunctor< \ + decltype(&meta_kernel_fn)>::Parse, \ args_def_fn, \ PHI_KERNEL(meta_kernel_fn), \ PHI_VARIADIC_KERNEL(meta_kernel_fn)); \ @@ -809,8 +805,8 @@ struct KernelRegistrar { #backend, \ DATALAYOUT(layout), \ ::paddle::experimental::CppTypeToDataType::Type(), \ - ::phi::KernelArgsParseFunctor)>::Parse, \ + ::phi::KernelArgsParseFunctor< \ + decltype(&meta_kernel_fn)>::Parse, \ args_def_fn, \ PHI_KERNEL(meta_kernel_fn), \ PHI_VARIADIC_KERNEL(meta_kernel_fn)); \ @@ -840,8 +836,8 @@ struct KernelRegistrar { #backend, \ DATALAYOUT(layout), \ ::paddle::experimental::CppTypeToDataType::Type(), \ - ::phi::KernelArgsParseFunctor)>::Parse, \ + ::phi::KernelArgsParseFunctor< \ + decltype(&meta_kernel_fn)>::Parse, \ args_def_fn, \ PHI_KERNEL(meta_kernel_fn), \ PHI_VARIADIC_KERNEL(meta_kernel_fn)); \ @@ -871,8 +867,8 @@ struct KernelRegistrar { #backend, \ DATALAYOUT(layout), \ ::paddle::experimental::CppTypeToDataType::Type(), \ - ::phi::KernelArgsParseFunctor)>::Parse, \ + ::phi::KernelArgsParseFunctor< \ + decltype(&meta_kernel_fn)>::Parse, \ args_def_fn, \ PHI_KERNEL(meta_kernel_fn), \ PHI_VARIADIC_KERNEL(meta_kernel_fn)); \ @@ -902,8 +898,8 @@ struct KernelRegistrar { #backend, \ DATALAYOUT(layout), \ ::paddle::experimental::CppTypeToDataType::Type(), \ - ::phi::KernelArgsParseFunctor)>::Parse, \ + ::phi::KernelArgsParseFunctor< \ + decltype(&meta_kernel_fn)>::Parse, \ args_def_fn, \ PHI_KERNEL(meta_kernel_fn), \ PHI_VARIADIC_KERNEL(meta_kernel_fn)); \ @@ -933,8 +929,8 @@ struct KernelRegistrar { #backend, \ DATALAYOUT(layout), \ ::paddle::experimental::CppTypeToDataType::Type(), \ - ::phi::KernelArgsParseFunctor)>::Parse, \ + ::phi::KernelArgsParseFunctor< \ + decltype(&meta_kernel_fn)>::Parse, \ args_def_fn, \ PHI_KERNEL(meta_kernel_fn), \ PHI_VARIADIC_KERNEL(meta_kernel_fn)); \ @@ -964,8 +960,8 @@ struct KernelRegistrar { #backend, \ DATALAYOUT(layout), \ ::paddle::experimental::CppTypeToDataType::Type(), \ - ::phi::KernelArgsParseFunctor)>::Parse, \ + ::phi::KernelArgsParseFunctor< \ + decltype(&meta_kernel_fn)>::Parse, \ args_def_fn, \ PHI_KERNEL(meta_kernel_fn), \ PHI_VARIADIC_KERNEL(meta_kernel_fn)); \ @@ -995,8 +991,8 @@ struct KernelRegistrar { #backend, \ DATALAYOUT(layout), \ ::paddle::experimental::CppTypeToDataType::Type(), \ - ::phi::KernelArgsParseFunctor)>::Parse, \ + ::phi::KernelArgsParseFunctor< \ + decltype(&meta_kernel_fn)>::Parse, \ args_def_fn, \ PHI_KERNEL(meta_kernel_fn), \ PHI_VARIADIC_KERNEL(meta_kernel_fn)); \ diff --git a/paddle/phi/core/kernel_utils.h b/paddle/phi/core/kernel_utils.h index d4765d1c4c3b426e93b5fbf0cec3e0c6cbfff2b8..3b5fd0247a4847cf88ea9fa5f8629da7aee4725b 100644 --- a/paddle/phi/core/kernel_utils.h +++ b/paddle/phi/core/kernel_utils.h @@ -233,9 +233,8 @@ template struct KernelImpl { static void Compute(KernelContext* ctx) { - KernelCallHelper>::template Compute<0, 0, 0, 0>(ctx); + KernelCallHelper>:: + template Compute<0, 0, 0, 0>(ctx); } static void VariadicCompute(const DeviceContext& dev_ctx, Args... args) { diff --git a/paddle/phi/core/meta_tensor.h b/paddle/phi/core/meta_tensor.h index d277f32d8ea9a3c88dc1c6af2cca69a3c9c3b566..271759161868bf0e93f9e0a4de5f2c824091e112 100644 --- a/paddle/phi/core/meta_tensor.h +++ b/paddle/phi/core/meta_tensor.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once +#include "glog/logging.h" #include "paddle/phi/common/data_type.h" #include "paddle/phi/common/layout.h" #include "paddle/phi/core/ddim.h" @@ -21,8 +22,6 @@ limitations under the License. */ #include "paddle/phi/core/tensor_base.h" #include "paddle/phi/core/tensor_meta.h" -#include "glog/logging.h" - namespace phi { // TODO(chenweihang): add other flags if needed diff --git a/paddle/phi/core/string_tensor.cc b/paddle/phi/core/string_tensor.cc index 0a4e0d61915100801173c450b8392ebf5bdf90c8..20cbf3dffcb1603b1e6c8d69520d441c9c80ad66 100644 --- a/paddle/phi/core/string_tensor.cc +++ b/paddle/phi/core/string_tensor.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/core/string_tensor.h" + #include "paddle/fluid/memory/malloc.h" namespace phi { diff --git a/paddle/phi/core/tensor_base.cc b/paddle/phi/core/tensor_base.cc index 1b3628906af09337e0d4dcb7dcd722e23422374d..718bf09ff7eb9c30635ed16f7b88ee481547ec1e 100644 --- a/paddle/phi/core/tensor_base.cc +++ b/paddle/phi/core/tensor_base.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/core/tensor_base.h" + #include "paddle/phi/core/utils/type_registry.h" namespace phi {} diff --git a/paddle/phi/core/utils/intrusive_ptr.h b/paddle/phi/core/utils/intrusive_ptr.h index 2b7580192539f7dcd8a4ec9b6dff562a39ac9b85..e2e6cb7060d057f9ca136aeb0367acde3a4bf1c4 100644 --- a/paddle/phi/core/utils/intrusive_ptr.h +++ b/paddle/phi/core/utils/intrusive_ptr.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "glog/logging.h" #include "paddle/phi/core/enforce.h" diff --git a/paddle/phi/infermeta/binary.cc b/paddle/phi/infermeta/binary.cc index a8d5ad564fe9b7b53748fa47fc085f43ddcb815f..f10fc54795ddb05d6ee9c5095e4adaa113b3428b 100644 --- a/paddle/phi/infermeta/binary.cc +++ b/paddle/phi/infermeta/binary.cc @@ -16,6 +16,7 @@ limitations under the License. */ #include #include + #include "paddle/phi/common/data_type.h" #include "paddle/phi/common/layout.h" #include "paddle/phi/core/ddim.h" diff --git a/paddle/phi/infermeta/multiary.cc b/paddle/phi/infermeta/multiary.cc index 63f0d0c1eeb28254375e60e50afd5ef049d83c1b..61c57981f94b51872c94a356b31dda7454148c8e 100644 --- a/paddle/phi/infermeta/multiary.cc +++ b/paddle/phi/infermeta/multiary.cc @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/infermeta/multiary.h" + #include + #include "paddle/phi/common/layout.h" #include "paddle/phi/common/scalar.h" #include "paddle/phi/core/infermeta_utils.h" diff --git a/paddle/phi/infermeta/ternary.cc b/paddle/phi/infermeta/ternary.cc index 3c2888cee58c7ba1c4e870ccb7e8f8cdb5aac87b..d84cc9e6d75aff009f65b865ba32ba471c3911c7 100644 --- a/paddle/phi/infermeta/ternary.cc +++ b/paddle/phi/infermeta/ternary.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/infermeta/ternary.h" + #include "paddle/phi/core/ddim.h" #include "paddle/phi/kernels/funcs/common_shape.h" diff --git a/paddle/phi/kernels/assign_kernel.cc b/paddle/phi/kernels/assign_kernel.cc index 2349bf990acd3934c10c76168739fb075acbcb3a..3d8e4db08bba15349b42f1b5294c5121e97b297c 100644 --- a/paddle/phi/kernels/assign_kernel.cc +++ b/paddle/phi/kernels/assign_kernel.cc @@ -14,12 +14,11 @@ #include "paddle/phi/kernels/assign_kernel.h" +#include "paddle/fluid/framework/tensor_util.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/copy_kernel.h" #include "paddle/utils/optional.h" -#include "paddle/fluid/framework/tensor_util.h" - namespace phi { template diff --git a/paddle/phi/kernels/auc_kernel.h b/paddle/phi/kernels/auc_kernel.h index acbd17c7801e240e933798773d54a50822dec68f..f58c3ce112bd77069e67a865951cc67e1397b8c1 100644 --- a/paddle/phi/kernels/auc_kernel.h +++ b/paddle/phi/kernels/auc_kernel.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/phi/common/scalar.h" #include "paddle/phi/core/dense_tensor.h" diff --git a/paddle/phi/kernels/autotune/auto_tune_base.h b/paddle/phi/kernels/autotune/auto_tune_base.h index eaf325dad75000b92673d3b5baad757c0b46a5ed..e18b854cf34b390e1e7dad3079b9bb2ad14eb05b 100644 --- a/paddle/phi/kernels/autotune/auto_tune_base.h +++ b/paddle/phi/kernels/autotune/auto_tune_base.h @@ -15,6 +15,7 @@ #pragma once #include + #include "glog/logging.h" #include "paddle/phi/core/enforce.h" #include "paddle/phi/kernels/autotune/gpu_timer.h" diff --git a/paddle/phi/kernels/autotune/auto_tune_test.cu b/paddle/phi/kernels/autotune/auto_tune_test.cu index f477cd1219331ab2bde6e7f298381a3437696961..c3918b8ebe59d8c9c05a2bcdb98ee44f55a585ce 100644 --- a/paddle/phi/kernels/autotune/auto_tune_test.cu +++ b/paddle/phi/kernels/autotune/auto_tune_test.cu @@ -13,6 +13,7 @@ // limitations under the License. #include + #include "glog/logging.h" #include "paddle/phi/api/lib/utils/allocator.h" #include "paddle/phi/backends/all_context.h" @@ -66,8 +67,8 @@ float Algo(const phi::GPUContext& ctx, N); #else VLOG(3) << "Vecsize is " << Vecsize; - VecSumTest<<>>( - d_in_data, d_out_data, N); + VecSumTest + <<>>(d_in_data, d_out_data, N); #endif return Vecsize; } diff --git a/paddle/phi/kernels/autotune/cache.cc b/paddle/phi/kernels/autotune/cache.cc index ef2cbe633d4965d37a23c790ad605607c76e12ae..5e2c9e1c742ff56a729ab91cf8cb649d5500ad14 100644 --- a/paddle/phi/kernels/autotune/cache.cc +++ b/paddle/phi/kernels/autotune/cache.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/phi/kernels/autotune/cache.h" + #include + #include "glog/logging.h" namespace phi { diff --git a/paddle/phi/kernels/autotune/cache.h b/paddle/phi/kernels/autotune/cache.h index 37c5d134e8a61344996379741248366bce96d72c..9d7f57e96e3735ed2cb8444ee25d5fa21c4b3aff 100644 --- a/paddle/phi/kernels/autotune/cache.h +++ b/paddle/phi/kernels/autotune/cache.h @@ -19,6 +19,7 @@ #include #include #include + #include "paddle/phi/common/data_type.h" #include "paddle/phi/core/enforce.h" #include "paddle/phi/core/errors.h" diff --git a/paddle/phi/kernels/autotune/cache_test.cc b/paddle/phi/kernels/autotune/cache_test.cc index f99f8bfc8b821204b24e70f14805a394d6121300..53574c3d0c9ac0caf7213c5b09b1a880737b2504 100644 --- a/paddle/phi/kernels/autotune/cache_test.cc +++ b/paddle/phi/kernels/autotune/cache_test.cc @@ -13,9 +13,12 @@ // limitations under the License. #include "paddle/phi/kernels/autotune/cache.h" + #include + #include #include + #include "glog/logging.h" enum ConvAlgos { GEMMKernel = 0, CuDNNKernel_1 = 1, CuDNNKernel_2 = 2 }; diff --git a/paddle/phi/kernels/autotune/gpu_timer_test.cu b/paddle/phi/kernels/autotune/gpu_timer_test.cu index b6eb345885f30e2c0ab2406b65bbe5f2d01f944e..d24508dfa206451d29efc1cccac52d48cf07ce36 100644 --- a/paddle/phi/kernels/autotune/gpu_timer_test.cu +++ b/paddle/phi/kernels/autotune/gpu_timer_test.cu @@ -13,7 +13,9 @@ // limitations under the License. #include + #include + #include "glog/logging.h" #include "paddle/phi/kernels/autotune/gpu_timer.h" #include "paddle/phi/kernels/funcs/aligned_vector.h" diff --git a/paddle/phi/kernels/autotune/switch_autotune.h b/paddle/phi/kernels/autotune/switch_autotune.h index 1793940542d4790ee6a5d020bf7deae22a50bb02..de638ac4eda751b8cf9f08de32943de09b933855 100644 --- a/paddle/phi/kernels/autotune/switch_autotune.h +++ b/paddle/phi/kernels/autotune/switch_autotune.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/phi/kernels/autotune/cache.h" namespace phi { diff --git a/paddle/phi/kernels/batch_norm_grad_kernel.h b/paddle/phi/kernels/batch_norm_grad_kernel.h index 3de2f69f452dbadca55cc08efc9a826a178f34a7..afbb0c78ca9811582f8e7a66282615b2d773693c 100644 --- a/paddle/phi/kernels/batch_norm_grad_kernel.h +++ b/paddle/phi/kernels/batch_norm_grad_kernel.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/phi/core/dense_tensor.h" namespace phi { diff --git a/paddle/phi/kernels/broadcast_tensors_grad_kernel.h b/paddle/phi/kernels/broadcast_tensors_grad_kernel.h index 5d24f6684a48f2fb4a65673e0bb888a9f37b1246..79d5b8a445b48eb320f80341b9c8863186f97de6 100644 --- a/paddle/phi/kernels/broadcast_tensors_grad_kernel.h +++ b/paddle/phi/kernels/broadcast_tensors_grad_kernel.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/phi/core/dense_tensor.h" namespace phi { diff --git a/paddle/phi/kernels/broadcast_tensors_kernel.h b/paddle/phi/kernels/broadcast_tensors_kernel.h index 22b5201b6900dd18b645c2d7645adb96a6f11e91..dccaebcf41ffeeeb40cb3f771709bcfa2e35b3ea 100644 --- a/paddle/phi/kernels/broadcast_tensors_kernel.h +++ b/paddle/phi/kernels/broadcast_tensors_kernel.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/phi/core/dense_tensor.h" namespace phi { diff --git a/paddle/phi/kernels/channel_shuffle_grad_kernel.h b/paddle/phi/kernels/channel_shuffle_grad_kernel.h index ac89f3336bc76d97ed400aff71b58ca2c810392a..d75d887d0fcd81ac3f2537785fe764b7dc4b783b 100644 --- a/paddle/phi/kernels/channel_shuffle_grad_kernel.h +++ b/paddle/phi/kernels/channel_shuffle_grad_kernel.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/phi/core/dense_tensor.h" namespace phi { diff --git a/paddle/phi/kernels/channel_shuffle_kernel.h b/paddle/phi/kernels/channel_shuffle_kernel.h index 12de25606dd968f9ea503875743f1a4533c8be15..c15e06fb552bfe4a41274d077710b406dab5fc2c 100644 --- a/paddle/phi/kernels/channel_shuffle_kernel.h +++ b/paddle/phi/kernels/channel_shuffle_kernel.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/phi/core/dense_tensor.h" namespace phi { diff --git a/paddle/phi/kernels/conv_kernel.cc b/paddle/phi/kernels/conv_kernel.cc index 7268384f401a1f9c30555aeda4521c35bb76a677..542a4ec8a61c832ec0b5fe9c39d4ea42466350be 100644 --- a/paddle/phi/kernels/conv_kernel.cc +++ b/paddle/phi/kernels/conv_kernel.cc @@ -14,9 +14,8 @@ #include "paddle/phi/kernels/conv_kernel.h" -#include "paddle/phi/core/kernel_registry.h" - #include "paddle/fluid/platform/cudnn_workspace_helper.h" +#include "paddle/phi/core/kernel_registry.h" namespace phi { @@ -41,8 +40,8 @@ void ConvInferKernel(const Context& dev_ctx, dilations, data_format, /*use_addto=*/false, - /*workspace_size_MB=*/paddle::platform:: - GetDefaultConvWorkspaceSizeLimitMB(), + /*workspace_size_MB=*/ + paddle::platform::GetDefaultConvWorkspaceSizeLimitMB(), /*exhaustive_search=*/false, out); } diff --git a/paddle/phi/kernels/conv_transpose_grad_kernel.h b/paddle/phi/kernels/conv_transpose_grad_kernel.h index 2b1c0c1a934cf64dad552b36ce9cfd3808be6810..00d5fb51f01eef0ac161827e5acbc1d785a90eae 100644 --- a/paddle/phi/kernels/conv_transpose_grad_kernel.h +++ b/paddle/phi/kernels/conv_transpose_grad_kernel.h @@ -16,6 +16,7 @@ #include #include + #include "paddle/phi/core/dense_tensor.h" namespace phi { diff --git a/paddle/phi/kernels/conv_transpose_kernel.h b/paddle/phi/kernels/conv_transpose_kernel.h index de56f13ddf73e5c33e49227468e565e374d14c84..e39617e0e7c0ca8ceee65e7bdc92df661a548204 100644 --- a/paddle/phi/kernels/conv_transpose_kernel.h +++ b/paddle/phi/kernels/conv_transpose_kernel.h @@ -16,6 +16,7 @@ #include #include + #include "paddle/phi/core/dense_tensor.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/abs_kernel.cc b/paddle/phi/kernels/cpu/abs_kernel.cc index 9f89fc27a7167dac575bdd5a8d1e7b60f3510d2b..a10e0eed64aec894e8639bbcff54f4723295adc5 100644 --- a/paddle/phi/kernels/cpu/abs_kernel.cc +++ b/paddle/phi/kernels/cpu/abs_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/abs_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/complex.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/accuracy_kernel.cc b/paddle/phi/kernels/cpu/accuracy_kernel.cc index 6ff8a1f7558973965f51f42bdd0984757f285b47..17246de35db22c079a0bcad3598b172abe6ea808 100644 --- a/paddle/phi/kernels/cpu/accuracy_kernel.cc +++ b/paddle/phi/kernels/cpu/accuracy_kernel.cc @@ -15,6 +15,7 @@ #include "paddle/phi/kernels/accuracy_kernel.h" #include + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/activation_kernel.cc b/paddle/phi/kernels/cpu/activation_kernel.cc index 165627839a3083a4bd03a1e60c5a20250a56c74c..bd3e16d54dcad460c066fbe6ea5213f09712039f 100644 --- a/paddle/phi/kernels/cpu/activation_kernel.cc +++ b/paddle/phi/kernels/cpu/activation_kernel.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/kernels/activation_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/activation_functor.h" diff --git a/paddle/phi/kernels/cpu/adagrad_kernel.cc b/paddle/phi/kernels/cpu/adagrad_kernel.cc index fcd89caf7fa29d404a427fc6b445a790f7fee2ec..d6867deff4c1567c42b0750d4586062fa2f16529 100644 --- a/paddle/phi/kernels/cpu/adagrad_kernel.cc +++ b/paddle/phi/kernels/cpu/adagrad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/adagrad_kernel.h" + #include "paddle/fluid/operators/math/selected_rows_functor.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/allclose_kernel.cc b/paddle/phi/kernels/cpu/allclose_kernel.cc index f95ddc5621e9a47d004e3338a64af6c28643c9c7..c6a512aa95cb1846b1c7d2ec5bd7f2e9f9fb8792 100644 --- a/paddle/phi/kernels/cpu/allclose_kernel.cc +++ b/paddle/phi/kernels/cpu/allclose_kernel.cc @@ -15,6 +15,7 @@ #include "paddle/phi/kernels/allclose_kernel.h" #include + #include "glog/logging.h" #include "paddle/phi/core/enforce.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/arange_kernel.cc b/paddle/phi/kernels/cpu/arange_kernel.cc index 478251b0d3b6a0b2f853e58018243f74a27abf76..7f7e5554231760cbcd9ef9dcbfbc7e7d2f8b67ed 100644 --- a/paddle/phi/kernels/cpu/arange_kernel.cc +++ b/paddle/phi/kernels/cpu/arange_kernel.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/kernels/arange_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/range_function.h" diff --git a/paddle/phi/kernels/cpu/atan2_grad_kernel.cc b/paddle/phi/kernels/cpu/atan2_grad_kernel.cc index 7a519aab0ad71e4cd20270b216bf65262cab8ba6..3bc8c853a7b427a07cfbf0fea41f3eb2c81a0768 100644 --- a/paddle/phi/kernels/cpu/atan2_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/atan2_grad_kernel.cc @@ -12,10 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/phi/kernels/impl/atan2_grad_kernel_impl.h" - #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/atan2_grad_kernel_impl.h" PD_REGISTER_KERNEL(atan2_grad, CPU, diff --git a/paddle/phi/kernels/cpu/atan2_kernel.cc b/paddle/phi/kernels/cpu/atan2_kernel.cc index df6f5f59ac0056f36749faec8a300c1b5a1da1c9..4cb96ad8b6c6cdff384924f3e1ba4fa83900d1b1 100644 --- a/paddle/phi/kernels/cpu/atan2_kernel.cc +++ b/paddle/phi/kernels/cpu/atan2_kernel.cc @@ -12,10 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/phi/kernels/impl/atan2_kernel_impl.h" - #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/atan2_kernel_impl.h" PD_REGISTER_KERNEL(atan2, CPU, diff --git a/paddle/phi/kernels/cpu/batch_norm_grad_kernel.cc b/paddle/phi/kernels/cpu/batch_norm_grad_kernel.cc index 366a08e59fee3b9892c2ee32770c4e375f011e71..beda276c8ef3ad9cc16aff0a56231f00f4a94fbc 100644 --- a/paddle/phi/kernels/cpu/batch_norm_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/batch_norm_grad_kernel.cc @@ -12,12 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/fluid/framework/tensor_util.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/batch_norm_kernel.h" #include "paddle/phi/kernels/funcs/eigen/common.h" - -#include "paddle/fluid/framework/tensor_util.h" #include "paddle/phi/kernels/funcs/math_function.h" #include "paddle/phi/kernels/gpu/batch_norm_utils.h" diff --git a/paddle/phi/kernels/cpu/batch_norm_kernel.cc b/paddle/phi/kernels/cpu/batch_norm_kernel.cc index 743128e8dea99296def25f79c47bbcfda8c65f40..cb8af06b540f8916b89ed8dfd1d1e3efc3ed8ec4 100644 --- a/paddle/phi/kernels/cpu/batch_norm_kernel.cc +++ b/paddle/phi/kernels/cpu/batch_norm_kernel.cc @@ -13,12 +13,12 @@ // limitations under the License. #include "paddle/phi/kernels/batch_norm_kernel.h" + +#include "paddle/fluid/framework/tensor_util.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/eigen/common.h" -#include "paddle/fluid/framework/tensor_util.h" - namespace phi { template diff --git a/paddle/phi/kernels/cpu/bce_loss_grad_kernel.cc b/paddle/phi/kernels/cpu/bce_loss_grad_kernel.cc index 6859451e8be32d6d70003d6ce790810d1cc815aa..fc91af3ff71bc4652dee1f0204ec20b3ffcb6627 100644 --- a/paddle/phi/kernels/cpu/bce_loss_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/bce_loss_grad_kernel.cc @@ -15,6 +15,7 @@ #include "paddle/phi/kernels/bce_loss_grad_kernel.h" #include // for max + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/bce_loss_kernel.cc b/paddle/phi/kernels/cpu/bce_loss_kernel.cc index 76b979365148468c883962f07db1b923e7ef25b8..9d62fabcbe736a6c38c69b089b38f4eb214b8eaa 100644 --- a/paddle/phi/kernels/cpu/bce_loss_kernel.cc +++ b/paddle/phi/kernels/cpu/bce_loss_kernel.cc @@ -15,6 +15,7 @@ #include "paddle/phi/kernels/bce_loss_kernel.h" #include // for max + #include "paddle/fluid/operators/math.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/bernoulli_kernel.cc b/paddle/phi/kernels/cpu/bernoulli_kernel.cc index 09c07d9ec9dea028bd3b1921056b78bc97c07ec2..6bf548154a40499fcaf2ba8b8d3b0de2722be639 100644 --- a/paddle/phi/kernels/cpu/bernoulli_kernel.cc +++ b/paddle/phi/kernels/cpu/bernoulli_kernel.cc @@ -13,7 +13,9 @@ // limitations under the License. #include "paddle/phi/kernels/bernoulli_kernel.h" + #include + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/bilinear_tensor_product_grad_kernel.cc b/paddle/phi/kernels/cpu/bilinear_tensor_product_grad_kernel.cc index 2268212316af68433a18d9037136e3e0f733e4dc..ef7e8a981c520c0f169482b6e06301638d1ab895 100644 --- a/paddle/phi/kernels/cpu/bilinear_tensor_product_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/bilinear_tensor_product_grad_kernel.cc @@ -13,9 +13,9 @@ // limitations under the License. #include "paddle/phi/kernels/bilinear_tensor_product_grad_kernel.h" -#include "paddle/phi/kernels/impl/bilinear_tensor_product_grad_kernel_impl.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/bilinear_tensor_product_grad_kernel_impl.h" PD_REGISTER_KERNEL(bilinear_tensor_product_grad, CPU, diff --git a/paddle/phi/kernels/cpu/bilinear_tensor_product_kernel.cc b/paddle/phi/kernels/cpu/bilinear_tensor_product_kernel.cc index 25bc5913865a0717024c3bfe24281ab3b110b159..d822656418261434e0af4a69e1844632b721d09c 100644 --- a/paddle/phi/kernels/cpu/bilinear_tensor_product_kernel.cc +++ b/paddle/phi/kernels/cpu/bilinear_tensor_product_kernel.cc @@ -13,9 +13,9 @@ // limitations under the License. #include "paddle/phi/kernels/bilinear_tensor_product_kernel.h" -#include "paddle/phi/kernels/impl/bilinear_tensor_product_kernel_impl.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/bilinear_tensor_product_kernel_impl.h" PD_REGISTER_KERNEL(bilinear_tensor_product, CPU, diff --git a/paddle/phi/kernels/cpu/broadcast_tensors_grad_kernel.cc b/paddle/phi/kernels/cpu/broadcast_tensors_grad_kernel.cc index 0869cd62024dc9e11ce1e1a1fc5349c0c966ef9e..413638e17722251762360a0e9919c7c52d3d0df7 100644 --- a/paddle/phi/kernels/cpu/broadcast_tensors_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/broadcast_tensors_grad_kernel.cc @@ -15,6 +15,7 @@ #include "paddle/phi/kernels/broadcast_tensors_grad_kernel.h" #include + #include "paddle/fluid/framework/tensor_util.h" #include "paddle/phi/common/float16.h" #include "paddle/phi/core/dense_tensor.h" diff --git a/paddle/phi/kernels/cpu/broadcast_tensors_kernel.cc b/paddle/phi/kernels/cpu/broadcast_tensors_kernel.cc index 4cb6db876927142baac0ba0cde3438a4e3b00159..3ad26164d7d8da6a23f93fb03fccbe0195587084 100644 --- a/paddle/phi/kernels/cpu/broadcast_tensors_kernel.cc +++ b/paddle/phi/kernels/cpu/broadcast_tensors_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/broadcast_tensors_kernel.h" -#include "paddle/phi/kernels/impl/broadcast_tensors_kernel_impl.h" #include "paddle/phi/common/float16.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/broadcast_tensors_kernel_impl.h" PD_REGISTER_KERNEL(broadcast_tensors, CPU, diff --git a/paddle/phi/kernels/cpu/cast_kernel.cc b/paddle/phi/kernels/cpu/cast_kernel.cc index 2132f0d5ae86cc6bf127f9fa4e30797f686e5f99..8abfa173fd06dd734b45061db2e97e333eeed4e7 100644 --- a/paddle/phi/kernels/cpu/cast_kernel.cc +++ b/paddle/phi/kernels/cpu/cast_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/cast_kernel.h" -#include "paddle/phi/kernels/cpu/cast_impl.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/core/visit_type.h" +#include "paddle/phi/kernels/cpu/cast_impl.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/channel_shuffle_grad_kernel.cc b/paddle/phi/kernels/cpu/channel_shuffle_grad_kernel.cc index fcc91b21916731595bab67421676c71f88e7d855..e95b454dbf9000528e727461e019c109d306eb75 100644 --- a/paddle/phi/kernels/cpu/channel_shuffle_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/channel_shuffle_grad_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/channel_shuffle_grad_kernel.h" -#include "paddle/phi/kernels/impl/channel_shuffle_grad_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/channel_shuffle_grad_kernel_impl.h" PD_REGISTER_KERNEL(channel_shuffle_grad, CPU, diff --git a/paddle/phi/kernels/cpu/channel_shuffle_kernel.cc b/paddle/phi/kernels/cpu/channel_shuffle_kernel.cc index 95d19ec6a7746ef704878a327ebc238c063317db..0bac82e779c21b86ec99a3d01d95fa3b8b1e77a4 100644 --- a/paddle/phi/kernels/cpu/channel_shuffle_kernel.cc +++ b/paddle/phi/kernels/cpu/channel_shuffle_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/channel_shuffle_kernel.h" -#include "paddle/phi/kernels/impl/channel_shuffle_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/channel_shuffle_kernel_impl.h" PD_REGISTER_KERNEL(channel_shuffle, CPU, diff --git a/paddle/phi/kernels/cpu/cholesky_solve_grad_kernel.cc b/paddle/phi/kernels/cpu/cholesky_solve_grad_kernel.cc index b6f5dd29ba2b7a31b8346d3d25148852344221a0..612d10994cb17d16dc67d18c2477a7ca23503dfb 100644 --- a/paddle/phi/kernels/cpu/cholesky_solve_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/cholesky_solve_grad_kernel.cc @@ -12,10 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/phi/kernels/impl/cholesky_solve_grad_kernel_impl.h" - #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/cholesky_solve_grad_kernel_impl.h" PD_REGISTER_KERNEL(cholesky_solve_grad, CPU, diff --git a/paddle/phi/kernels/cpu/cholesky_solve_kernel.cc b/paddle/phi/kernels/cpu/cholesky_solve_kernel.cc index 02597560a7f51f2df6173215b09536292a70ef3f..11cb66f88c1f6251c0ee90c02000d55525e23f8f 100644 --- a/paddle/phi/kernels/cpu/cholesky_solve_kernel.cc +++ b/paddle/phi/kernels/cpu/cholesky_solve_kernel.cc @@ -12,11 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/phi/kernels/impl/cholesky_solve_kernel_impl.h" - #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/lapack/lapack_function.h" +#include "paddle/phi/kernels/impl/cholesky_solve_kernel_impl.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/clip_grad_kernel.cc b/paddle/phi/kernels/cpu/clip_grad_kernel.cc index bccdc0746d51ca63643ab8b5068618ee71ae8751..89a14af10d16c522556cef08f7a79d60e4589fb4 100644 --- a/paddle/phi/kernels/cpu/clip_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/clip_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/clip_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/clip_grad_kernel_impl.h" diff --git a/paddle/phi/kernels/cpu/clip_kernel.cc b/paddle/phi/kernels/cpu/clip_kernel.cc index 5fd9aea966f8d24fa113ca88fbdf1bfc26791e01..bcbb85279277e5e242f0dedaae58a1e4daed1b1f 100644 --- a/paddle/phi/kernels/cpu/clip_kernel.cc +++ b/paddle/phi/kernels/cpu/clip_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/clip_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/clip_kernel_impl.h" diff --git a/paddle/phi/kernels/cpu/compare_kernel.cc b/paddle/phi/kernels/cpu/compare_kernel.cc index 9006325a521ec88eba80a9bf27762730be08fecc..694b44c16d80e409493cbc04b03dcabff5f63903 100644 --- a/paddle/phi/kernels/cpu/compare_kernel.cc +++ b/paddle/phi/kernels/cpu/compare_kernel.cc @@ -13,11 +13,11 @@ // limitations under the License. #include "paddle/phi/kernels/compare_kernel.h" -#include "paddle/phi/kernels/impl/compare_kernel_impl.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/elementwise_base.h" +#include "paddle/phi/kernels/impl/compare_kernel_impl.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/complex_grad_kernel.cc b/paddle/phi/kernels/cpu/complex_grad_kernel.cc index 5c1d50f5bf27d2cf7b3e0078f1bcab13d1b898a8..11b7a05834607ca6d316ae40b485b937acf34b0f 100644 --- a/paddle/phi/kernels/cpu/complex_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/complex_grad_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/complex_grad_kernel.h" -#include "paddle/phi/kernels/impl/complex_grad_kernel_impl.h" #include "paddle/phi/common/complex.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/complex_grad_kernel_impl.h" PD_REGISTER_KERNEL(real_grad, CPU, diff --git a/paddle/phi/kernels/cpu/complex_kernel.cc b/paddle/phi/kernels/cpu/complex_kernel.cc index 859d5a84527a2e342b6f0f25999f8fc3d6f8fa3e..bef0b7b747a420f501057d506a7bfe2f1b34971c 100644 --- a/paddle/phi/kernels/cpu/complex_kernel.cc +++ b/paddle/phi/kernels/cpu/complex_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/complex_kernel.h" -#include "paddle/phi/kernels/impl/complex_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/complex_kernel_impl.h" // See Note [ Why still include the fluid headers? ] #include "paddle/phi/common/complex.h" diff --git a/paddle/phi/kernels/cpu/conv_grad_grad_kernel.cc b/paddle/phi/kernels/cpu/conv_grad_grad_kernel.cc index 4538ccf9433f9a1345783f24e8b7a57ebd04de1e..3289c8f5c84d6372e6512b031d3037953d7c53b6 100644 --- a/paddle/phi/kernels/cpu/conv_grad_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/conv_grad_grad_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/conv_grad_grad_kernel.h" -#include "paddle/phi/kernels/impl/conv_grad_grad_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/conv_grad_grad_kernel_impl.h" namespace phi { template diff --git a/paddle/phi/kernels/cpu/conv_grad_kernel.cc b/paddle/phi/kernels/cpu/conv_grad_kernel.cc index 2d8a9bf1de7337655fa1341dca78ec0903e38471..880837dd7cd61530f5329beffa2e4afd28cbd01d 100644 --- a/paddle/phi/kernels/cpu/conv_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/conv_grad_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/conv_grad_kernel.h" -#include "paddle/phi/kernels/impl/conv_grad_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/conv_grad_kernel_impl.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/conv_kernel.cc b/paddle/phi/kernels/cpu/conv_kernel.cc index e0b4ee7d5776fdaf51955b2d35bb339735411a28..ec3253194930b0816fc81ebebcc74d752f1b78fb 100644 --- a/paddle/phi/kernels/cpu/conv_kernel.cc +++ b/paddle/phi/kernels/cpu/conv_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/conv_kernel.h" -#include "paddle/phi/kernels/impl/conv_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/conv_kernel_impl.h" namespace phi { template diff --git a/paddle/phi/kernels/cpu/conv_transpose_grad_kernel.cc b/paddle/phi/kernels/cpu/conv_transpose_grad_kernel.cc index 8d0749500695c5db2f07872e59d295981c598c9e..17fe44dea3f651f111bbef388e7a8665a7c8dccf 100644 --- a/paddle/phi/kernels/cpu/conv_transpose_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/conv_transpose_grad_kernel.cc @@ -13,9 +13,9 @@ // limitations under the License. #include "paddle/phi/kernels/conv_transpose_grad_kernel.h" -#include "paddle/phi/kernels/impl/conv_transpose_grad_kernel_impl.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/conv_transpose_grad_kernel_impl.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/conv_transpose_kernel.cc b/paddle/phi/kernels/cpu/conv_transpose_kernel.cc index b4cacc850938ea87c34499c68b3aa8821e65943d..ad9a5933f28091cbd7407980374e409bf40583af 100644 --- a/paddle/phi/kernels/cpu/conv_transpose_kernel.cc +++ b/paddle/phi/kernels/cpu/conv_transpose_kernel.cc @@ -13,9 +13,9 @@ // limitations under the License. #include "paddle/phi/kernels/conv_transpose_kernel.h" -#include "paddle/phi/kernels/impl/conv_transpose_kernel_impl.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/conv_transpose_kernel_impl.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/cross_entropy_kernel.cc b/paddle/phi/kernels/cpu/cross_entropy_kernel.cc index c684fb416eaab38461d490dec940998ad705b6f6..bd3eb3eb754c3959a831c0529a2aa6fe09c0916f 100644 --- a/paddle/phi/kernels/cpu/cross_entropy_kernel.cc +++ b/paddle/phi/kernels/cpu/cross_entropy_kernel.cc @@ -14,6 +14,7 @@ limitations under the License. */ #include "paddle/phi/kernels/cross_entropy_kernel.h" +#include "paddle/fluid/operators/math/cross_entropy.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/copy_kernel.h" @@ -21,8 +22,6 @@ limitations under the License. */ #include "paddle/phi/kernels/funcs/math_function.h" #include "paddle/phi/kernels/softmax_kernel.h" -#include "paddle/fluid/operators/math/cross_entropy.h" - namespace phi { template diff --git a/paddle/phi/kernels/cpu/cross_grad_kernel.cc b/paddle/phi/kernels/cpu/cross_grad_kernel.cc index 390420008e6ea107573bbc2038c3a82af19b06e6..8dddc6f6e4e95a1585e7375730d4e59216ffab44 100644 --- a/paddle/phi/kernels/cpu/cross_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/cross_grad_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/cross_grad_kernel.h" -#include "paddle/phi/kernels/impl/cross_grad_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/cross_grad_kernel_impl.h" PD_REGISTER_KERNEL(cross_grad, CPU, diff --git a/paddle/phi/kernels/cpu/cross_kernel.cc b/paddle/phi/kernels/cpu/cross_kernel.cc index a63f33174eacda551e595affc34343030468f2c5..1f3a8fe5a38790fb88c980af887e06f73d0c6ffc 100644 --- a/paddle/phi/kernels/cpu/cross_kernel.cc +++ b/paddle/phi/kernels/cpu/cross_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/cross_kernel.h" -#include "paddle/phi/kernels/impl/cross_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/cross_kernel_impl.h" PD_REGISTER_KERNEL( cross, CPU, ALL_LAYOUT, phi::CrossKernel, float, double, int, int64_t) {} diff --git a/paddle/phi/kernels/cpu/cumprod_kernel.cc b/paddle/phi/kernels/cpu/cumprod_kernel.cc index aea338027f5bb983788c382982dd2e1ad8db5e9a..4ecf09291841835957dfb8d5ef8a21f615acc5a8 100644 --- a/paddle/phi/kernels/cpu/cumprod_kernel.cc +++ b/paddle/phi/kernels/cpu/cumprod_kernel.cc @@ -16,6 +16,7 @@ #include #include + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/complex_functors.h" diff --git a/paddle/phi/kernels/cpu/deformable_conv_grad_kernel.cc b/paddle/phi/kernels/cpu/deformable_conv_grad_kernel.cc index f64b1d3291f5e3868ab04e096b5b279df6c1df55..a4d43ef8fbe8927198ff6e83a39454a3a94a9886 100644 --- a/paddle/phi/kernels/cpu/deformable_conv_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/deformable_conv_grad_kernel.cc @@ -58,10 +58,9 @@ inline void ModulatedDeformableCol2imCPUKernel( int w_in = w_out * stride_w - pad_w; int h_in = h_out * stride_h - pad_h; - const T* data_offset_ptr = data_offset + - (b * deformable_group + deformable_group_index) * - 2 * kernel_h * kernel_w * height_col * - width_col; + const T* data_offset_ptr = + data_offset + (b * deformable_group + deformable_group_index) * 2 * + kernel_h * kernel_w * height_col * width_col; const int data_offset_h_ptr = ((2 * (i * kernel_w + j)) * height_col + h_out) * width_col + w_out; const int data_offset_w_ptr = @@ -75,9 +74,9 @@ inline void ModulatedDeformableCol2imCPUKernel( T cur_top_grad = data_col[thread]; if (data_mask) { - const T* data_mask_ptr = data_mask + - (b * deformable_group + deformable_group_index) * - kernel_h * kernel_w * height_col * width_col; + const T* data_mask_ptr = + data_mask + (b * deformable_group + deformable_group_index) * + kernel_h * kernel_w * height_col * width_col; const T mask = data_mask_ptr[data_mask_hw_ptr]; cur_top_grad *= mask; } @@ -180,23 +179,20 @@ void ModulatedDeformableCol2imCoordCPUKernel( const int deformable_group_index = c / (2 * kernel_h * kernel_w); const int col_step = kernel_h * kernel_w; int cnt = 0; - const T* data_col_ptr = data_col + - deformable_group_index * - channel_per_deformable_group * batch_size * - width_col * height_col; - const T* data_im_ptr = data_im + - (b * deformable_group + deformable_group_index) * - channel_per_deformable_group / kernel_h / - kernel_w * height * width; - const T* data_offset_ptr = data_offset + - (b * deformable_group + deformable_group_index) * - 2 * kernel_h * kernel_w * height_col * - width_col; + const T* data_col_ptr = data_col + deformable_group_index * + channel_per_deformable_group * + batch_size * width_col * height_col; + const T* data_im_ptr = + data_im + (b * deformable_group + deformable_group_index) * + channel_per_deformable_group / kernel_h / kernel_w * + height * width; + const T* data_offset_ptr = + data_offset + (b * deformable_group + deformable_group_index) * 2 * + kernel_h * kernel_w * height_col * width_col; const T* data_mask_ptr = data_mask - ? data_mask + - (b * deformable_group + deformable_group_index) * kernel_h * - kernel_w * height_col * width_col + ? data_mask + (b * deformable_group + deformable_group_index) * + kernel_h * kernel_w * height_col * width_col : nullptr; const int offset_c = c - deformable_group_index * 2 * kernel_h * kernel_w; diff --git a/paddle/phi/kernels/cpu/diag_grad_kernel.cc b/paddle/phi/kernels/cpu/diag_grad_kernel.cc index c56b225e2a753f963651f5e3f0a5cf711f5bb8a6..616ea753ef1bac40b0f33ef5eb35e8607a6f7936 100644 --- a/paddle/phi/kernels/cpu/diag_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/diag_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/diag_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/diag_functor.h" diff --git a/paddle/phi/kernels/cpu/diagonal_grad_kernel.cc b/paddle/phi/kernels/cpu/diagonal_grad_kernel.cc index c3c290b4fe91ec1ecee6f0026ed5af39288e2618..5671e70c96e0a94c31c99110361c41b29d26fc59 100644 --- a/paddle/phi/kernels/cpu/diagonal_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/diagonal_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/diagonal_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/diagonal.h" diff --git a/paddle/phi/kernels/cpu/diagonal_kernel.cc b/paddle/phi/kernels/cpu/diagonal_kernel.cc index df17b458e1166b49815d405a4e7d97c5384ab4f0..8ea5826ba25f7fe9fb544202494f5d32bd0be8c6 100644 --- a/paddle/phi/kernels/cpu/diagonal_kernel.cc +++ b/paddle/phi/kernels/cpu/diagonal_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/diagonal_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/diagonal.h" diff --git a/paddle/phi/kernels/cpu/digamma_grad_kernel.cc b/paddle/phi/kernels/cpu/digamma_grad_kernel.cc index da1b5ae556609c05a91623cf9cac408e190868b9..dc7fcaf6f92bedad38ad99b8cdbd853c73175c38 100644 --- a/paddle/phi/kernels/cpu/digamma_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/digamma_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/digamma_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/scalar.h" #include "paddle/phi/core/dense_tensor.h" diff --git a/paddle/phi/kernels/cpu/digamma_kernel.cc b/paddle/phi/kernels/cpu/digamma_kernel.cc index ee120a29b6061efcadfb88ecce8ba3235d865ca1..80cbda4b7a9fc9b1a1b9666dc20692db1a6229de 100644 --- a/paddle/phi/kernels/cpu/digamma_kernel.cc +++ b/paddle/phi/kernels/cpu/digamma_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/digamma_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/scalar.h" #include "paddle/phi/core/dense_tensor.h" diff --git a/paddle/phi/kernels/cpu/dist_grad_kernel.cc b/paddle/phi/kernels/cpu/dist_grad_kernel.cc index 2b7f8f98f9473c03e26d6edaebb7dd04e0428072..c1aaa2adf7563c89dee61c08b07800b61b9abb79 100644 --- a/paddle/phi/kernels/cpu/dist_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/dist_grad_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/dist_grad_kernel.h" -#include "paddle/phi/kernels/impl/dist_grad_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/dist_grad_kernel_impl.h" PD_REGISTER_KERNEL( dist_grad, CPU, ALL_LAYOUT, phi::DistGradKernel, float, double) {} diff --git a/paddle/phi/kernels/cpu/dist_kernel.cc b/paddle/phi/kernels/cpu/dist_kernel.cc index ccf3d4be8323090985a5c7a4eaf0ed8efcfaf5de..0c7b5db64b38f5ff1d5ce5d4702b54b6c195a6cf 100644 --- a/paddle/phi/kernels/cpu/dist_kernel.cc +++ b/paddle/phi/kernels/cpu/dist_kernel.cc @@ -13,9 +13,9 @@ // limitations under the License. #include "paddle/phi/kernels/dist_kernel.h" -#include "paddle/phi/kernels/impl/dist_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/dist_kernel_impl.h" PD_REGISTER_KERNEL(dist, CPU, ALL_LAYOUT, phi::DistKernel, float, double) {} diff --git a/paddle/phi/kernels/cpu/dot_grad_kernel.cc b/paddle/phi/kernels/cpu/dot_grad_kernel.cc index a2abdb7c00900ecd103562430d1f965cbaf92d4e..883b77802217b1ea771e43635e7fea9d752b41ee 100644 --- a/paddle/phi/kernels/cpu/dot_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/dot_grad_kernel.cc @@ -13,12 +13,11 @@ // limitations under the License. #include "paddle/phi/kernels/dot_grad_kernel.h" -#include "paddle/phi/kernels/impl/dot_grad_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" -#include "paddle/phi/core/kernel_registry.h" - #include "paddle/phi/common/complex.h" +#include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/dot_grad_kernel_impl.h" PD_REGISTER_KERNEL(dot_grad, CPU, diff --git a/paddle/phi/kernels/cpu/dropout_grad_kernel.cc b/paddle/phi/kernels/cpu/dropout_grad_kernel.cc index b77a6c55b14716e2747a2cb76d4b1bda380a2d02..db95656421884d1df29fa4be695ea2da2f7e025b 100644 --- a/paddle/phi/kernels/cpu/dropout_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/dropout_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/dropout_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/eigen/common.h" diff --git a/paddle/phi/kernels/cpu/dropout_kernel.cc b/paddle/phi/kernels/cpu/dropout_kernel.cc index fa12e505e420953085f41f1ea9ee58452ed5ee7b..d9c02eff0106fecf932d29ed358a0d1c5ec80c4f 100644 --- a/paddle/phi/kernels/cpu/dropout_kernel.cc +++ b/paddle/phi/kernels/cpu/dropout_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/dropout_kernel.h" + #include "paddle/fluid/framework/generator.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/eigh_grad_kernel.cc b/paddle/phi/kernels/cpu/eigh_grad_kernel.cc index 5135778db56c5a59b8d1e2cebf49ba2595070f7f..db533416d27488b37a25bbea05864b7647a0db16 100644 --- a/paddle/phi/kernels/cpu/eigh_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/eigh_grad_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/eigh_grad_kernel.h" -#include "paddle/phi/kernels/impl/eigh_grad_kernel_impl.h" #include "paddle/phi/common/complex.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/eigh_grad_kernel_impl.h" PD_REGISTER_KERNEL(eigh_grad, CPU, diff --git a/paddle/phi/kernels/cpu/eigh_kernel.cc b/paddle/phi/kernels/cpu/eigh_kernel.cc index 92fd20ca9b8251a3ba1b493f8cd35a803e20dfba..0f0a10c8377921b81e189f36bc6a926771876d26 100644 --- a/paddle/phi/kernels/cpu/eigh_kernel.cc +++ b/paddle/phi/kernels/cpu/eigh_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/eigh_kernel.h" -#include "paddle/phi/kernels/funcs/values_vectors_functor.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/complex_functors.h" +#include "paddle/phi/kernels/funcs/values_vectors_functor.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/einsum_kernel.cc b/paddle/phi/kernels/cpu/einsum_kernel.cc index 8968542b3e0b898f0a058c4588932c8bac2c97bf..401d2fd158a5d1b1456c632dc5c59aebd78d9c8b 100644 --- a/paddle/phi/kernels/cpu/einsum_kernel.cc +++ b/paddle/phi/kernels/cpu/einsum_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/einsum_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/einsum_impl.h" diff --git a/paddle/phi/kernels/cpu/elementwise.h b/paddle/phi/kernels/cpu/elementwise.h index 0f67df661136dc659c28da3855b661e4a7df2af0..255dae7da014dd2a5d89d26565882a2c48b6135e 100644 --- a/paddle/phi/kernels/cpu/elementwise.h +++ b/paddle/phi/kernels/cpu/elementwise.h @@ -16,10 +16,9 @@ limitations under the License. */ #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/dense_tensor.h" +#include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/broadcast_function.h" #include "paddle/phi/kernels/funcs/common_shape.h" - -#include "paddle/phi/kernels/funcs/blas/blas.h" #include "paddle/phi/kernels/funcs/eigen/common.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/elementwise_add_kernel.cc b/paddle/phi/kernels/cpu/elementwise_add_kernel.cc index 5019b9f57062874b5f78a002dbf1cdd411bc4e9c..b5e28ab39e5a629cc2f3f97bf25569bf4aca38ce 100644 --- a/paddle/phi/kernels/cpu/elementwise_add_kernel.cc +++ b/paddle/phi/kernels/cpu/elementwise_add_kernel.cc @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/phi/kernels/cpu/elementwise.h" #include "paddle/phi/api/ext/dispatch.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/bfloat16.h" #include "paddle/phi/common/complex.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/cpu/elementwise.h" #include "paddle/phi/kernels/impl/elementwise_kernel_impl.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/elementwise_divide_kernel.cc b/paddle/phi/kernels/cpu/elementwise_divide_kernel.cc index d380621818b3595f3df5f08653848ec60eb741ab..15fe92c9291942f99b53e06ef57b9a0c0dbbc719 100644 --- a/paddle/phi/kernels/cpu/elementwise_divide_kernel.cc +++ b/paddle/phi/kernels/cpu/elementwise_divide_kernel.cc @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/phi/kernels/cpu/elementwise.h" #include "paddle/phi/api/ext/dispatch.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/bfloat16.h" #include "paddle/phi/common/complex.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/cpu/elementwise.h" #include "paddle/phi/kernels/impl/elementwise_kernel_impl.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/elementwise_kernel.cc b/paddle/phi/kernels/cpu/elementwise_kernel.cc index 286b0d0ffaad93159b3d9eb1fc7a1ab4618d40e8..f090ddd5bbe9a7bc77ddaf469913bed3fdbdce72 100644 --- a/paddle/phi/kernels/cpu/elementwise_kernel.cc +++ b/paddle/phi/kernels/cpu/elementwise_kernel.cc @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/phi/kernels/cpu/elementwise.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/bfloat16.h" #include "paddle/phi/common/complex.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/cpu/elementwise.h" #include "paddle/phi/kernels/impl/elementwise_kernel_impl.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/elementwise_multiply_kernel.cc b/paddle/phi/kernels/cpu/elementwise_multiply_kernel.cc index 2424a5330109c06d132c5029f1b7b3508aaa022e..349150373844b974377d45626d714a9703bbff91 100644 --- a/paddle/phi/kernels/cpu/elementwise_multiply_kernel.cc +++ b/paddle/phi/kernels/cpu/elementwise_multiply_kernel.cc @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/phi/kernels/cpu/elementwise.h" #include "paddle/phi/api/ext/dispatch.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/bfloat16.h" #include "paddle/phi/common/complex.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/cpu/elementwise.h" #include "paddle/phi/kernels/impl/elementwise_kernel_impl.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/elementwise_subtract_kernel.cc b/paddle/phi/kernels/cpu/elementwise_subtract_kernel.cc index 0e97852ac33e14b7aa321746e67ee9894f88deea..a013309233d47dc8d9ed40ba65b5397d832f8998 100644 --- a/paddle/phi/kernels/cpu/elementwise_subtract_kernel.cc +++ b/paddle/phi/kernels/cpu/elementwise_subtract_kernel.cc @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/phi/kernels/cpu/elementwise.h" #include "paddle/phi/api/ext/dispatch.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/bfloat16.h" #include "paddle/phi/common/complex.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/cpu/elementwise.h" #include "paddle/phi/kernels/impl/elementwise_kernel_impl.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/embedding_grad_kernel.cc b/paddle/phi/kernels/cpu/embedding_grad_kernel.cc index 21b3e6da8d9efdac1e5866ef3ac1aac580d5a0b8..fabb4e83d52f7d1e6671d0b1ccb28f2d162b3780 100644 --- a/paddle/phi/kernels/cpu/embedding_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/embedding_grad_kernel.cc @@ -13,11 +13,11 @@ // limitations under the License. #include "paddle/phi/kernels/embedding_grad_kernel.h" -#include "paddle/phi/kernels/funcs/embedding_util.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/data_type.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/funcs/embedding_util.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/embedding_kernel.cc b/paddle/phi/kernels/cpu/embedding_kernel.cc index 76cc3814b0567087ef8e5d40fe4031ed6598a49b..0430f7a005221c0ca95c0719a2a2c91bdb5e0d32 100644 --- a/paddle/phi/kernels/cpu/embedding_kernel.cc +++ b/paddle/phi/kernels/cpu/embedding_kernel.cc @@ -13,12 +13,12 @@ // limitations under the License. #include "paddle/phi/kernels/embedding_kernel.h" -#include "paddle/phi/kernels/funcs/embedding_util.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/data_type.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/core/utils/data_type.h" +#include "paddle/phi/kernels/funcs/embedding_util.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/erf_grad_kernel.cc b/paddle/phi/kernels/cpu/erf_grad_kernel.cc index 3c1cd0df1531a50524958b527ee39b09460f042c..ae0b218bc0be3f9ed621a8ca712e1f08dd069180 100644 --- a/paddle/phi/kernels/cpu/erf_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/erf_grad_kernel.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/kernels/erf_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/float16.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/erf_kernel.cc b/paddle/phi/kernels/cpu/erf_kernel.cc index 05ce4cab7fcef4d1da7d378093f9f3d04827acd2..ace9775c0b869a72e6f174d6e7b7f6cb671fd51a 100644 --- a/paddle/phi/kernels/cpu/erf_kernel.cc +++ b/paddle/phi/kernels/cpu/erf_kernel.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/kernels/erf_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/float16.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/erfinv_grad_kernel.cc b/paddle/phi/kernels/cpu/erfinv_grad_kernel.cc index b1fe4f026ab07ef2370c2c69ac10a3a9c831c6a3..2d363189936b09d03a5c4ab30b48bbcce23bafa1 100644 --- a/paddle/phi/kernels/cpu/erfinv_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/erfinv_grad_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/erfinv_grad_kernel.h" -#include "paddle/phi/kernels/impl/erfinv_grad_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/erfinv_grad_kernel_impl.h" PD_REGISTER_KERNEL( erfinv_grad, CPU, ALL_LAYOUT, phi::ErfinvGradKernel, float, double) {} diff --git a/paddle/phi/kernels/cpu/erfinv_kernel.cc b/paddle/phi/kernels/cpu/erfinv_kernel.cc index 4f3a740f9d9be3e68c5e7d3a13933d6b09cdbc75..f298cc358d6623d748cc16593360844e4b64764b 100644 --- a/paddle/phi/kernels/cpu/erfinv_kernel.cc +++ b/paddle/phi/kernels/cpu/erfinv_kernel.cc @@ -13,9 +13,9 @@ // limitations under the License. #include "paddle/phi/kernels/erfinv_kernel.h" -#include "paddle/phi/kernels/impl/erfinv_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/erfinv_kernel_impl.h" PD_REGISTER_KERNEL(erfinv, CPU, ALL_LAYOUT, phi::ErfinvKernel, float, double) {} diff --git a/paddle/phi/kernels/cpu/expand_as_grad_kernel.cc b/paddle/phi/kernels/cpu/expand_as_grad_kernel.cc index 6eafe9aa49dfe820881ca1394716a29e0ced4ec4..c57e3a87281e07586c008a7d1097d18333daa020 100644 --- a/paddle/phi/kernels/cpu/expand_as_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/expand_as_grad_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/expand_as_grad_kernel.h" -#include "paddle/phi/kernels/impl/expand_as_grad_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/expand_as_grad_kernel_impl.h" PD_REGISTER_KERNEL(expand_as_grad, CPU, diff --git a/paddle/phi/kernels/cpu/expand_as_kernel.cc b/paddle/phi/kernels/cpu/expand_as_kernel.cc index 697ea138097ee9d57f23a11d7403b2d4b78158b6..4ec28ef8413ccdf6598af3f76efc5e6ccb4579ac 100644 --- a/paddle/phi/kernels/cpu/expand_as_kernel.cc +++ b/paddle/phi/kernels/cpu/expand_as_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/expand_as_kernel.h" -#include "paddle/phi/kernels/impl/expand_as_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/expand_as_kernel_impl.h" PD_REGISTER_KERNEL(expand_as, CPU, diff --git a/paddle/phi/kernels/cpu/expand_grad_kernel.cc b/paddle/phi/kernels/cpu/expand_grad_kernel.cc index 4799a6aa7afdf85a759d5940edea05e885b965e3..5cbbf253b747d1eadeb9d2b4161c43f18be23368 100644 --- a/paddle/phi/kernels/cpu/expand_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/expand_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/expand_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/scalar.h" #include "paddle/phi/core/dense_tensor.h" diff --git a/paddle/phi/kernels/cpu/expand_kernel.cc b/paddle/phi/kernels/cpu/expand_kernel.cc index 077048976729fddefe8162f8eebb4961843dd2e0..2df833d0f9c3075d097dfce22082aa3261b852d8 100644 --- a/paddle/phi/kernels/cpu/expand_kernel.cc +++ b/paddle/phi/kernels/cpu/expand_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/expand_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/scalar.h" #include "paddle/phi/core/dense_tensor.h" diff --git a/paddle/phi/kernels/cpu/eye_kernel.cc b/paddle/phi/kernels/cpu/eye_kernel.cc index a0d0f2c43909690078ff268356242b557dd6e6aa..ef3489d3fae0d973dc554477778f5c2c974f66cf 100644 --- a/paddle/phi/kernels/cpu/eye_kernel.cc +++ b/paddle/phi/kernels/cpu/eye_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/eye_kernel.h" -#include "paddle/phi/kernels/impl/eye_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/eye_kernel_impl.h" PD_REGISTER_KERNEL(eye, CPU, diff --git a/paddle/phi/kernels/cpu/frobenius_norm_grad_kernel.cc b/paddle/phi/kernels/cpu/frobenius_norm_grad_kernel.cc index 338be9e252da3349cd81cdfa61a8eae4d2d30166..5434296be4dbe7beaf1585e1a23300573fc34cb6 100644 --- a/paddle/phi/kernels/cpu/frobenius_norm_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/frobenius_norm_grad_kernel.cc @@ -13,9 +13,9 @@ // limitations under the License. #include "paddle/phi/kernels/frobenius_norm_grad_kernel.h" -#include "paddle/phi/kernels/impl/frobenius_norm_grad_kernel_impl.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/frobenius_norm_grad_kernel_impl.h" PD_REGISTER_KERNEL(frobenius_norm_grad, CPU, diff --git a/paddle/phi/kernels/cpu/frobenius_norm_kernel.cc b/paddle/phi/kernels/cpu/frobenius_norm_kernel.cc index 77509b953bf39bc472b9f3e8b134b294253d1998..56444ddad8d8b65488ee3607c2019d1dd95f3441 100644 --- a/paddle/phi/kernels/cpu/frobenius_norm_kernel.cc +++ b/paddle/phi/kernels/cpu/frobenius_norm_kernel.cc @@ -13,9 +13,9 @@ // limitations under the License. #include "paddle/phi/kernels/frobenius_norm_kernel.h" -#include "paddle/phi/kernels/impl/frobenius_norm_kernel_impl.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/frobenius_norm_kernel_impl.h" PD_REGISTER_KERNEL( frobenius_norm, CPU, ALL_LAYOUT, phi::FrobeniusNormKernel, float, double) {} diff --git a/paddle/phi/kernels/cpu/full_kernel.cc b/paddle/phi/kernels/cpu/full_kernel.cc index 0b76425a659a0ef51a94e0c8d2b769a5e25cd957..ceb2312b53a0bd3ef3e118926433f9771c17259f 100644 --- a/paddle/phi/kernels/cpu/full_kernel.cc +++ b/paddle/phi/kernels/cpu/full_kernel.cc @@ -16,7 +16,6 @@ limitations under the License. */ #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" - #include "paddle/phi/kernels/funcs/eigen/common.h" #include "paddle/phi/kernels/funcs/eigen/eigen_function.h" diff --git a/paddle/phi/kernels/cpu/gather_nd_grad_kernel.cc b/paddle/phi/kernels/cpu/gather_nd_grad_kernel.cc index b375a7ec4691c723f2f029c39b7e364b8332c402..88a288afd318efc1da8f41bdb1e61d86e73c1d35 100644 --- a/paddle/phi/kernels/cpu/gather_nd_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/gather_nd_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/gather_nd_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/eigen/eigen_function.h" diff --git a/paddle/phi/kernels/cpu/gather_nd_kernel.cc b/paddle/phi/kernels/cpu/gather_nd_kernel.cc index aa32d036934e838b7630a19a152e0c14de907253..8ae866a1c8addca96bbb8811f08f0ca295493f79 100644 --- a/paddle/phi/kernels/cpu/gather_nd_kernel.cc +++ b/paddle/phi/kernels/cpu/gather_nd_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/gather_nd_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/gather.h" diff --git a/paddle/phi/kernels/cpu/gather_tree_kernel.cc b/paddle/phi/kernels/cpu/gather_tree_kernel.cc index 25fb870d851f673a9e66a76ec2ef74fad9acd12f..6f3cac6c4aa1039622875f733ea4abc3a37817ca 100644 --- a/paddle/phi/kernels/cpu/gather_tree_kernel.cc +++ b/paddle/phi/kernels/cpu/gather_tree_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/gather_tree_kernel.h" + #include "paddle/phi/core/kernel_registry.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/gaussian_random_kernel.cc b/paddle/phi/kernels/cpu/gaussian_random_kernel.cc index 348d24b534e3e22758de4e2c564796cd494ca1f8..c600149cbbacce1031194a91f0921f5787a1f9ae 100644 --- a/paddle/phi/kernels/cpu/gaussian_random_kernel.cc +++ b/paddle/phi/kernels/cpu/gaussian_random_kernel.cc @@ -14,11 +14,10 @@ #include "paddle/phi/kernels/gaussian_random_kernel.h" +#include "paddle/fluid/framework/generator.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" -#include "paddle/fluid/framework/generator.h" - namespace phi { template diff --git a/paddle/phi/kernels/cpu/gelu_kernel.cc b/paddle/phi/kernels/cpu/gelu_kernel.cc index d7af220574565ea96706c2a87aec6751c9203af4..4d23470aa4e9e2d146c601e955955d4164603678 100644 --- a/paddle/phi/kernels/cpu/gelu_kernel.cc +++ b/paddle/phi/kernels/cpu/gelu_kernel.cc @@ -13,8 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/gelu_kernel.h" + #include #include + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/blas/blas.h" diff --git a/paddle/phi/kernels/cpu/graph_reindex_kernel.cc b/paddle/phi/kernels/cpu/graph_reindex_kernel.cc index 92f2dc41e65fb114e0170a4bf818bf26d420c3c2..428bcb031704cdfb53a8a035a96260d0575b292f 100644 --- a/paddle/phi/kernels/cpu/graph_reindex_kernel.cc +++ b/paddle/phi/kernels/cpu/graph_reindex_kernel.cc @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/phi/kernels/graph_reindex_kernel.h" + #include #include -#include "paddle/phi/kernels/graph_reindex_kernel.h" - #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/graph_sample_neighbors_kernel.cc b/paddle/phi/kernels/cpu/graph_sample_neighbors_kernel.cc index 70aac053417b8eec345fdc001e070e5cdfd4b305..1ef5373d6310b941453c90f6b9f4cf377ee516a5 100644 --- a/paddle/phi/kernels/cpu/graph_sample_neighbors_kernel.cc +++ b/paddle/phi/kernels/cpu/graph_sample_neighbors_kernel.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "paddle/phi/kernels/graph_sample_neighbors_kernel.h" +#include + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/graph_send_recv_grad_kernel.cc b/paddle/phi/kernels/cpu/graph_send_recv_grad_kernel.cc index 6ea65d005c1adb23c0b3d3c27ff0168558c665d3..ad04bd258e1413f638b859694d9479bcdae207ac 100644 --- a/paddle/phi/kernels/cpu/graph_send_recv_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/graph_send_recv_grad_kernel.cc @@ -13,12 +13,12 @@ // limitations under the License. #include "paddle/phi/kernels/graph_send_recv_grad_kernel.h" -#include "paddle/phi/kernels/cpu/graph_send_recv_funcs.h" #include #include #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/cpu/graph_send_recv_funcs.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/graph_send_recv_kernel.cc b/paddle/phi/kernels/cpu/graph_send_recv_kernel.cc index 8f71ba12cc4fa25bc20e337bf3986518e3ce3672..e4034230c7866f1223172e9be1bf6fdcd7f3d124 100644 --- a/paddle/phi/kernels/cpu/graph_send_recv_kernel.cc +++ b/paddle/phi/kernels/cpu/graph_send_recv_kernel.cc @@ -13,7 +13,6 @@ // limitations under the License. #include "paddle/phi/kernels/graph_send_recv_kernel.h" -#include "paddle/phi/kernels/cpu/graph_send_recv_funcs.h" #include #include @@ -22,6 +21,7 @@ #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/hostdevice.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/cpu/graph_send_recv_funcs.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/grid_sample_grad_kernel.cc b/paddle/phi/kernels/cpu/grid_sample_grad_kernel.cc index 923cb8424115e00f07274f959ffe34adaa9a0327..32fa0d5aafefeead2252138c35b4033758235130 100644 --- a/paddle/phi/kernels/cpu/grid_sample_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/grid_sample_grad_kernel.cc @@ -73,8 +73,9 @@ static inline void ClipWithMask(const CPUContext& ctx, .cwiseMin(static_cast(max_val)); auto in_bound = (clipped == reflected).template cast(); grid_scale_t.device(place) = - grid_scale_t * ((is_neg == one_more_flip).template cast() - - (is_neg != one_more_flip).template cast()) * + grid_scale_t * + ((is_neg == one_more_flip).template cast() - + (is_neg != one_more_flip).template cast()) * in_bound; grid_slice_t.device(place) = clipped; } diff --git a/paddle/phi/kernels/cpu/gumbel_softmax_grad_kernel.cc b/paddle/phi/kernels/cpu/gumbel_softmax_grad_kernel.cc index a4c131e72b59a9b6a975dbb7f43d33321ae9a549..832df98e0f3f695a27ced80978f662046244373f 100644 --- a/paddle/phi/kernels/cpu/gumbel_softmax_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/gumbel_softmax_grad_kernel.cc @@ -13,9 +13,9 @@ // limitations under the License. #include "paddle/phi/kernels/gumbel_softmax_grad_kernel.h" -#include "paddle/phi/kernels/impl/gumbel_softmax_grad_kernel_impl.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/gumbel_softmax_grad_kernel_impl.h" PD_REGISTER_KERNEL(gumbel_softmax_grad, CPU, diff --git a/paddle/phi/kernels/cpu/gumbel_softmax_kernel.cc b/paddle/phi/kernels/cpu/gumbel_softmax_kernel.cc index eb406665c5f4f63a67ea84f5516b93fc82644e67..7638ca3aa7ee63f521d59ebabcd5d2930a2e5d0b 100644 --- a/paddle/phi/kernels/cpu/gumbel_softmax_kernel.cc +++ b/paddle/phi/kernels/cpu/gumbel_softmax_kernel.cc @@ -13,11 +13,11 @@ // limitations under the License. #include "paddle/phi/kernels/gumbel_softmax_kernel.h" -#include "paddle/phi/kernels/impl/gumbel_softmax_kernel_impl.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/axis_utils.h" #include "paddle/phi/kernels/funcs/math_function.h" +#include "paddle/phi/kernels/impl/gumbel_softmax_kernel_impl.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/histogram_kernel.cc b/paddle/phi/kernels/cpu/histogram_kernel.cc index 82b88f868d8a70cd61073b65bb24fd195baeb5c2..d9c41508efde08f80454a8586163bbc06dbfc984 100644 --- a/paddle/phi/kernels/cpu/histogram_kernel.cc +++ b/paddle/phi/kernels/cpu/histogram_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/histogram_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/phi/kernels/cpu/huber_loss_grad_kernel.cc b/paddle/phi/kernels/cpu/huber_loss_grad_kernel.cc index 654f2c9400af00484e6921aae63aeb0d93b521ae..b52a587070af63720f45e40ae79f316bbde57326 100644 --- a/paddle/phi/kernels/cpu/huber_loss_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/huber_loss_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/huber_loss_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/huber_loss_grad_kernel_impl.h" diff --git a/paddle/phi/kernels/cpu/huber_loss_kernel.cc b/paddle/phi/kernels/cpu/huber_loss_kernel.cc index 702c0589057af7079e6e0a41f1058063922790fe..2c4d8941ab87b6ce4ff3c2839a2b9f6d72915e74 100644 --- a/paddle/phi/kernels/cpu/huber_loss_kernel.cc +++ b/paddle/phi/kernels/cpu/huber_loss_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/huber_loss_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/huber_loss_kernel_impl.h" diff --git a/paddle/phi/kernels/cpu/index_sample_grad_kernel.cc b/paddle/phi/kernels/cpu/index_sample_grad_kernel.cc index d060e8c9b283706e0e585a46d55dfcbf8f4e2561..fe8ca4e432e2140027acd828689a3efdd1219762 100644 --- a/paddle/phi/kernels/cpu/index_sample_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/index_sample_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/index_sample_grad_kernel.h" + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/tensor_util.h" #include "paddle/phi/backends/cpu/cpu_context.h" diff --git a/paddle/phi/kernels/cpu/index_sample_kernel.cc b/paddle/phi/kernels/cpu/index_sample_kernel.cc index b895e4aa7c0e7c3315092a8603a4390cd5f76792..faa6953704e8087d6007bcdc95e7a5fb703aa836 100644 --- a/paddle/phi/kernels/cpu/index_sample_kernel.cc +++ b/paddle/phi/kernels/cpu/index_sample_kernel.cc @@ -13,12 +13,14 @@ // limitations under the License. #include "paddle/phi/kernels/index_sample_kernel.h" + #include #include #include #include #include #include + #include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/tensor_util.h" #include "paddle/phi/backends/cpu/cpu_context.h" diff --git a/paddle/phi/kernels/cpu/instance_norm_grad_kernel.cc b/paddle/phi/kernels/cpu/instance_norm_grad_kernel.cc index 867d43fd833de5caf97295d7ee99f4c6de2c6474..45ef003410926057c605be55c0d4cb7691d10fa1 100644 --- a/paddle/phi/kernels/cpu/instance_norm_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/instance_norm_grad_kernel.cc @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/layout.h" #include "paddle/phi/core/kernel_registry.h" @@ -142,12 +143,11 @@ void InstanceNormGradKernel(const Context& dev_ctx, dx_arr.device(*place) = scale_arr.broadcast(bcast_param) * inv_var_arr.broadcast(bcast) * (dy_arr - dy_mean - - tmp * - (dy_arr * tmp) - .mean(mean_rdims) - .reshape(NxC_shape) - .eval() - .broadcast(bcast)); + tmp * (dy_arr * tmp) + .mean(mean_rdims) + .reshape(NxC_shape) + .eval() + .broadcast(bcast)); } template diff --git a/paddle/phi/kernels/cpu/instance_norm_kernel.cc b/paddle/phi/kernels/cpu/instance_norm_kernel.cc index 5eac473effa0e7598f7fc44b6b2571e517db6b11..4deced5499ecb6272396fc633d72525eca75e4b5 100644 --- a/paddle/phi/kernels/cpu/instance_norm_kernel.cc +++ b/paddle/phi/kernels/cpu/instance_norm_kernel.cc @@ -17,6 +17,7 @@ #include #include #include + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/layout.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/interpolate_grad_kernel.cc b/paddle/phi/kernels/cpu/interpolate_grad_kernel.cc index d4e13aa3b24fe065a501c746146ec775c4eb6eda..edd41b2c7a31d084011da7ec6e026135c5588cb3 100644 --- a/paddle/phi/kernels/cpu/interpolate_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/interpolate_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/interpolate_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/layout.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/isclose_kernel.cc b/paddle/phi/kernels/cpu/isclose_kernel.cc index 633c6ba093e42762e3d5b64415d6098c3add6b8a..dca21494b3ee951c73177eb5bce628bc9a6cfc2a 100644 --- a/paddle/phi/kernels/cpu/isclose_kernel.cc +++ b/paddle/phi/kernels/cpu/isclose_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/isclose_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/isclose_kernel_impl.h" diff --git a/paddle/phi/kernels/cpu/kldiv_loss_grad_kernel.cc b/paddle/phi/kernels/cpu/kldiv_loss_grad_kernel.cc index f9399d38d711f56305641c9f3170306bacdd6095..9f6e2573e33e50d9dca67eaf117cb5d292639c96 100644 --- a/paddle/phi/kernels/cpu/kldiv_loss_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/kldiv_loss_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/kldiv_loss_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/kldiv_loss_grad_kernel_impl.h" diff --git a/paddle/phi/kernels/cpu/kldiv_loss_kernel.cc b/paddle/phi/kernels/cpu/kldiv_loss_kernel.cc index c462b8ec32c89dfcf2657018baf9b13764f2858e..ecb1915cf420e0300aae75a2ff2a689cb2409126 100644 --- a/paddle/phi/kernels/cpu/kldiv_loss_kernel.cc +++ b/paddle/phi/kernels/cpu/kldiv_loss_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/kldiv_loss_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/kldiv_loss_kernel_impl.h" diff --git a/paddle/phi/kernels/cpu/label_smooth_grad_kernel.cc b/paddle/phi/kernels/cpu/label_smooth_grad_kernel.cc index 74664fb270b2d27a56e7eb6634b50f167b2764ba..1a900b4bc2aff7f30715b7697a2e9b3ee9149157 100644 --- a/paddle/phi/kernels/cpu/label_smooth_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/label_smooth_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/label_smooth_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/eigen/common.h" diff --git a/paddle/phi/kernels/cpu/label_smooth_kernel.cc b/paddle/phi/kernels/cpu/label_smooth_kernel.cc index af9548e8186bcc96f4e54b1ec82b6a4b9bd12709..cdeed73310d24b8d9442593041276972e670e628 100644 --- a/paddle/phi/kernels/cpu/label_smooth_kernel.cc +++ b/paddle/phi/kernels/cpu/label_smooth_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/label_smooth_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/eigen/common.h" diff --git a/paddle/phi/kernels/cpu/layer_norm_grad_kernel.cc b/paddle/phi/kernels/cpu/layer_norm_grad_kernel.cc index a30f54fd4b60e746f9ae8b5aa8f1923a3ef9fad7..081a32b4f245b5e988ddfe4c99a8202f870d37af 100644 --- a/paddle/phi/kernels/cpu/layer_norm_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/layer_norm_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/layer_norm_grad_kernel.h" + #include "paddle/phi/kernels/cpu/elementwise.h" #include "paddle/phi/kernels/funcs/layer_norm_util.h" #if !defined(PADDLE_WITH_CUDA) && !defined(_WIN32) && !defined(__APPLE__) && \ diff --git a/paddle/phi/kernels/cpu/layer_norm_kernel.cc b/paddle/phi/kernels/cpu/layer_norm_kernel.cc index 52722468e16bd48144ae9aca7db88d9e1f48e355..dbc3da0ca15acae080ab5b2983abbb48f9db1d92 100644 --- a/paddle/phi/kernels/cpu/layer_norm_kernel.cc +++ b/paddle/phi/kernels/cpu/layer_norm_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/layer_norm_kernel.h" + #include "paddle/phi/kernels/cpu/elementwise.h" #include "paddle/phi/kernels/funcs/layer_norm_util.h" #if !defined(PADDLE_WITH_CUDA) && !defined(_WIN32) && !defined(__APPLE__) && \ diff --git a/paddle/phi/kernels/cpu/lerp_grad_kernel.cc b/paddle/phi/kernels/cpu/lerp_grad_kernel.cc index d74919011ec5da08b700b974393fcc70de22b21c..ae98cb9d03aeedbd2aa881dd32a22232cbe887f5 100644 --- a/paddle/phi/kernels/cpu/lerp_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/lerp_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/lerp_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/lerp_grad_kernel_impl.h" diff --git a/paddle/phi/kernels/cpu/lerp_kernel.cc b/paddle/phi/kernels/cpu/lerp_kernel.cc index 7adfc35bfa321e8c111a11998e3b0b683009e619..d02e706d8d600332d5a38b0b040e5ddc9e4a1117 100644 --- a/paddle/phi/kernels/cpu/lerp_kernel.cc +++ b/paddle/phi/kernels/cpu/lerp_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/lerp_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/lerp_kernel_impl.h" diff --git a/paddle/phi/kernels/cpu/lgamma_grad_kernel.cc b/paddle/phi/kernels/cpu/lgamma_grad_kernel.cc index 116fa3f8d3f6a91ec0705b92ff65aa2a411f4f23..a87c01214a93d3b4029eeb07b198401f88bbee36 100644 --- a/paddle/phi/kernels/cpu/lgamma_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/lgamma_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/lgamma_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/lgamma_grad_kernel_impl.h" diff --git a/paddle/phi/kernels/cpu/lgamma_kernel.cc b/paddle/phi/kernels/cpu/lgamma_kernel.cc index f849322174d295d95fcd9080e090d5a7ece0ec79..4979ad0b30bcd13dfb04b5a5d58079d98c15c3a8 100644 --- a/paddle/phi/kernels/cpu/lgamma_kernel.cc +++ b/paddle/phi/kernels/cpu/lgamma_kernel.cc @@ -15,6 +15,7 @@ #include "paddle/phi/kernels/lgamma_kernel.h" #include + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/for_range.h" diff --git a/paddle/phi/kernels/cpu/log_softmax_grad_kernel.cc b/paddle/phi/kernels/cpu/log_softmax_grad_kernel.cc index 5f344b9cc3fe0a4c71470c361f2e8f370bc5908a..d3e5e90fd17a37c61f07cc59255962fa094ec09e 100644 --- a/paddle/phi/kernels/cpu/log_softmax_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/log_softmax_grad_kernel.cc @@ -55,10 +55,9 @@ struct LogSoftmaxGradFunctor { Eigen::DSizes one_axis(1, axis_dim); dx.device(*context.eigen_device()) = - dy - - (y.exp()) * (dy.reshape(batch_axis_remain) - .sum(along_class) - .broadcast(one_axis)); + dy - (y.exp()) * (dy.reshape(batch_axis_remain) + .sum(along_class) + .broadcast(one_axis)); } }; diff --git a/paddle/phi/kernels/cpu/log_softmax_kernel.cc b/paddle/phi/kernels/cpu/log_softmax_kernel.cc index 241742378cc5d012d2816745d0f83fc586089ef7..510eb7a6ca97ade101d8538e5a7bce99e747defa 100644 --- a/paddle/phi/kernels/cpu/log_softmax_kernel.cc +++ b/paddle/phi/kernels/cpu/log_softmax_kernel.cc @@ -72,34 +72,31 @@ struct LogSoftmaxFunctor { // axis == -1, axis and class in same dimension, calculate along // class dimension directly for higher performance log_softmax.device(*context.eigen_device()) = - (logits - - logits.maximum(along_axis) - .eval() - .reshape(batch_by_one) - .broadcast(one_by_class)) + (logits - logits.maximum(along_axis) + .eval() + .reshape(batch_by_one) + .broadcast(one_by_class)) .unaryExpr(ValueClip()); } else { // axis != -1, class dimension split into (axis, remain), max and sum // should be calculated along axis dimension log_softmax.device(*context.eigen_device()) = - (logits.reshape(batch_axis_remain) - - logits.reshape(batch_axis_remain) - .maximum(along_axis) - .eval() - .reshape(batch_one_remain) - .broadcast(one_axis_one) - .reshape(batch_classes)) + (logits.reshape(batch_axis_remain) - logits.reshape(batch_axis_remain) + .maximum(along_axis) + .eval() + .reshape(batch_one_remain) + .broadcast(one_axis_one) + .reshape(batch_classes)) .unaryExpr(ValueClip()); } log_softmax.device(*context.eigen_device()) = - log_softmax - - log_softmax.exp() - .eval() - .reshape(batch_axis_remain) - .sum(along_axis) - .log() - .broadcast(one_axis); + log_softmax - log_softmax.exp() + .eval() + .reshape(batch_axis_remain) + .sum(along_axis) + .log() + .broadcast(one_axis); } }; diff --git a/paddle/phi/kernels/cpu/logsumexp_kernel.cc b/paddle/phi/kernels/cpu/logsumexp_kernel.cc index 06e0b30a9ca6567d04f7946a1732fd1483289e03..f1fecdfbe9e66a52279faf3395f76735362d1cb0 100644 --- a/paddle/phi/kernels/cpu/logsumexp_kernel.cc +++ b/paddle/phi/kernels/cpu/logsumexp_kernel.cc @@ -16,7 +16,6 @@ #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" - #include "paddle/phi/kernels/impl/logsumexp_kernel_impl.h" PD_REGISTER_KERNEL( diff --git a/paddle/phi/kernels/cpu/matmul_grad_kernel.cc b/paddle/phi/kernels/cpu/matmul_grad_kernel.cc index aba519ff04849a54bfe1a69a6381f4298822279f..e3cd8fff8a50e7360127b5c84c82c477b7702b72 100644 --- a/paddle/phi/kernels/cpu/matmul_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/matmul_grad_kernel.cc @@ -16,7 +16,6 @@ limitations under the License. */ #include "paddle/phi/common/complex.h" #include "paddle/phi/core/kernel_registry.h" - #include "paddle/phi/kernels/impl/matmul_grad_kernel_impl.h" PD_REGISTER_KERNEL(matmul_grad, diff --git a/paddle/phi/kernels/cpu/matmul_kernel.cc b/paddle/phi/kernels/cpu/matmul_kernel.cc index 8aa25c0da07d9617d1734647d511e3707e60ebc3..c75a50130db767e903decd4b60e979b77a6a7af7 100644 --- a/paddle/phi/kernels/cpu/matmul_kernel.cc +++ b/paddle/phi/kernels/cpu/matmul_kernel.cc @@ -15,9 +15,8 @@ limitations under the License. */ #include "paddle/phi/kernels/matmul_kernel.h" #include "paddle/phi/backends/cpu/cpu_context.h" -#include "paddle/phi/core/kernel_registry.h" - #include "paddle/phi/common/complex.h" +#include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/matmul_kernel_impl.h" PD_REGISTER_KERNEL(matmul, diff --git a/paddle/phi/kernels/cpu/matrix_power_grad_kernel.cc b/paddle/phi/kernels/cpu/matrix_power_grad_kernel.cc index ae3b4d2b45582b84d81a2a57865c6cc287f86535..0f60f8da71a8bda41db49b79a1bb454eff2630f0 100644 --- a/paddle/phi/kernels/cpu/matrix_power_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/matrix_power_grad_kernel.cc @@ -13,10 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/kernels/matrix_power_grad_kernel.h" -#include "paddle/phi/kernels/impl/matrix_power_grad_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/matrix_power_grad_kernel_impl.h" PD_REGISTER_KERNEL(matrix_power_grad, CPU, diff --git a/paddle/phi/kernels/cpu/matrix_power_kernel.cc b/paddle/phi/kernels/cpu/matrix_power_kernel.cc index f40e1e616f526262eee2a50b319935e7ab160bee..08ee7cbc865dfc1eae549f938feff8b5e0eaae82 100644 --- a/paddle/phi/kernels/cpu/matrix_power_kernel.cc +++ b/paddle/phi/kernels/cpu/matrix_power_kernel.cc @@ -13,10 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/kernels/matrix_power_kernel.h" -#include "paddle/phi/kernels/impl/matrix_power_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/matrix_power_kernel_impl.h" PD_REGISTER_KERNEL( matrix_power, CPU, ALL_LAYOUT, phi::MatrixPowerKernel, float, double) {} diff --git a/paddle/phi/kernels/cpu/matrix_rank_kernel.cc b/paddle/phi/kernels/cpu/matrix_rank_kernel.cc index 5e13abe8aed2caf205871a24cfddff0b8b959498..f56bd3d6dbe8aad653dcc94e974ef6a857f6f398 100644 --- a/paddle/phi/kernels/cpu/matrix_rank_kernel.cc +++ b/paddle/phi/kernels/cpu/matrix_rank_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/matrix_rank_kernel.h" -#include "paddle/phi/kernels/matrix_rank_tol_kernel.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/full_kernel.h" +#include "paddle/phi/kernels/matrix_rank_tol_kernel.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/matrix_rank_tol_kernel.cc b/paddle/phi/kernels/cpu/matrix_rank_tol_kernel.cc index 3bfc07319e98dac12fcec00a6172ea113f654b29..af9b7728389ba44c0e1b922282739f0948ea0013 100644 --- a/paddle/phi/kernels/cpu/matrix_rank_tol_kernel.cc +++ b/paddle/phi/kernels/cpu/matrix_rank_tol_kernel.cc @@ -16,6 +16,7 @@ #include #include + #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/elementwise_multiply_kernel.h" #include "paddle/phi/kernels/full_kernel.h" diff --git a/paddle/phi/kernels/cpu/maxout_grad_kernel.cc b/paddle/phi/kernels/cpu/maxout_grad_kernel.cc index 429344a362b1c3215f6019b70941db0255e304f3..dad4e96b5a8b1ecfc4c3489e6112a5dedb7f5e61 100644 --- a/paddle/phi/kernels/cpu/maxout_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/maxout_grad_kernel.cc @@ -12,9 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/phi/kernels/impl/maxout_grad_kernel_impl.h" - #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/maxout_grad_kernel_impl.h" PD_REGISTER_KERNEL( maxout_grad, CPU, ALL_LAYOUT, phi::MaxOutGradKernel, float, double) {} diff --git a/paddle/phi/kernels/cpu/maxout_kernel.cc b/paddle/phi/kernels/cpu/maxout_kernel.cc index e7cd3ab07ff598230338fcb1a3804952a000d14d..cc1d21d310b1f54caf31457a48371a4ed2382a8c 100644 --- a/paddle/phi/kernels/cpu/maxout_kernel.cc +++ b/paddle/phi/kernels/cpu/maxout_kernel.cc @@ -12,8 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/phi/kernels/impl/maxout_kernel_impl.h" - #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/maxout_kernel_impl.h" PD_REGISTER_KERNEL(maxout, CPU, ALL_LAYOUT, phi::MaxOutKernel, float, double) {} diff --git a/paddle/phi/kernels/cpu/meshgrid_grad_kernel.cc b/paddle/phi/kernels/cpu/meshgrid_grad_kernel.cc index 159d109255381bf80a6129ed8df9ea24ffbe74f6..5b43fb02b5117b2182f6e9d3056e60161ff4b054 100644 --- a/paddle/phi/kernels/cpu/meshgrid_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/meshgrid_grad_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/meshgrid_grad_kernel.h" -#include "paddle/phi/kernels/impl/meshgrid_grad_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/meshgrid_grad_kernel_impl.h" PD_REGISTER_KERNEL(meshgrid_grad, CPU, diff --git a/paddle/phi/kernels/cpu/meshgrid_kernel.cc b/paddle/phi/kernels/cpu/meshgrid_kernel.cc index c201103b3dac4a2304a18ffb17dd0bce16236d64..35e43f7bbc85ebe2cc79ed2dc810cc3bcfe1c0e2 100644 --- a/paddle/phi/kernels/cpu/meshgrid_kernel.cc +++ b/paddle/phi/kernels/cpu/meshgrid_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/meshgrid_kernel.h" -#include "paddle/phi/kernels/impl/meshgrid_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/meshgrid_kernel_impl.h" PD_REGISTER_KERNEL(meshgrid, CPU, diff --git a/paddle/phi/kernels/cpu/momentum_kernel.cc b/paddle/phi/kernels/cpu/momentum_kernel.cc index 63cc5592ef42200833001701e11422011ecef5d8..7a4ea9f19e5c2d64c55a5dd570108bac4baa8300 100644 --- a/paddle/phi/kernels/cpu/momentum_kernel.cc +++ b/paddle/phi/kernels/cpu/momentum_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/momentum_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/momentum_kernel_impl.h" diff --git a/paddle/phi/kernels/cpu/multi_dot_grad_kernel.cc b/paddle/phi/kernels/cpu/multi_dot_grad_kernel.cc index 2cd75404be821ce1f2303237fcb92cae53ee25d1..f6b07584ce44e8102a81ce55587347e339a8768e 100644 --- a/paddle/phi/kernels/cpu/multi_dot_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/multi_dot_grad_kernel.cc @@ -13,10 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/kernels/multi_dot_grad_kernel.h" -#include "paddle/phi/kernels/impl/multi_dot_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/multi_dot_kernel_impl.h" PD_REGISTER_KERNEL( multi_dot_grad, CPU, ALL_LAYOUT, phi::MultiDotGradKernel, float, double) {} diff --git a/paddle/phi/kernels/cpu/multi_dot_kernel.cc b/paddle/phi/kernels/cpu/multi_dot_kernel.cc index a4249a98e46dde19ea0bf91bee73ba7a0d425f28..00cf425a038a1546a29e3db01a162c91cb2f147d 100644 --- a/paddle/phi/kernels/cpu/multi_dot_kernel.cc +++ b/paddle/phi/kernels/cpu/multi_dot_kernel.cc @@ -13,10 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/kernels/multi_dot_kernel.h" -#include "paddle/phi/kernels/impl/multi_dot_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/multi_dot_kernel_impl.h" PD_REGISTER_KERNEL( multi_dot, CPU, ALL_LAYOUT, phi::MultiDotKernel, float, double) {} diff --git a/paddle/phi/kernels/cpu/multiplex_grad_kernel.cc b/paddle/phi/kernels/cpu/multiplex_grad_kernel.cc index f5a426e93db2cf23962276632fead69565999d37..12ba6dadde304b7f25ff400bd621afaeb84fd71c 100644 --- a/paddle/phi/kernels/cpu/multiplex_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/multiplex_grad_kernel.cc @@ -15,7 +15,6 @@ #include "paddle/phi/kernels/multiplex_grad_kernel.h" #include "paddle/fluid/memory/memcpy.h" - #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/eigen/common.h" diff --git a/paddle/phi/kernels/cpu/mv_kernel.cc b/paddle/phi/kernels/cpu/mv_kernel.cc index 7f76ddda6dde5ba686fa7403910a245644a16f2d..408eda34e1c00016acb363d0f9e6963a8ffe2104 100644 --- a/paddle/phi/kernels/cpu/mv_kernel.cc +++ b/paddle/phi/kernels/cpu/mv_kernel.cc @@ -16,7 +16,6 @@ #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" - #include "paddle/phi/kernels/impl/mv_kernel_impl.h" PD_REGISTER_KERNEL(mv, CPU, ALL_LAYOUT, phi::MvKernel, float, double) {} diff --git a/paddle/phi/kernels/cpu/nll_loss_grad_kernel.cc b/paddle/phi/kernels/cpu/nll_loss_grad_kernel.cc index dd2b09ee39acb3dc5afcb3cb0762aba102529fe8..9048e87d049895f80183bb424d72ac2f57d68e26 100644 --- a/paddle/phi/kernels/cpu/nll_loss_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/nll_loss_grad_kernel.cc @@ -16,6 +16,7 @@ #include #include + #include "paddle/fluid/operators/math.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/nll_loss_kernel.cc b/paddle/phi/kernels/cpu/nll_loss_kernel.cc index 92cb6a1ad17dec256c84c1d7d349a336cacd47ef..c966e91a9a6e96ce01cbc153e50e8e4c5278d4e8 100644 --- a/paddle/phi/kernels/cpu/nll_loss_kernel.cc +++ b/paddle/phi/kernels/cpu/nll_loss_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/nll_loss_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/enforce.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/norm_grad_kernel.cc b/paddle/phi/kernels/cpu/norm_grad_kernel.cc index bd05e2c4c6ec1759b55a6f4fb0e7f83d1aeac954..92ca51b499c7a892deecac4526344cd9d9a8daca 100644 --- a/paddle/phi/kernels/cpu/norm_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/norm_grad_kernel.cc @@ -13,15 +13,13 @@ // limitations under the License. #include "paddle/phi/kernels/norm_grad_kernel.h" -#include "paddle/phi/kernels/funcs/eigen/eigen_function.h" -#include "paddle/phi/kernels/funcs/math_function.h" - -#include "paddle/phi/kernels/funcs/eigen/common.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" - #include "paddle/phi/kernels/funcs/common_shape.h" +#include "paddle/phi/kernels/funcs/eigen/common.h" +#include "paddle/phi/kernels/funcs/eigen/eigen_function.h" +#include "paddle/phi/kernels/funcs/math_function.h" namespace phi { template diff --git a/paddle/phi/kernels/cpu/norm_kernel.cc b/paddle/phi/kernels/cpu/norm_kernel.cc index 50906d9c3bb9495817e81678b60fe3e426a22444..f69d03b66b1b5d8364099ce2f6410075bc010382 100644 --- a/paddle/phi/kernels/cpu/norm_kernel.cc +++ b/paddle/phi/kernels/cpu/norm_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/norm_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/common_shape.h" diff --git a/paddle/phi/kernels/cpu/one_hot_kernel.cc b/paddle/phi/kernels/cpu/one_hot_kernel.cc index fc7979e41d938cdc381a2821d1bf33ff5706569d..f408c9f036152308c23eb04be5d394089b3054b9 100644 --- a/paddle/phi/kernels/cpu/one_hot_kernel.cc +++ b/paddle/phi/kernels/cpu/one_hot_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/one_hot_kernel.h" + #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/core/utils/data_type.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/phi/kernels/cpu/p_norm_grad_kernel.cc b/paddle/phi/kernels/cpu/p_norm_grad_kernel.cc index 44ab050408653033805a821a79f9fc871542970c..32905ab0878832fe3c7c01801c9d8c8433118609 100644 --- a/paddle/phi/kernels/cpu/p_norm_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/p_norm_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/p_norm_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/eigen/common.h" diff --git a/paddle/phi/kernels/cpu/p_norm_kernel.cc b/paddle/phi/kernels/cpu/p_norm_kernel.cc index 9da7fdbb297c225059fa322332a2f2c38c866995..597939953b27713cf2c9a6caf0dc1577a0421d8d 100644 --- a/paddle/phi/kernels/cpu/p_norm_kernel.cc +++ b/paddle/phi/kernels/cpu/p_norm_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/p_norm_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/common_shape.h" diff --git a/paddle/phi/kernels/cpu/pixel_shuffle_grad_kernel.cc b/paddle/phi/kernels/cpu/pixel_shuffle_grad_kernel.cc index b32065d4f0a145c382648cc1f192b032f7df0802..0e2bfd04b620e45246e60f6999c50fb860c4e5f2 100644 --- a/paddle/phi/kernels/cpu/pixel_shuffle_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/pixel_shuffle_grad_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/pixel_shuffle_grad_kernel.h" -#include "paddle/phi/kernels/impl/pixel_shuffle_grad_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/pixel_shuffle_grad_kernel_impl.h" PD_REGISTER_KERNEL(pixel_shuffle_grad, CPU, diff --git a/paddle/phi/kernels/cpu/pixel_shuffle_kernel.cc b/paddle/phi/kernels/cpu/pixel_shuffle_kernel.cc index 80f8fa7b50efb7f2e685b7e202d89c0f9a382a18..44dcb8b59f77c67a9cd9f8e22c90b0fda2ab18ad 100644 --- a/paddle/phi/kernels/cpu/pixel_shuffle_kernel.cc +++ b/paddle/phi/kernels/cpu/pixel_shuffle_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/pixel_shuffle_kernel.h" -#include "paddle/phi/kernels/impl/pixel_shuffle_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/pixel_shuffle_kernel_impl.h" PD_REGISTER_KERNEL( pixel_shuffle, CPU, ALL_LAYOUT, phi::PixelShuffleKernel, float, double) {} diff --git a/paddle/phi/kernels/cpu/pixel_unshuffle_grad_kernel.cc b/paddle/phi/kernels/cpu/pixel_unshuffle_grad_kernel.cc index ef61fca35957e8dc6c243633dbbb07acfe0d58f6..cbcbf1e129d20a9abf26d0d2023cfe70f6e1a0d3 100644 --- a/paddle/phi/kernels/cpu/pixel_unshuffle_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/pixel_unshuffle_grad_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/pixel_unshuffle_grad_kernel.h" -#include "paddle/phi/kernels/impl/pixel_unshuffle_grad_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/pixel_unshuffle_grad_kernel_impl.h" PD_REGISTER_KERNEL(pixel_unshuffle_grad, CPU, diff --git a/paddle/phi/kernels/cpu/pixel_unshuffle_kernel.cc b/paddle/phi/kernels/cpu/pixel_unshuffle_kernel.cc index 9f4bc747f3209bc8851550352efe95d98a1714f1..837378972c69a8faa84651a7a8dbe6efb7bf0f05 100644 --- a/paddle/phi/kernels/cpu/pixel_unshuffle_kernel.cc +++ b/paddle/phi/kernels/cpu/pixel_unshuffle_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/pixel_unshuffle_kernel.h" -#include "paddle/phi/kernels/impl/pixel_unshuffle_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/pixel_unshuffle_kernel_impl.h" PD_REGISTER_KERNEL(pixel_unshuffle, CPU, diff --git a/paddle/phi/kernels/cpu/poisson_kernel.cc b/paddle/phi/kernels/cpu/poisson_kernel.cc index 6a3e32c2f07853f57e123e64660cd6bc50d8574b..8ba1afe229eee19ddd660be6023aab7cc8a109f9 100644 --- a/paddle/phi/kernels/cpu/poisson_kernel.cc +++ b/paddle/phi/kernels/cpu/poisson_kernel.cc @@ -12,11 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/phi/kernels/poisson_kernel.h" + #include #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" -#include "paddle/phi/kernels/poisson_kernel.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/pool_grad_kernel.cc b/paddle/phi/kernels/cpu/pool_grad_kernel.cc index bb97694d8fc38d92f5290894a2c45dd21e7b1717..68cd57c52277b47919d38d477477aeb6273e3ca5 100644 --- a/paddle/phi/kernels/cpu/pool_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/pool_grad_kernel.cc @@ -14,9 +14,8 @@ #include "paddle/phi/kernels/pool_grad_kernel.h" -#include "paddle/phi/kernels/impl/pool_grad_kernel_impl.h" - #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/pool_grad_kernel_impl.h" PD_REGISTER_KERNEL( pool2d_grad, CPU, ALL_LAYOUT, phi::Pool2dGradKernel, float, double) {} diff --git a/paddle/phi/kernels/cpu/pool_kernel.cc b/paddle/phi/kernels/cpu/pool_kernel.cc index 1d57e282c3c8ae85573bf11eff43e6551a808ea0..3d3880692c0c8d53a3b499145774edcda61f1386 100644 --- a/paddle/phi/kernels/cpu/pool_kernel.cc +++ b/paddle/phi/kernels/cpu/pool_kernel.cc @@ -14,9 +14,8 @@ #include "paddle/phi/kernels/pool_kernel.h" -#include "paddle/phi/kernels/impl/pool_kernel_impl.h" - #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/pool_kernel_impl.h" PD_REGISTER_KERNEL(pool2d, CPU, ALL_LAYOUT, phi::Pool2dKernel, float, double) {} PD_REGISTER_KERNEL(max_pool2d_with_index, diff --git a/paddle/phi/kernels/cpu/psroi_pool_grad_kernel.cc b/paddle/phi/kernels/cpu/psroi_pool_grad_kernel.cc index b68c3ad545d337a4c469ac380a793ceac688ef64..202baddd713a45f10e7f31c81ff688a0762a2b5a 100644 --- a/paddle/phi/kernels/cpu/psroi_pool_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/psroi_pool_grad_kernel.cc @@ -15,6 +15,7 @@ #include "paddle/phi/kernels/psroi_pool_grad_kernel.h" #include + #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/math_function.h" diff --git a/paddle/phi/kernels/cpu/psroi_pool_kernel.cc b/paddle/phi/kernels/cpu/psroi_pool_kernel.cc index 4f7925ad00f5a74a6ace2a6755e8a211c0434d2d..82eff70b7564307e9b82644a6120d06b2db4fa96 100644 --- a/paddle/phi/kernels/cpu/psroi_pool_kernel.cc +++ b/paddle/phi/kernels/cpu/psroi_pool_kernel.cc @@ -15,6 +15,7 @@ #include "paddle/phi/kernels/psroi_pool_kernel.h" #include + #include "paddle/phi/core/kernel_registry.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/qr_kernel.cc b/paddle/phi/kernels/cpu/qr_kernel.cc index b0e82cedb6b8b88e04d6e2128b6c3aa438901996..6a5551d95571b272935e33b8f9a03d30030ca9b5 100644 --- a/paddle/phi/kernels/cpu/qr_kernel.cc +++ b/paddle/phi/kernels/cpu/qr_kernel.cc @@ -12,10 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - #include "paddle/phi/kernels/qr_kernel.h" +#include + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/complex_functors.h" diff --git a/paddle/phi/kernels/cpu/reduce.h b/paddle/phi/kernels/cpu/reduce.h index 35395dccca1afe6c384191986fecf621d97ece42..dad288cff2c1a4565a7b67d688936d231a6947c9 100644 --- a/paddle/phi/kernels/cpu/reduce.h +++ b/paddle/phi/kernels/cpu/reduce.h @@ -17,10 +17,9 @@ #include #include "paddle/phi/backends/cpu/cpu_context.h" +#include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/core/visit_type.h" #include "paddle/phi/kernels/cast_kernel.h" - -#include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/kernels/funcs/eigen/common.h" #include "paddle/phi/kernels/funcs/math_function.h" // See Note [ Why still include the fluid headers? ] diff --git a/paddle/phi/kernels/cpu/reduce_sum_grad_kernel.cc b/paddle/phi/kernels/cpu/reduce_sum_grad_kernel.cc index 66ae5e02ffc7590dd2b748a63649c02aac22023d..abc18b1c578a822c3ba1f8e27e39e7047e135773 100644 --- a/paddle/phi/kernels/cpu/reduce_sum_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/reduce_sum_grad_kernel.cc @@ -111,4 +111,3 @@ PD_REGISTER_KERNEL(sum_grad, int64_t, phi::dtype::complex, phi::dtype::complex) {} - diff --git a/paddle/phi/kernels/cpu/rmsprop_kernel.cc b/paddle/phi/kernels/cpu/rmsprop_kernel.cc index fa1e1a2eed345b833f07d3738530af43f9c57bb2..1d60823d75949c0110a49af01d34b8b4c0253bff 100644 --- a/paddle/phi/kernels/cpu/rmsprop_kernel.cc +++ b/paddle/phi/kernels/cpu/rmsprop_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/rmsprop_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/rmsprop_kernel_impl.h" diff --git a/paddle/phi/kernels/cpu/rnn_functor.h b/paddle/phi/kernels/cpu/rnn_functor.h index ab6f98ffcd5d6c2115b6f781d061cd2bc0ce7373..911814647d6c03855b9268b3a6766a8be3811539 100644 --- a/paddle/phi/kernels/cpu/rnn_functor.h +++ b/paddle/phi/kernels/cpu/rnn_functor.h @@ -14,6 +14,8 @@ #pragma once +#include "paddle/fluid/framework/generator.h" +#include "paddle/fluid/operators/utils.h" #include "paddle/phi/core/dense_tensor.h" #include "paddle/phi/kernels/copy_kernel.h" #include "paddle/phi/kernels/empty_kernel.h" @@ -21,9 +23,6 @@ #include "paddle/phi/kernels/funcs/eigen/eigen_function.h" #include "paddle/phi/kernels/funcs/math_function.h" -#include "paddle/fluid/framework/generator.h" -#include "paddle/fluid/operators/utils.h" - namespace phi { #define DEFINE_MODE_DETECTOR(MODE_NAME, MODE_STR) \ @@ -252,9 +251,12 @@ inline std::vector Unbind(const DenseTensor& in) { } template class LayerT, - template class SingleLayerT, - template class BidirLayerT, + template + class LayerT, + template + class SingleLayerT, + template + class BidirLayerT, typename T, typename Context> void RnnFunc(const Context& dev_ctx, diff --git a/paddle/phi/kernels/cpu/rnn_grad_kernel.cc b/paddle/phi/kernels/cpu/rnn_grad_kernel.cc index 4dd1894320af7bbbebb7a27bf8e539d0c93b2e79..1cd4add7d50e6da06c016475f434fd646e22effa 100644 --- a/paddle/phi/kernels/cpu/rnn_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/rnn_grad_kernel.cc @@ -16,7 +16,6 @@ #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" - #include "paddle/phi/kernels/copy_kernel.h" #include "paddle/phi/kernels/cpu/rnn_functor.h" #include "paddle/phi/kernels/funcs/activation_functor.h" @@ -962,8 +961,10 @@ void dropout_cpu_grad_function_inplace(const CPUContext& dev_ctx, } template class SingleGradLayerT, - template class BidirGradLayerT, + template + class SingleGradLayerT, + template + class BidirGradLayerT, typename T> void RnnGradFunc(const CPUContext& dev_ctx, const DenseTensor& x, diff --git a/paddle/phi/kernels/cpu/rnn_kernel.cc b/paddle/phi/kernels/cpu/rnn_kernel.cc index 80c521918ed07fc1330070963287d47eb52de3f5..e2e784b2943ccd42e61634f944abb22607d3c325 100644 --- a/paddle/phi/kernels/cpu/rnn_kernel.cc +++ b/paddle/phi/kernels/cpu/rnn_kernel.cc @@ -49,7 +49,8 @@ struct Cell { }; template class EigenActivationFunctor, + template + class EigenActivationFunctor, funcs::detail::ActivationType act_type> struct SimpleRNNCell : Cell { void operator()(const CPUContext* dev_ctx, diff --git a/paddle/phi/kernels/cpu/roi_align_kernel.cc b/paddle/phi/kernels/cpu/roi_align_kernel.cc index cd779b72e7a84d263251b9867afff0490c28d260..cf0dc47f47bd34f786fa509091a609986798728c 100644 --- a/paddle/phi/kernels/cpu/roi_align_kernel.cc +++ b/paddle/phi/kernels/cpu/roi_align_kernel.cc @@ -79,16 +79,12 @@ std::vector> GetIndexesAndRatios( for (std::size_t px = 0; px < pooled_width; px++) { for (std::size_t iy = 0; iy < roi_bin_grid_h; iy++) { // calculate x of sample points - auto y = - roi_ymin + - bin_h * (py + - static_cast(iy + .5f) / static_cast(roi_bin_grid_h)); + auto y = roi_ymin + bin_h * (py + static_cast(iy + .5f) / + static_cast(roi_bin_grid_h)); for (std::size_t ix = 0; ix < roi_bin_grid_w; ix++) { // calculate x of sample points - auto x = roi_xmin + - bin_w * (px + - static_cast(ix + .5f) / - static_cast(roi_bin_grid_w)); + auto x = roi_xmin + bin_w * (px + static_cast(ix + .5f) / + static_cast(roi_bin_grid_w)); // deal with elements out of map if (y < -1.0 || y > height || x < -1.0 || x > width) { diff --git a/paddle/phi/kernels/cpu/scatter_grad_kernel.cc b/paddle/phi/kernels/cpu/scatter_grad_kernel.cc index 62fd58704c4fef7c23cd8255d6958103b9755bff..f09015f24a136a023988b5241da4d298e6643d08 100644 --- a/paddle/phi/kernels/cpu/scatter_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/scatter_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/scatter_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/copy_kernel.h" diff --git a/paddle/phi/kernels/cpu/scatter_kernel.cc b/paddle/phi/kernels/cpu/scatter_kernel.cc index d48ceaf29a08c58de6f06746c36f2a8e8725852f..7032c3bb5a3357f062873c05cec40d4a8267c68f 100644 --- a/paddle/phi/kernels/cpu/scatter_kernel.cc +++ b/paddle/phi/kernels/cpu/scatter_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/scatter_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/copy_kernel.h" diff --git a/paddle/phi/kernels/cpu/scatter_nd_add_grad_kernel.cc b/paddle/phi/kernels/cpu/scatter_nd_add_grad_kernel.cc index cc143ba8d0e4557f8aaf07a4d4606bbf6c2b4d73..7c3665c5d2e2ef5ebef91d5a1d320ed61d7f6be3 100644 --- a/paddle/phi/kernels/cpu/scatter_nd_add_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/scatter_nd_add_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/scatter_nd_add_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/copy_kernel.h" diff --git a/paddle/phi/kernels/cpu/scatter_nd_add_kernel.cc b/paddle/phi/kernels/cpu/scatter_nd_add_kernel.cc index 04ae10f5e8b5d551819a97ea1594140e535e6a12..31e2f4c716122dacb945c3e3871f77f344e1b6dd 100644 --- a/paddle/phi/kernels/cpu/scatter_nd_add_kernel.cc +++ b/paddle/phi/kernels/cpu/scatter_nd_add_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/scatter_nd_add_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/copy_kernel.h" diff --git a/paddle/phi/kernels/cpu/segment_pool_grad_kernel.cc b/paddle/phi/kernels/cpu/segment_pool_grad_kernel.cc index a5c9dc4c55e495833f40ec7499e6c0373594d319..744ec7805fa600f16aa58aabc8a7c2af2f09e968 100644 --- a/paddle/phi/kernels/cpu/segment_pool_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/segment_pool_grad_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/segment_pool_grad_kernel.h" -#include "paddle/phi/kernels/impl/segment_pool_grad_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/segment_pool_grad_kernel_impl.h" PD_REGISTER_KERNEL(segment_pool_grad, CPU, diff --git a/paddle/phi/kernels/cpu/segment_pool_kernel.cc b/paddle/phi/kernels/cpu/segment_pool_kernel.cc index ad76a7a86bcb28f291288418c43740ed0b7adb97..541ccd3436548e59f3265cb3e34ddccae5da0a97 100644 --- a/paddle/phi/kernels/cpu/segment_pool_kernel.cc +++ b/paddle/phi/kernels/cpu/segment_pool_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/segment_pool_kernel.h" -#include "paddle/phi/kernels/impl/segment_pool_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/segment_pool_kernel_impl.h" PD_REGISTER_KERNEL(segment_pool, CPU, diff --git a/paddle/phi/kernels/cpu/selu_grad_kernel.cc b/paddle/phi/kernels/cpu/selu_grad_kernel.cc index 32101b19132825d77534a55b857c2a169e94e9ac..9f83e39a363d337d5786e1150521c2baeb83aa3a 100644 --- a/paddle/phi/kernels/cpu/selu_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/selu_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/selu_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/selu_grad_kernel_impl.h" diff --git a/paddle/phi/kernels/cpu/sgd_kernel.cc b/paddle/phi/kernels/cpu/sgd_kernel.cc index 214fd82bef358fa196490ed2854782b0c8bca806..055c44d38e4b2e75abcd537afbe0852f25f9084e 100644 --- a/paddle/phi/kernels/cpu/sgd_kernel.cc +++ b/paddle/phi/kernels/cpu/sgd_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/sgd_kernel.h" + #include "paddle/fluid/operators/jit/kernels.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/sign_kernel.cc b/paddle/phi/kernels/cpu/sign_kernel.cc index 5fe11ffbd6d5c08b5072b61ab23d6fbea1879b53..9ded252c5c5920a1ee2bb1bc29a045a488de1e65 100644 --- a/paddle/phi/kernels/cpu/sign_kernel.cc +++ b/paddle/phi/kernels/cpu/sign_kernel.cc @@ -13,10 +13,10 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/kernels/sign_kernel.h" -#include "paddle/phi/kernels/impl/sign_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/sign_kernel_impl.h" // See Note [ Why still include the fluid headers? ] #include "paddle/phi/common/bfloat16.h" diff --git a/paddle/phi/kernels/cpu/size_kernel.cc b/paddle/phi/kernels/cpu/size_kernel.cc index 71ebf9cdc09f79fc214f1e7790c502513daf1b11..ca8373b84889d975f8bb8500b0943416dd83db08 100644 --- a/paddle/phi/kernels/cpu/size_kernel.cc +++ b/paddle/phi/kernels/cpu/size_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/size_kernel.h" -#include "paddle/phi/kernels/impl/size_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/size_kernel_impl.h" PD_REGISTER_KERNEL(size, CPU, diff --git a/paddle/phi/kernels/cpu/slice_grad_kernel.cc b/paddle/phi/kernels/cpu/slice_grad_kernel.cc index 5c2cb3ea80e8765265c78a64e5da2f6e688d0970..7e3efd217511f851efec2e616fe116b196cbda07 100644 --- a/paddle/phi/kernels/cpu/slice_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/slice_grad_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/slice_grad_kernel.h" -#include "paddle/phi/kernels/impl/slice_grad_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/slice_grad_kernel_impl.h" PD_REGISTER_KERNEL(slice_grad, CPU, diff --git a/paddle/phi/kernels/cpu/slice_kernel.cc b/paddle/phi/kernels/cpu/slice_kernel.cc index 736540609dd720aa8cab93487c273ac2b3dfab52..0f2fe98a853235afb7ac27259a5ce7ff172edde8 100644 --- a/paddle/phi/kernels/cpu/slice_kernel.cc +++ b/paddle/phi/kernels/cpu/slice_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/slice_kernel.h" -#include "paddle/phi/kernels/impl/slice_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/slice_kernel_impl.h" PD_REGISTER_KERNEL(slice, CPU, diff --git a/paddle/phi/kernels/cpu/sparse_weight_embedding_grad_kernel.cc b/paddle/phi/kernels/cpu/sparse_weight_embedding_grad_kernel.cc index d78477073ad03b1b39aaae00c16aed81ea7fd056..d296aba66503b7da4b4ec500c798e8cfaa8d0773 100644 --- a/paddle/phi/kernels/cpu/sparse_weight_embedding_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/sparse_weight_embedding_grad_kernel.cc @@ -13,12 +13,12 @@ // limitations under the License. #include "paddle/phi/kernels/sparse_weight_embedding_grad_kernel.h" -#include "paddle/phi/kernels/funcs/embedding_util.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/data_type.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/core/utils/data_type.h" +#include "paddle/phi/kernels/funcs/embedding_util.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/sparse_weight_embedding_kernel.cc b/paddle/phi/kernels/cpu/sparse_weight_embedding_kernel.cc index c0f95d03888b8df825341c282e08f80dafc988a8..cfdccb5c8d9bacbdd65bdf1b56b78d6e3d1219f6 100644 --- a/paddle/phi/kernels/cpu/sparse_weight_embedding_kernel.cc +++ b/paddle/phi/kernels/cpu/sparse_weight_embedding_kernel.cc @@ -12,14 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/phi/kernels/embedding_kernel.h" -#include "paddle/phi/kernels/funcs/embedding_util.h" - #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/data_type.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/core/utils/data_type.h" +#include "paddle/phi/kernels/embedding_kernel.h" #include "paddle/phi/kernels/funcs/blas/blas.h" +#include "paddle/phi/kernels/funcs/embedding_util.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/split_kernel.cc b/paddle/phi/kernels/cpu/split_kernel.cc index 56d872922490aa02be954f8048e8ed042dbc83ae..288cdd235aede1c9023f211ca84fe79d32222349 100644 --- a/paddle/phi/kernels/cpu/split_kernel.cc +++ b/paddle/phi/kernels/cpu/split_kernel.cc @@ -17,7 +17,6 @@ #include "paddle/fluid/operators/strided_memcpy.h" #include "paddle/phi/common/float16.h" #include "paddle/phi/core/kernel_registry.h" - #include "paddle/phi/infermeta/unary.h" #include "paddle/phi/kernels/funcs/concat_and_split_functor.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/temporal_shift_grad_kernel.cc b/paddle/phi/kernels/cpu/temporal_shift_grad_kernel.cc index 400f7e8783932c1a3e40f0c4e3ec6fe45421d6db..2aff156819748ce0ae2b82497715b7e5ffb0f64c 100644 --- a/paddle/phi/kernels/cpu/temporal_shift_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/temporal_shift_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/temporal_shift_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/layout.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/temporal_shift_kernel.cc b/paddle/phi/kernels/cpu/temporal_shift_kernel.cc index 6721117992dd538b436da8fde0e03b7c8714a831..29be487131964915adf77fe7d515b777c227aa45 100644 --- a/paddle/phi/kernels/cpu/temporal_shift_kernel.cc +++ b/paddle/phi/kernels/cpu/temporal_shift_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/temporal_shift_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/layout.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/transpose_grad_kernel.cc b/paddle/phi/kernels/cpu/transpose_grad_kernel.cc index 9dbcf575f33c1a3e881b0260b1e35783553ae7ef..dee69222e6dc0810c53bc5bb4d9033365ecf0ffd 100644 --- a/paddle/phi/kernels/cpu/transpose_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/transpose_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/transpose_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/common/bfloat16.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/tril_triu_grad_kernel.cc b/paddle/phi/kernels/cpu/tril_triu_grad_kernel.cc index 14aca258a2c71a0651868f6917e2707987179ee0..660254fef86f6e67b41014f4d5c2e081f4076c56 100644 --- a/paddle/phi/kernels/cpu/tril_triu_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/tril_triu_grad_kernel.cc @@ -12,10 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/phi/kernels/impl/tril_triu_grad_kernel_impl.h" - #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/tril_triu_grad_kernel_impl.h" PD_REGISTER_KERNEL(tril_triu_grad, CPU, diff --git a/paddle/phi/kernels/cpu/tril_triu_kernel.cc b/paddle/phi/kernels/cpu/tril_triu_kernel.cc index a3d20e55e21fb6e11f63ef05f5de63fbc51caf5e..f3599bb92b97bd36dfbc68ce891140d50f5b3853 100644 --- a/paddle/phi/kernels/cpu/tril_triu_kernel.cc +++ b/paddle/phi/kernels/cpu/tril_triu_kernel.cc @@ -12,10 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/phi/kernels/impl/tril_triu_kernel_impl.h" - #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/tril_triu_kernel_impl.h" PD_REGISTER_KERNEL(tril_triu, CPU, diff --git a/paddle/phi/kernels/cpu/trunc_grad_kernel.cc b/paddle/phi/kernels/cpu/trunc_grad_kernel.cc index 4d85dd609e2d1f14cc476a1c53ba0506e6b519a5..24fc3892562220b0072393eded589f9f7700935c 100644 --- a/paddle/phi/kernels/cpu/trunc_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/trunc_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/trunc_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" diff --git a/paddle/phi/kernels/cpu/trunc_kernel.cc b/paddle/phi/kernels/cpu/trunc_kernel.cc index babae6ce7c9318f7cb4ba1f15aedbe38de5ebbd3..5fe33ec6a4b2e82ba877802a9d9dea73ba6591b9 100644 --- a/paddle/phi/kernels/cpu/trunc_kernel.cc +++ b/paddle/phi/kernels/cpu/trunc_kernel.cc @@ -12,11 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/phi/kernels/trunc_kernel.h" + #include #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" -#include "paddle/phi/kernels/trunc_kernel.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/unfold_grad_kernel.cc b/paddle/phi/kernels/cpu/unfold_grad_kernel.cc index c97005dd84547eeb04603da6dc29b922715b936a..6ba4ba49b9af9bd3cf068360fa8e4ad58b35c071 100644 --- a/paddle/phi/kernels/cpu/unfold_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/unfold_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/unfold_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/unfold_grad_kernel_impl.h" diff --git a/paddle/phi/kernels/cpu/unfold_kernel.cc b/paddle/phi/kernels/cpu/unfold_kernel.cc index e38d8acd098204e82245ab697967b8c209bfb0e6..f15201542e6c17fcc3de036461e513a607c132ce 100644 --- a/paddle/phi/kernels/cpu/unfold_kernel.cc +++ b/paddle/phi/kernels/cpu/unfold_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/unfold_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/unfold_kernel_impl.h" diff --git a/paddle/phi/kernels/cpu/uniform_random_kernel.cc b/paddle/phi/kernels/cpu/uniform_random_kernel.cc index c95a8f4ded6dc2f9efd6f18a06f5f655dbece28c..a09812363f1d8d81fa7c81fec7f8db2041e8dc87 100644 --- a/paddle/phi/kernels/cpu/uniform_random_kernel.cc +++ b/paddle/phi/kernels/cpu/uniform_random_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/uniform_random_kernel.h" + #include "paddle/phi/core/kernel_registry.h" namespace phi { diff --git a/paddle/phi/kernels/cpu/unique_kernel.cc b/paddle/phi/kernels/cpu/unique_kernel.cc index 853b401315d22fdfc4e80d4991bb663a7e389cc8..834f05f73e2289de76d256b1fd90e54454f22320 100644 --- a/paddle/phi/kernels/cpu/unique_kernel.cc +++ b/paddle/phi/kernels/cpu/unique_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/unique_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/core/utils/data_type.h" diff --git a/paddle/phi/kernels/cpu/unstack_grad_kernel.cc b/paddle/phi/kernels/cpu/unstack_grad_kernel.cc index 9c2dce808dca76b8bb6ea0ec867988ba729210af..c494cbc965eff855c3eace72750566e139834a16 100644 --- a/paddle/phi/kernels/cpu/unstack_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/unstack_grad_kernel.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/kernels/unstack_grad_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/unstack_grad_kernel_impl.h" diff --git a/paddle/phi/kernels/cpu/unstack_kernel.cc b/paddle/phi/kernels/cpu/unstack_kernel.cc index 3d233e9ec405fb98787faf2a7d2fbb38b6e338b5..4bc8d1b2c93b2f0c85e1d90c3d368b404409dfa9 100644 --- a/paddle/phi/kernels/cpu/unstack_kernel.cc +++ b/paddle/phi/kernels/cpu/unstack_kernel.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/phi/kernels/unstack_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/impl/unstack_kernel_impl.h" diff --git a/paddle/phi/kernels/cpu/viterbi_decode_kernel.cc b/paddle/phi/kernels/cpu/viterbi_decode_kernel.cc index fab49f5416048a2655412056e5375b30fdaad923..c98a098aa0e6fe462caae458cc3e6372496349fa 100644 --- a/paddle/phi/kernels/cpu/viterbi_decode_kernel.cc +++ b/paddle/phi/kernels/cpu/viterbi_decode_kernel.cc @@ -109,7 +109,8 @@ struct Gather { }; template typename CompareFunctor, + template + typename CompareFunctor, typename T> struct GetMask { void operator()(const Context& dev_ctx, @@ -122,7 +123,8 @@ struct GetMask { }; template typename BinaryFunctor, + template + typename BinaryFunctor, typename T> struct BinaryOperation { void operator()(const Context& dev_ctx, diff --git a/paddle/phi/kernels/cpu/warpctc_grad_kernel.cc b/paddle/phi/kernels/cpu/warpctc_grad_kernel.cc index 0b293363354818aefa327efa1c2358cb106b788e..7d70d825250ee6dedab408b862b57de1e4f91647 100644 --- a/paddle/phi/kernels/cpu/warpctc_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/warpctc_grad_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/warpctc_grad_kernel.h" -#include "paddle/phi/kernels/impl/warpctc_grad_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/warpctc_grad_kernel_impl.h" PD_REGISTER_KERNEL( warpctc_grad, CPU, ALL_LAYOUT, phi::WarpctcGradKernel, float, double) {} diff --git a/paddle/phi/kernels/cpu/warpctc_kernel.cc b/paddle/phi/kernels/cpu/warpctc_kernel.cc index 4b87202c11e926283ea6da8c3751dae228ee5952..239c6cb0cbe0409b4ed3ac84736b82cd86cbb040 100644 --- a/paddle/phi/kernels/cpu/warpctc_kernel.cc +++ b/paddle/phi/kernels/cpu/warpctc_kernel.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/phi/kernels/warpctc_kernel.h" -#include "paddle/phi/kernels/impl/warpctc_kernel_impl.h" #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" +#include "paddle/phi/kernels/impl/warpctc_kernel_impl.h" PD_REGISTER_KERNEL( warpctc, CPU, ALL_LAYOUT, phi::WarpctcKernel, float, double) {} diff --git a/paddle/phi/kernels/cpu/yolo_box_kernel.cc b/paddle/phi/kernels/cpu/yolo_box_kernel.cc index a83bc019fc3af395cedc20edd548b70149a915d5..6b882ad28951297810e210321e03ab3cb837ea0c 100644 --- a/paddle/phi/kernels/cpu/yolo_box_kernel.cc +++ b/paddle/phi/kernels/cpu/yolo_box_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/yolo_box_kernel.h" + #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/funcs/yolo_box_util.h" diff --git a/paddle/phi/kernels/cpu/yolov3_loss_grad_kernel.cc b/paddle/phi/kernels/cpu/yolov3_loss_grad_kernel.cc index 383009229f9a159e1c23d9e2b1d13bd291c02654..655106e9cb44daebc9ccdd29e3b92c0abcf2a93e 100644 --- a/paddle/phi/kernels/cpu/yolov3_loss_grad_kernel.cc +++ b/paddle/phi/kernels/cpu/yolov3_loss_grad_kernel.cc @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/phi/kernels/yolov3_loss_grad_kernel.h" + #include #include -#include "paddle/phi/kernels/yolov3_loss_grad_kernel.h" - #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/cpu/yolov3_loss_functor.h" diff --git a/paddle/phi/kernels/cpu/yolov3_loss_kernel.cc b/paddle/phi/kernels/cpu/yolov3_loss_kernel.cc index 8a190ab25a7b2743e43fcd5abbd613dda0bba484..75b2e3c5c4a0e672d8f50220308ba233840e151a 100644 --- a/paddle/phi/kernels/cpu/yolov3_loss_kernel.cc +++ b/paddle/phi/kernels/cpu/yolov3_loss_kernel.cc @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "paddle/phi/kernels/yolov3_loss_kernel.h" + #include #include -#include "paddle/phi/kernels/yolov3_loss_kernel.h" - #include "paddle/phi/backends/cpu/cpu_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/cpu/yolov3_loss_functor.h" diff --git a/paddle/phi/kernels/cumprod_grad_kernel.h b/paddle/phi/kernels/cumprod_grad_kernel.h index b3cb17b28e07f3d9d4d0a1671acc9d639b855e08..7610cad31e32774fe44615eb80b7cd3ba5ec2bca 100644 --- a/paddle/phi/kernels/cumprod_grad_kernel.h +++ b/paddle/phi/kernels/cumprod_grad_kernel.h @@ -25,4 +25,4 @@ void CumprodGradKernel(const Context& dev_ctx, const DenseTensor& dout, int dim, DenseTensor* dx); -} // phi +} // namespace phi diff --git a/paddle/phi/kernels/cumprod_kernel.h b/paddle/phi/kernels/cumprod_kernel.h index 96d76cb0f43702cb5798ec9c2d527464ea51ba1f..bb8b1427b30c46206059bf0f359203ef7a5f2620 100644 --- a/paddle/phi/kernels/cumprod_kernel.h +++ b/paddle/phi/kernels/cumprod_kernel.h @@ -23,4 +23,4 @@ void CumprodKernel(const Context& dev_ctx, const DenseTensor& x, int dim, DenseTensor* out); -} // phi +} // namespace phi diff --git a/paddle/phi/kernels/diagonal_kernel.h b/paddle/phi/kernels/diagonal_kernel.h index 7cf7282307a4b91a771441d3218121b606afdf81..10afd7dbe920a820ed969c4c97f0f1bfb628c481 100644 --- a/paddle/phi/kernels/diagonal_kernel.h +++ b/paddle/phi/kernels/diagonal_kernel.h @@ -25,4 +25,4 @@ void DiagonalKernel(const Context& dev_ctx, int axis1, int axis2, DenseTensor* out); -} // phi +} // namespace phi diff --git a/paddle/phi/kernels/digamma_grad_kernel.h b/paddle/phi/kernels/digamma_grad_kernel.h index ae5346080d30df9836ee55852f0d7469a3cb7438..abd8634518d2c6b12aebaa6e0fa9bdbeb404494f 100644 --- a/paddle/phi/kernels/digamma_grad_kernel.h +++ b/paddle/phi/kernels/digamma_grad_kernel.h @@ -24,4 +24,4 @@ void DigammaGradKernel(const Context& ctx, const DenseTensor& out_grad, DenseTensor* x_grad); -} // namepsace phi +} // namespace phi diff --git a/paddle/phi/kernels/digamma_kernel.h b/paddle/phi/kernels/digamma_kernel.h index ce25f2e148e963054fcfa2a51321954b45a4297b..3cf1eae67cc3ef8ee212c3b065a77e629cc9608a 100644 --- a/paddle/phi/kernels/digamma_kernel.h +++ b/paddle/phi/kernels/digamma_kernel.h @@ -21,4 +21,4 @@ namespace phi { template void DigammaKernel(const Context& ctx, const DenseTensor& x, DenseTensor* out); -} // namepsace phi +} // namespace phi diff --git a/paddle/phi/kernels/empty_kernel.cc b/paddle/phi/kernels/empty_kernel.cc index 06d258a8a4e80d1dcabc708c534c3dd34bf6e8c4..d8cf0bd2ef90dd751aeb981d9ac3af5d5afd142d 100644 --- a/paddle/phi/kernels/empty_kernel.cc +++ b/paddle/phi/kernels/empty_kernel.cc @@ -14,9 +14,8 @@ #include "paddle/phi/kernels/empty_kernel.h" #include "paddle/phi/backends/all_context.h" -#include "paddle/phi/core/kernel_registry.h" - #include "paddle/phi/common/complex.h" +#include "paddle/phi/core/kernel_registry.h" namespace phi { diff --git a/paddle/phi/kernels/expand_kernel.h b/paddle/phi/kernels/expand_kernel.h index 3b44c46e4dd7c77c1cd50d43745911b68a17e9f1..930240db6ccca737d9bc7435587895848c3c35e5 100644 --- a/paddle/phi/kernels/expand_kernel.h +++ b/paddle/phi/kernels/expand_kernel.h @@ -26,4 +26,4 @@ void ExpandKernel(const Context& ctx, const IntArray& shape, DenseTensor* out); -} // namepsace phi +} // namespace phi diff --git a/paddle/phi/kernels/flatten_grad_kernel.cc b/paddle/phi/kernels/flatten_grad_kernel.cc index 83f96c1f9f521de0c47ce525dd76b37e58346a59..54279fca6e429e3da9b7fc3a5726f27ab78f4cd1 100644 --- a/paddle/phi/kernels/flatten_grad_kernel.cc +++ b/paddle/phi/kernels/flatten_grad_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/flatten_grad_kernel.h" + #include "paddle/phi/backends/all_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/kernels/copy_kernel.h" diff --git a/paddle/phi/kernels/flatten_kernel.cc b/paddle/phi/kernels/flatten_kernel.cc index f304e7706add4c670bcc3b05e2035ee964c561ae..dd000896073c70fedf82a501e84200837e4af4d1 100644 --- a/paddle/phi/kernels/flatten_kernel.cc +++ b/paddle/phi/kernels/flatten_kernel.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/phi/kernels/flatten_kernel.h" + #include "paddle/phi/backends/all_context.h" #include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/infermeta/unary.h" diff --git a/paddle/phi/kernels/frobenius_norm_grad_kernel.h b/paddle/phi/kernels/frobenius_norm_grad_kernel.h index cfe8192d1a69b2bb22de0bca83415f5a95bf045f..65db8dd9e0a108acfc45e218fa5dacffe5d36832 100644 --- a/paddle/phi/kernels/frobenius_norm_grad_kernel.h +++ b/paddle/phi/kernels/frobenius_norm_grad_kernel.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/phi/core/dense_tensor.h" namespace phi { diff --git a/paddle/phi/kernels/frobenius_norm_kernel.h b/paddle/phi/kernels/frobenius_norm_kernel.h index f5f37ee0c0fa5f0a4b32f032a02c1671386b909b..30122cb416094df06a934a930286af8f20ca47b6 100644 --- a/paddle/phi/kernels/frobenius_norm_kernel.h +++ b/paddle/phi/kernels/frobenius_norm_kernel.h @@ -15,6 +15,7 @@ #pragma once #include + #include "paddle/phi/core/dense_tensor.h" namespace phi { diff --git a/paddle/phi/kernels/full_kernel.h b/paddle/phi/kernels/full_kernel.h index d5785f2eedafa187621c1965f6e14ec57fff0c85..228e862a09c7906816c6120f4928897ba96608d3 100644 --- a/paddle/phi/kernels/full_kernel.h +++ b/paddle/phi/kernels/full_kernel.h @@ -19,7 +19,6 @@ #include "paddle/phi/common/int_array.h" #include "paddle/phi/common/scalar.h" #include "paddle/phi/core/dense_tensor.h" - #include "paddle/phi/infermeta/nullary.h" #include "paddle/phi/kernels/empty_kernel.h" diff --git a/paddle/phi/kernels/funcs/activation_functor.h b/paddle/phi/kernels/funcs/activation_functor.h index f80117ccec7998ce927533a0e59da43b9992cfcb..f481821a7bfcc1a3ba1bb6f15d13ccf618dfdd54 100644 --- a/paddle/phi/kernels/funcs/activation_functor.h +++ b/paddle/phi/kernels/funcs/activation_functor.h @@ -15,14 +15,14 @@ #pragma once #include + #include +#include #include #include #include #include #include - -#include #ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES #endif @@ -986,9 +986,9 @@ struct BReluGradFunctor : public BaseActivationFunctor { typename dOut, typename dX> void operator()(Device d, X x, Out out, dOut dout, dX dx) const { - dx.device(d) = dout * - ((x > static_cast(t_min)) * (x < static_cast(t_max))) - .template cast(); + dx.device(d) = + dout * ((x > static_cast(t_min)) * (x < static_cast(t_max))) + .template cast(); } static constexpr ActBwdOpFwdDeps FwdDeps() { return ActBwdOpFwdDeps::kDepX; } @@ -1054,11 +1054,10 @@ struct LeakyReluGradGradFunctor : public BaseActivationFunctor { GET_DATA_SAFELY(X, "Input", "X", "LeakyReluGradGrad")); auto ddout = EigenVector::Flatten( GET_DATA_SAFELY(ddOut, "Output", "DOut", "LeakyReluGradGrad")); - ddout.device(*d) = - ddx * - ((x > static_cast(0)).template cast() + - static_cast(alpha) * (x <= static_cast(0)).template cast()) - .template cast(); + ddout.device(*d) = ddx * ((x > static_cast(0)).template cast() + + static_cast(alpha) * + (x <= static_cast(0)).template cast()) + .template cast(); } } static constexpr ActBwdOpFwdDeps FwdDeps() { return ActBwdOpFwdDeps::kDepX; } @@ -1290,11 +1289,10 @@ struct ELUGradGradFunctor : public BaseActivationFunctor { if (ddOut) { auto ddout = EigenVector::Flatten( GET_DATA_SAFELY(ddOut, "Output", "DDOut", "ELUGradGrad")); - ddout.device(*d) = ddx * - ((x > static_cast(0)).template cast() + - static_cast(alpha) * x.exp() * - (x <= static_cast(0)).template cast()) - .template cast(); + ddout.device(*d) = ddx * ((x > static_cast(0)).template cast() + + static_cast(alpha) * x.exp() * + (x <= static_cast(0)).template cast()) + .template cast(); } } static constexpr ActBwdOpFwdDeps FwdDeps() { return ActBwdOpFwdDeps::kDepX; } @@ -1980,11 +1978,10 @@ struct CELUGradGradFunctor : public BaseActivationFunctor { if (ddOut) { auto ddout = EigenVector::Flatten( GET_DATA_SAFELY(ddOut, "Output", "DDOut", "CELUGradGrad")); - ddout.device(*d) = ddx * - ((x > static_cast(0)).template cast() + - (x / static_cast(alpha)).exp() * - (x <= static_cast(0)).template cast()) - .template cast(); + ddout.device(*d) = ddx * ((x > static_cast(0)).template cast() + + (x / static_cast(alpha)).exp() * + (x <= static_cast(0)).template cast()) + .template cast(); } } static constexpr ActBwdOpFwdDeps FwdDeps() { return ActBwdOpFwdDeps::kDepX; } diff --git a/paddle/phi/kernels/funcs/adam_functors.h b/paddle/phi/kernels/funcs/adam_functors.h index 2f706f0ef1c36de3081bc298a8b882263c493586..b14ee7f072e4ebfdee405cc7dcdab5878315c764 100644 --- a/paddle/phi/kernels/funcs/adam_functors.h +++ b/paddle/phi/kernels/funcs/adam_functors.h @@ -14,6 +14,7 @@ #pragma once #include // for sqrt in CPU and CUDA + #include #include "paddle/phi/kernels/funcs/algorithm.h" @@ -169,9 +170,8 @@ class AdamFunctor { moment1_out = beta1_ * mom1 + (1 - beta1_) * g; moment2_out = beta2_ * mom2 + (1 - beta2_) * g * g; - param_out = param - - lr * (moment1_out / - (moment2_out.sqrt() + epsilon_ * sqrt(1 - beta2_pow))); + param_out = param - lr * (moment1_out / (moment2_out.sqrt() + + epsilon_ * sqrt(1 - beta2_pow))); } }; diff --git a/paddle/phi/kernels/funcs/aligned_vector.h b/paddle/phi/kernels/funcs/aligned_vector.h index 14a9560b841fa898a44acacc5976d52ef7ed4225..70f75d5352ac54748dda69dac27b8a8607646f19 100644 --- a/paddle/phi/kernels/funcs/aligned_vector.h +++ b/paddle/phi/kernels/funcs/aligned_vector.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/phi/core/hostdevice.h" #if defined(__xpu__) #define CHAR_BIT 8 @@ -45,11 +46,11 @@ HOSTDEVICE inline void Store(const AlignedVector& vec, T* addr) { } /* -* Only the address of input data is the multiplier of 1,2,4, vectorized load -* with corresponding multiplier-value is possible. Moreover, the maximum length -* of vectorized load is 128 bits once. Hence, valid length of vectorized load -* shall be determined under both former constraints. -*/ + * Only the address of input data is the multiplier of 1,2,4, vectorized load + * with corresponding multiplier-value is possible. Moreover, the maximum length + * of vectorized load is 128 bits once. Hence, valid length of vectorized load + * shall be determined under both former constraints. + */ template int GetVectorizedSize(const T* pointer) { constexpr int max_load_bits = 128; @@ -60,11 +61,11 @@ int GetVectorizedSize(const T* pointer) { constexpr int vec2 = std::alignment_of>::value; // NOLINT if (address % vec8 == 0) { /* - * Currently, decide to deal with no more than 4 data once while adopting - * vectorization load/store, if performance test shows that dealing with - * 8 data once in vectorization load/store does get optimized, return code - * below can be changed into " return std::min(8, valid_vec_size); " . - */ + * Currently, decide to deal with no more than 4 data once while adopting + * vectorization load/store, if performance test shows that dealing with + * 8 data once in vectorization load/store does get optimized, return code + * below can be changed into " return std::min(8, valid_vec_size); " . + */ return std::min(4, valid_vec_size); } else if (address % vec4 == 0) { return std::min(4, valid_vec_size); diff --git a/paddle/phi/kernels/funcs/blas/blas_impl.cu.h b/paddle/phi/kernels/funcs/blas/blas_impl.cu.h index e2b16a1eb7ff115d416aec351035d4288baf4bf7..3e197a18f96b90ee88b0f7af76c1f42911d0fe57 100644 --- a/paddle/phi/kernels/funcs/blas/blas_impl.cu.h +++ b/paddle/phi/kernels/funcs/blas/blas_impl.cu.h @@ -14,11 +14,10 @@ #pragma once -#include "paddle/fluid/platform/dynload/cublas.h" -#include "paddle/phi/kernels/funcs/math_function.h" - #include "paddle/fluid/platform/device/gpu/gpu_info.h" +#include "paddle/fluid/platform/dynload/cublas.h" #include "paddle/phi/backends/gpu/gpu_context.h" +#include "paddle/phi/kernels/funcs/math_function.h" DECLARE_bool(enable_cublas_tensor_op_math); DECLARE_bool(gemm_use_half_precision_compute_type); diff --git a/paddle/phi/kernels/funcs/broadcast_function.h b/paddle/phi/kernels/funcs/broadcast_function.h index ecdfa7abcfd424565d314e2ecb88be7214683647..88b87c07c7615ccef3a20e3441854bbb6b940394 100644 --- a/paddle/phi/kernels/funcs/broadcast_function.h +++ b/paddle/phi/kernels/funcs/broadcast_function.h @@ -456,21 +456,16 @@ void LaunchBroadcastKernel( read_lens * gpu_config.GetBlockSize(); int tail_tid = numel % (read_lens * gpu_config.GetBlockSize()); #endif - VectorizedBroadcastKernel<<>>( - ins_data, - outs_data, - use_broadcast, - numel, - configs, - main_offset, - tail_tid, - read_lens, - func); + VectorizedBroadcastKernel + <<>>(ins_data, + outs_data, + use_broadcast, + numel, + configs, + main_offset, + tail_tid, + read_lens, + func); } template dims().size()); } - axis = axis == -1 - ? *std::max_element(dims_size.begin(), dims_size.end()) - - *std::min_element(dims_size.begin(), dims_size.end()) - : axis; + axis = axis == -1 ? *std::max_element(dims_size.begin(), dims_size.end()) - + *std::min_element(dims_size.begin(), dims_size.end()) + : axis; BroadcastKernelForDifferentVecSize( ctx, ins, outs, axis, func); } diff --git a/paddle/phi/kernels/funcs/concat_and_split_functor.cu b/paddle/phi/kernels/funcs/concat_and_split_functor.cu index 06be592dd9375902cdbd0289caa347bc11015bd2..5abaf6c2ffa87cf4e63d082edbb26294d99b2932 100644 --- a/paddle/phi/kernels/funcs/concat_and_split_functor.cu +++ b/paddle/phi/kernels/funcs/concat_and_split_functor.cu @@ -12,10 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/phi/kernels/funcs/concat_and_split_functor.h" - #include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/platform/cuda_graph_with_memory_pool.h" +#include "paddle/phi/kernels/funcs/concat_and_split_functor.h" namespace phi { namespace funcs { diff --git a/paddle/phi/kernels/funcs/deformable_conv_functor.cc b/paddle/phi/kernels/funcs/deformable_conv_functor.cc index ea256e93bba75f336fd96fe8d4265c8d15b23755..48858fa59390efbdb1a01b69fc8453729d9800e9 100644 --- a/paddle/phi/kernels/funcs/deformable_conv_functor.cc +++ b/paddle/phi/kernels/funcs/deformable_conv_functor.cc @@ -60,14 +60,12 @@ inline void ModulatedDeformableIm2colCPUKernel( const T* data_im_ptr = data_im + (b_col * num_channels + c_im) * height * width; const T* data_offset_ptr = - data_offset + - (b_col * deformable_group + deformable_group_index) * 2 * kernel_h * - kernel_w * height_col * width_col; + data_offset + (b_col * deformable_group + deformable_group_index) * 2 * + kernel_h * kernel_w * height_col * width_col; const T* data_mask_ptr = data_mask - ? data_mask + - (b_col * deformable_group + deformable_group_index) * - kernel_h * kernel_w * height_col * width_col + ? data_mask + (b_col * deformable_group + deformable_group_index) * + kernel_h * kernel_w * height_col * width_col : nullptr; for (int i = 0; i < kernel_h; ++i) { diff --git a/paddle/phi/kernels/funcs/deformable_conv_functor.cu b/paddle/phi/kernels/funcs/deformable_conv_functor.cu index 8bfb46c6636e9144c45055876be179086b107709..bebea5dcb74cae601cda5315f192d0b23dbc1fc6 100644 --- a/paddle/phi/kernels/funcs/deformable_conv_functor.cu +++ b/paddle/phi/kernels/funcs/deformable_conv_functor.cu @@ -12,9 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "paddle/phi/kernels/funcs/deformable_conv_functor.h" - #include "paddle/phi/backends/gpu/gpu_context.h" +#include "paddle/phi/kernels/funcs/deformable_conv_functor.h" namespace phi { namespace funcs { @@ -70,14 +69,12 @@ __global__ void ModulatedDeformableIm2colGpuKernel( const T* data_im_ptr = data_im + (b_col * num_channels + c_im) * height * width; const T* data_offset_ptr = - data_offset + - (b_col * deformable_group + deformable_group_index) * 2 * kernel_h * - kernel_w * height_col * width_col; + data_offset + (b_col * deformable_group + deformable_group_index) * 2 * + kernel_h * kernel_w * height_col * width_col; const T* data_mask_ptr = data_mask - ? data_mask + - (b_col * deformable_group + deformable_group_index) * - kernel_h * kernel_w * height_col * width_col + ? data_mask + (b_col * deformable_group + deformable_group_index) * + kernel_h * kernel_w * height_col * width_col : nullptr; for (int i = 0; i < kernel_h; ++i) { @@ -129,28 +126,28 @@ void ModulatedDeformableIm2col(const Context& dev_ctx, int blocks = NumBlocks(num_kernels); int threads = kNumCUDAThreads; - ModulatedDeformableIm2colGpuKernel< - T><<>>(num_kernels, - data_im, - data_offset, - data_mask, - im_shape[1], - im_shape[2], - filter_shape[2], - filter_shape[3], - paddings[0], - paddings[1], - strides[0], - strides[1], - dilations[0], - dilations[1], - channel_per_deformable_group, - col_shape[1], - im_shape[0], - deformable_groups, - col_shape[2], - col_shape[3], - data_col); + ModulatedDeformableIm2colGpuKernel + <<>>(num_kernels, + data_im, + data_offset, + data_mask, + im_shape[1], + im_shape[2], + filter_shape[2], + filter_shape[3], + paddings[0], + paddings[1], + strides[0], + strides[1], + dilations[0], + dilations[1], + channel_per_deformable_group, + col_shape[1], + im_shape[0], + deformable_groups, + col_shape[2], + col_shape[3], + data_col); } template void ModulatedDeformableIm2col( diff --git a/paddle/phi/kernels/funcs/detail/activation_functions.h b/paddle/phi/kernels/funcs/detail/activation_functions.h index 475557f16421094f75c36359b5d3c73694e65bc5..d41dca33f75717774062b5b873019c2d7ce69412 100644 --- a/paddle/phi/kernels/funcs/detail/activation_functions.h +++ b/paddle/phi/kernels/funcs/detail/activation_functions.h @@ -14,8 +14,10 @@ limitations under the License. */ #pragma once #include + #include #include + #include "paddle/fluid/platform/cpu_info.h" #include "paddle/phi/core/hostdevice.h" diff --git a/paddle/phi/kernels/funcs/detail/avx_mathfun.h b/paddle/phi/kernels/funcs/detail/avx_mathfun.h index e5e7388d51dff86790b2a4ed3fb48558d01deb7d..75e4922648c202bd07bad9326a90b962836a1cbb 100644 --- a/paddle/phi/kernels/funcs/detail/avx_mathfun.h +++ b/paddle/phi/kernels/funcs/detail/avx_mathfun.h @@ -356,11 +356,11 @@ v8sf sin256_ps(v8sf x) { // any x /* scale by 4/Pi */ y = _mm256_mul_ps(x, *(v8sf *)_ps256_cephes_FOPI); -/* - Here we start a series of integer operations, which are in the - realm of AVX2. - If we don't have AVX, let's perform them using SSE2 directives -*/ + /* + Here we start a series of integer operations, which are in the + realm of AVX2. + If we don't have AVX, let's perform them using SSE2 directives + */ #ifdef __AVX2__ /* store the integer part of y in mm0 */ diff --git a/paddle/phi/kernels/funcs/detail/gru_cpu_kernel.h b/paddle/phi/kernels/funcs/detail/gru_cpu_kernel.h index 0016bfb64c96e758223f9acb7d1065fb955f85d6..0fdf490c5534d1f1d89a69789dbec8b85aa8f41b 100644 --- a/paddle/phi/kernels/funcs/detail/gru_cpu_kernel.h +++ b/paddle/phi/kernels/funcs/detail/gru_cpu_kernel.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/phi/kernels/funcs/activation_functor.h" #include "paddle/phi/kernels/funcs/detail/activation_functions.h" diff --git a/paddle/phi/kernels/funcs/detail/gru_gpu_kernel.h b/paddle/phi/kernels/funcs/detail/gru_gpu_kernel.h index 6657417beac8d8b1a7b74f551c6497162f80633e..93232d8f7f4348446dd8439fd83150d512c05471 100644 --- a/paddle/phi/kernels/funcs/detail/gru_gpu_kernel.h +++ b/paddle/phi/kernels/funcs/detail/gru_gpu_kernel.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/platform/device/gpu/gpu_primitives.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/phi/kernels/funcs/detail/activation_functions.h" diff --git a/paddle/phi/kernels/funcs/detail/gru_kernel.h b/paddle/phi/kernels/funcs/detail/gru_kernel.h index db53fc4576daac993883737f5cc7041115567a78..9e2aef19406191ced2a20d52c582f58953c3d72f 100644 --- a/paddle/phi/kernels/funcs/detail/gru_kernel.h +++ b/paddle/phi/kernels/funcs/detail/gru_kernel.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/phi/core/hostdevice.h" #include "paddle/phi/kernels/funcs/detail/activation_functions.h" diff --git a/paddle/phi/kernels/funcs/detail/lstm_cpu_kernel.h b/paddle/phi/kernels/funcs/detail/lstm_cpu_kernel.h index ed8e749f7fdade2997400c0784cc1b62b0443907..02fddc57b313a0169373ab4cb82d72a586ce3cc9 100644 --- a/paddle/phi/kernels/funcs/detail/lstm_cpu_kernel.h +++ b/paddle/phi/kernels/funcs/detail/lstm_cpu_kernel.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/fluid/framework/eigen.h" #include "paddle/phi/kernels/funcs/activation_functor.h" #include "paddle/phi/kernels/funcs/detail/activation_functions.h" diff --git a/paddle/phi/kernels/funcs/detail/lstm_gpu_kernel.h b/paddle/phi/kernels/funcs/detail/lstm_gpu_kernel.h index 6d4c430d9e64832fca453575eb9f47cb8d19a8ec..5d06dddd9645b09f93b9cc91d5c23ec80b17ba99 100644 --- a/paddle/phi/kernels/funcs/detail/lstm_gpu_kernel.h +++ b/paddle/phi/kernels/funcs/detail/lstm_gpu_kernel.h @@ -249,27 +249,27 @@ void gpu_lstm_forward(const paddle::platform::DeviceContext& context, if (batch_size == 1) { KeLstmForward<<>>( - op, - value, - frame_size, - batch_size, - cell_clip, - active_node, - active_gate, - active_state); + /* is_batch= */ false> + <<>>(op, + value, + frame_size, + batch_size, + cell_clip, + active_node, + active_gate, + active_state); } else { KeLstmForward<<>>( - op, - value, - frame_size, - batch_size, - cell_clip, - active_node, - active_gate, - active_state); + /* is_batch= */ true> + <<>>(op, + value, + frame_size, + batch_size, + cell_clip, + active_node, + active_gate, + active_state); } } @@ -303,29 +303,29 @@ void gpu_lstm_backward(const paddle::platform::DeviceContext& context, if (batch_size == 1) { KeLstmBackward<<>>( - op, - value, - grad, - frame_size, - batch_size, - cell_clip, - active_node, - active_gate, - active_state); + /* is_batch= */ false> + <<>>(op, + value, + grad, + frame_size, + batch_size, + cell_clip, + active_node, + active_gate, + active_state); } else { KeLstmBackward<<>>( - op, - value, - grad, - frame_size, - batch_size, - cell_clip, - active_node, - active_gate, - active_state); + /* is_batch= */ true> + <<>>(op, + value, + grad, + frame_size, + batch_size, + cell_clip, + active_node, + active_gate, + active_state); } } diff --git a/paddle/phi/kernels/funcs/detail/lstm_kernel.h b/paddle/phi/kernels/funcs/detail/lstm_kernel.h index 8b429264125259932ac7b0b3f5b27eca7524d604..0846f05a0c2c53dfcf5dd5acbccb443974c0bc51 100644 --- a/paddle/phi/kernels/funcs/detail/lstm_kernel.h +++ b/paddle/phi/kernels/funcs/detail/lstm_kernel.h @@ -14,6 +14,7 @@ limitations under the License. */ #pragma once #include + #include "paddle/phi/core/hostdevice.h" #include "paddle/phi/kernels/funcs/detail/activation_functions.h" diff --git a/paddle/phi/kernels/funcs/diagonal.h b/paddle/phi/kernels/funcs/diagonal.h index 19a93970d090af060b888f512782975b073fff72..81525cb25449ee5a48ee36f8fd472e754d32a8a9 100644 --- a/paddle/phi/kernels/funcs/diagonal.h +++ b/paddle/phi/kernels/funcs/diagonal.h @@ -17,6 +17,7 @@ #if defined(__NVCC__) || defined(__HIPCC__) #include #include + #include "paddle/phi/kernels/primitive/kernel_primitives.h" #endif diff --git a/paddle/phi/kernels/funcs/distribution_helper.h b/paddle/phi/kernels/funcs/distribution_helper.h index 68e986c334ecb872739c332e32a565b5df13bb3d..0e6b3a3f9d733ea6a43f71daabf6d640bb85b424 100644 --- a/paddle/phi/kernels/funcs/distribution_helper.h +++ b/paddle/phi/kernels/funcs/distribution_helper.h @@ -319,10 +319,9 @@ void distribution_and_transform(const GPUContext &ctx, uint64_t seed = seed_offset.first; uint64_t offset = seed_offset.second; - DistributionKernel<<>>( - size, seed, offset, dist, trans, out_data, total_thread); + DistributionKernel + <<>>( + size, seed, offset, dist, trans, out_data, total_thread); } #endif diff --git a/paddle/phi/kernels/funcs/eigen/extensions.h b/paddle/phi/kernels/funcs/eigen/extensions.h index fbb9d8e3d2ef552750fc98d10a63d230661adf49..c724564417b19a27d7532896bdc3971799894d25 100644 --- a/paddle/phi/kernels/funcs/eigen/extensions.h +++ b/paddle/phi/kernels/funcs/eigen/extensions.h @@ -20,7 +20,6 @@ #include "paddle/phi/common/complex.h" #include "paddle/phi/common/float16.h" #include "paddle/phi/core/hostdevice.h" - #include "unsupported/Eigen/CXX11/Tensor" namespace Eigen { diff --git a/paddle/phi/kernels/funcs/elementwise_base.h b/paddle/phi/kernels/funcs/elementwise_base.h index 1093bdfa726c83ba095a433662b46530b0b30b4e..71dfbc206a19104702b08dde22c8231550a09b75 100644 --- a/paddle/phi/kernels/funcs/elementwise_base.h +++ b/paddle/phi/kernels/funcs/elementwise_base.h @@ -494,7 +494,7 @@ template