From ab6f8745fd39f09ce9a5f1ba8128d23b886f30e9 Mon Sep 17 00:00:00 2001 From: wuhuanzhou Date: Wed, 21 Apr 2021 13:05:32 +0800 Subject: [PATCH] remove thrust include files (#32395) * remove thrust includes, test=develop * fix compilation error, test=develop * fix compilation of truncated_gaussian_random_op, test=develop --- paddle/fluid/framework/lod_tensor.h | 7 +------ paddle/fluid/operators/diag_embed_op.cu | 2 ++ paddle/fluid/operators/gaussian_random_op.cu | 2 ++ paddle/fluid/operators/modified_huber_loss_op.cu | 2 ++ paddle/fluid/operators/trace_op.cu | 2 ++ .../operators/truncated_gaussian_random_op.cu | 15 +++++++++------ paddle/fluid/operators/uniform_random_op.cu | 3 ++- 7 files changed, 20 insertions(+), 13 deletions(-) diff --git a/paddle/fluid/framework/lod_tensor.h b/paddle/fluid/framework/lod_tensor.h index b8911154e6..6b6112f1f3 100644 --- a/paddle/fluid/framework/lod_tensor.h +++ b/paddle/fluid/framework/lod_tensor.h @@ -14,16 +14,11 @@ limitations under the License. */ #pragma once +#include #include #include #include #include -#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -#include -#include -#endif - -#include #include "paddle/fluid/framework/ddim.h" #include "paddle/fluid/framework/mixed_vector.h" diff --git a/paddle/fluid/operators/diag_embed_op.cu b/paddle/fluid/operators/diag_embed_op.cu index 2e03622e10..7e3ab6be66 100644 --- a/paddle/fluid/operators/diag_embed_op.cu +++ b/paddle/fluid/operators/diag_embed_op.cu @@ -12,6 +12,8 @@ // 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/operators/diag_embed_op.h" diff --git a/paddle/fluid/operators/gaussian_random_op.cu b/paddle/fluid/operators/gaussian_random_op.cu index 7a0c93eb1b..453ae20656 100644 --- a/paddle/fluid/operators/gaussian_random_op.cu +++ b/paddle/fluid/operators/gaussian_random_op.cu @@ -11,6 +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 +#include #include #include #include "paddle/fluid/framework/generator.h" diff --git a/paddle/fluid/operators/modified_huber_loss_op.cu b/paddle/fluid/operators/modified_huber_loss_op.cu index 71bfacb928..3c85da3c52 100644 --- a/paddle/fluid/operators/modified_huber_loss_op.cu +++ b/paddle/fluid/operators/modified_huber_loss_op.cu @@ -11,7 +11,9 @@ 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 #include +#include #include #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/operators/modified_huber_loss_op.h" diff --git a/paddle/fluid/operators/trace_op.cu b/paddle/fluid/operators/trace_op.cu index ea328361de..2c2745018b 100644 --- a/paddle/fluid/operators/trace_op.cu +++ b/paddle/fluid/operators/trace_op.cu @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include +#include #include "paddle/fluid/operators/reduce_ops/cub_reduce.h" #include "paddle/fluid/operators/trace_op.h" diff --git a/paddle/fluid/operators/truncated_gaussian_random_op.cu b/paddle/fluid/operators/truncated_gaussian_random_op.cu index 798709b108..1f25a88075 100644 --- a/paddle/fluid/operators/truncated_gaussian_random_op.cu +++ b/paddle/fluid/operators/truncated_gaussian_random_op.cu @@ -12,25 +12,28 @@ 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 #include #include "paddle/fluid/framework/generator.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" +#include "paddle/fluid/operators/truncated_gaussian_random_op.h" namespace paddle { namespace operators { template -struct TruncatedNormal { +struct GPUTruncatedNormal { T mean, std; T a_normal_cdf; T b_normal_cdf; unsigned int seed; T numeric_min; - __host__ __device__ TruncatedNormal(T mean, T std, T numeric_min, int seed) + __host__ __device__ GPUTruncatedNormal(T mean, T std, T numeric_min, int seed) : mean(mean), std(std), seed(seed), numeric_min(numeric_min) { a_normal_cdf = (1.0 + erff(-2.0 / sqrtf(2.0))) / 2.0; b_normal_cdf = (1.0 + erff(2.0 / sqrtf(2.0))) / 2.0; @@ -110,10 +113,10 @@ class GPUTruncatedGaussianRandomKernel : public framework::OpKernel { TruncatedNormalOffset(mean, std, std::numeric_limits::min(), seed_offset.first, gen_offset)); } else { - thrust::transform( - index_sequence_begin, index_sequence_begin + size, - thrust::device_ptr(data), - TruncatedNormal(mean, std, std::numeric_limits::min(), seed)); + thrust::transform(index_sequence_begin, index_sequence_begin + size, + thrust::device_ptr(data), + GPUTruncatedNormal( + mean, std, std::numeric_limits::min(), seed)); } } }; diff --git a/paddle/fluid/operators/uniform_random_op.cu b/paddle/fluid/operators/uniform_random_op.cu index 563a6c165b..ceb13a3dda 100644 --- a/paddle/fluid/operators/uniform_random_op.cu +++ b/paddle/fluid/operators/uniform_random_op.cu @@ -11,9 +11,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 +#include #include #include - #include "paddle/fluid/framework/generator.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/operator.h" -- GitLab