未验证 提交 4c375454 编写于 作者: H huangjiyi 提交者: GitHub

[PHI Decoupling] remove dependency on "paddle/fluid/platform/errors.h" and...

[PHI Decoupling] remove dependency on "paddle/fluid/platform/errors.h" and "paddle/fluid/platform/fast_divmod.h" in phi. (#47815)

* rm "paddle/fluid/platform/errors.h" in phi

* rm "paddle/fluid/platform/fast_divmod.h" in phi
上级 3a14857b
...@@ -40,10 +40,10 @@ void* GetDsoHandle(const std::string& dso_name) { ...@@ -40,10 +40,10 @@ void* GetDsoHandle(const std::string& dso_name) {
void* dso_handle = dlopen(dso_name.c_str(), dynload_flags); void* dso_handle = dlopen(dso_name.c_str(), dynload_flags);
PADDLE_ENFORCE_NOT_NULL(dso_handle, PADDLE_ENFORCE_NOT_NULL(
paddle::platform::errors::NotFound( dso_handle,
"TensorRT is needed, " phi::errors::NotFound("TensorRT is needed, "
"but TensorRT dynamic library is not found.")); "but TensorRT dynamic library is not found."));
return dso_handle; return dso_handle;
} }
......
...@@ -174,10 +174,10 @@ void SelectedRowsImpl::Get(const phi::DenseTensor& ids, ...@@ -174,10 +174,10 @@ void SelectedRowsImpl::Get(const phi::DenseTensor& ids,
phi::DenseTensor* value, phi::DenseTensor* value,
bool auto_grown, bool auto_grown,
bool is_test) { bool is_test) {
PADDLE_ENFORCE_EQ(value->IsInitialized(), PADDLE_ENFORCE_EQ(
true, value->IsInitialized(),
paddle::platform::errors::InvalidArgument( true,
"The value tensor is not initialized.")); phi::errors::InvalidArgument("The value tensor is not initialized."));
if (ids.numel() == 0) { if (ids.numel() == 0) {
VLOG(3) << "keys is empty, please check data!"; VLOG(3) << "keys is empty, please check data!";
} else { } else {
......
...@@ -70,7 +70,7 @@ class AutoTuneBase { ...@@ -70,7 +70,7 @@ class AutoTuneBase {
PADDLE_ENFORCE_GT( PADDLE_ENFORCE_GT(
kernels_.size(), kernels_.size(),
0, 0,
paddle::platform::errors::InvalidArgument( phi::errors::InvalidArgument(
"kernel num must be greater than 0, now is %d", kernels_.size())); "kernel num must be greater than 0, now is %d", kernels_.size()));
is_init_ = true; is_init_ = true;
...@@ -102,7 +102,7 @@ class AutoTuneBase { ...@@ -102,7 +102,7 @@ class AutoTuneBase {
PADDLE_ENFORCE_GT( PADDLE_ENFORCE_GT(
kernels_.size(), kernels_.size(),
0, 0,
paddle::platform::errors::InvalidArgument( phi::errors::InvalidArgument(
"kernel num must be greater than 0, now is %d", kernels_.size())); "kernel num must be greater than 0, now is %d", kernels_.size()));
size_t best_idx = 0; size_t best_idx = 0;
float min_time = std::numeric_limits<float>::max(); float min_time = std::numeric_limits<float>::max();
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#pragma once #pragma once
#include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/errors.h" #include "paddle/phi/core/errors.h"
namespace phi { namespace phi {
namespace funcs { namespace funcs {
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "paddle/phi/kernels/funcs/eigen/common.h" #include "paddle/phi/kernels/funcs/eigen/common.h"
#if defined(__NVCC__) || defined(__HIPCC__) #if defined(__NVCC__) || defined(__HIPCC__)
#include "paddle/fluid/platform/fast_divmod.h" #include "paddle/phi/kernels/primitive/datamover_primitives.h"
#endif #endif
namespace phi { namespace phi {
...@@ -142,7 +142,7 @@ inline std::vector<T> get_new_data_from_tensor( ...@@ -142,7 +142,7 @@ inline std::vector<T> get_new_data_from_tensor(
} }
#if defined(__NVCC__) || defined(__HIPCC__) #if defined(__NVCC__) || defined(__HIPCC__)
using paddle::platform::FastDivMod; using phi::kps::details::FastDivMod;
struct FastDivModForInterpolate { struct FastDivModForInterpolate {
public: public:
......
...@@ -16,56 +16,56 @@ limitations under the License. */ ...@@ -16,56 +16,56 @@ limitations under the License. */
#include <vector> #include <vector>
#include "paddle/fluid/platform/device/gpu/gpu_primitives.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h"
#include "paddle/fluid/platform/fast_divmod.h"
#include "paddle/phi/backends/gpu/gpu_launch_config.h" #include "paddle/phi/backends/gpu/gpu_launch_config.h"
#include "paddle/phi/kernels/funcs/pooling.h" #include "paddle/phi/kernels/funcs/pooling.h"
#include "paddle/phi/kernels/funcs/reduce_function.h" #include "paddle/phi/kernels/funcs/reduce_function.h"
#include "paddle/phi/kernels/primitive/datamover_primitives.h"
namespace phi { namespace phi {
namespace funcs { namespace funcs {
struct FastDivModForPooling { struct FastDivModForPooling {
public: public:
paddle::platform::FastDivMod channel; phi::kps::details::FastDivMod channel;
paddle::platform::FastDivMod width; phi::kps::details::FastDivMod width;
paddle::platform::FastDivMod height; phi::kps::details::FastDivMod height;
explicit HOSTDEVICE FastDivModForPooling(const int channels, explicit HOSTDEVICE FastDivModForPooling(const int channels,
const int output_width, const int output_width,
const int output_height) { const int output_height) {
channel = paddle::platform::FastDivMod(channels); channel = phi::kps::details::FastDivMod(channels);
width = paddle::platform::FastDivMod(output_width); width = phi::kps::details::FastDivMod(output_width);
height = paddle::platform::FastDivMod(output_height); height = phi::kps::details::FastDivMod(output_height);
} }
}; };
struct FastDivModForPooling3D { struct FastDivModForPooling3D {
public: public:
paddle::platform::FastDivMod channel; phi::kps::details::FastDivMod channel;
paddle::platform::FastDivMod width; phi::kps::details::FastDivMod width;
paddle::platform::FastDivMod height; phi::kps::details::FastDivMod height;
paddle::platform::FastDivMod depth; phi::kps::details::FastDivMod depth;
explicit HOSTDEVICE FastDivModForPooling3D(const int channels, explicit HOSTDEVICE FastDivModForPooling3D(const int channels,
const int output_width, const int output_width,
const int output_height, const int output_height,
const int output_depth) { const int output_depth) {
channel = paddle::platform::FastDivMod(channels); channel = phi::kps::details::FastDivMod(channels);
width = paddle::platform::FastDivMod(output_width); width = phi::kps::details::FastDivMod(output_width);
height = paddle::platform::FastDivMod(output_height); height = phi::kps::details::FastDivMod(output_height);
depth = paddle::platform::FastDivMod(output_depth); depth = phi::kps::details::FastDivMod(output_depth);
} }
}; };
struct FastDivModForPoolingWithMoreStaff { struct FastDivModForPoolingWithMoreStaff {
public: public:
paddle::platform::FastDivMod channel; phi::kps::details::FastDivMod channel;
paddle::platform::FastDivMod width; phi::kps::details::FastDivMod width;
paddle::platform::FastDivMod height; phi::kps::details::FastDivMod height;
paddle::platform::FastDivMod ksize_w; phi::kps::details::FastDivMod ksize_w;
paddle::platform::FastDivMod ksize_h; phi::kps::details::FastDivMod ksize_h;
paddle::platform::FastDivMod stride_w; phi::kps::details::FastDivMod stride_w;
paddle::platform::FastDivMod stride_h; phi::kps::details::FastDivMod stride_h;
explicit HOSTDEVICE FastDivModForPoolingWithMoreStaff( explicit HOSTDEVICE FastDivModForPoolingWithMoreStaff(
const int channels, const int channels,
...@@ -75,13 +75,13 @@ struct FastDivModForPoolingWithMoreStaff { ...@@ -75,13 +75,13 @@ struct FastDivModForPoolingWithMoreStaff {
const int ksize_height, const int ksize_height,
const int stride_width, const int stride_width,
const int stride_height) { const int stride_height) {
channel = paddle::platform::FastDivMod(channels); channel = phi::kps::details::FastDivMod(channels);
width = paddle::platform::FastDivMod(input_width); width = phi::kps::details::FastDivMod(input_width);
height = paddle::platform::FastDivMod(input_height); height = phi::kps::details::FastDivMod(input_height);
ksize_w = paddle::platform::FastDivMod(ksize_width); ksize_w = phi::kps::details::FastDivMod(ksize_width);
ksize_h = paddle::platform::FastDivMod(ksize_height); ksize_h = phi::kps::details::FastDivMod(ksize_height);
stride_w = paddle::platform::FastDivMod(stride_width); stride_w = phi::kps::details::FastDivMod(stride_width);
stride_h = paddle::platform::FastDivMod(stride_height); stride_h = phi::kps::details::FastDivMod(stride_height);
} }
}; };
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "paddle/phi/kernels/interpolate_grad_kernel.h" #include "paddle/phi/kernels/interpolate_grad_kernel.h"
#include "paddle/fluid/platform/device/gpu/gpu_primitives.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h"
#include "paddle/fluid/platform/fast_divmod.h"
#include "paddle/phi/backends/gpu/gpu_context.h" #include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/backends/gpu/gpu_launch_config.h" #include "paddle/phi/backends/gpu/gpu_launch_config.h"
#include "paddle/phi/common/amp_type_traits.h" #include "paddle/phi/common/amp_type_traits.h"
...@@ -24,6 +23,7 @@ ...@@ -24,6 +23,7 @@
#include "paddle/phi/kernels/funcs/interpolate_function.h" #include "paddle/phi/kernels/funcs/interpolate_function.h"
#include "paddle/phi/kernels/funcs/math_cuda_utils.h" #include "paddle/phi/kernels/funcs/math_cuda_utils.h"
#include "paddle/phi/kernels/funcs/math_function.h" #include "paddle/phi/kernels/funcs/math_function.h"
#include "paddle/phi/kernels/primitive/datamover_primitives.h"
namespace phi { namespace phi {
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "paddle/fluid/platform/device/gpu/gpu_device_function.h" #include "paddle/fluid/platform/device/gpu/gpu_device_function.h"
#include "paddle/fluid/platform/device/gpu/gpu_primitives.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h"
#include "paddle/fluid/platform/fast_divmod.h"
#include "paddle/phi/backends/gpu/gpu_context.h" #include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/backends/gpu/gpu_launch_config.h" #include "paddle/phi/backends/gpu/gpu_launch_config.h"
#include "paddle/phi/common/amp_type_traits.h" #include "paddle/phi/common/amp_type_traits.h"
...@@ -24,9 +23,10 @@ ...@@ -24,9 +23,10 @@
#include "paddle/phi/common/layout.h" #include "paddle/phi/common/layout.h"
#include "paddle/phi/core/kernel_registry.h" #include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/funcs/interpolate_function.h" #include "paddle/phi/kernels/funcs/interpolate_function.h"
#include "paddle/phi/kernels/primitive/datamover_primitives.h"
namespace phi { namespace phi {
using paddle::platform::FastDivMod; using phi::kps::details::FastDivMod;
template <typename T> template <typename T>
__forceinline__ __device__ void PreCalculatorForLinearInterpInputIndex( __forceinline__ __device__ void PreCalculatorForLinearInterpInputIndex(
......
...@@ -108,7 +108,7 @@ void BroadcastTensorsKernel(const Context& ctx, ...@@ -108,7 +108,7 @@ void BroadcastTensorsKernel(const Context& ctx,
SWITCH_OUT_RANK_CASE(5) SWITCH_OUT_RANK_CASE(5)
SWITCH_OUT_RANK_CASE(6) SWITCH_OUT_RANK_CASE(6)
default: { default: {
PADDLE_THROW(paddle::platform::errors::InvalidArgument( PADDLE_THROW(phi::errors::InvalidArgument(
"Target tensor rank out of range" "Target tensor rank out of range"
"Maximum supported rank for broadcast is: 6")); "Maximum supported rank for broadcast is: 6"));
} }
......
...@@ -129,7 +129,7 @@ static void ScaleCPU(DataType kernel_dtype, ...@@ -129,7 +129,7 @@ static void ScaleCPU(DataType kernel_dtype,
break; break;
} }
default: { default: {
PADDLE_THROW(paddle::platform::errors::Fatal( PADDLE_THROW(phi::errors::Fatal(
"Detected unsupported data type." "Detected unsupported data type."
"Only Float64, Float32, BFloat16, Int64, Int32, Int16, Int8, UInt8 " "Only Float64, Float32, BFloat16, Int64, Int32, Int16, Int8, UInt8 "
"are supported for now.")); "are supported for now."));
...@@ -188,7 +188,7 @@ static void ScaleGPU(DataType kernel_dtype, ...@@ -188,7 +188,7 @@ static void ScaleGPU(DataType kernel_dtype,
break; break;
} }
default: { default: {
PADDLE_THROW(paddle::platform::errors::Fatal( PADDLE_THROW(phi::errors::Fatal(
"Detected unsupported data type." "Detected unsupported data type."
"Only Float64, Float32, Float16, Int64, Int32, Int16, Int8, UInt8 " "Only Float64, Float32, Float16, Int64, Int32, Int16, Int8, UInt8 "
"are " "are "
...@@ -262,7 +262,7 @@ Tensor scale_switch_case(const Tensor& x, ...@@ -262,7 +262,7 @@ Tensor scale_switch_case(const Tensor& x,
break; break;
#endif #endif
default: default:
PADDLE_THROW(paddle::platform::errors::Fatal( PADDLE_THROW(phi::errors::Fatal(
"Detected unsupported backend." "Detected unsupported backend."
"Only CPU and CUDA Backend are supported for now." "Only CPU and CUDA Backend are supported for now."
"Please double check if your backend falls into the above two " "Please double check if your backend falls into the above two "
......
...@@ -275,12 +275,12 @@ TEST(math_funciton, set_constant) { ...@@ -275,12 +275,12 @@ TEST(math_funciton, set_constant) {
auto* ctx = new phi::CPUContext(); auto* ctx = new phi::CPUContext();
phi::funcs::set_constant(*ctx, &t, 10); phi::funcs::set_constant(*ctx, &t, 10);
for (int64_t i = 0; i < t.numel(); ++i) { for (int64_t i = 0; i < t.numel(); ++i) {
PADDLE_ENFORCE_EQ(10, PADDLE_ENFORCE_EQ(
t.data<int>()[i], 10,
paddle::platform::errors::InvalidArgument( t.data<int>()[i],
"Each value of input tensor should be 10, " phi::errors::InvalidArgument("Each value of input tensor should be 10, "
"but received %d.", "but received %d.",
t.data<int>()[i])); t.data<int>()[i]));
} }
delete ctx; delete ctx;
} }
......
...@@ -26,7 +26,7 @@ void fill_fp16_data(phi::dtype::float16* in_ptr, ...@@ -26,7 +26,7 @@ void fill_fp16_data(phi::dtype::float16* in_ptr,
PADDLE_ENFORCE_EQ( PADDLE_ENFORCE_EQ(
size, size,
data.size(), data.size(),
paddle::platform::errors::InvalidArgument( phi::errors::InvalidArgument(
"The size of argument data should" "The size of argument data should"
" be equal to the argument size. Expected %d, but received %d.", " be equal to the argument size. Expected %d, but received %d.",
size, size,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册