Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions paddle/fluid/operators/cross_entropy_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ limitations under the License. */

#pragma once
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/platform/for_range.h"
#include "paddle/phi/core/tensor_utils.h"
#include "paddle/phi/kernels/funcs/cross_entropy.h"
#include "paddle/phi/kernels/funcs/eigen/common.h"
#include "paddle/phi/kernels/funcs/for_range.h"
#include "paddle/phi/kernels/funcs/math.h"
#include "paddle/phi/kernels/funcs/math_function.h"

Expand Down Expand Up @@ -142,7 +142,7 @@ class CrossEntropyGradientOpKernel : public framework::OpKernel<T> {
x->data<T>(),
label->data<T>(),
static_cast<size_t>(class_num));
platform::ForRange<DeviceContext> for_range(
phi::funcs::ForRange<DeviceContext> for_range(
ctx.template device_context<DeviceContext>(),
static_cast<size_t>(dx->numel()));
for_range(functor);
Expand All @@ -153,7 +153,7 @@ class CrossEntropyGradientOpKernel : public framework::OpKernel<T> {
label->data<int64_t>(),
static_cast<size_t>(class_num),
static_cast<size_t>(ignore_index));
platform::ForRange<DeviceContext> for_range(
phi::funcs::ForRange<DeviceContext> for_range(
ctx.template device_context<DeviceContext>(),
static_cast<size_t>(dy->numel()));
for_range(functor);
Expand Down Expand Up @@ -259,7 +259,7 @@ class CrossEntropyOpKernel2 : public framework::OpKernel<T> {

auto ignore_index = ctx.Attr<int>("ignore_index");

platform::ForRange<DeviceContext> for_range(
phi::funcs::ForRange<DeviceContext> for_range(
ctx.template device_context<DeviceContext>(), batch_size);
for_range(HardLabelCrossEntropyForwardFunctor<T>(
p_x, p_y, p_match_x, p_label, ignore_index, feature_size));
Expand All @@ -285,7 +285,7 @@ class CrossEntropyGradientOpKernel2 : public framework::OpKernel<T> {
int64_t feature_size = dx->dims()[rank - 1];
int64_t batch_size = common::product(dx->dims()) / feature_size;

platform::ForRange<DeviceContext> for_range(
phi::funcs::ForRange<DeviceContext> for_range(
ctx.template device_context<DeviceContext>(),
batch_size * feature_size);
for_range(HardLabelCrossEntropyBackwardFunctor<T>(
Expand Down
8 changes: 5 additions & 3 deletions paddle/fluid/operators/detection/collect_fpn_proposals_op.cu
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ 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/platform/for_range.h"
#include "paddle/phi/backends/gpu/gpu_primitives.h"
#include "paddle/phi/common/memory_utils.h"
#include "paddle/phi/core/mixed_vector.h"
#include "paddle/phi/kernels/funcs/concat_and_split_functor.h"
#include "paddle/phi/kernels/funcs/for_range.h"
#include "paddle/phi/kernels/funcs/gather.cu.h"
#include "paddle/phi/kernels/funcs/strided_memcpy.h"

Expand Down Expand Up @@ -139,7 +139,8 @@ class GPUCollectFpnProposalsOpKernel : public framework::OpKernel<T> {
phi::DenseTensor index_in_t;
int* idx_in =
index_in_t.mutable_data<int>({total_roi_num}, dev_ctx.GetPlace());
platform::ForRange<phi::GPUContext> for_range_total(dev_ctx, total_roi_num);
phi::funcs::ForRange<phi::GPUContext> for_range_total(dev_ctx,
total_roi_num);
for_range_total(RangeInitFunctor{0, 1, idx_in});

phi::DenseTensor keys_out_t;
Expand Down Expand Up @@ -188,7 +189,8 @@ class GPUCollectFpnProposalsOpKernel : public framework::OpKernel<T> {
phi::DenseTensor batch_index_t;
int* batch_idx_in =
batch_index_t.mutable_data<int>({real_post_num}, dev_ctx.GetPlace());
platform::ForRange<phi::GPUContext> for_range_post(dev_ctx, real_post_num);
phi::funcs::ForRange<phi::GPUContext> for_range_post(dev_ctx,
real_post_num);
for_range_post(RangeInitFunctor{0, 1, batch_idx_in});

phi::DenseTensor out_id_t;
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/detection/generate_proposals_op.cu
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static std::pair<phi::DenseTensor, phi::DenseTensor> ProposalForOneImage(
proposals.mutable_data<T>({pre_nms_num, 4}, ctx.GetPlace());

{
platform::ForRange<phi::GPUContext> for_range(ctx, pre_nms_num);
phi::funcs::ForRange<phi::GPUContext> for_range(ctx, pre_nms_num);
for_range(BoxDecodeAndClipFunctor<T>{anchors.data<T>(),
bbox_deltas.data<T>(),
variances.data<T>(),
Expand Down
6 changes: 3 additions & 3 deletions paddle/fluid/operators/elementwise/elementwise_op_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ limitations under the License. */

#endif

#include "paddle/fluid/platform/for_range.h"
#include "paddle/phi/kernels/funcs/for_range.h"
#include "paddle/phi/kernels/funcs/math_function.h"

#define DIVUP(x, y) (((x) + (y)-1) / (y))
Expand Down Expand Up @@ -474,7 +474,7 @@ void FusedElemwiseAndActComputeNoBroadcast(
phi::DenseTensor *intermediate_out) {
size_t N = static_cast<size_t>(common::product(x_dim));

platform::ForRange<DeviceContext> for_range(
phi::funcs::ForRange<DeviceContext> for_range(
ctx.template device_context<DeviceContext>(), N);

for_range(
Expand Down Expand Up @@ -654,7 +654,7 @@ void FusedElemwiseAndActGradComputeNoBroadcast(
DY_OP dy_op,
DIntermediate_OP dintermediate_op) {
size_t N = static_cast<size_t>(common::product(x_dim));
platform::ForRange<DeviceContext> for_range(
phi::funcs::ForRange<DeviceContext> for_range(
ctx.template device_context<DeviceContext>(), N);
const T *x_data = nullptr;
const T *y_data = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/operators/optimizers/ftrl_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ limitations under the License. */

#pragma once
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/platform/for_range.h"
#include "paddle/phi/kernels/funcs/eigen/common.h"
#include "paddle/phi/kernels/funcs/for_range.h"
#include "paddle/phi/kernels/funcs/selected_rows_functor.h"

namespace paddle {
Expand Down Expand Up @@ -202,7 +202,7 @@ class FTRLOpKernel : public framework::OpKernel<T> {
auto row_numel = static_cast<int64_t>(merged_grad->value().dims()[1]);
auto row_height = static_cast<int64_t>(merged_grad->rows().size());

platform::ForRange<DeviceContext> for_range(
phi::funcs::ForRange<DeviceContext> for_range(
static_cast<const DeviceContext&>(ctx.device_context()),
row_numel * row_height);

Expand Down
6 changes: 3 additions & 3 deletions paddle/fluid/operators/optimizers/sparse_momentum_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

#include "paddle/fluid/framework/convert_utils.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/platform/for_range.h"
#include "paddle/phi/common/amp_type_traits.h"
#include "paddle/phi/common/float16.h"
#include "paddle/phi/kernels/funcs/eigen/common.h"
#include "paddle/phi/kernels/funcs/for_range.h"

#ifdef __NVCC__
#include "cub/cub.cuh"
Expand Down Expand Up @@ -436,7 +436,7 @@ class SparseMomentumOpKernel : public framework::OpKernel<T> {

auto grad = ctx.Input<phi::DenseTensor>("Grad");

platform::ForRange<DeviceContext> for_range(
phi::funcs::ForRange<DeviceContext> for_range(
static_cast<const DeviceContext&>(ctx.device_context()),
param->numel());

Expand Down Expand Up @@ -465,7 +465,7 @@ class SparseMomentumOpKernel : public framework::OpKernel<T> {
auto sort_value_ptr =
sort_value.mutable_data<IndexT>({num_index}, ctx.GetPlace());

platform::ForRange<DeviceContext> for_range_index(
phi::funcs::ForRange<DeviceContext> for_range_index(
static_cast<const DeviceContext&>(ctx.device_context()), num_index);
RangeFunctor<IndexT> range_functor(sort_value_ptr);
for_range_index(range_functor);
Expand Down
8 changes: 4 additions & 4 deletions paddle/fluid/operators/svd_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
#include "paddle/fluid/operators/diag_op.h"
#include "paddle/fluid/operators/elementwise/elementwise_op_function.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/for_range.h"
#include "paddle/phi/kernels/funcs/blas/blas.h"
#include "paddle/phi/kernels/funcs/complex_functors.h"
#include "paddle/phi/kernels/funcs/eigen/eigen_function.h"
#include "paddle/phi/kernels/funcs/for_range.h"
#include "paddle/phi/kernels/funcs/lapack/lapack_function.h"
#include "paddle/phi/kernels/funcs/math_function.h"

Expand Down Expand Up @@ -666,7 +666,7 @@ struct DeviceIndependenceTensorOperations {
const phi::DenseTensor& input) {
phi::DenseTensor out;
auto& dev_ctx = context.template device_context<DeviceContext>();
platform::ForRange<DeviceContext> for_range(dev_ctx, input.numel());
phi::funcs::ForRange<DeviceContext> for_range(dev_ctx, input.numel());
DiagAndFillFunctor<T, ValueType> diag_and_copy_functor(
m,
n,
Expand All @@ -685,9 +685,9 @@ struct DeviceIndependenceTensorOperations {
auto& dev_ctx = context.template device_context<DeviceContext>();
return phi::funcs::GetBlas<DeviceContext, T>(dev_ctx);
}
platform::ForRange<DeviceContext> GetForRange(int numel) {
phi::funcs::ForRange<DeviceContext> GetForRange(int numel) {
auto& dev_ctx = context.template device_context<DeviceContext>();
return platform::ForRange<DeviceContext>(dev_ctx, numel);
return phi::funcs::ForRange<DeviceContext>(dev_ctx, numel);
}
template <size_t D>
void EigenSliceWrapper(const phi::DenseTensor* in,
Expand Down