未验证 提交 839d8bb3 编写于 作者: C Chen Weihang 提交者: GitHub

Fix kernels header pos error (#44902)

* fix header pos error

* fix namespace error
上级 849eccb7
......@@ -15,7 +15,6 @@
#pragma once
#include "paddle/phi/common/int_array.h"
#include "paddle/phi/kernels/affine_grid_impl.h"
namespace phi {
......
......@@ -15,7 +15,6 @@
#pragma once
#include "paddle/phi/common/int_array.h"
#include "paddle/phi/kernels/affine_grid_impl.h"
namespace phi {
......
......@@ -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 {
......
......@@ -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 {
......
......@@ -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 {
......@@ -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]);
......
......@@ -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 {
......@@ -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
......
......@@ -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>
......
......@@ -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>
......
......@@ -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
......@@ -15,6 +15,7 @@
#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"
......@@ -22,6 +23,7 @@
#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 {
......
......@@ -15,6 +15,7 @@
#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"
......@@ -22,6 +23,7 @@
#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 {
......
......@@ -18,6 +18,7 @@
#include <vector>
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/funcs/common_shape.h"
namespace phi {
......@@ -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
......
......@@ -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 {
......@@ -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
......
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// 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.
#pragma once
#include "paddle/phi/core/dense_tensor.h"
namespace phi {
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 phi
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册