Skip to content

Commit

Permalink
Fix kernels header pos error (#44902)
Browse files Browse the repository at this point in the history
* fix header pos error

* fix namespace error
  • Loading branch information
chenwhql authored Aug 7, 2022
1 parent 849eccb commit 839d8bb
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 43 deletions.
1 change: 0 additions & 1 deletion paddle/phi/kernels/affine_grid_grad_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#pragma once

#include "paddle/phi/common/int_array.h"
#include "paddle/phi/kernels/affine_grid_impl.h"

namespace phi {

Expand Down
1 change: 0 additions & 1 deletion paddle/phi/kernels/affine_grid_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#pragma once

#include "paddle/phi/common/int_array.h"
#include "paddle/phi/kernels/affine_grid_impl.h"

namespace phi {

Expand Down
2 changes: 2 additions & 0 deletions paddle/phi/kernels/cpu/affine_grid_grad_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
// limitations under the License.

#include "paddle/phi/kernels/affine_grid_grad_kernel.h"

#include "paddle/phi/backends/cpu/cpu_context.h"
#include "paddle/phi/common/int_array.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/funcs/affine_grid_utils.h"

namespace phi {

Expand Down
2 changes: 2 additions & 0 deletions paddle/phi/kernels/cpu/affine_grid_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
// limitations under the License.

#include "paddle/phi/kernels/affine_grid_kernel.h"

#include "paddle/phi/backends/cpu/cpu_context.h"
#include "paddle/phi/common/int_array.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/funcs/affine_grid_utils.h"

namespace phi {

Expand Down
3 changes: 2 additions & 1 deletion paddle/phi/kernels/cpu/fill_diagonal_grad_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "paddle/phi/kernels/fill_diagonal_grad_kernel.h"

#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/funcs/common_shape.h"

namespace phi {

Expand All @@ -30,7 +31,7 @@ void FillDiagonalGradKernel(const Context& ctx,
phi::Copy(ctx, out_grad, ctx.GetPlace(), false, x_grad);

auto dx_dims = x_grad->dims();
auto strides = CalStride(dx_dims);
auto strides = funcs::CalStride(dx_dims);
auto size = x_grad->numel();
auto wrapsize = std::min(size, dx_dims[1] * dx_dims[1]);

Expand Down
3 changes: 2 additions & 1 deletion paddle/phi/kernels/cpu/fill_diagonal_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/core/tensor_utils.h"
#include "paddle/phi/kernels/funcs/common_shape.h"

namespace phi {

Expand All @@ -32,7 +33,7 @@ void FillDiagonalKernel(const Context& ctx,
phi::Copy(ctx, x, ctx.GetPlace(), false, out);

auto out_dims = out->dims();
auto strides = CalStride(out_dims);
auto strides = funcs::CalStride(out_dims);
auto size = out->numel();

// The wrap mode supported only the dims equels to 2; In wrap mode, the
Expand Down
2 changes: 0 additions & 2 deletions paddle/phi/kernels/fill_diagonal_grad_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

#include "paddle/phi/core/dense_tensor.h"

#include "paddle/phi/kernels/impl/fill_diagonal_kernel_impl.h"

namespace phi {

template <typename T, typename Context>
Expand Down
3 changes: 0 additions & 3 deletions paddle/phi/kernels/fill_diagonal_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
#pragma once

#include "paddle/phi/core/dense_tensor.h"

#include "paddle/phi/kernels/impl/fill_diagonal_kernel_impl.h"

namespace phi {

template <typename T, typename Context>
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions paddle/phi/kernels/funcs/common_shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,16 @@ inline DDim GetOutputDims(const DDim &s_dims, const DDim &l_dims) {
return phi::make_ddim(shapes);
}

inline int64_t CalStride(phi::DDim dim) {
int rank = dim.size();
int64_t dimsum = 1;
int64_t strides = 0;
for (int i = rank - 1; i >= 0; i--) {
strides += dimsum;
dimsum *= dim[i];
}
return strides;
}

} // namespace funcs
} // namespace phi
2 changes: 2 additions & 0 deletions paddle/phi/kernels/gpu/affine_grid_grad_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
#pragma once

#include "paddle/phi/kernels/affine_grid_grad_kernel.h"

#include "paddle/fluid/platform/device/gpu/gpu_device_function.h"
#include "paddle/fluid/platform/device/gpu/gpu_info.h"
#include "paddle/fluid/platform/device/gpu/gpu_primitives.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/common/int_array.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/funcs/affine_grid_utils.h"

namespace phi {

Expand Down
2 changes: 2 additions & 0 deletions paddle/phi/kernels/gpu/affine_grid_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
#pragma once

#include "paddle/phi/kernels/affine_grid_kernel.h"

#include "paddle/fluid/platform/device/gpu/gpu_device_function.h"
#include "paddle/fluid/platform/device/gpu/gpu_info.h"
#include "paddle/fluid/platform/device/gpu/gpu_primitives.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/common/int_array.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/funcs/affine_grid_utils.h"

namespace phi {

Expand Down
3 changes: 2 additions & 1 deletion paddle/phi/kernels/gpu/fill_diagonal_grad_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <vector>

#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/funcs/common_shape.h"

namespace phi {

Expand Down Expand Up @@ -60,7 +61,7 @@ void FillDiagonalGradKernel(const Context& ctx,

auto size = x_grad->numel();
auto out_dims = x_grad->dims();
auto strides = CalStride(out_dims);
auto strides = funcs::CalStride(out_dims);

auto wrapsize = std::min(size, out_dims[1] * out_dims[1]);
// The wrap mode supported only the dims equels to 2; In wrap mode, the
Expand Down
3 changes: 2 additions & 1 deletion paddle/phi/kernels/gpu/fill_diagonal_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "paddle/fluid/framework/convert_utils.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/funcs/common_shape.h"

namespace phi {

Expand Down Expand Up @@ -63,7 +64,7 @@ void FillDiagonalKernel(const Context& ctx,

auto size = out->numel();
auto out_dims = out->dims();
auto strides = CalStride(out_dims);
auto strides = funcs::CalStride(out_dims);

// The wrap mode supported only the dims equels to 2; In wrap mode, the
// value will be filled in cycles
Expand Down
32 changes: 0 additions & 32 deletions paddle/phi/kernels/impl/fill_diagonal_kernel_impl.h

This file was deleted.

0 comments on commit 839d8bb

Please sign in to comment.