Skip to content

[NPU] fix compile and update to release 2.6 #853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 20, 2023
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "Paddle"]
path = Paddle
url = https://github.com/PaddlePaddle/Paddle.git
branch = develop
branch = release/2.6
2 changes: 1 addition & 1 deletion Paddle
Submodule Paddle updated 5512 files
4 changes: 2 additions & 2 deletions backends/npu/kernels/batch_norm_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void BatchNormKernel(const Context& dev_ctx,
auto* Bias = bias.get_ptr();

phi::DenseTensor new_scale, new_bias;
const auto data_layout = phi::StringToDataLayout(data_layout_str);
const auto data_layout = common::StringToDataLayout(data_layout_str);

int C;
if (x_dims.size() == 2) {
Expand Down Expand Up @@ -308,7 +308,7 @@ void BatchNormGradKernel(
auto* Bias = bias.get_ptr();

phi::DenseTensor new_scale, new_bias;
const auto data_layout = phi::StringToDataLayout(data_layout_str);
const auto data_layout = common::StringToDataLayout(data_layout_str);

int C;
if (x_dims.size() == 2) {
Expand Down
2 changes: 1 addition & 1 deletion backends/npu/kernels/conv_transpose_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void Conv2dTransposeGradKernel(const Context& dev_ctx,
auto dilations = dilation;
if ((!dx) && (!dfilter)) return;

const phi::DataLayout data_layout = phi::StringToDataLayout(data_format);
const phi::DataLayout data_layout = common::StringToDataLayout(data_format);

auto in_dims = x.dims();
auto filter_dims = filter.dims();
Expand Down
6 changes: 4 additions & 2 deletions backends/npu/kernels/fill_diagonal_tensor_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ void FillDiagonalTensorKernel(const Context &dev_ctx,
int64_t new_dims[2], strides[2];
std::vector<int64_t> matdim;
matdim.resize(fill_dims[0]);
CalMatDims(out_dims, dim1, dim2, &offset, new_dims, strides, matdim.data());
phi::CalMatDims(
out_dims, dim1, dim2, &offset, new_dims, strides, matdim.data());
PADDLE_ENFORCE_EQ(
new_dims[0],
fill_dims[0],
Expand Down Expand Up @@ -125,7 +126,8 @@ void FillDiagonalTensorGradKernel(const Context &dev_ctx,
int64_t new_dims[2], strides[2];
std::vector<int64_t> matdim;
matdim.resize(matrows);
CalMatDims(dx_dims, dim1, dim2, &offset, new_dims, strides, matdim.data());
phi::CalMatDims(
dx_dims, dim1, dim2, &offset, new_dims, strides, matdim.data());

auto size = x_grad->numel();

Expand Down
4 changes: 2 additions & 2 deletions backends/npu/kernels/funcs/string_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ std::string GetPDTensorString(const Context& dev_ctx,

log_stream << " - place: " << print_tensor.place() << std::endl;
log_stream << " - shape: " << print_tensor.dims().to_str() << std::endl;
log_stream << " - layout: " << phi::DataLayoutToString(print_tensor.layout())
<< std::endl;
log_stream << " - layout: "
<< common::DataLayoutToString(print_tensor.layout()) << std::endl;

auto dtype = print_tensor.dtype();
log_stream << " - dtype: " << dtype << std::endl;
Expand Down
3 changes: 2 additions & 1 deletion backends/npu/kernels/group_norm_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ void GroupNormKernel(const Context& dev_ctx,
phi::DenseTensor* mean,
phi::DenseTensor* variance) {
auto x_dims = phi::vectorize(x.dims());
const phi::DataLayout data_layout_data = phi::StringToDataLayout(data_layout);
const phi::DataLayout data_layout_data =
common::StringToDataLayout(data_layout);

if (x_dims.size() > 3) {
phi::DenseTensor x_tmp(x);
Expand Down
4 changes: 2 additions & 2 deletions backends/npu/kernels/pool2d_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ void Pool2dKernel(const Context& dev_ctx,
// AdaptiveAvgPool2d only support NCHW
phi::DenseTensor transformed_input, transformed_output;
if (pooling_type == "avg" && channel_last) {
transformed_input.Resize(phi::make_dim(
transformed_input.Resize(common::make_dim(
in_x_dims[0], in_x_dims[3], in_x_dims[1], in_x_dims[2]));
dev_ctx.template Alloc<T>(&transformed_input);
transformed_output.Resize(
phi::make_dim(out_dims[0], out_dims[3], out_dims[1], out_dims[2]));
common::make_dim(out_dims[0], out_dims[3], out_dims[1], out_dims[2]));
dev_ctx.template Alloc<T>(&transformed_output);

const auto& trans_runner =
Expand Down
12 changes: 9 additions & 3 deletions backends/npu/runtime/runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ FLAGS_DEFINE_uint64(npu_profiling_dtypes,
ACL_PROF_HCCL_TRACE | ACL_PROF_RUNTIME_API,
"ACL datatypes to profile");
FLAGS_DEFINE_uint64(npu_profiling_metrics,
static_cast<uint64_t>(ACL_AICORE_ARITHMETIC_UTILIZATION),
static_cast<uint64_t>(ACL_AICORE_PIPE_UTILIZATION),
"AI Core metric to profile");

FLAGS_DEFINE_bool(set_to_1d, true, "set_to_1d");
Expand Down Expand Up @@ -199,7 +199,10 @@ aclrtStream SecondaryStream::Get(aclrtStream aicore_stream) {
void SecondaryStream::Create(aclrtStream aicore_stream) {
RUN_CHECK(aicpu_streams.find(aicore_stream) == aicpu_streams.cend());
aclrtStream aicpu_stream;
ACL_CHECK(aclrtCreateStream(&aicpu_stream));
ACL_CHECK(aclrtCreateStreamWithConfig(
reinterpret_cast<aclrtStream *>(&aicpu_stream),
0,
(ACL_STREAM_FAST_LAUNCH | ACL_STREAM_FAST_SYNC)));
aicpu_streams[aicore_stream] = aicpu_stream;
}

Expand Down Expand Up @@ -597,7 +600,10 @@ C_Status HostDeallocate(const C_Device device, void *ptr, size_t size) {
}

C_Status CreateStream(const C_Device device, C_Stream *stream) {
ACL_CHECK(aclrtCreateStream(reinterpret_cast<aclrtStream *>(stream)));
ACL_CHECK(aclrtCreateStreamWithConfig(
reinterpret_cast<aclrtStream *>(stream),
0,
(ACL_STREAM_FAST_LAUNCH | ACL_STREAM_FAST_SYNC)));
LOG_IF(INFO, FLAGS_npu_runtime_debug)
<< "[RUNTIME] CreateStream: device=" << device->id
<< ", stream=" << *stream;
Expand Down
3 changes: 3 additions & 0 deletions backends/npu/tools/disable_ut_npu
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ test_zero_dim_tensor_npu
test_momentum_op_npu
test_matmul_op_npu
test_linear_op_npu
test_compare_op_npu
test_elementwise_sub_op_npu
test_index_sample_op_npu
1 change: 0 additions & 1 deletion backends/npu/tools/pr_ci_npu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# For Paddle CI
#=================================================

set -ex

if [ -z ${PADDLE_BRANCH} ]; then
PADDLE_BRANCH="develop"
Expand Down
1 change: 1 addition & 0 deletions python/tests/auto_parallel_op_test.py