Skip to content

Commit eedb71e

Browse files
authored
[NPU] fix compile and update to release 2.6 (#853)
1 parent 15d4633 commit eedb71e

File tree

12 files changed

+28
-16
lines changed

12 files changed

+28
-16
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "Paddle"]
22
path = Paddle
33
url = https://github.com/PaddlePaddle/Paddle.git
4-
branch = develop
4+
branch = release/2.6

Paddle

Submodule Paddle updated 5512 files

backends/npu/kernels/batch_norm_kernel.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void BatchNormKernel(const Context& dev_ctx,
6161
auto* Bias = bias.get_ptr();
6262

6363
phi::DenseTensor new_scale, new_bias;
64-
const auto data_layout = phi::StringToDataLayout(data_layout_str);
64+
const auto data_layout = common::StringToDataLayout(data_layout_str);
6565

6666
int C;
6767
if (x_dims.size() == 2) {
@@ -308,7 +308,7 @@ void BatchNormGradKernel(
308308
auto* Bias = bias.get_ptr();
309309

310310
phi::DenseTensor new_scale, new_bias;
311-
const auto data_layout = phi::StringToDataLayout(data_layout_str);
311+
const auto data_layout = common::StringToDataLayout(data_layout_str);
312312

313313
int C;
314314
if (x_dims.size() == 2) {

backends/npu/kernels/conv_transpose_kernel.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void Conv2dTransposeGradKernel(const Context& dev_ctx,
119119
auto dilations = dilation;
120120
if ((!dx) && (!dfilter)) return;
121121

122-
const phi::DataLayout data_layout = phi::StringToDataLayout(data_format);
122+
const phi::DataLayout data_layout = common::StringToDataLayout(data_format);
123123

124124
auto in_dims = x.dims();
125125
auto filter_dims = filter.dims();

backends/npu/kernels/fill_diagonal_tensor_kernel.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ void FillDiagonalTensorKernel(const Context &dev_ctx,
4040
int64_t new_dims[2], strides[2];
4141
std::vector<int64_t> matdim;
4242
matdim.resize(fill_dims[0]);
43-
CalMatDims(out_dims, dim1, dim2, &offset, new_dims, strides, matdim.data());
43+
phi::CalMatDims(
44+
out_dims, dim1, dim2, &offset, new_dims, strides, matdim.data());
4445
PADDLE_ENFORCE_EQ(
4546
new_dims[0],
4647
fill_dims[0],
@@ -125,7 +126,8 @@ void FillDiagonalTensorGradKernel(const Context &dev_ctx,
125126
int64_t new_dims[2], strides[2];
126127
std::vector<int64_t> matdim;
127128
matdim.resize(matrows);
128-
CalMatDims(dx_dims, dim1, dim2, &offset, new_dims, strides, matdim.data());
129+
phi::CalMatDims(
130+
dx_dims, dim1, dim2, &offset, new_dims, strides, matdim.data());
129131

130132
auto size = x_grad->numel();
131133

backends/npu/kernels/funcs/string_helper.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ std::string GetPDTensorString(const Context& dev_ctx,
173173

174174
log_stream << " - place: " << print_tensor.place() << std::endl;
175175
log_stream << " - shape: " << print_tensor.dims().to_str() << std::endl;
176-
log_stream << " - layout: " << phi::DataLayoutToString(print_tensor.layout())
177-
<< std::endl;
176+
log_stream << " - layout: "
177+
<< common::DataLayoutToString(print_tensor.layout()) << std::endl;
178178

179179
auto dtype = print_tensor.dtype();
180180
log_stream << " - dtype: " << dtype << std::endl;

backends/npu/kernels/group_norm_kernel.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ void GroupNormKernel(const Context& dev_ctx,
152152
phi::DenseTensor* mean,
153153
phi::DenseTensor* variance) {
154154
auto x_dims = phi::vectorize(x.dims());
155-
const phi::DataLayout data_layout_data = phi::StringToDataLayout(data_layout);
155+
const phi::DataLayout data_layout_data =
156+
common::StringToDataLayout(data_layout);
156157

157158
if (x_dims.size() > 3) {
158159
phi::DenseTensor x_tmp(x);

backends/npu/kernels/pool2d_kernel.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ void Pool2dKernel(const Context& dev_ctx,
164164
// AdaptiveAvgPool2d only support NCHW
165165
phi::DenseTensor transformed_input, transformed_output;
166166
if (pooling_type == "avg" && channel_last) {
167-
transformed_input.Resize(phi::make_dim(
167+
transformed_input.Resize(common::make_dim(
168168
in_x_dims[0], in_x_dims[3], in_x_dims[1], in_x_dims[2]));
169169
dev_ctx.template Alloc<T>(&transformed_input);
170170
transformed_output.Resize(
171-
phi::make_dim(out_dims[0], out_dims[3], out_dims[1], out_dims[2]));
171+
common::make_dim(out_dims[0], out_dims[3], out_dims[1], out_dims[2]));
172172
dev_ctx.template Alloc<T>(&transformed_output);
173173

174174
const auto& trans_runner =

backends/npu/runtime/runtime.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ FLAGS_DEFINE_uint64(npu_profiling_dtypes,
3434
ACL_PROF_HCCL_TRACE | ACL_PROF_RUNTIME_API,
3535
"ACL datatypes to profile");
3636
FLAGS_DEFINE_uint64(npu_profiling_metrics,
37-
static_cast<uint64_t>(ACL_AICORE_ARITHMETIC_UTILIZATION),
37+
static_cast<uint64_t>(ACL_AICORE_PIPE_UTILIZATION),
3838
"AI Core metric to profile");
3939

4040
FLAGS_DEFINE_bool(set_to_1d, true, "set_to_1d");
@@ -199,7 +199,10 @@ aclrtStream SecondaryStream::Get(aclrtStream aicore_stream) {
199199
void SecondaryStream::Create(aclrtStream aicore_stream) {
200200
RUN_CHECK(aicpu_streams.find(aicore_stream) == aicpu_streams.cend());
201201
aclrtStream aicpu_stream;
202-
ACL_CHECK(aclrtCreateStream(&aicpu_stream));
202+
ACL_CHECK(aclrtCreateStreamWithConfig(
203+
reinterpret_cast<aclrtStream *>(&aicpu_stream),
204+
0,
205+
(ACL_STREAM_FAST_LAUNCH | ACL_STREAM_FAST_SYNC)));
203206
aicpu_streams[aicore_stream] = aicpu_stream;
204207
}
205208

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

599602
C_Status CreateStream(const C_Device device, C_Stream *stream) {
600-
ACL_CHECK(aclrtCreateStream(reinterpret_cast<aclrtStream *>(stream)));
603+
ACL_CHECK(aclrtCreateStreamWithConfig(
604+
reinterpret_cast<aclrtStream *>(stream),
605+
0,
606+
(ACL_STREAM_FAST_LAUNCH | ACL_STREAM_FAST_SYNC)));
601607
LOG_IF(INFO, FLAGS_npu_runtime_debug)
602608
<< "[RUNTIME] CreateStream: device=" << device->id
603609
<< ", stream=" << *stream;

backends/npu/tools/disable_ut_npu

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ test_zero_dim_tensor_npu
99
test_momentum_op_npu
1010
test_matmul_op_npu
1111
test_linear_op_npu
12+
test_compare_op_npu
13+
test_elementwise_sub_op_npu
14+
test_index_sample_op_npu

0 commit comments

Comments
 (0)