未验证 提交 d25a7f9e 编写于 作者: F Feiyu Chan 提交者: GitHub

[Pten] move operators/math/math_function_* to pten/kernels/func (#39300)

* move operators/math/math_function_* to pten/kernels/func
* namespace from `paddle::operators::math` to `pten::funcs`
上级 d763a91a
...@@ -35,12 +35,12 @@ limitations under the License. */ ...@@ -35,12 +35,12 @@ limitations under the License. */
#include "paddle/fluid/framework/variable.h" #include "paddle/fluid/framework/variable.h"
#include "paddle/fluid/framework/variable_helper.h" #include "paddle/fluid/framework/variable_helper.h"
#include "paddle/fluid/operators/math/blas.h" #include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/operators/math/selected_rows_functor.h" #include "paddle/fluid/operators/math/selected_rows_functor.h"
#include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/place.h" #include "paddle/fluid/platform/place.h"
#include "paddle/fluid/string/split.h" #include "paddle/fluid/string/split.h"
#include "paddle/pten/kernels/funcs/math_function.h"
#include "paddle/fluid/distributed/ps/service/ps_client.h" #include "paddle/fluid/distributed/ps/service/ps_client.h"
...@@ -180,7 +180,7 @@ inline void MergeVars(const std::string &var_name, ...@@ -180,7 +180,7 @@ inline void MergeVars(const std::string &var_name,
// set output tensor to 0. // set output tensor to 0.
paddle::platform::CPUDeviceContext cpu_ctx; paddle::platform::CPUDeviceContext cpu_ctx;
paddle::operators::math::SetConstant<paddle::platform::CPUDeviceContext, T> pten::funcs::SetConstant<paddle::platform::CPUDeviceContext, T>
constant_functor; constant_functor;
constant_functor(cpu_ctx, out_t, static_cast<T>(0)); constant_functor(cpu_ctx, out_t, static_cast<T>(0));
// sum all vars to out // sum all vars to out
......
...@@ -38,9 +38,10 @@ ...@@ -38,9 +38,10 @@
#include "paddle/fluid/distributed/ps/service/ps_service/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/service/sendrecv.pb.h"
#include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/place.h" #include "paddle/fluid/platform/place.h"
#include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/printf.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace distributed { namespace distributed {
class GraphPyService { class GraphPyService {
......
...@@ -21,8 +21,8 @@ limitations under the License. */ ...@@ -21,8 +21,8 @@ limitations under the License. */
#include "paddle/fluid/distributed/ps/service/brpc_ps_server.h" #include "paddle/fluid/distributed/ps/service/brpc_ps_server.h"
#include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/framework/scope.h" #include "paddle/fluid/framework/scope.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/place.h" #include "paddle/fluid/platform/place.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace distributed { namespace distributed {
...@@ -42,7 +42,6 @@ class DenseTensor; ...@@ -42,7 +42,6 @@ class DenseTensor;
namespace framework = paddle::framework; namespace framework = paddle::framework;
namespace platform = paddle::platform; namespace platform = paddle::platform;
namespace operators = paddle::operators; namespace operators = paddle::operators;
namespace math = paddle::operators::math;
namespace memory = paddle::memory; namespace memory = paddle::memory;
namespace distributed = paddle::distributed; namespace distributed = paddle::distributed;
......
...@@ -22,8 +22,8 @@ limitations under the License. */ ...@@ -22,8 +22,8 @@ limitations under the License. */
#include "paddle/fluid/distributed/ps/service/brpc_ps_server.h" #include "paddle/fluid/distributed/ps/service/brpc_ps_server.h"
#include "paddle/fluid/distributed/ps/service/env.h" #include "paddle/fluid/distributed/ps/service/env.h"
#include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/place.h" #include "paddle/fluid/platform/place.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace distributed { namespace distributed {
...@@ -43,7 +43,6 @@ class DenseTensor; ...@@ -43,7 +43,6 @@ class DenseTensor;
namespace framework = paddle::framework; namespace framework = paddle::framework;
namespace platform = paddle::platform; namespace platform = paddle::platform;
namespace operators = paddle::operators; namespace operators = paddle::operators;
namespace math = paddle::operators::math;
namespace memory = paddle::memory; namespace memory = paddle::memory;
namespace distributed = paddle::distributed; namespace distributed = paddle::distributed;
......
...@@ -17,7 +17,7 @@ limitations under the License. */ ...@@ -17,7 +17,7 @@ limitations under the License. */
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "paddle/fluid/distributed/ps/service/brpc_utils.h" #include "paddle/fluid/distributed/ps/service/brpc_utils.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace framework { namespace framework {
...@@ -28,7 +28,6 @@ class Variable; ...@@ -28,7 +28,6 @@ class Variable;
namespace framework = paddle::framework; namespace framework = paddle::framework;
namespace platform = paddle::platform; namespace platform = paddle::platform;
namespace operators = paddle::operators; namespace operators = paddle::operators;
namespace math = paddle::operators::math;
namespace memory = paddle::memory; namespace memory = paddle::memory;
namespace distributed = paddle::distributed; namespace distributed = paddle::distributed;
...@@ -42,7 +41,7 @@ void CreateVarsOnScope(framework::Scope* scope, platform::Place* place, ...@@ -42,7 +41,7 @@ void CreateVarsOnScope(framework::Scope* scope, platform::Place* place,
lod1.push_back(framework::Vector<size_t>({1, 3, 8})); lod1.push_back(framework::Vector<size_t>({1, 3, 8}));
tensor1->set_lod(lod1); tensor1->set_lod(lod1);
tensor1->mutable_data<float>(*place); tensor1->mutable_data<float>(*place);
math::set_constant(ctx, tensor1, 31.9); pten::funcs::set_constant(ctx, tensor1, 31.9);
// var 2 // var 2
framework::Variable* var2 = scope->Var("x2"); framework::Variable* var2 = scope->Var("x2");
...@@ -52,7 +51,7 @@ void CreateVarsOnScope(framework::Scope* scope, platform::Place* place, ...@@ -52,7 +51,7 @@ void CreateVarsOnScope(framework::Scope* scope, platform::Place* place,
lod2.push_back(framework::Vector<size_t>({1, 1})); lod2.push_back(framework::Vector<size_t>({1, 1}));
tensor2->set_lod(lod2); tensor2->set_lod(lod2);
tensor2->mutable_data<int>(*place); tensor2->mutable_data<int>(*place);
math::set_constant(ctx, tensor2, 100); pten::funcs::set_constant(ctx, tensor2, 100);
// var 3 // var 3
framework::Variable* var3 = scope->Var("x3"); framework::Variable* var3 = scope->Var("x3");
...@@ -62,7 +61,7 @@ void CreateVarsOnScope(framework::Scope* scope, platform::Place* place, ...@@ -62,7 +61,7 @@ void CreateVarsOnScope(framework::Scope* scope, platform::Place* place,
auto* rows = slr->mutable_rows(); auto* rows = slr->mutable_rows();
tensor3->Resize(framework::make_ddim({564, 128})); tensor3->Resize(framework::make_ddim({564, 128}));
tensor3->mutable_data<float>(*place); tensor3->mutable_data<float>(*place);
math::set_constant(ctx, tensor3, 32.7); pten::funcs::set_constant(ctx, tensor3, 32.7);
for (int i = 0; i < 564; ++i) rows->push_back(i); for (int i = 0; i < 564; ++i) rows->push_back(i);
} }
......
...@@ -36,14 +36,13 @@ limitations under the License. */ ...@@ -36,14 +36,13 @@ limitations under the License. */
#include "paddle/fluid/framework/scope.h" #include "paddle/fluid/framework/scope.h"
#include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/framework/tensor_util.h"
#include "paddle/fluid/framework/variable.h" #include "paddle/fluid/framework/variable.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/place.h" #include "paddle/fluid/platform/place.h"
#include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/printf.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace framework = paddle::framework; namespace framework = paddle::framework;
namespace platform = paddle::platform; namespace platform = paddle::platform;
namespace operators = paddle::operators; namespace operators = paddle::operators;
namespace math = paddle::operators::math;
namespace memory = paddle::memory; namespace memory = paddle::memory;
namespace distributed = paddle::distributed; namespace distributed = paddle::distributed;
......
...@@ -36,14 +36,13 @@ limitations under the License. */ ...@@ -36,14 +36,13 @@ limitations under the License. */
#include "paddle/fluid/framework/scope.h" #include "paddle/fluid/framework/scope.h"
#include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/framework/tensor_util.h"
#include "paddle/fluid/framework/variable.h" #include "paddle/fluid/framework/variable.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/place.h" #include "paddle/fluid/platform/place.h"
#include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/printf.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace framework = paddle::framework; namespace framework = paddle::framework;
namespace platform = paddle::platform; namespace platform = paddle::platform;
namespace operators = paddle::operators; namespace operators = paddle::operators;
namespace math = paddle::operators::math;
namespace memory = paddle::memory; namespace memory = paddle::memory;
namespace distributed = paddle::distributed; namespace distributed = paddle::distributed;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "paddle/fluid/imperative/gradient_accumulator.h" #include "paddle/fluid/imperative/gradient_accumulator.h"
#include "paddle/fluid/framework/var_type.h" #include "paddle/fluid/framework/var_type.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace egr { namespace egr {
......
...@@ -19,9 +19,9 @@ limitations under the License. */ ...@@ -19,9 +19,9 @@ limitations under the License. */
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/scope.h" #include "paddle/fluid/framework/scope.h"
#include "paddle/fluid/operators/elementwise/elementwise_op_function.h" #include "paddle/fluid/operators/elementwise/elementwise_op_function.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/init.h" #include "paddle/fluid/platform/init.h"
#include "paddle/pten/kernels/funcs/math_function.h"
#include "paddle/fluid/framework/pten_utils.h" #include "paddle/fluid/framework/pten_utils.h"
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "paddle/fluid/framework/data_layout_transform.h" #include "paddle/fluid/framework/data_layout_transform.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
#ifdef PADDLE_WITH_MKLDNN #ifdef PADDLE_WITH_MKLDNN
#include "paddle/fluid/platform/mkldnn_reuse.h" #include "paddle/fluid/platform/mkldnn_reuse.h"
#endif #endif
...@@ -42,7 +42,7 @@ void CastDataLayout::apply() { ...@@ -42,7 +42,7 @@ void CastDataLayout::apply() {
auto place = ctx_->GetPlace(); auto place = ctx_->GetPlace();
if (platform::is_cpu_place(place)) { if (platform::is_cpu_place(place)) {
operators::math::Transpose<platform::CPUDeviceContext, T, 4> trans4; pten::funcs::Transpose<platform::CPUDeviceContext, T, 4> trans4;
auto* context = static_cast<const platform::CPUDeviceContext*>(ctx_); auto* context = static_cast<const platform::CPUDeviceContext*>(ctx_);
trans4(*context, in_, out_, axis_); trans4(*context, in_, out_, axis_);
} else { } else {
......
...@@ -22,10 +22,10 @@ limitations under the License. */ ...@@ -22,10 +22,10 @@ limitations under the License. */
#include "paddle/fluid/framework/selected_rows_utils.h" #include "paddle/fluid/framework/selected_rows_utils.h"
#include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/framework/variable.h" #include "paddle/fluid/framework/variable.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/macros.h" #include "paddle/fluid/platform/macros.h"
#include "paddle/fluid/platform/transform.h" #include "paddle/fluid/platform/transform.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace framework { namespace framework {
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "paddle/fluid/framework/ir/node.h" #include "paddle/fluid/framework/ir/node.h"
#include "paddle/fluid/framework/op_info.h" #include "paddle/fluid/framework/op_info.h"
#include "paddle/fluid/framework/scope.h" #include "paddle/fluid/framework/scope.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
#if defined(PADDLE_WITH_DGC) #if defined(PADDLE_WITH_DGC)
#include "paddle/fluid/framework/details/sparse_all_reduce_op_handle.h" #include "paddle/fluid/framework/details/sparse_all_reduce_op_handle.h"
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
#include "paddle/fluid/imperative/layer.h" #include "paddle/fluid/imperative/layer.h"
#include "paddle/fluid/imperative/op_base.h" #include "paddle/fluid/imperative/op_base.h"
#include "paddle/fluid/imperative/tracer.h" #include "paddle/fluid/imperative/tracer.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/profiler.h" #include "paddle/fluid/platform/profiler.h"
#include "paddle/pten/kernels/funcs/math_function.h"
DECLARE_bool(sort_sum_gradient); DECLARE_bool(sort_sum_gradient);
...@@ -103,7 +103,7 @@ void BasicEngine::Init( ...@@ -103,7 +103,7 @@ void BasicEngine::Init(
if (grad_tensor == nullptr) { if (grad_tensor == nullptr) {
grad_var->Resize(fwd_var.dims()); grad_var->Resize(fwd_var.dims());
grad_var->mutable_data(fwd_var.place(), fwd_var.type()); grad_var->mutable_data(fwd_var.place(), fwd_var.type());
operators::math::set_constant(*dev_ctx, grad_var, 1.0); pten::funcs::set_constant(*dev_ctx, grad_var, 1.0);
} else { } else {
paddle::framework::TensorCopy( paddle::framework::TensorCopy(
grad_tensor->Var().Get<framework::LoDTensor>(), fwd_var.place(), grad_tensor->Var().Get<framework::LoDTensor>(), fwd_var.place(),
...@@ -156,7 +156,7 @@ void BasicEngine::CheckBackwardInputs(const OpBase& op) { ...@@ -156,7 +156,7 @@ void BasicEngine::CheckBackwardInputs(const OpBase& op) {
VLOG(6) << "Set ungenerated Grad: " << var->Name() VLOG(6) << "Set ungenerated Grad: " << var->Name()
<< " as zero with dtype " << " as zero with dtype "
<< framework::DataTypeToString(var->ForwardDataType()); << framework::DataTypeToString(var->ForwardDataType());
operators::math::set_constant(*dev_ctx, tensor, 0.0); pten::funcs::set_constant(*dev_ctx, tensor, 0.0);
} }
} }
} }
......
...@@ -22,12 +22,12 @@ ...@@ -22,12 +22,12 @@
#include "paddle/fluid/framework/selected_rows_utils.h" #include "paddle/fluid/framework/selected_rows_utils.h"
#include "paddle/fluid/imperative/layer.h" #include "paddle/fluid/imperative/layer.h"
#include "paddle/fluid/operators/math/blas.h" #include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/operators/math/selected_rows_functor.h" #include "paddle/fluid/operators/math/selected_rows_functor.h"
#include "paddle/fluid/platform/complex.h" #include "paddle/fluid/platform/complex.h"
#include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/float16.h" #include "paddle/fluid/platform/float16.h"
#include "paddle/fluid/platform/profiler.h" #include "paddle/fluid/platform/profiler.h"
#include "paddle/pten/kernels/funcs/math_function.h"
#ifdef PADDLE_WITH_XPU #ifdef PADDLE_WITH_XPU
#include "xpu/refactor/math.h" #include "xpu/refactor/math.h"
#endif #endif
...@@ -210,7 +210,7 @@ void TensorAddImpl(const framework::Tensor& src, framework::Tensor* dst, ...@@ -210,7 +210,7 @@ void TensorAddImpl(const framework::Tensor& src, framework::Tensor* dst,
platform::DeviceContextPool& pool = platform::DeviceContextPool::Instance(); platform::DeviceContextPool& pool = platform::DeviceContextPool::Instance();
paddle::platform::DeviceContext* ctx = pool.Get(place); paddle::platform::DeviceContext* ctx = pool.Get(place);
auto dev_ctx = dynamic_cast<DeviceContext*>(ctx); auto dev_ctx = dynamic_cast<DeviceContext*>(ctx);
operators::math::ElementwiseAddTo<DeviceContext, T> func; pten::funcs::ElementwiseAddTo<DeviceContext, T> func;
func(dev_ctx, src, dst); func(dev_ctx, src, dst);
} }
...@@ -703,12 +703,12 @@ void EagerGradientAccumulator::SumGrad(std::shared_ptr<VariableWrapper> var, ...@@ -703,12 +703,12 @@ void EagerGradientAccumulator::SumGrad(std::shared_ptr<VariableWrapper> var,
<< var->Var().Get<framework::LoDTensor>().dims(); << var->Var().Get<framework::LoDTensor>().dims();
tensor->Resize(var->Var().Get<framework::LoDTensor>().dims()); tensor->Resize(var->Var().Get<framework::LoDTensor>().dims());
tensor->mutable_data(place, var->DataType()); tensor->mutable_data(place, var->DataType());
operators::math::set_constant(*dev_ctx, tensor, 0.0); pten::funcs::set_constant(*dev_ctx, tensor, 0.0);
} else { } else {
auto* tensor = auto* tensor =
dst_var->MutableVar()->GetMutable<framework::LoDTensor>(); dst_var->MutableVar()->GetMutable<framework::LoDTensor>();
tensor->mutable_data(place, var->DataType()); tensor->mutable_data(place, var->DataType());
operators::math::set_constant(*dev_ctx, tensor, 0.0); pten::funcs::set_constant(*dev_ctx, tensor, 0.0);
} }
} }
} }
...@@ -835,12 +835,12 @@ void SortedGradientAccumulator::SumGrad(std::shared_ptr<VariableWrapper> var, ...@@ -835,12 +835,12 @@ void SortedGradientAccumulator::SumGrad(std::shared_ptr<VariableWrapper> var,
<< var->Var().Get<framework::LoDTensor>().dims(); << var->Var().Get<framework::LoDTensor>().dims();
tensor->Resize(var->Var().Get<framework::LoDTensor>().dims()); tensor->Resize(var->Var().Get<framework::LoDTensor>().dims());
tensor->mutable_data(place, var->DataType()); tensor->mutable_data(place, var->DataType());
operators::math::set_constant(*dev_ctx, tensor, 0.0); pten::funcs::set_constant(*dev_ctx, tensor, 0.0);
} else { } else {
auto* tensor = auto* tensor =
dst_var->MutableVar()->GetMutable<framework::LoDTensor>(); dst_var->MutableVar()->GetMutable<framework::LoDTensor>();
tensor->mutable_data(place, var->DataType()); tensor->mutable_data(place, var->DataType());
operators::math::set_constant(*dev_ctx, tensor, 0.0); pten::funcs::set_constant(*dev_ctx, tensor, 0.0);
} }
} }
// looks like tmp_grad_vars will not have any member but just in case // looks like tmp_grad_vars will not have any member but just in case
......
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
#include "paddle/fluid/imperative/op_base.h" #include "paddle/fluid/imperative/op_base.h"
#include "paddle/fluid/imperative/prepared_operator.h" #include "paddle/fluid/imperative/prepared_operator.h"
#include "paddle/fluid/imperative/var_helper.h" #include "paddle/fluid/imperative/var_helper.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/profiler.h" #include "paddle/fluid/platform/profiler.h"
#include "paddle/pten/kernels/funcs/math_function.h"
#ifdef PADDLE_WITH_MKLDNN #ifdef PADDLE_WITH_MKLDNN
#include "paddle/fluid/platform/mkldnn_helper.h" #include "paddle/fluid/platform/mkldnn_helper.h"
#endif #endif
...@@ -229,7 +229,7 @@ void VarBase::ClearGradient(bool set_to_zero) { ...@@ -229,7 +229,7 @@ void VarBase::ClearGradient(bool set_to_zero) {
if (set_to_zero) { if (set_to_zero) {
auto* dev_ctx = auto* dev_ctx =
platform::DeviceContextPool::Instance().Get(grad_t->place()); platform::DeviceContextPool::Instance().Get(grad_t->place());
operators::math::set_constant(*dev_ctx, grad_t, 0.0); pten::funcs::set_constant(*dev_ctx, grad_t, 0.0);
} else { } else {
grad_t->clear(); grad_t->clear();
} }
......
...@@ -28,10 +28,10 @@ ...@@ -28,10 +28,10 @@
#include "paddle/fluid/imperative/layer.h" #include "paddle/fluid/imperative/layer.h"
#include "paddle/fluid/imperative/op_base.h" #include "paddle/fluid/imperative/op_base.h"
#include "paddle/fluid/imperative/tracer.h" #include "paddle/fluid/imperative/tracer.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/profiler.h" #include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/string/string_helper.h" #include "paddle/fluid/string/string_helper.h"
#include "paddle/pten/kernels/funcs/math_function.h"
DECLARE_bool(sort_sum_gradient); DECLARE_bool(sort_sum_gradient);
...@@ -316,7 +316,7 @@ static void FillConstantLike(const VariableWrapper &ref_var, ...@@ -316,7 +316,7 @@ static void FillConstantLike(const VariableWrapper &ref_var,
} else { } else {
dst_tensor->mutable_data(place, ref_var.DataType()); dst_tensor->mutable_data(place, ref_var.DataType());
} }
operators::math::set_constant(*dev_ctx, dst_tensor, value); pten::funcs::set_constant(*dev_ctx, dst_tensor, value);
} }
/** /**
......
...@@ -755,7 +755,7 @@ void Reducer::MarkVarReady(const size_t var_index, const bool is_used_var) { ...@@ -755,7 +755,7 @@ void Reducer::MarkVarReady(const size_t var_index, const bool is_used_var) {
{static_cast<int64_t>(length)}); {static_cast<int64_t>(length)});
} else { } else {
group_tensor.Resize({static_cast<int64_t>(length)}); group_tensor.Resize({static_cast<int64_t>(length)});
operators::math::set_constant(*dev_ctx, &group_tensor, 0.0); pten::funcs::set_constant(*dev_ctx, &group_tensor, 0.0);
} }
#endif #endif
} }
......
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
#include "paddle/fluid/framework/tensor.h" #include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/framework/tensor_util.h" #include "paddle/fluid/framework/tensor_util.h"
#include "paddle/fluid/framework/variable.h" #include "paddle/fluid/framework/variable.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/for_range.h" #include "paddle/fluid/platform/for_range.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace imperative { namespace imperative {
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "paddle/fluid/framework/variable.h" #include "paddle/fluid/framework/variable.h"
#include "paddle/fluid/imperative/gradient_accumulator.h" #include "paddle/fluid/imperative/gradient_accumulator.h"
#include "paddle/fluid/memory/memcpy.h" #include "paddle/fluid/memory/memcpy.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace imperative = paddle::imperative; namespace imperative = paddle::imperative;
namespace platform = paddle::platform; namespace platform = paddle::platform;
......
...@@ -20,7 +20,7 @@ limitations under the License. */ ...@@ -20,7 +20,7 @@ limitations under the License. */
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/operators/eigen/eigen_function.h" #include "paddle/fluid/operators/eigen/eigen_function.h"
#include "paddle/fluid/operators/math/blas.h" #include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace ops = paddle::operators; namespace ops = paddle::operators;
namespace plat = paddle::platform; namespace plat = paddle::platform;
......
...@@ -170,7 +170,7 @@ class AffineGridGradOpCUDAKernel : public framework::OpKernel<T> { ...@@ -170,7 +170,7 @@ class AffineGridGradOpCUDAKernel : public framework::OpKernel<T> {
w = size_attr[3]; w = size_attr[3];
} }
T* theta_grad_data = theta_grad->mutable_data<T>({n, 2, 3}, ctx.GetPlace()); T* theta_grad_data = theta_grad->mutable_data<T>({n, 2, 3}, ctx.GetPlace());
math::SetConstant<paddle::platform::CUDADeviceContext, T>()( pten::funcs::SetConstant<paddle::platform::CUDADeviceContext, T>()(
ctx.cuda_device_context(), theta_grad, static_cast<T>(0)); ctx.cuda_device_context(), theta_grad, static_cast<T>(0));
T h_step; T h_step;
......
...@@ -17,7 +17,7 @@ limitations under the License. */ ...@@ -17,7 +17,7 @@ limitations under the License. */
#include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/eigen.h"
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/blas.h" #include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -61,7 +61,7 @@ inline void GetIdxMap(int n, int h, int w, bool align_corners, Tensor* grid, ...@@ -61,7 +61,7 @@ inline void GetIdxMap(int n, int h, int w, bool align_corners, Tensor* grid,
Tensor ones; Tensor ones;
ones.mutable_data<T>({h, w, 1}, ctx.GetPlace()); ones.mutable_data<T>({h, w, 1}, ctx.GetPlace());
math::SetConstant<DeviceContext, T>()( pten::funcs::SetConstant<DeviceContext, T>()(
ctx.template device_context<DeviceContext>(), &ones, static_cast<T>(1)); ctx.template device_context<DeviceContext>(), &ones, static_cast<T>(1));
auto ones_t = EigenTensor<T, 3>::From(ones); auto ones_t = EigenTensor<T, 3>::From(ones);
// Get grid tensor with shape [n, h, w, 3] by concatenating h_idx, w_idx and // Get grid tensor with shape [n, h, w, 3] by concatenating h_idx, w_idx and
...@@ -115,7 +115,7 @@ class AffineGridOpKernel : public framework::OpKernel<T> { ...@@ -115,7 +115,7 @@ class AffineGridOpKernel : public framework::OpKernel<T> {
} }
auto* output = ctx.Output<Tensor>("Output"); auto* output = ctx.Output<Tensor>("Output");
output->mutable_data<T>({n, h, w, 2}, ctx.GetPlace()); output->mutable_data<T>({n, h, w, 2}, ctx.GetPlace());
math::SetConstant<DeviceContext, T>()( pten::funcs::SetConstant<DeviceContext, T>()(
ctx.template device_context<DeviceContext>(), output, ctx.template device_context<DeviceContext>(), output,
static_cast<T>(0)); static_cast<T>(0));
Tensor grid; Tensor grid;
...@@ -158,7 +158,7 @@ class AffineGridGradOpKernel : public framework::OpKernel<T> { ...@@ -158,7 +158,7 @@ class AffineGridGradOpKernel : public framework::OpKernel<T> {
w = size_attr[3]; w = size_attr[3];
} }
theta_grad->mutable_data<T>({n, 2, 3}, ctx.GetPlace()); theta_grad->mutable_data<T>({n, 2, 3}, ctx.GetPlace());
math::SetConstant<DeviceContext, T>()( pten::funcs::SetConstant<DeviceContext, T>()(
ctx.template device_context<DeviceContext>(), theta_grad, ctx.template device_context<DeviceContext>(), theta_grad,
static_cast<T>(0)); static_cast<T>(0));
Tensor grid; Tensor grid;
......
...@@ -24,12 +24,11 @@ limitations under the License. */ ...@@ -24,12 +24,11 @@ limitations under the License. */
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/enforce.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace f = paddle::framework; namespace f = paddle::framework;
namespace p = paddle::platform; namespace p = paddle::platform;
namespace m = paddle::operators::math;
using Tensor = paddle::framework::Tensor; using Tensor = paddle::framework::Tensor;
......
...@@ -24,12 +24,11 @@ limitations under the License. */ ...@@ -24,12 +24,11 @@ limitations under the License. */
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/dropout_op.h" #include "paddle/fluid/operators/dropout_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/printf.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace f = paddle::framework; namespace f = paddle::framework;
namespace p = paddle::platform; namespace p = paddle::platform;
namespace m = paddle::operators::math;
USE_OP(assign); USE_OP(assign);
USE_OP_DEVICE_KERNEL(assign, NPU); USE_OP_DEVICE_KERNEL(assign, NPU);
......
...@@ -16,7 +16,7 @@ limitations under the License. */ ...@@ -16,7 +16,7 @@ limitations under the License. */
#include <algorithm> #include <algorithm>
#include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/eigen.h"
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -78,7 +78,7 @@ class AverageAccumulatesKernel : public framework::OpKernel<T> { ...@@ -78,7 +78,7 @@ class AverageAccumulatesKernel : public framework::OpKernel<T> {
// Compute // Compute
auto& place = *ctx.template device_context<DeviceContext>().eigen_device(); auto& place = *ctx.template device_context<DeviceContext>().eigen_device();
math::SetConstant<DeviceContext, T> constant_functor; pten::funcs::SetConstant<DeviceContext, T> constant_functor;
++num_updates; ++num_updates;
++num_accumulates; ++num_accumulates;
out_sum_1_tensor.device(place) = in_sum_1_tensor + param_tensor; out_sum_1_tensor.device(place) = in_sum_1_tensor + param_tensor;
......
...@@ -989,7 +989,7 @@ class BatchNormDoubleGradKernel<platform::CPUDeviceContext, T> ...@@ -989,7 +989,7 @@ class BatchNormDoubleGradKernel<platform::CPUDeviceContext, T>
(data_layout == DataLayout::kNCHW ? x_dims[1] (data_layout == DataLayout::kNCHW ? x_dims[1]
: x_dims[x_dims.size() - 1]); : x_dims[x_dims.size() - 1]);
const int sample_size = X->numel() / C; const int sample_size = X->numel() / C;
math::SetConstant<platform::CPUDeviceContext, T> set_constant; pten::funcs::SetConstant<platform::CPUDeviceContext, T> set_constant;
const T *mean_data = Saved_mean->data<T>(); const T *mean_data = Saved_mean->data<T>();
const T *inv_var_data = Saved_variance->data<T>(); const T *inv_var_data = Saved_variance->data<T>();
......
...@@ -25,9 +25,9 @@ namespace cub = hipcub; ...@@ -25,9 +25,9 @@ namespace cub = hipcub;
#endif #endif
#include "paddle/fluid/framework/data_layout.h" #include "paddle/fluid/framework/data_layout.h"
#include "paddle/fluid/operators/batch_norm_op.h" #include "paddle/fluid/operators/batch_norm_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/operators/norm_utils.cu.h" #include "paddle/fluid/operators/norm_utils.cu.h"
#include "paddle/fluid/platform/float16.h" #include "paddle/fluid/platform/float16.h"
#include "paddle/pten/kernels/funcs/math_function.h"
DECLARE_bool(cudnn_batchnorm_spatial_persistent); DECLARE_bool(cudnn_batchnorm_spatial_persistent);
...@@ -967,7 +967,8 @@ class BatchNormGradKernel<platform::CUDADeviceContext, T> ...@@ -967,7 +967,8 @@ class BatchNormGradKernel<platform::CUDADeviceContext, T>
if (d_x) { if (d_x) {
framework::TensorCopy(*d_y, ctx.GetPlace(), d_x); framework::TensorCopy(*d_y, ctx.GetPlace(), d_x);
} }
math::SetConstant<platform::CUDADeviceContext, BatchNormParamType<T>> pten::funcs::SetConstant<platform::CUDADeviceContext,
BatchNormParamType<T>>
functor; functor;
functor(dev_ctx, d_scale, static_cast<BatchNormParamType<T>>(0)); functor(dev_ctx, d_scale, static_cast<BatchNormParamType<T>>(0));
functor(dev_ctx, d_bias, static_cast<BatchNormParamType<T>>(0)); functor(dev_ctx, d_bias, static_cast<BatchNormParamType<T>>(0));
......
...@@ -20,8 +20,8 @@ limitations under the License. */ ...@@ -20,8 +20,8 @@ limitations under the License. */
#include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/eigen.h"
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/layout_utils.h" #include "paddle/fluid/operators/layout_utils.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/operators/norm_utils.h" #include "paddle/fluid/operators/norm_utils.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -16,7 +16,7 @@ limitations under the License. */ ...@@ -16,7 +16,7 @@ limitations under the License. */
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -111,7 +111,7 @@ class BilinearTensorProductGradKernel : public framework::OpKernel<T> { ...@@ -111,7 +111,7 @@ class BilinearTensorProductGradKernel : public framework::OpKernel<T> {
ctx.GetPlace()); ctx.GetPlace());
auto y_scale_mat = EigenMatrix<T>::From(y_scale); auto y_scale_mat = EigenMatrix<T>::From(y_scale);
math::SetConstant<DeviceContext, T> set_zero; pten::funcs::SetConstant<DeviceContext, T> set_zero;
if (d_x) { if (d_x) {
d_x->mutable_data<T>(ctx.GetPlace()); d_x->mutable_data<T>(ctx.GetPlace());
......
...@@ -105,7 +105,7 @@ void BincountCUDAInner(const framework::ExecutionContext& context) { ...@@ -105,7 +105,7 @@ void BincountCUDAInner(const framework::ExecutionContext& context) {
if (!has_weights) { if (!has_weights) {
int64_t* output_data = output->mutable_data<int64_t>(context.GetPlace()); int64_t* output_data = output->mutable_data<int64_t>(context.GetPlace());
math::SetConstant<DeviceContext, int64_t>()( pten::funcs::SetConstant<DeviceContext, int64_t>()(
context.template device_context<DeviceContext>(), output, 0L); context.template device_context<DeviceContext>(), output, 0L);
KernelBincount<T, InputT, int64_t><<<GET_BLOCKS(input_numel), KernelBincount<T, InputT, int64_t><<<GET_BLOCKS(input_numel),
...@@ -116,7 +116,7 @@ void BincountCUDAInner(const framework::ExecutionContext& context) { ...@@ -116,7 +116,7 @@ void BincountCUDAInner(const framework::ExecutionContext& context) {
if (weights_type == framework::proto::VarType::FP32) { if (weights_type == framework::proto::VarType::FP32) {
float* output_data = output->mutable_data<float>(context.GetPlace()); float* output_data = output->mutable_data<float>(context.GetPlace());
math::SetConstant<DeviceContext, float>()( pten::funcs::SetConstant<DeviceContext, float>()(
context.template device_context<DeviceContext>(), output, context.template device_context<DeviceContext>(), output,
static_cast<float>(0)); static_cast<float>(0));
...@@ -125,7 +125,7 @@ void BincountCUDAInner(const framework::ExecutionContext& context) { ...@@ -125,7 +125,7 @@ void BincountCUDAInner(const framework::ExecutionContext& context) {
input_data, input_numel, has_weights, weights_data, output_data); input_data, input_numel, has_weights, weights_data, output_data);
} else { } else {
double* output_data = output->mutable_data<double>(context.GetPlace()); double* output_data = output->mutable_data<double>(context.GetPlace());
math::SetConstant<DeviceContext, double>()( pten::funcs::SetConstant<DeviceContext, double>()(
context.template device_context<DeviceContext>(), output, context.template device_context<DeviceContext>(), output,
static_cast<double>(0)); static_cast<double>(0));
......
...@@ -18,7 +18,7 @@ limitations under the License. */ ...@@ -18,7 +18,7 @@ limitations under the License. */
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -64,7 +64,7 @@ void BincountInner(const framework::ExecutionContext& context) { ...@@ -64,7 +64,7 @@ void BincountInner(const framework::ExecutionContext& context) {
const auto& weights_type = weights->type(); const auto& weights_type = weights->type();
if (weights_type == framework::proto::VarType::FP32) { if (weights_type == framework::proto::VarType::FP32) {
float* output_data = output->mutable_data<float>(context.GetPlace()); float* output_data = output->mutable_data<float>(context.GetPlace());
math::SetConstant<DeviceContext, float>()( pten::funcs::SetConstant<DeviceContext, float>()(
context.template device_context<DeviceContext>(), output, context.template device_context<DeviceContext>(), output,
static_cast<float>(0)); static_cast<float>(0));
for (int64_t i = 0; i < input_numel; i++) { for (int64_t i = 0; i < input_numel; i++) {
...@@ -72,7 +72,7 @@ void BincountInner(const framework::ExecutionContext& context) { ...@@ -72,7 +72,7 @@ void BincountInner(const framework::ExecutionContext& context) {
} }
} else { } else {
double* output_data = output->mutable_data<double>(context.GetPlace()); double* output_data = output->mutable_data<double>(context.GetPlace());
math::SetConstant<DeviceContext, double>()( pten::funcs::SetConstant<DeviceContext, double>()(
context.template device_context<DeviceContext>(), output, context.template device_context<DeviceContext>(), output,
static_cast<double>(0)); static_cast<double>(0));
for (int64_t i = 0; i < input_numel; i++) { for (int64_t i = 0; i < input_numel; i++) {
...@@ -82,7 +82,7 @@ void BincountInner(const framework::ExecutionContext& context) { ...@@ -82,7 +82,7 @@ void BincountInner(const framework::ExecutionContext& context) {
} else { } else {
int64_t* output_data = output->mutable_data<int64_t>(context.GetPlace()); int64_t* output_data = output->mutable_data<int64_t>(context.GetPlace());
math::SetConstant<DeviceContext, int64_t>()( pten::funcs::SetConstant<DeviceContext, int64_t>()(
context.template device_context<DeviceContext>(), output, 0L); context.template device_context<DeviceContext>(), output, 0L);
for (int64_t i = 0; i < input_numel; i++) { for (int64_t i = 0; i < input_numel; i++) {
output_data[input_data[i]] += 1L; output_data[input_data[i]] += 1L;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/operators/math/blas.h" #include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -15,8 +15,8 @@ limitations under the License. */ ...@@ -15,8 +15,8 @@ limitations under the License. */
#pragma once #pragma once
#include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/eigen.h"
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/for_range.h" #include "paddle/fluid/platform/for_range.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -19,7 +19,7 @@ limitations under the License. */ ...@@ -19,7 +19,7 @@ limitations under the License. */
#include "paddle/fluid/framework/lod_tensor_array.h" #include "paddle/fluid/framework/lod_tensor_array.h"
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/eigen/eigen_function.h" #include "paddle/fluid/operators/eigen/eigen_function.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
#define SWITCH_OUT_RANK_CASE(n) \ #define SWITCH_OUT_RANK_CASE(n) \
case n: { \ case n: { \
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
#include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/framework/op_version_registry.h"
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/var_type.h" #include "paddle/fluid/framework/var_type.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/device_memory_aligment.h" #include "paddle/fluid/platform/device_memory_aligment.h"
#include "paddle/pten/kernels/funcs/math_function.h"
#ifdef PADDLE_WITH_ASCEND_CL #ifdef PADDLE_WITH_ASCEND_CL
#include "paddle/fluid/platform/device/npu/npu_op_runner.h" #include "paddle/fluid/platform/device/npu/npu_op_runner.h"
#endif #endif
...@@ -65,11 +65,11 @@ struct FillConstantVisitor { ...@@ -65,11 +65,11 @@ struct FillConstantVisitor {
.stream(); .stream();
runner.Run(stream); runner.Run(stream);
} else { } else {
math::SetConstant<DeviceContext, T> set_constant; pten::funcs::SetConstant<DeviceContext, T> set_constant;
set_constant(dev_ctx_, tensor_, static_cast<T>(value_)); set_constant(dev_ctx_, tensor_, static_cast<T>(value_));
} }
#else #else
math::SetConstant<DeviceContext, T> set_constant; pten::funcs::SetConstant<DeviceContext, T> set_constant;
set_constant(dev_ctx_, tensor_, static_cast<T>(value_)); set_constant(dev_ctx_, tensor_, static_cast<T>(value_));
#endif #endif
} }
......
...@@ -27,8 +27,8 @@ limitations under the License. */ ...@@ -27,8 +27,8 @@ limitations under the License. */
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/dropout_op.h" #include "paddle/fluid/operators/dropout_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/printf.h"
#include "paddle/pten/kernels/funcs/math_function.h"
#include "paddle/fluid/operators/collective/c_allgather_op.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_allreduce_op.h"
...@@ -43,7 +43,6 @@ limitations under the License. */ ...@@ -43,7 +43,6 @@ limitations under the License. */
namespace f = paddle::framework; namespace f = paddle::framework;
namespace p = paddle::platform; namespace p = paddle::platform;
namespace m = paddle::operators::math;
USE_OP(c_allgather); USE_OP(c_allgather);
USE_NO_KERNEL_OP(c_gen_hccl_id); USE_NO_KERNEL_OP(c_gen_hccl_id);
......
...@@ -27,8 +27,8 @@ limitations under the License. */ ...@@ -27,8 +27,8 @@ limitations under the License. */
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/dropout_op.h" #include "paddle/fluid/operators/dropout_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/printf.h"
#include "paddle/pten/kernels/funcs/math_function.h"
#include "paddle/fluid/operators/collective/c_allgather_op.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_allreduce_op.h"
...@@ -43,7 +43,6 @@ limitations under the License. */ ...@@ -43,7 +43,6 @@ limitations under the License. */
namespace f = paddle::framework; namespace f = paddle::framework;
namespace p = paddle::platform; namespace p = paddle::platform;
namespace m = paddle::operators::math;
USE_OP(c_allreduce_max); USE_OP(c_allreduce_max);
USE_NO_KERNEL_OP(c_gen_hccl_id); USE_NO_KERNEL_OP(c_gen_hccl_id);
......
...@@ -27,8 +27,8 @@ limitations under the License. */ ...@@ -27,8 +27,8 @@ limitations under the License. */
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/dropout_op.h" #include "paddle/fluid/operators/dropout_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/printf.h"
#include "paddle/pten/kernels/funcs/math_function.h"
#include "paddle/fluid/operators/collective/c_allreduce_op.h" #include "paddle/fluid/operators/collective/c_allreduce_op.h"
#include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h"
...@@ -45,7 +45,6 @@ limitations under the License. */ ...@@ -45,7 +45,6 @@ limitations under the License. */
namespace f = paddle::framework; namespace f = paddle::framework;
namespace p = paddle::platform; namespace p = paddle::platform;
namespace m = paddle::operators::math;
USE_OP(c_allreduce_sum); USE_OP(c_allreduce_sum);
USE_NO_KERNEL_OP(c_gen_hccl_id); USE_NO_KERNEL_OP(c_gen_hccl_id);
......
...@@ -27,8 +27,8 @@ limitations under the License. */ ...@@ -27,8 +27,8 @@ limitations under the License. */
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/dropout_op.h" #include "paddle/fluid/operators/dropout_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/printf.h"
#include "paddle/pten/kernels/funcs/math_function.h"
#include "paddle/fluid/operators/collective/c_broadcast_op.h" #include "paddle/fluid/operators/collective/c_broadcast_op.h"
#include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h"
...@@ -40,7 +40,6 @@ limitations under the License. */ ...@@ -40,7 +40,6 @@ limitations under the License. */
namespace f = paddle::framework; namespace f = paddle::framework;
namespace p = paddle::platform; namespace p = paddle::platform;
namespace m = paddle::operators::math;
USE_OP(c_broadcast); USE_OP(c_broadcast);
USE_NO_KERNEL_OP(c_gen_hccl_id); USE_NO_KERNEL_OP(c_gen_hccl_id);
......
...@@ -27,8 +27,8 @@ limitations under the License. */ ...@@ -27,8 +27,8 @@ limitations under the License. */
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/dropout_op.h" #include "paddle/fluid/operators/dropout_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/printf.h"
#include "paddle/pten/kernels/funcs/math_function.h"
#include "paddle/fluid/operators/collective/c_reduce_op.h" #include "paddle/fluid/operators/collective/c_reduce_op.h"
#include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h"
...@@ -40,7 +40,6 @@ limitations under the License. */ ...@@ -40,7 +40,6 @@ limitations under the License. */
namespace f = paddle::framework; namespace f = paddle::framework;
namespace p = paddle::platform; namespace p = paddle::platform;
namespace m = paddle::operators::math;
USE_OP(c_reduce_sum); USE_OP(c_reduce_sum);
USE_NO_KERNEL_OP(c_gen_hccl_id); USE_NO_KERNEL_OP(c_gen_hccl_id);
......
...@@ -27,8 +27,8 @@ limitations under the License. */ ...@@ -27,8 +27,8 @@ limitations under the License. */
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/dropout_op.h" #include "paddle/fluid/operators/dropout_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/printf.h"
#include "paddle/pten/kernels/funcs/math_function.h"
#include "paddle/fluid/operators/collective/c_allgather_op.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_allreduce_op.h"
...@@ -43,7 +43,6 @@ limitations under the License. */ ...@@ -43,7 +43,6 @@ limitations under the License. */
namespace f = paddle::framework; namespace f = paddle::framework;
namespace p = paddle::platform; namespace p = paddle::platform;
namespace m = paddle::operators::math;
USE_OP(c_reducescatter); USE_OP(c_reducescatter);
USE_NO_KERNEL_OP(c_gen_hccl_id); USE_NO_KERNEL_OP(c_gen_hccl_id);
......
...@@ -26,12 +26,11 @@ limitations under the License. */ ...@@ -26,12 +26,11 @@ limitations under the License. */
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/printf.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace f = paddle::framework; namespace f = paddle::framework;
namespace p = paddle::platform; namespace p = paddle::platform;
namespace m = paddle::operators::math;
USE_OP(elementwise_add); USE_OP(elementwise_add);
USE_OP_DEVICE_KERNEL(elementwise_add, NPU); USE_OP_DEVICE_KERNEL(elementwise_add, NPU);
......
...@@ -27,8 +27,8 @@ limitations under the License. */ ...@@ -27,8 +27,8 @@ limitations under the License. */
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/dropout_op.h" #include "paddle/fluid/operators/dropout_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/printf.h"
#include "paddle/pten/kernels/funcs/math_function.h"
#include "paddle/fluid/operators/collective/c_broadcast_op.h" #include "paddle/fluid/operators/collective/c_broadcast_op.h"
#include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h"
...@@ -40,7 +40,6 @@ limitations under the License. */ ...@@ -40,7 +40,6 @@ limitations under the License. */
namespace f = paddle::framework; namespace f = paddle::framework;
namespace p = paddle::platform; namespace p = paddle::platform;
namespace m = paddle::operators::math;
USE_OP(c_broadcast); USE_OP(c_broadcast);
USE_OP_DEVICE_KERNEL(c_sync_comm_stream, NPU); USE_OP_DEVICE_KERNEL(c_sync_comm_stream, NPU);
......
...@@ -28,8 +28,8 @@ limitations under the License. */ ...@@ -28,8 +28,8 @@ limitations under the License. */
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/dropout_op.h" #include "paddle/fluid/operators/dropout_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/printf.h"
#include "paddle/pten/kernels/funcs/math_function.h"
#include "paddle/fluid/operators/collective/c_allreduce_op.h" #include "paddle/fluid/operators/collective/c_allreduce_op.h"
#include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h"
...@@ -41,7 +41,6 @@ limitations under the License. */ ...@@ -41,7 +41,6 @@ limitations under the License. */
namespace f = paddle::framework; namespace f = paddle::framework;
namespace p = paddle::platform; namespace p = paddle::platform;
namespace m = paddle::operators::math;
USE_OP(c_allreduce_sum); USE_OP(c_allreduce_sum);
USE_OP_DEVICE_KERNEL(c_allreduce_sum, NPU); USE_OP_DEVICE_KERNEL(c_allreduce_sum, NPU);
......
...@@ -27,8 +27,8 @@ limitations under the License. */ ...@@ -27,8 +27,8 @@ limitations under the License. */
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/dropout_op.h" #include "paddle/fluid/operators/dropout_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/printf.h"
#include "paddle/pten/kernels/funcs/math_function.h"
#include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h"
#include "paddle/fluid/operators/collective/recv_v2_op.h" #include "paddle/fluid/operators/collective/recv_v2_op.h"
...@@ -40,7 +40,6 @@ limitations under the License. */ ...@@ -40,7 +40,6 @@ limitations under the License. */
namespace f = paddle::framework; namespace f = paddle::framework;
namespace p = paddle::platform; namespace p = paddle::platform;
namespace m = paddle::operators::math;
USE_OP(recv_v2); USE_OP(recv_v2);
USE_NO_KERNEL_OP(c_gen_hccl_id); USE_NO_KERNEL_OP(c_gen_hccl_id);
......
...@@ -26,8 +26,8 @@ limitations under the License. */ ...@@ -26,8 +26,8 @@ limitations under the License. */
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/dropout_op.h" #include "paddle/fluid/operators/dropout_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/string/printf.h" #include "paddle/fluid/string/printf.h"
#include "paddle/pten/kernels/funcs/math_function.h"
#include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h" #include "paddle/fluid/operators/collective/gen_hccl_id_op_helper.h"
#include "paddle/fluid/operators/collective/send_v2_op.h" #include "paddle/fluid/operators/collective/send_v2_op.h"
...@@ -39,7 +39,6 @@ limitations under the License. */ ...@@ -39,7 +39,6 @@ limitations under the License. */
namespace f = paddle::framework; namespace f = paddle::framework;
namespace p = paddle::platform; namespace p = paddle::platform;
namespace m = paddle::operators::math;
USE_OP(send_v2); USE_OP(send_v2);
USE_NO_KERNEL_OP(c_gen_hccl_id); USE_NO_KERNEL_OP(c_gen_hccl_id);
......
...@@ -15,7 +15,7 @@ limitations under the License. */ ...@@ -15,7 +15,7 @@ limitations under the License. */
#include "paddle/fluid/operators/controlflow/conditional_block_op.h" #include "paddle/fluid/operators/controlflow/conditional_block_op.h"
#include "paddle/fluid/operators/assign_op.h" #include "paddle/fluid/operators/assign_op.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -245,7 +245,7 @@ class ConditionalBlockGradOp : public ConditionalOp { ...@@ -245,7 +245,7 @@ class ConditionalBlockGradOp : public ConditionalOp {
outside_tensor->mutable_data(place, input_tensor.type()); outside_tensor->mutable_data(place, input_tensor.type());
const platform::DeviceContext *dev_ctx = const platform::DeviceContext *dev_ctx =
platform::DeviceContextPool::Instance().Get(place); platform::DeviceContextPool::Instance().Get(place);
math::set_constant(*dev_ctx, outside_tensor, 0.0f); pten::funcs::set_constant(*dev_ctx, outside_tensor, 0.0f);
outside_tensor->set_lod(input_tensor.lod()); outside_tensor->set_lod(input_tensor.lod());
} }
}; };
......
...@@ -861,7 +861,7 @@ class CUDNNConvDoubleGradOpKernel : public framework::OpKernel<T> { ...@@ -861,7 +861,7 @@ class CUDNNConvDoubleGradOpKernel : public framework::OpKernel<T> {
auto dX = ctx.Output<Tensor>("DInput"); auto dX = ctx.Output<Tensor>("DInput");
if (ddO) { if (ddO) {
ddO->mutable_data<T>(ctx.GetPlace()); ddO->mutable_data<T>(ctx.GetPlace());
math::SetConstant<platform::CUDADeviceContext, T> set_zero; pten::funcs::SetConstant<platform::CUDADeviceContext, T> set_zero;
set_zero(dev_ctx, ddO, static_cast<T>(0)); set_zero(dev_ctx, ddO, static_cast<T>(0));
} }
if (dW) { if (dW) {
......
...@@ -485,7 +485,7 @@ class GemmConvGradKernel : public framework::OpKernel<T> { ...@@ -485,7 +485,7 @@ class GemmConvGradKernel : public framework::OpKernel<T> {
col_matrix.Resize(col_matrix_shape); col_matrix.Resize(col_matrix_shape);
} }
math::SetConstant<DeviceContext, T> set_zero; pten::funcs::SetConstant<DeviceContext, T> set_zero;
auto blas = math::GetBlas<DeviceContext, T>(dev_ctx); auto blas = math::GetBlas<DeviceContext, T>(dev_ctx);
if (input_grad) { if (input_grad) {
...@@ -692,7 +692,7 @@ class GemmConvDoubleGradKernel : public framework::OpKernel<T> { ...@@ -692,7 +692,7 @@ class GemmConvDoubleGradKernel : public framework::OpKernel<T> {
col_matrix.Resize(col_matrix_shape); col_matrix.Resize(col_matrix_shape);
} }
math::SetConstant<DeviceContext, T> set_zero; pten::funcs::SetConstant<DeviceContext, T> set_zero;
auto blas = math::GetBlas<DeviceContext, T>(dev_ctx); auto blas = math::GetBlas<DeviceContext, T>(dev_ctx);
// dx convolution double grad: gemm + col2im(col2vol) // dx convolution double grad: gemm + col2im(col2vol)
...@@ -991,7 +991,7 @@ class DepthwiseConvGradKernel : public framework::OpKernel<T> { ...@@ -991,7 +991,7 @@ class DepthwiseConvGradKernel : public framework::OpKernel<T> {
paddings.erase(paddings.begin() + i + 1); paddings.erase(paddings.begin() + i + 1);
} }
} }
math::SetConstant<DeviceContext, T> set_zero; pten::funcs::SetConstant<DeviceContext, T> set_zero;
auto& dev_ctx = context.template device_context<DeviceContext>(); auto& dev_ctx = context.template device_context<DeviceContext>();
if (input_grad) { if (input_grad) {
......
...@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and ...@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#include "paddle/fluid/operators/conv_shift_op.h" #include "paddle/fluid/operators/conv_shift_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/device/gpu/gpu_primitives.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -163,7 +163,7 @@ class ConvShiftGradKernel<platform::CUDADeviceContext, T> ...@@ -163,7 +163,7 @@ class ConvShiftGradKernel<platform::CUDADeviceContext, T>
auto &device_ctx = auto &device_ctx =
context.template device_context<platform::CUDADeviceContext>(); context.template device_context<platform::CUDADeviceContext>();
math::SetConstant<platform::CUDADeviceContext, T> zero; pten::funcs::SetConstant<platform::CUDADeviceContext, T> zero;
const int x_per_block = 256; const int x_per_block = 256;
int num_x_blocks = DivUp(x_width, x_per_block); int num_x_blocks = DivUp(x_width, x_per_block);
......
...@@ -21,8 +21,8 @@ limitations under the License. */ ...@@ -21,8 +21,8 @@ limitations under the License. */
#include "paddle/fluid/operators/conv_cudnn_helper.h" #include "paddle/fluid/operators/conv_cudnn_helper.h"
#endif #endif
#include "paddle/fluid/operators/conv_transpose_op.h" #include "paddle/fluid/operators/conv_transpose_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/operators/math/padding.h" #include "paddle/fluid/operators/math/padding.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -34,7 +34,7 @@ static void DataTranspose(const framework::ExecutionContext& ctx, ...@@ -34,7 +34,7 @@ static void DataTranspose(const framework::ExecutionContext& ctx,
const Tensor* input, Tensor* output, const Tensor* input, Tensor* output,
const std::vector<int>& axis, int flag = 0) { const std::vector<int>& axis, int flag = 0) {
auto& dev_ctx = ctx.template device_context<platform::CUDADeviceContext>(); auto& dev_ctx = ctx.template device_context<platform::CUDADeviceContext>();
math::Transpose<platform::CUDADeviceContext, T, D> transpose; pten::funcs::Transpose<platform::CUDADeviceContext, T, D> transpose;
auto in_dims = input->dims(); auto in_dims = input->dims();
std::vector<int64_t> input_transpose_vec; std::vector<int64_t> input_transpose_vec;
for (size_t i = 0; i < axis.size(); ++i) { for (size_t i = 0; i < axis.size(); ++i) {
...@@ -650,7 +650,7 @@ class CUDNNConvTransposeDoubleGradOpKernel : public framework::OpKernel<T> { ...@@ -650,7 +650,7 @@ class CUDNNConvTransposeDoubleGradOpKernel : public framework::OpKernel<T> {
if (ddO) { if (ddO) {
ddO->mutable_data<T>(ctx.GetPlace()); ddO->mutable_data<T>(ctx.GetPlace());
math::SetConstant<platform::CUDADeviceContext, T> set_zero; pten::funcs::SetConstant<platform::CUDADeviceContext, T> set_zero;
set_zero(dev_ctx, ddO, static_cast<T>(0)); set_zero(dev_ctx, ddO, static_cast<T>(0));
} }
if (dW) { if (dW) {
......
...@@ -226,7 +226,7 @@ class GemmConvTransposeKernel : public framework::OpKernel<T> { ...@@ -226,7 +226,7 @@ class GemmConvTransposeKernel : public framework::OpKernel<T> {
filter.Resize(filter_matrix_shape); filter.Resize(filter_matrix_shape);
output->mutable_data<T>(context.GetPlace()); output->mutable_data<T>(context.GetPlace());
math::SetConstant<DeviceContext, T> set_zero; pten::funcs::SetConstant<DeviceContext, T> set_zero;
auto& dev_ctx = context.template device_context<DeviceContext>(); auto& dev_ctx = context.template device_context<DeviceContext>();
auto blas = math::GetBlas<DeviceContext, T>(dev_ctx); auto blas = math::GetBlas<DeviceContext, T>(dev_ctx);
set_zero(dev_ctx, output, static_cast<T>(0)); set_zero(dev_ctx, output, static_cast<T>(0));
...@@ -437,7 +437,7 @@ class GemmConvTransposeGradKernel : public framework::OpKernel<T> { ...@@ -437,7 +437,7 @@ class GemmConvTransposeGradKernel : public framework::OpKernel<T> {
col_matrix.Resize(col_matrix_shape); col_matrix.Resize(col_matrix_shape);
Tensor filter_grad_; Tensor filter_grad_;
math::SetConstant<DeviceContext, T> set_zero; pten::funcs::SetConstant<DeviceContext, T> set_zero;
math::Im2ColFunctor<math::ColFormat::kCFO, DeviceContext, T> im2col; math::Im2ColFunctor<math::ColFormat::kCFO, DeviceContext, T> im2col;
math::Vol2ColFunctor<DeviceContext, T> vol2col; math::Vol2ColFunctor<DeviceContext, T> vol2col;
...@@ -628,7 +628,7 @@ class DepthwiseConvTransposeKernel : public framework::OpKernel<T> { ...@@ -628,7 +628,7 @@ class DepthwiseConvTransposeKernel : public framework::OpKernel<T> {
output->mutable_data<T>(context.GetPlace()); output->mutable_data<T>(context.GetPlace());
auto& dev_ctx = context.template device_context<DeviceContext>(); auto& dev_ctx = context.template device_context<DeviceContext>();
math::SetConstant<DeviceContext, T> set_zero; pten::funcs::SetConstant<DeviceContext, T> set_zero;
set_zero(dev_ctx, output, static_cast<T>(0)); set_zero(dev_ctx, output, static_cast<T>(0));
math::DepthwiseConvInputGradFunctor<DeviceContext, T> math::DepthwiseConvInputGradFunctor<DeviceContext, T>
...@@ -690,7 +690,7 @@ class DepthwiseConvTransposeGradKernel : public framework::OpKernel<T> { ...@@ -690,7 +690,7 @@ class DepthwiseConvTransposeGradKernel : public framework::OpKernel<T> {
} }
if (filter_grad) { if (filter_grad) {
math::SetConstant<DeviceContext, T> set_zero; pten::funcs::SetConstant<DeviceContext, T> set_zero;
filter_grad->mutable_data<T>(context.GetPlace()); filter_grad->mutable_data<T>(context.GetPlace());
set_zero(dev_ctx, filter_grad, static_cast<T>(0)); set_zero(dev_ctx, filter_grad, static_cast<T>(0));
......
...@@ -15,8 +15,8 @@ limitations under the License. */ ...@@ -15,8 +15,8 @@ limitations under the License. */
#pragma once #pragma once
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/cos_sim_functor.h" #include "paddle/fluid/operators/math/cos_sim_functor.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/for_range.h" #include "paddle/fluid/platform/for_range.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -121,7 +121,7 @@ class CosSimGradKernel : public framework::OpKernel<T> { ...@@ -121,7 +121,7 @@ class CosSimGradKernel : public framework::OpKernel<T> {
if (out_grad_y) { if (out_grad_y) {
out_grad_y->Resize(in_y->dims()); out_grad_y->Resize(in_y->dims());
out_grad_y->mutable_data<T>(context.GetPlace()); out_grad_y->mutable_data<T>(context.GetPlace());
math::SetConstant<DeviceContext, T> set_zero; pten::funcs::SetConstant<DeviceContext, T> set_zero;
auto& dev_ctx = context.template device_context<DeviceContext>(); auto& dev_ctx = context.template device_context<DeviceContext>();
set_zero(dev_ctx, out_grad_y, static_cast<T>(0)); set_zero(dev_ctx, out_grad_y, static_cast<T>(0));
......
...@@ -17,7 +17,7 @@ limitations under the License. */ ...@@ -17,7 +17,7 @@ limitations under the License. */
#include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/eigen.h"
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/jit/kernels.h" #include "paddle/fluid/operators/jit/kernels.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -36,7 +36,7 @@ class CRFDecodingOpKernel : public framework::OpKernel<T> { ...@@ -36,7 +36,7 @@ class CRFDecodingOpKernel : public framework::OpKernel<T> {
auto* decoded_path = ctx.Output<Tensor>("ViterbiPath"); auto* decoded_path = ctx.Output<Tensor>("ViterbiPath");
int64_t* path = decoded_path->mutable_data<int64_t>(platform::CPUPlace()); int64_t* path = decoded_path->mutable_data<int64_t>(platform::CPUPlace());
math::SetConstant<DeviceContext, int64_t>()( pten::funcs::SetConstant<DeviceContext, int64_t>()(
ctx.template device_context<DeviceContext>(), decoded_path, 0); ctx.template device_context<DeviceContext>(), decoded_path, 0);
bool has_length = ctx.HasInput("Length"); bool has_length = ctx.HasInput("Length");
......
...@@ -17,8 +17,8 @@ limitations under the License. */ ...@@ -17,8 +17,8 @@ limitations under the License. */
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math.h" #include "paddle/fluid/operators/math.h"
#include "paddle/fluid/operators/math/cross_entropy.h" #include "paddle/fluid/operators/math/cross_entropy.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/for_range.h" #include "paddle/fluid/platform/for_range.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -128,7 +128,7 @@ class CTCAlignOpCUDAKernel : public framework::OpKernel<T> { ...@@ -128,7 +128,7 @@ class CTCAlignOpCUDAKernel : public framework::OpKernel<T> {
if (host_out_lod0.back() == 0) { if (host_out_lod0.back() == 0) {
output->Resize({1, 1}); output->Resize({1, 1});
output->mutable_data<T>(ctx.GetPlace()); output->mutable_data<T>(ctx.GetPlace());
math::SetConstant<platform::CUDADeviceContext, T> set_constant; pten::funcs::SetConstant<platform::CUDADeviceContext, T> set_constant;
set_constant(ctx.template device_context<platform::CUDADeviceContext>(), set_constant(ctx.template device_context<platform::CUDADeviceContext>(),
output, -1); output, -1);
} }
......
...@@ -17,7 +17,7 @@ limitations under the License. */ ...@@ -17,7 +17,7 @@ limitations under the License. */
#include <string.h> #include <string.h>
#include <vector> #include <vector>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -14,8 +14,8 @@ limitations under the License. */ ...@@ -14,8 +14,8 @@ limitations under the License. */
#include "paddle/fluid/framework/generator.h" #include "paddle/fluid/framework/generator.h"
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/operators/utils.h" #include "paddle/fluid/operators/utils.h"
#include "paddle/pten/kernels/funcs/math_function.h"
#ifdef PADDLE_WITH_CUDA #ifdef PADDLE_WITH_CUDA
#include "paddle/fluid/operators/cudnn_lstm_cache.h" #include "paddle/fluid/operators/cudnn_lstm_cache.h"
#endif #endif
...@@ -366,7 +366,7 @@ class CudnnLSTMGPUGradKernel : public framework::OpKernel<T> { ...@@ -366,7 +366,7 @@ class CudnnLSTMGPUGradKernel : public framework::OpKernel<T> {
} }
Tensor weight_grad; Tensor weight_grad;
math::SetConstant<paddle::platform::CUDADeviceContext, T> zero; pten::funcs::SetConstant<paddle::platform::CUDADeviceContext, T> zero;
weight_grad.mutable_data<T>({weight_numel}, ctx.GetPlace()); weight_grad.mutable_data<T>({weight_numel}, ctx.GetPlace());
zero(dev_ctx, &weight_grad, static_cast<T>(0.0)); zero(dev_ctx, &weight_grad, static_cast<T>(0.0));
T *weight_grad_data = weight_grad.data<T>(); T *weight_grad_data = weight_grad.data<T>();
......
...@@ -14,7 +14,7 @@ limitations under the License. */ ...@@ -14,7 +14,7 @@ limitations under the License. */
#include "paddle/fluid/operators/cvm_op.h" #include "paddle/fluid/operators/cvm_op.h"
#include <memory> #include <memory>
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#pragma once #pragma once
#include "paddle/fluid/operators/math/blas.h" #include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
template <typename T> template <typename T>
__global__ void FilterGradAddupCUDAKernel(const int nthreads, const int n, __global__ void FilterGradAddupCUDAKernel(const int nthreads, const int n,
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
#pragma once #pragma once
#include "paddle/fluid/operators/math/blas.h" #include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/pten/core/hostdevice.h" #include "paddle/pten/core/hostdevice.h"
#include "paddle/pten/kernels/funcs/math_function.h"
template <typename T> template <typename T>
HOSTDEVICE T DmcnGetGradientWeight(T argmax_h, T argmax_w, const int h, HOSTDEVICE T DmcnGetGradientWeight(T argmax_h, T argmax_w, const int h,
......
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/deformable_conv_op.h" #include "paddle/fluid/operators/deformable_conv_op.h"
#include "paddle/fluid/operators/math/blas.h" #include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/device/gpu/gpu_primitives.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -623,7 +623,7 @@ class DeformableConvGradCUDAKernel : public framework::OpKernel<T> { ...@@ -623,7 +623,7 @@ class DeformableConvGradCUDAKernel : public framework::OpKernel<T> {
Tensor col_buffer_3d; Tensor col_buffer_3d;
col_buffer_3d.ShareDataWith(col_buffer).Resize(col_buffer_3d_shape); col_buffer_3d.ShareDataWith(col_buffer).Resize(col_buffer_3d_shape);
math::SetConstant<DeviceContext, T> set_zero; pten::funcs::SetConstant<DeviceContext, T> set_zero;
auto blas = math::GetBlas<DeviceContext, T>(dev_ctx); auto blas = math::GetBlas<DeviceContext, T>(dev_ctx);
col_buffer.mutable_data<T>(ctx.GetPlace()); col_buffer.mutable_data<T>(ctx.GetPlace());
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/deformable_conv_func.h" #include "paddle/fluid/operators/deformable_conv_func.h"
#include "paddle/fluid/operators/math/blas.h" #include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -489,7 +489,7 @@ class DeformableConvGradCPUKernel : public framework::OpKernel<T> { ...@@ -489,7 +489,7 @@ class DeformableConvGradCPUKernel : public framework::OpKernel<T> {
Tensor col_buffer_3d; Tensor col_buffer_3d;
col_buffer_3d.ShareDataWith(col_buffer).Resize(col_buffer_3d_shape); col_buffer_3d.ShareDataWith(col_buffer).Resize(col_buffer_3d_shape);
math::SetConstant<CPUDeviceContext, T> set_zero; pten::funcs::SetConstant<CPUDeviceContext, T> set_zero;
auto blas = math::GetBlas<CPUDeviceContext, T>(dev_ctx); auto blas = math::GetBlas<CPUDeviceContext, T>(dev_ctx);
col_buffer.mutable_data<T>(ctx.GetPlace()); col_buffer.mutable_data<T>(ctx.GetPlace());
......
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
#include "paddle/fluid/operators/deformable_conv_func.h" #include "paddle/fluid/operators/deformable_conv_func.h"
#include "paddle/fluid/operators/deformable_conv_v1_op.h" #include "paddle/fluid/operators/deformable_conv_v1_op.h"
#include "paddle/fluid/operators/math/blas.h" #include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/device/gpu/gpu_primitives.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -489,7 +489,7 @@ class DeformableConvV1GradCUDAKernel : public framework::OpKernel<T> { ...@@ -489,7 +489,7 @@ class DeformableConvV1GradCUDAKernel : public framework::OpKernel<T> {
Tensor col_buffer_3d; Tensor col_buffer_3d;
col_buffer_3d.ShareDataWith(col_buffer).Resize(col_buffer_3d_shape); col_buffer_3d.ShareDataWith(col_buffer).Resize(col_buffer_3d_shape);
math::SetConstant<CUDADeviceContext, T> set_zero; pten::funcs::SetConstant<CUDADeviceContext, T> set_zero;
auto blas = math::GetBlas<CUDADeviceContext, T>(dev_ctx); auto blas = math::GetBlas<CUDADeviceContext, T>(dev_ctx);
col_buffer.mutable_data<T>(ctx.GetPlace()); col_buffer.mutable_data<T>(ctx.GetPlace());
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "paddle/fluid/operators/deformable_conv_func.h" #include "paddle/fluid/operators/deformable_conv_func.h"
#include "paddle/fluid/operators/deformable_conv_op.h" #include "paddle/fluid/operators/deformable_conv_op.h"
#include "paddle/fluid/operators/math/blas.h" #include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -451,7 +451,7 @@ class DeformableConvV1GradCPUKernel : public framework::OpKernel<T> { ...@@ -451,7 +451,7 @@ class DeformableConvV1GradCPUKernel : public framework::OpKernel<T> {
Tensor col_buffer_3d; Tensor col_buffer_3d;
col_buffer_3d.ShareDataWith(col_buffer).Resize(col_buffer_3d_shape); col_buffer_3d.ShareDataWith(col_buffer).Resize(col_buffer_3d_shape);
math::SetConstant<CPUDeviceContext, T> set_zero; pten::funcs::SetConstant<CPUDeviceContext, T> set_zero;
auto blas = math::GetBlas<CPUDeviceContext, T>(dev_ctx); auto blas = math::GetBlas<CPUDeviceContext, T>(dev_ctx);
col_buffer.mutable_data<T>(ctx.GetPlace()); col_buffer.mutable_data<T>(ctx.GetPlace());
......
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
#include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/memory/malloc.h"
#include "paddle/fluid/operators/deformable_psroi_pooling_op.h" #include "paddle/fluid/operators/deformable_psroi_pooling_op.h"
#include "paddle/fluid/operators/math/blas.h" #include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/device/gpu/gpu_primitives.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -436,7 +436,7 @@ class DeformablePSROIPoolGradCUDAKernel : public framework::OpKernel<T> { ...@@ -436,7 +436,7 @@ class DeformablePSROIPoolGradCUDAKernel : public framework::OpKernel<T> {
Tensor* input_grad = ctx.Output<Tensor>(framework::GradVarName("Input")); Tensor* input_grad = ctx.Output<Tensor>(framework::GradVarName("Input"));
Tensor* trans_grad = ctx.Output<Tensor>(framework::GradVarName("Trans")); Tensor* trans_grad = ctx.Output<Tensor>(framework::GradVarName("Trans"));
math::SetConstant<DeviceContext, T> set_zero; pten::funcs::SetConstant<DeviceContext, T> set_zero;
auto& dev_ctx = ctx.cuda_device_context(); auto& dev_ctx = ctx.cuda_device_context();
if (input_grad) { if (input_grad) {
input_grad->mutable_data<T>(ctx.GetPlace()); input_grad->mutable_data<T>(ctx.GetPlace());
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <vector> #include <vector>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/blas.h" #include "paddle/fluid/operators/math/blas.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -165,7 +165,7 @@ class DeformablePSROIPoolCPUKernel : public framework::OpKernel<T> { ...@@ -165,7 +165,7 @@ class DeformablePSROIPoolCPUKernel : public framework::OpKernel<T> {
auto* top_count = ctx.Output<Tensor>("TopCount"); auto* top_count = ctx.Output<Tensor>("TopCount");
top_count->mutable_data<T>(ctx.GetPlace()); top_count->mutable_data<T>(ctx.GetPlace());
math::SetConstant<DeviceContext, T> set_zero; pten::funcs::SetConstant<DeviceContext, T> set_zero;
auto& dev_ctx = ctx.template device_context<DeviceContext>(); auto& dev_ctx = ctx.template device_context<DeviceContext>();
set_zero(dev_ctx, out, static_cast<T>(0)); set_zero(dev_ctx, out, static_cast<T>(0));
set_zero(dev_ctx, top_count, static_cast<T>(0)); set_zero(dev_ctx, top_count, static_cast<T>(0));
...@@ -421,7 +421,7 @@ class DeformablePSROIPoolGradCPUKernel : public framework::OpKernel<T> { ...@@ -421,7 +421,7 @@ class DeformablePSROIPoolGradCPUKernel : public framework::OpKernel<T> {
auto* top_count = ctx.Input<Tensor>("TopCount"); auto* top_count = ctx.Input<Tensor>("TopCount");
auto* output_grad = ctx.Input<Tensor>(framework::GradVarName("Output")); auto* output_grad = ctx.Input<Tensor>(framework::GradVarName("Output"));
auto* input_grad = ctx.Output<Tensor>(framework::GradVarName("Input")); auto* input_grad = ctx.Output<Tensor>(framework::GradVarName("Input"));
math::SetConstant<DeviceContext, T> set_zero; pten::funcs::SetConstant<DeviceContext, T> set_zero;
auto& dev_ctx = ctx.template device_context<DeviceContext>(); auto& dev_ctx = ctx.template device_context<DeviceContext>();
if (input_grad) { if (input_grad) {
input_grad->mutable_data<T>(ctx.GetPlace()); input_grad->mutable_data<T>(ctx.GetPlace());
......
...@@ -16,8 +16,8 @@ limitations under the License. */ ...@@ -16,8 +16,8 @@ limitations under the License. */
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/transform.h" #include "paddle/fluid/platform/transform.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -24,9 +24,9 @@ limitations under the License. */ ...@@ -24,9 +24,9 @@ limitations under the License. */
namespace cub = hipcub; namespace cub = hipcub;
#endif #endif
#include "paddle/fluid/operators/gather.cu.h" #include "paddle/fluid/operators/gather.cu.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/device/gpu/gpu_dnn.h" #include "paddle/fluid/platform/device/gpu/gpu_dnn.h"
#include "paddle/fluid/platform/for_range.h" #include "paddle/fluid/platform/for_range.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and ...@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -205,9 +205,9 @@ class BipartiteMatchKernel : public framework::OpKernel<T> { ...@@ -205,9 +205,9 @@ class BipartiteMatchKernel : public framework::OpKernel<T> {
match_indices->mutable_data<int>({n, col}, context.GetPlace()); match_indices->mutable_data<int>({n, col}, context.GetPlace());
match_dist->mutable_data<T>({n, col}, context.GetPlace()); match_dist->mutable_data<T>({n, col}, context.GetPlace());
math::SetConstant<platform::CPUDeviceContext, int> iset; pten::funcs::SetConstant<platform::CPUDeviceContext, int> iset;
iset(dev_ctx, match_indices, static_cast<int>(-1)); iset(dev_ctx, match_indices, static_cast<int>(-1));
math::SetConstant<platform::CPUDeviceContext, T> tset; pten::funcs::SetConstant<platform::CPUDeviceContext, T> tset;
tset(dev_ctx, match_dist, static_cast<T>(0)); tset(dev_ctx, match_dist, static_cast<T>(0));
int* indices = match_indices->data<int>(); int* indices = match_indices->data<int>();
......
...@@ -14,9 +14,9 @@ limitations under the License. */ ...@@ -14,9 +14,9 @@ limitations under the License. */
#include <algorithm> #include <algorithm>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/detection/box_clip_op.h" #include "paddle/fluid/operators/detection/box_clip_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/device/gpu/gpu_primitives.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h"
#include "paddle/pten/core/hostdevice.h" #include "paddle/pten/core/hostdevice.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -13,7 +13,7 @@ limitations under the License. */ ...@@ -13,7 +13,7 @@ limitations under the License. */
#include <string> #include <string>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/detection/bbox_util.h" #include "paddle/fluid/operators/detection/bbox_util.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -13,7 +13,7 @@ limitations under the License. */ ...@@ -13,7 +13,7 @@ limitations under the License. */
#include <string> #include <string>
#include <vector> #include <vector>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -14,7 +14,7 @@ limitations under the License. */ ...@@ -14,7 +14,7 @@ limitations under the License. */
#include <string> #include <string>
#include <vector> #include <vector>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -195,7 +195,7 @@ class GPUCollectFpnProposalsOpKernel : public framework::OpKernel<T> { ...@@ -195,7 +195,7 @@ class GPUCollectFpnProposalsOpKernel : public framework::OpKernel<T> {
Tensor length_lod; Tensor length_lod;
int* length_lod_data = int* length_lod_data =
length_lod.mutable_data<int>({lod_size}, dev_ctx.GetPlace()); length_lod.mutable_data<int>({lod_size}, dev_ctx.GetPlace());
math::SetConstant<platform::CUDADeviceContext, int> set_zero; pten::funcs::SetConstant<platform::CUDADeviceContext, int> set_zero;
set_zero(dev_ctx, &length_lod, static_cast<int>(0)); set_zero(dev_ctx, &length_lod, static_cast<int>(0));
int blocks = NumBlocks(real_post_num); int blocks = NumBlocks(real_post_num);
......
...@@ -22,7 +22,7 @@ limitations under the License.*/ ...@@ -22,7 +22,7 @@ limitations under the License.*/
#include <vector> #include <vector>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/gather.h" #include "paddle/fluid/operators/gather.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -25,9 +25,9 @@ namespace cub = hipcub; ...@@ -25,9 +25,9 @@ namespace cub = hipcub;
#include "paddle/fluid/operators/detection/bbox_util.h" #include "paddle/fluid/operators/detection/bbox_util.h"
#include "paddle/fluid/operators/detection/distribute_fpn_proposals_op.h" #include "paddle/fluid/operators/detection/distribute_fpn_proposals_op.h"
#include "paddle/fluid/operators/gather.cu.h" #include "paddle/fluid/operators/gather.cu.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/device/gpu/gpu_primitives.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h"
#include "paddle/fluid/platform/for_range.h" #include "paddle/fluid/platform/for_range.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -121,7 +121,7 @@ class GPUDistributeFpnProposalsOpKernel : public framework::OpKernel<T> { ...@@ -121,7 +121,7 @@ class GPUDistributeFpnProposalsOpKernel : public framework::OpKernel<T> {
Tensor sub_lod_list; Tensor sub_lod_list;
sub_lod_list.Resize({num_level, lod_size}); sub_lod_list.Resize({num_level, lod_size});
int* sub_lod_list_data = sub_lod_list.mutable_data<int>(dev_ctx.GetPlace()); int* sub_lod_list_data = sub_lod_list.mutable_data<int>(dev_ctx.GetPlace());
math::SetConstant<platform::CUDADeviceContext, int> set_zero; pten::funcs::SetConstant<platform::CUDADeviceContext, int> set_zero;
set_zero(dev_ctx, &sub_lod_list, static_cast<int>(0)); set_zero(dev_ctx, &sub_lod_list, static_cast<int>(0));
Tensor target_lvls; Tensor target_lvls;
......
...@@ -21,7 +21,7 @@ limitations under the License. */ ...@@ -21,7 +21,7 @@ limitations under the License. */
#include <vector> #include <vector>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/gather.h" #include "paddle/fluid/operators/gather.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -19,7 +19,7 @@ limitations under the License. */ ...@@ -19,7 +19,7 @@ limitations under the License. */
#include "paddle/fluid/operators/detection/mask_util.h" #include "paddle/fluid/operators/detection/mask_util.h"
#include "paddle/fluid/operators/gather.h" #include "paddle/fluid/operators/gather.h"
#include "paddle/fluid/operators/math/concat_and_split.h" #include "paddle/fluid/operators/math/concat_and_split.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -122,7 +122,7 @@ static inline void ExpandMaskTarget(const platform::CPUDeviceContext& ctx, ...@@ -122,7 +122,7 @@ static inline void ExpandMaskTarget(const platform::CPUDeviceContext& ctx,
int* mask_targets_data = int* mask_targets_data =
mask_targets->mutable_data<int>({num_mask, mask_dim}, ctx.GetPlace()); mask_targets->mutable_data<int>({num_mask, mask_dim}, ctx.GetPlace());
math::set_constant(ctx, mask_targets, -1); pten::funcs::set_constant(ctx, mask_targets, -1);
for (int64_t mask_id = 0; mask_id < num_mask; ++mask_id) { for (int64_t mask_id = 0; mask_id < num_mask; ++mask_id) {
int cls = mask_class_labels_data[mask_id]; int cls = mask_class_labels_data[mask_id];
int start = M * cls; int start = M * cls;
...@@ -271,7 +271,7 @@ std::vector<Tensor> SampleMaskForOneImage( ...@@ -271,7 +271,7 @@ std::vector<Tensor> SampleMaskForOneImage(
} }
masks.mutable_data<uint8_t>({bg_num, resolution * resolution}, masks.mutable_data<uint8_t>({bg_num, resolution * resolution},
ctx.GetPlace()); ctx.GetPlace());
math::set_constant(ctx, &masks, -1); pten::funcs::set_constant(ctx, &masks, -1);
int* mask_class_labels_data = int* mask_class_labels_data =
mask_class_labels.mutable_data<int>({bg_num, 1}, ctx.GetPlace()); mask_class_labels.mutable_data<int>({bg_num, 1}, ctx.GetPlace());
mask_class_labels_data[0] = 0; mask_class_labels_data[0] = 0;
......
...@@ -18,7 +18,7 @@ limitations under the License. */ ...@@ -18,7 +18,7 @@ limitations under the License. */
#include "paddle/fluid/operators/detection/bbox_util.h" #include "paddle/fluid/operators/detection/bbox_util.h"
#include "paddle/fluid/operators/gather.h" #include "paddle/fluid/operators/gather.h"
#include "paddle/fluid/operators/math/concat_and_split.h" #include "paddle/fluid/operators/math/concat_and_split.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -289,7 +289,7 @@ void GatherBoxesLabels(const platform::CPUDeviceContext& context, ...@@ -289,7 +289,7 @@ void GatherBoxesLabels(const platform::CPUDeviceContext& context,
fg_labels.mutable_data<int>({fg_num}, context.GetPlace()); fg_labels.mutable_data<int>({fg_num}, context.GetPlace());
CPUGather<int>(context, gt_classes, gt_label_inds_t, &fg_labels); CPUGather<int>(context, gt_classes, gt_label_inds_t, &fg_labels);
bg_labels.mutable_data<int>({bg_num}, context.GetPlace()); bg_labels.mutable_data<int>({bg_num}, context.GetPlace());
math::set_constant(context, &bg_labels, 0); pten::funcs::set_constant(context, &bg_labels, 0);
Concat<int>(context, fg_labels, bg_labels, sampled_labels); Concat<int>(context, fg_labels, bg_labels, sampled_labels);
Tensor fg_max_overlap, bg_max_overlap; Tensor fg_max_overlap, bg_max_overlap;
...@@ -328,7 +328,7 @@ std::vector<Tensor> SampleRoisForOneImage( ...@@ -328,7 +328,7 @@ std::vector<Tensor> SampleRoisForOneImage(
Tensor roi_filter; Tensor roi_filter;
// Tensor box_filter; // Tensor box_filter;
if (keep.numel() == 0) { if (keep.numel() == 0) {
math::SetConstant<platform::CPUDeviceContext, T> set_zero; pten::funcs::SetConstant<platform::CPUDeviceContext, T> set_zero;
roi_filter.mutable_data<T>({proposals_num, kBoxDim}, context.GetPlace()); roi_filter.mutable_data<T>({proposals_num, kBoxDim}, context.GetPlace());
set_zero(context, &roi_filter, static_cast<T>(0)); set_zero(context, &roi_filter, static_cast<T>(0));
} else { } else {
...@@ -403,9 +403,9 @@ std::vector<Tensor> SampleRoisForOneImage( ...@@ -403,9 +403,9 @@ std::vector<Tensor> SampleRoisForOneImage(
bbox_targets.mutable_data<T>(bbox_expand_dim, context.GetPlace()); bbox_targets.mutable_data<T>(bbox_expand_dim, context.GetPlace());
bbox_inside_weights.mutable_data<T>(bbox_expand_dim, context.GetPlace()); bbox_inside_weights.mutable_data<T>(bbox_expand_dim, context.GetPlace());
bbox_outside_weights.mutable_data<T>(bbox_expand_dim, context.GetPlace()); bbox_outside_weights.mutable_data<T>(bbox_expand_dim, context.GetPlace());
math::set_constant(context, &bbox_targets, 0.0); pten::funcs::set_constant(context, &bbox_targets, 0.0);
math::set_constant(context, &bbox_inside_weights, 0.0); pten::funcs::set_constant(context, &bbox_inside_weights, 0.0);
math::set_constant(context, &bbox_outside_weights, 0.0); pten::funcs::set_constant(context, &bbox_outside_weights, 0.0);
auto* bbox_targets_single_data = bbox_targets_single.data<T>(); auto* bbox_targets_single_data = bbox_targets_single.data<T>();
auto* sampled_labels_data = sampled_labels.data<int>(); auto* sampled_labels_data = sampled_labels.data<int>();
......
...@@ -21,7 +21,7 @@ limitations under the License. */ ...@@ -21,7 +21,7 @@ limitations under the License. */
#include "paddle/fluid/operators/detection/bbox_util.h" #include "paddle/fluid/operators/detection/bbox_util.h"
#include "paddle/fluid/operators/detection/nms_util.h" #include "paddle/fluid/operators/detection/nms_util.h"
#include "paddle/fluid/operators/gather.h" #include "paddle/fluid/operators/gather.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -112,7 +112,7 @@ class GenerateProposalsKernel : public framework::OpKernel<T> { ...@@ -112,7 +112,7 @@ class GenerateProposalsKernel : public framework::OpKernel<T> {
scores_swap.mutable_data<T>({num, h_score, w_score, c_score}, scores_swap.mutable_data<T>({num, h_score, w_score, c_score},
dev_ctx.GetPlace()); dev_ctx.GetPlace());
math::Transpose<platform::CPUDeviceContext, T, 4> trans; pten::funcs::Transpose<platform::CPUDeviceContext, T, 4> trans;
std::vector<int> axis = {0, 2, 3, 1}; std::vector<int> axis = {0, 2, 3, 1};
trans(dev_ctx, *bbox_deltas, &bbox_deltas_swap, axis); trans(dev_ctx, *bbox_deltas, &bbox_deltas_swap, axis);
trans(dev_ctx, *scores, &scores_swap, axis); trans(dev_ctx, *scores, &scores_swap, axis);
...@@ -211,7 +211,7 @@ class GenerateProposalsKernel : public framework::OpKernel<T> { ...@@ -211,7 +211,7 @@ class GenerateProposalsKernel : public framework::OpKernel<T> {
FilterBoxes<T>(ctx, &proposals, min_size, im_info_slice, true, &keep); FilterBoxes<T>(ctx, &proposals, min_size, im_info_slice, true, &keep);
// Handle the case when there is no keep index left // Handle the case when there is no keep index left
if (keep.numel() == 0) { if (keep.numel() == 0) {
math::SetConstant<platform::CPUDeviceContext, T> set_zero; pten::funcs::SetConstant<platform::CPUDeviceContext, T> set_zero;
bbox_sel.mutable_data<T>({1, 4}, ctx.GetPlace()); bbox_sel.mutable_data<T>({1, 4}, ctx.GetPlace());
set_zero(ctx, &bbox_sel, static_cast<T>(0)); set_zero(ctx, &bbox_sel, static_cast<T>(0));
Tensor scores_filter; Tensor scores_filter;
......
...@@ -20,7 +20,7 @@ limitations under the License. */ ...@@ -20,7 +20,7 @@ limitations under the License. */
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/memory/memory.h" #include "paddle/fluid/memory/memory.h"
#include "paddle/fluid/operators/detection/bbox_util.cu.h" #include "paddle/fluid/operators/detection/bbox_util.cu.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -76,7 +76,7 @@ static std::pair<Tensor, Tensor> ProposalForOneImage( ...@@ -76,7 +76,7 @@ static std::pair<Tensor, Tensor> ProposalForOneImage(
Tensor scores_filter, proposals_filter; Tensor scores_filter, proposals_filter;
// Handle the case when there is no keep index left // Handle the case when there is no keep index left
if (keep_num == 0) { if (keep_num == 0) {
math::SetConstant<platform::CUDADeviceContext, T> set_zero; pten::funcs::SetConstant<platform::CUDADeviceContext, T> set_zero;
proposals_filter.mutable_data<T>({1, 4}, ctx.GetPlace()); proposals_filter.mutable_data<T>({1, 4}, ctx.GetPlace());
scores_filter.mutable_data<T>({1, 1}, ctx.GetPlace()); scores_filter.mutable_data<T>({1, 1}, ctx.GetPlace());
set_zero(ctx, &proposals_filter, static_cast<T>(0)); set_zero(ctx, &proposals_filter, static_cast<T>(0));
...@@ -154,7 +154,7 @@ class CUDAGenerateProposalsKernel : public framework::OpKernel<T> { ...@@ -154,7 +154,7 @@ class CUDAGenerateProposalsKernel : public framework::OpKernel<T> {
scores_swap.mutable_data<T>({num, h_score, w_score, c_score}, scores_swap.mutable_data<T>({num, h_score, w_score, c_score},
dev_ctx.GetPlace()); dev_ctx.GetPlace());
math::Transpose<DeviceContext, T, 4> trans; pten::funcs::Transpose<DeviceContext, T, 4> trans;
std::vector<int> axis = {0, 2, 3, 1}; std::vector<int> axis = {0, 2, 3, 1};
trans(dev_ctx, *bbox_deltas, &bbox_deltas_swap, axis); trans(dev_ctx, *bbox_deltas, &bbox_deltas_swap, axis);
trans(dev_ctx, *scores, &scores_swap, axis); trans(dev_ctx, *scores, &scores_swap, axis);
......
...@@ -21,7 +21,7 @@ limitations under the License. */ ...@@ -21,7 +21,7 @@ limitations under the License. */
#include "paddle/fluid/operators/detection/bbox_util.h" #include "paddle/fluid/operators/detection/bbox_util.h"
#include "paddle/fluid/operators/detection/nms_util.h" #include "paddle/fluid/operators/detection/nms_util.h"
#include "paddle/fluid/operators/gather.h" #include "paddle/fluid/operators/gather.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -113,7 +113,7 @@ class GenerateProposalsV2Kernel : public framework::OpKernel<T> { ...@@ -113,7 +113,7 @@ class GenerateProposalsV2Kernel : public framework::OpKernel<T> {
scores_swap.mutable_data<T>({num, h_score, w_score, c_score}, scores_swap.mutable_data<T>({num, h_score, w_score, c_score},
dev_ctx.GetPlace()); dev_ctx.GetPlace());
math::Transpose<platform::CPUDeviceContext, T, 4> trans; pten::funcs::Transpose<platform::CPUDeviceContext, T, 4> trans;
std::vector<int> axis = {0, 2, 3, 1}; std::vector<int> axis = {0, 2, 3, 1};
trans(dev_ctx, *bbox_deltas, &bbox_deltas_swap, axis); trans(dev_ctx, *bbox_deltas, &bbox_deltas_swap, axis);
trans(dev_ctx, *scores, &scores_swap, axis); trans(dev_ctx, *scores, &scores_swap, axis);
...@@ -215,7 +215,7 @@ class GenerateProposalsV2Kernel : public framework::OpKernel<T> { ...@@ -215,7 +215,7 @@ class GenerateProposalsV2Kernel : public framework::OpKernel<T> {
pixel_offset); pixel_offset);
// Handle the case when there is no keep index left // Handle the case when there is no keep index left
if (keep.numel() == 0) { if (keep.numel() == 0) {
math::SetConstant<platform::CPUDeviceContext, T> set_zero; pten::funcs::SetConstant<platform::CPUDeviceContext, T> set_zero;
bbox_sel.mutable_data<T>({1, 4}, ctx.GetPlace()); bbox_sel.mutable_data<T>({1, 4}, ctx.GetPlace());
set_zero(ctx, &bbox_sel, static_cast<T>(0)); set_zero(ctx, &bbox_sel, static_cast<T>(0));
Tensor scores_filter; Tensor scores_filter;
......
...@@ -20,7 +20,7 @@ limitations under the License. */ ...@@ -20,7 +20,7 @@ limitations under the License. */
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/memory/memory.h" #include "paddle/fluid/memory/memory.h"
#include "paddle/fluid/operators/detection/bbox_util.cu.h" #include "paddle/fluid/operators/detection/bbox_util.cu.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -77,7 +77,7 @@ static std::pair<Tensor, Tensor> ProposalForOneImage( ...@@ -77,7 +77,7 @@ static std::pair<Tensor, Tensor> ProposalForOneImage(
Tensor scores_filter, proposals_filter; Tensor scores_filter, proposals_filter;
// Handle the case when there is no keep index left // Handle the case when there is no keep index left
if (keep_num == 0) { if (keep_num == 0) {
math::SetConstant<platform::CUDADeviceContext, T> set_zero; pten::funcs::SetConstant<platform::CUDADeviceContext, T> set_zero;
proposals_filter.mutable_data<T>({1, 4}, ctx.GetPlace()); proposals_filter.mutable_data<T>({1, 4}, ctx.GetPlace());
scores_filter.mutable_data<T>({1, 1}, ctx.GetPlace()); scores_filter.mutable_data<T>({1, 1}, ctx.GetPlace());
set_zero(ctx, &proposals_filter, static_cast<T>(0)); set_zero(ctx, &proposals_filter, static_cast<T>(0));
...@@ -157,7 +157,7 @@ class CUDAGenerateProposalsV2Kernel : public framework::OpKernel<T> { ...@@ -157,7 +157,7 @@ class CUDAGenerateProposalsV2Kernel : public framework::OpKernel<T> {
scores_swap.mutable_data<T>({num, h_score, w_score, c_score}, scores_swap.mutable_data<T>({num, h_score, w_score, c_score},
dev_ctx.GetPlace()); dev_ctx.GetPlace());
math::Transpose<DeviceContext, T, 4> trans; pten::funcs::Transpose<DeviceContext, T, 4> trans;
std::vector<int> axis = {0, 2, 3, 1}; std::vector<int> axis = {0, 2, 3, 1};
trans(dev_ctx, *bbox_deltas, &bbox_deltas_swap, axis); trans(dev_ctx, *bbox_deltas, &bbox_deltas_swap, axis);
trans(dev_ctx, *scores, &scores_swap, axis); trans(dev_ctx, *scores, &scores_swap, axis);
......
...@@ -16,8 +16,8 @@ limitations under the License. */ ...@@ -16,8 +16,8 @@ limitations under the License. */
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/transform.h" #include "paddle/fluid/platform/transform.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -16,7 +16,7 @@ limitations under the License. */ ...@@ -16,7 +16,7 @@ limitations under the License. */
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -14,9 +14,9 @@ limitations under the License. */ ...@@ -14,9 +14,9 @@ limitations under the License. */
#include <algorithm> #include <algorithm>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/device/gpu/gpu_primitives.h" #include "paddle/fluid/platform/device/gpu/gpu_primitives.h"
#include "paddle/fluid/platform/float16.h" #include "paddle/fluid/platform/float16.h"
#include "paddle/pten/kernels/funcs/math_function.h"
using paddle::platform::PADDLE_CUDA_NUM_THREADS; using paddle::platform::PADDLE_CUDA_NUM_THREADS;
using paddle::platform::float16; using paddle::platform::float16;
...@@ -356,7 +356,7 @@ class CUDAROIPerspectiveTransformOpKernel : public framework::OpKernel<T> { ...@@ -356,7 +356,7 @@ class CUDAROIPerspectiveTransformOpKernel : public framework::OpKernel<T> {
T* out2in_w_data = T* out2in_w_data =
out2in_w->mutable_data<T>({out->numel(), 4}, ctx.GetPlace()); out2in_w->mutable_data<T>({out->numel(), 4}, ctx.GetPlace());
math::SetConstant<platform::CUDADeviceContext, int> init; pten::funcs::SetConstant<platform::CUDADeviceContext, int> init;
init(ctx.cuda_device_context(), out2in_idx, static_cast<int>(-1)); init(ctx.cuda_device_context(), out2in_idx, static_cast<int>(-1));
auto transformed_height = ctx.Attr<int>("transformed_height"); auto transformed_height = ctx.Attr<int>("transformed_height");
...@@ -482,7 +482,7 @@ class CUDAROIPerspectiveTransformGradOpKernel : public framework::OpKernel<T> { ...@@ -482,7 +482,7 @@ class CUDAROIPerspectiveTransformGradOpKernel : public framework::OpKernel<T> {
T* in_grad_data = in_grad->mutable_data<T>(ctx.GetPlace()); T* in_grad_data = in_grad->mutable_data<T>(ctx.GetPlace());
math::SetConstant<platform::CUDADeviceContext, T> set_zero; pten::funcs::SetConstant<platform::CUDADeviceContext, T> set_zero;
set_zero(ctx.cuda_device_context(), in_grad, static_cast<T>(0)); set_zero(ctx.cuda_device_context(), in_grad, static_cast<T>(0));
const T* out_grad_data = out_grad->data<T>(); const T* out_grad_data = out_grad->data<T>();
......
...@@ -15,7 +15,7 @@ limitations under the License. */ ...@@ -15,7 +15,7 @@ limitations under the License. */
#include <random> #include <random>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/detection/bbox_util.h" #include "paddle/fluid/operators/detection/bbox_util.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -14,8 +14,8 @@ limitations under the License. */ ...@@ -14,8 +14,8 @@ limitations under the License. */
#include "paddle/fluid/memory/malloc.h" #include "paddle/fluid/memory/malloc.h"
#include "paddle/fluid/operators/detection/yolo_box_op.h" #include "paddle/fluid/operators/detection/yolo_box_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/device/gpu/gpu_launch_config.h" #include "paddle/fluid/platform/device/gpu/gpu_launch_config.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -114,7 +114,7 @@ class YoloBoxOpCUDAKernel : public framework::OpKernel<T> { ...@@ -114,7 +114,7 @@ class YoloBoxOpCUDAKernel : public framework::OpKernel<T> {
T* boxes_data = boxes->mutable_data<T>({n, box_num, 4}, ctx.GetPlace()); T* boxes_data = boxes->mutable_data<T>({n, box_num, 4}, ctx.GetPlace());
T* scores_data = T* scores_data =
scores->mutable_data<T>({n, box_num, class_num}, ctx.GetPlace()); scores->mutable_data<T>({n, box_num, class_num}, ctx.GetPlace());
math::SetConstant<platform::CUDADeviceContext, T> set_zero; pten::funcs::SetConstant<platform::CUDADeviceContext, T> set_zero;
set_zero(dev_ctx, boxes, static_cast<T>(0)); set_zero(dev_ctx, boxes, static_cast<T>(0));
set_zero(dev_ctx, scores, static_cast<T>(0)); set_zero(dev_ctx, scores, static_cast<T>(0));
platform::GpuLaunchConfig config = platform::GpuLaunchConfig config =
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/pten/core/hostdevice.h" #include "paddle/pten/core/hostdevice.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -305,7 +305,7 @@ class Yolov3LossKernel : public framework::OpKernel<T> { ...@@ -305,7 +305,7 @@ class Yolov3LossKernel : public framework::OpKernel<T> {
Tensor gtscore; Tensor gtscore;
if (!gt_score) { if (!gt_score) {
gtscore.mutable_data<T>({n, b}, ctx.GetPlace()); gtscore.mutable_data<T>({n, b}, ctx.GetPlace());
math::SetConstant<platform::CPUDeviceContext, T>()( pten::funcs::SetConstant<platform::CPUDeviceContext, T>()(
ctx.template device_context<platform::CPUDeviceContext>(), &gtscore, ctx.template device_context<platform::CPUDeviceContext>(), &gtscore,
static_cast<T>(1.0)); static_cast<T>(1.0));
gt_score = &gtscore; gt_score = &gtscore;
...@@ -461,7 +461,7 @@ class Yolov3LossGradKernel : public framework::OpKernel<T> { ...@@ -461,7 +461,7 @@ class Yolov3LossGradKernel : public framework::OpKernel<T> {
Tensor gtscore; Tensor gtscore;
if (!gt_score) { if (!gt_score) {
gtscore.mutable_data<T>({n, b}, ctx.GetPlace()); gtscore.mutable_data<T>({n, b}, ctx.GetPlace());
math::SetConstant<platform::CPUDeviceContext, T>()( pten::funcs::SetConstant<platform::CPUDeviceContext, T>()(
ctx.template device_context<platform::CPUDeviceContext>(), &gtscore, ctx.template device_context<platform::CPUDeviceContext>(), &gtscore,
static_cast<T>(1.0)); static_cast<T>(1.0));
gt_score = &gtscore; gt_score = &gtscore;
......
...@@ -150,7 +150,7 @@ inline bool CheckMatrixInvertible(const framework::ExecutionContext& ctx, ...@@ -150,7 +150,7 @@ inline bool CheckMatrixInvertible(const framework::ExecutionContext& ctx,
auto* data = dev_tensor.mutable_data<bool>({1}, ctx.GetPlace()); auto* data = dev_tensor.mutable_data<bool>({1}, ctx.GetPlace());
// set false // set false
math::SetConstant<DeviceContext, bool> zero; pten::funcs::SetConstant<DeviceContext, bool> zero;
zero(dev_ctx, &dev_tensor, false); zero(dev_ctx, &dev_tensor, false);
// find whether zero // find whether zero
...@@ -208,7 +208,7 @@ class DeterminantGradKernel : public framework::OpKernel<T> { ...@@ -208,7 +208,7 @@ class DeterminantGradKernel : public framework::OpKernel<T> {
VLOG(3) << "The input matrix not invertible!"; VLOG(3) << "The input matrix not invertible!";
ddet->Resize(input->dims()); ddet->Resize(input->dims());
ddet->mutable_data<T>(context.GetPlace()); ddet->mutable_data<T>(context.GetPlace());
math::SetConstant<DeviceContext, T> zero; pten::funcs::SetConstant<DeviceContext, T> zero;
zero(dev_ctx, ddet, static_cast<T>(0.0f)); zero(dev_ctx, ddet, static_cast<T>(0.0f));
return; return;
} }
...@@ -363,7 +363,7 @@ class SlogDeterminantGradKernel : public framework::OpKernel<T> { ...@@ -363,7 +363,7 @@ class SlogDeterminantGradKernel : public framework::OpKernel<T> {
VLOG(3) << "The input matrix not invertible!"; VLOG(3) << "The input matrix not invertible!";
dslogdet->Resize(input->dims()); dslogdet->Resize(input->dims());
dslogdet->mutable_data<T>(context.GetPlace()); dslogdet->mutable_data<T>(context.GetPlace());
math::SetConstant<DeviceContext, T> zero; pten::funcs::SetConstant<DeviceContext, T> zero;
zero(dev_ctx, dslogdet, std::numeric_limits<T>::quiet_NaN()); zero(dev_ctx, dslogdet, std::numeric_limits<T>::quiet_NaN());
return; return;
} }
......
...@@ -187,7 +187,7 @@ class DGCOpKernel : public framework::OpKernel<T> { ...@@ -187,7 +187,7 @@ class DGCOpKernel : public framework::OpKernel<T> {
"V_out numel error, V_out numel is %d.", v_out->numel())); "V_out numel error, V_out numel is %d.", v_out->numel()));
} }
math::SetConstant<DeviceContext, T> tset; pten::funcs::SetConstant<DeviceContext, T> tset;
tset(dev_ctx, grad_out, static_cast<T>(0)); tset(dev_ctx, grad_out, static_cast<T>(0));
} }
}; };
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
#include <algorithm> #include <algorithm>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/for_range.h" #include "paddle/fluid/platform/for_range.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -70,7 +70,7 @@ class DiagEmbedKernel : public framework::OpKernel<T> { ...@@ -70,7 +70,7 @@ class DiagEmbedKernel : public framework::OpKernel<T> {
auto* input_data = input->data<T>(); auto* input_data = input->data<T>();
T* out_data = out->mutable_data<T>(context.GetPlace()); T* out_data = out->mutable_data<T>(context.GetPlace());
math::SetConstant<DeviceContext, T> set_zero; pten::funcs::SetConstant<DeviceContext, T> set_zero;
auto& dev_ctx = context.template device_context<DeviceContext>(); auto& dev_ctx = context.template device_context<DeviceContext>();
set_zero(dev_ctx, out, static_cast<T>(0.0)); set_zero(dev_ctx, out, static_cast<T>(0.0));
......
...@@ -15,8 +15,8 @@ limitations under the License. */ ...@@ -15,8 +15,8 @@ limitations under the License. */
#pragma once #pragma once
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/for_range.h" #include "paddle/fluid/platform/for_range.h"
#include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -45,7 +45,7 @@ class DiagKernel : public framework::OpKernel<T> { ...@@ -45,7 +45,7 @@ class DiagKernel : public framework::OpKernel<T> {
auto* out = context.Output<framework::Tensor>("Out"); auto* out = context.Output<framework::Tensor>("Out");
T* out_data = out->mutable_data<T>(context.GetPlace()); T* out_data = out->mutable_data<T>(context.GetPlace());
math::SetConstant<DeviceContext, T> set_zero; pten::funcs::SetConstant<DeviceContext, T> set_zero;
auto& dev_ctx = context.template device_context<DeviceContext>(); auto& dev_ctx = context.template device_context<DeviceContext>();
set_zero(dev_ctx, out, static_cast<T>(0)); set_zero(dev_ctx, out, static_cast<T>(0));
......
...@@ -15,7 +15,7 @@ limitations under the License. */ ...@@ -15,7 +15,7 @@ limitations under the License. */
#include "paddle/fluid/operators/diag_v2_op.h" #include "paddle/fluid/operators/diag_v2_op.h"
#include <algorithm> #include <algorithm>
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -109,7 +109,7 @@ class DiagV2Kernel : public framework::OpKernel<T> { ...@@ -109,7 +109,7 @@ class DiagV2Kernel : public framework::OpKernel<T> {
int64_t i; int64_t i;
if (x_dims.size() == 1) { if (x_dims.size() == 1) {
float padding_value = context.Attr<float>("padding_value"); float padding_value = context.Attr<float>("padding_value");
math::SetConstant<DeviceContext, T> set_padding_value; pten::funcs::SetConstant<DeviceContext, T> set_padding_value;
auto& dev_ctx = context.template device_context<DeviceContext>(); auto& dev_ctx = context.template device_context<DeviceContext>();
set_padding_value(dev_ctx, out, static_cast<T>(padding_value)); set_padding_value(dev_ctx, out, static_cast<T>(padding_value));
......
...@@ -72,7 +72,7 @@ class DiagV2CUDAKernel : public framework::OpKernel<T> { ...@@ -72,7 +72,7 @@ class DiagV2CUDAKernel : public framework::OpKernel<T> {
if (x_dims.size() == 1) { if (x_dims.size() == 1) {
float padding_value = context.Attr<float>("padding_value"); float padding_value = context.Attr<float>("padding_value");
math::SetConstant<DeviceContext, T> set_padding_value; pten::funcs::SetConstant<DeviceContext, T> set_padding_value;
set_padding_value(dev_ctx, out, static_cast<T>(padding_value)); set_padding_value(dev_ctx, out, static_cast<T>(padding_value));
auto x_length = x_dims[0]; auto x_length = x_dims[0];
......
...@@ -15,7 +15,7 @@ limitations under the License. */ ...@@ -15,7 +15,7 @@ limitations under the License. */
#pragma once #pragma once
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <vector> #include <vector>
#include "paddle/fluid/framework/eigen.h" #include "paddle/fluid/framework/eigen.h"
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/math_function.h" #include "paddle/pten/kernels/funcs/math_function.h"
namespace paddle { namespace paddle {
namespace operators { namespace operators {
...@@ -171,7 +171,7 @@ static void DistGradFunction(const framework::ExecutionContext& context) { ...@@ -171,7 +171,7 @@ static void DistGradFunction(const framework::ExecutionContext& context) {
// 1: Lp-norm(z), z = x-y, compute dz // 1: Lp-norm(z), z = x-y, compute dz
if (p == 0) { if (p == 0) {
math::SetConstant<DeviceContext, T> set_zero; pten::funcs::SetConstant<DeviceContext, T> set_zero;
auto& dev_ctx = context.template device_context<DeviceContext>(); auto& dev_ctx = context.template device_context<DeviceContext>();
set_zero(dev_ctx, &grad, static_cast<T>(0)); set_zero(dev_ctx, &grad, static_cast<T>(0));
} else if (p == INFINITY || p == -INFINITY) { } else if (p == INFINITY || p == -INFINITY) {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册