Skip to content

Commit

Permalink
Replace operators::math to phi::math in fluid/operators (#63854)
Browse files Browse the repository at this point in the history
  • Loading branch information
co63oc authored May 7, 2024
1 parent 3993e61 commit 0bd6669
Show file tree
Hide file tree
Showing 22 changed files with 45 additions and 637 deletions.
4 changes: 2 additions & 2 deletions paddle/fluid/distributed/collective/reducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ struct ConcatTensorsForAllReduce {
void operator()(const DeviceContext &context,
const std::vector<phi::DenseTensor> &dense_tensors_,
Tensor *p_dense_contents) {
operators::math::ConcatFunctor<DeviceContext, T> concat_functor_;
phi::funcs::ConcatFunctor<DeviceContext, T> concat_functor_;
concat_functor_(
context,
dense_tensors_,
Expand Down Expand Up @@ -191,7 +191,7 @@ struct SplitTensorsForAllReduce {
shape_refer.emplace_back(&tensor);
}

operators::math::SplitFunctor<DeviceContext, T> split_functor_;
phi::funcs::SplitFunctor<DeviceContext, T> split_functor_;
split_functor_(context, *in, shape_refer, 0, &outs);
}
};
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/distributed/collective/reducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
#include "paddle/fluid/eager/api/utils/hook_utils.h"
#include "paddle/fluid/eager/autograd_meta.h"
#include "paddle/fluid/eager/utils.h"
#include "paddle/fluid/operators/math/concat_and_split.h"
#include "paddle/fluid/platform/device/gpu/gpu_info.h"
#include "paddle/phi/api/include/api.h"
#include "paddle/phi/api/include/fused_api.h"
#include "paddle/phi/api/include/tensor.h"
#include "paddle/phi/common/data_type.h"
#include "paddle/phi/kernels/funcs/concat_and_split_functor.h"
#include "paddle/phi/kernels/funcs/math_function.h"
#include "paddle/utils/string/string_helper.h"

Expand Down
9 changes: 4 additions & 5 deletions paddle/fluid/distributed/index_dataset/index_sampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include "paddle/fluid/distributed/index_dataset/index_wrapper.h"
#include "paddle/fluid/framework/data_feed.h"
#include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/math/sampler.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/phi/kernels/funcs/math/sampler.h"

namespace paddle {
namespace distributed {
Expand Down Expand Up @@ -107,9 +107,8 @@ class LayerWiseSampler : public IndexSampler {
while (layer_index >= start_sample_layer_) {
auto layer_codes = tree_->GetLayerCodes(layer_index);
layer_ids_.push_back(tree_->GetNodes(layer_codes));
auto sampler_temp =
std::make_shared<paddle::operators::math::UniformSampler>(
layer_ids_[idx].size() - 1, seed_);
auto sampler_temp = std::make_shared<phi::math::UniformSampler>(
layer_ids_[idx].size() - 1, seed_);
sampler_vec_.push_back(sampler_temp);
layer_index--;
idx++;
Expand All @@ -131,7 +130,7 @@ class LayerWiseSampler : public IndexSampler {
std::shared_ptr<TreeIndex> tree_{nullptr};
int seed_{0};
int start_sample_layer_{1};
std::vector<std::shared_ptr<paddle::operators::math::Sampler>> sampler_vec_;
std::vector<std::shared_ptr<phi::math::Sampler>> sampler_vec_;
std::vector<std::vector<IndexNode>> layer_ids_;
};

Expand Down
1 change: 0 additions & 1 deletion paddle/fluid/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,6 @@ if(WITH_DISTRIBUTE)
glog
index_sampler
index_wrapper
sampler
index_dataset_proto
lod_rank_table
framework_io
Expand Down
9 changes: 4 additions & 5 deletions paddle/fluid/imperative/reducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "paddle/fluid/framework/tensor_util.h"
#include "paddle/fluid/imperative/layer.h"
#include "paddle/fluid/imperative/parallel_context.h"
#include "paddle/fluid/operators/math/concat_and_split.h"
#include "paddle/phi/kernels/funcs/concat_and_split_functor.h"
#include "paddle/phi/kernels/funcs/strided_memcpy.h"
#ifdef PADDLE_WITH_XPU
#include "paddle/fluid/platform/device/xpu/enforce_xpu.h"
Expand Down Expand Up @@ -74,7 +74,7 @@ static void ConcatTensorsForAllReduce(
const DeviceContext &context,
const std::vector<phi::DenseTensor> &dense_tensors_,
framework::Variable *p_dense_contents) {
operators::math::ConcatFunctor<DeviceContext, T> concat_functor_;
phi::funcs::ConcatFunctor<DeviceContext, T> concat_functor_;
concat_functor_(context,
dense_tensors_,
0,
Expand Down Expand Up @@ -102,7 +102,7 @@ static void SplitTensorsForAllReduce(
phi::funcs::StridedMemcpyWithAxis0<T, DeviceContext>(
context, *in, shape_refer, &outs);
} else {
operators::math::SplitFunctor<DeviceContext, T> split_functor_;
phi::funcs::SplitFunctor<DeviceContext, T> split_functor_;
split_functor_(context, *in, shape_refer, 0, &outs);
}
}
Expand Down Expand Up @@ -179,8 +179,7 @@ void SplitTensorsForAllReduce<platform::XPUDeviceContext, float>(
outs.emplace_back(&tensor);
shape_refer.emplace_back(&tensor);
}
operators::math::SplitFunctor<platform::XPUDeviceContext, float>
split_functor_;
phi::funcs::SplitFunctor<platform::XPUDeviceContext, float> split_functor_;
split_functor_(context, *in, shape_refer, 0, &outs);
}

Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ set(COMMON_OP_DEPS ${COMMON_OP_DEPS} phi common)
set(COMMON_OP_DEPS ${COMMON_OP_DEPS} selected_rows_utils
lod_tensor unpooling lod_rank_table context_project executor static_prim_api)
set(COMMON_OP_DEPS ${COMMON_OP_DEPS} dynload_warpctc static_prim_api static_utils static_global_utils prim_utils)
set(COMMON_OP_DEPS ${COMMON_OP_DEPS} cos_sim_functor concat_and_split sampler sample_prob tree2col)
set(COMMON_OP_DEPS ${COMMON_OP_DEPS} cos_sim_functor concat_and_split tree2col)
set(COMMON_OP_DEPS ${COMMON_OP_DEPS} beam_search)
set(COMMON_OP_DEPS ${COMMON_OP_DEPS} box_wrapper ps_gpu_wrapper)
set(COMMON_OP_DEPS ${COMMON_OP_DEPS} common_infer_shape_functions)
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/array_to_lod_tensor_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include <paddle/fluid/operators/math/concat_and_split.h>
#include "paddle/phi/kernels/funcs/concat_and_split_functor.h"

#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/platform/device_context.h"
Expand Down Expand Up @@ -77,7 +77,7 @@ struct ArrayToLoDFunctor {
template <typename DeviceContext>
template <typename T>
void ArrayToLoDFunctorImpl<DeviceContext>::apply() {
math::ConcatFunctor<DeviceContext, T> func;
phi::funcs::ConcatFunctor<DeviceContext, T> func;
func(*dev_ctx_, prev_functor_->in, 0, prev_functor_->out);
}

Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/collective/c_concat_op.cu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ limitations under the License. */
#include <vector>
#include "paddle/phi/core/distributed/comm_context_manager.h"

#include "paddle/fluid/operators/math/concat_and_split.h"
#include "paddle/phi/api/include/tensor.h"
#include "paddle/phi/kernels/funcs/concat_and_split_functor.h"

#if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL)
#include "paddle/common/flags.h"
Expand Down Expand Up @@ -151,7 +151,7 @@ class CConcatOpCUDAKernel : public framework::OpKernel<T> {
offset += rows_per_tensor;
}

math::ConcatFunctor<phi::GPUContext, T> functor;
phi::funcs::ConcatFunctor<phi::GPUContext, T> functor;
out->mutable_data<T>(out_dims, place);
auto& dev_ctx2 = ctx.template device_context<phi::GPUContext>();
functor(dev_ctx2, inputs, axis, out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ namespace cub = hipcub;
#include "paddle/fluid/memory/memcpy.h"
#include "paddle/fluid/operators/detection/bbox_util.h"
#include "paddle/fluid/operators/detection/collect_fpn_proposals_op.h"
#include "paddle/fluid/operators/math/concat_and_split.h"
#include "paddle/fluid/platform/for_range.h"
#include "paddle/phi/backends/gpu/gpu_primitives.h"
#include "paddle/phi/core/mixed_vector.h"
#include "paddle/phi/kernels/funcs/concat_and_split_functor.h"
#include "paddle/phi/kernels/funcs/gather.cu.h"
#include "paddle/phi/kernels/funcs/strided_memcpy.h"

Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/lod_tensor_to_array_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/math/concat_and_split.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/phi/core/lod_utils.h"
#include "paddle/phi/kernels/funcs/concat_and_split_functor.h"

namespace paddle {
namespace framework {
Expand Down Expand Up @@ -88,7 +88,7 @@ struct LoDTensorToArrayFunctor {
template <typename DeviceContext>
template <typename T>
void LoDTensorToArrayFunctorImpl<DeviceContext>::apply() {
math::SplitFunctor<DeviceContext, T> func;
phi::funcs::SplitFunctor<DeviceContext, T> func;
func(*dev_ctx_,
prev_functor_->input_,
prev_functor_->ref_inputs_,
Expand Down
2 changes: 0 additions & 2 deletions paddle/fluid/operators/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ math_library(concat_and_split DEPS phi common)
math_library(context_project DEPS phi common)
math_library(cos_sim_functor)
math_library(depthwise_conv)
math_library(sample_prob)
math_library(sampler DEPS phi common)

if(WITH_XPU)
math_library(beam_search DEPS phi common beam_search_xpu)
Expand Down
21 changes: 0 additions & 21 deletions paddle/fluid/operators/math/sample_prob.cc

This file was deleted.

Loading

0 comments on commit 0bd6669

Please sign in to comment.