Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
d2b0d63f
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
d2b0d63f
编写于
4月 17, 2023
作者:
Z
zhangyuqin1998
提交者:
GitHub
4月 17, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename_SliceKernel (#52863)
上级
514d83de
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
85 addition
and
99 deletion
+85
-99
paddle/phi/kernels/accuracy_kernel.h
paddle/phi/kernels/accuracy_kernel.h
+7
-7
paddle/phi/kernels/cpu/accuracy_kernel.cc
paddle/phi/kernels/cpu/accuracy_kernel.cc
+8
-8
paddle/phi/kernels/cpu/slice_kernel.cc
paddle/phi/kernels/cpu/slice_kernel.cc
+1
-1
paddle/phi/kernels/gpu/accuracy_kernel.cu
paddle/phi/kernels/gpu/accuracy_kernel.cu
+8
-8
paddle/phi/kernels/gpu/qr_kernel.cu
paddle/phi/kernels/gpu/qr_kernel.cu
+6
-6
paddle/phi/kernels/gpu/slice_kernel.cu.cc
paddle/phi/kernels/gpu/slice_kernel.cu.cc
+1
-1
paddle/phi/kernels/impl/qr_grad_kernel_impl.h
paddle/phi/kernels/impl/qr_grad_kernel_impl.h
+4
-8
paddle/phi/kernels/impl/slice_kernel_impl.h
paddle/phi/kernels/impl/slice_kernel_impl.h
+8
-8
paddle/phi/kernels/impl/svd_grad_kernel_impl.h
paddle/phi/kernels/impl/svd_grad_kernel_impl.h
+8
-18
paddle/phi/kernels/onednn/slice_kernel.cc
paddle/phi/kernels/onednn/slice_kernel.cc
+9
-9
paddle/phi/kernels/slice_kernel.h
paddle/phi/kernels/slice_kernel.h
+16
-16
paddle/phi/kernels/xpu/slice_kernel.cc
paddle/phi/kernels/xpu/slice_kernel.cc
+9
-9
未找到文件。
paddle/phi/kernels/accuracy_kernel.h
浏览文件 @
d2b0d63f
...
...
@@ -20,11 +20,11 @@
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
Accuracy
Raw
Kernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
out
,
const
DenseTensor
&
indices
,
const
DenseTensor
&
label
,
DenseTensor
*
accuracy
,
DenseTensor
*
correct
,
DenseTensor
*
total
);
void
AccuracyKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
out
,
const
DenseTensor
&
indices
,
const
DenseTensor
&
label
,
DenseTensor
*
accuracy
,
DenseTensor
*
correct
,
DenseTensor
*
total
);
}
// namespace phi
paddle/phi/kernels/cpu/accuracy_kernel.cc
浏览文件 @
d2b0d63f
...
...
@@ -21,13 +21,13 @@
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
Accuracy
Raw
Kernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
inference
,
const
DenseTensor
&
indices
,
const
DenseTensor
&
label
,
DenseTensor
*
accuracy
,
DenseTensor
*
correct
,
DenseTensor
*
total
)
{
void
AccuracyKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
inference
,
const
DenseTensor
&
indices
,
const
DenseTensor
&
label
,
DenseTensor
*
accuracy
,
DenseTensor
*
correct
,
DenseTensor
*
total
)
{
int
*
correct_data
=
dev_ctx
.
template
Alloc
<
int
>(
correct
);
int
*
total_data
=
dev_ctx
.
template
Alloc
<
int
>(
total
);
float
*
accuracy_data
=
dev_ctx
.
template
Alloc
<
float
>(
accuracy
);
...
...
@@ -93,7 +93,7 @@ void AccuracyRawKernel(const Context& dev_ctx,
// TODO(add supported dtype.)
PD_REGISTER_KERNEL
(
accuracy
,
CPU
,
ALL_LAYOUT
,
phi
::
Accuracy
Raw
Kernel
,
float
,
double
)
{
accuracy
,
CPU
,
ALL_LAYOUT
,
phi
::
AccuracyKernel
,
float
,
double
)
{
kernel
->
InputAt
(
1
).
SetDataType
(
phi
::
DataType
::
INT64
);
kernel
->
InputAt
(
2
).
SetDataType
(
phi
::
DataType
::
INT64
);
kernel
->
OutputAt
(
0
).
SetDataType
(
phi
::
DataType
::
FLOAT32
);
...
...
paddle/phi/kernels/cpu/slice_kernel.cc
浏览文件 @
d2b0d63f
...
...
@@ -21,7 +21,7 @@
PD_REGISTER_KERNEL
(
slice
,
CPU
,
ALL_LAYOUT
,
phi
::
Slice
Raw
Kernel
,
phi
::
SliceKernel
,
bool
,
uint8_t
,
int
,
...
...
paddle/phi/kernels/gpu/accuracy_kernel.cu
浏览文件 @
d2b0d63f
...
...
@@ -73,13 +73,13 @@ __global__ void AccuracyCudaKernel(const int N,
}
template
<
typename
T
,
typename
Context
>
void
Accuracy
Raw
Kernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
inference
,
const
DenseTensor
&
indices
,
const
DenseTensor
&
label
,
DenseTensor
*
accuracy
,
DenseTensor
*
correct
,
DenseTensor
*
total
)
{
void
AccuracyKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
inference
,
const
DenseTensor
&
indices
,
const
DenseTensor
&
label
,
DenseTensor
*
accuracy
,
DenseTensor
*
correct
,
DenseTensor
*
total
)
{
// FIXME(typhoonzero): only support indices currently
// if add support for output values, how to detect the data type?
const
int64_t
*
indices_data
=
indices
.
data
<
int64_t
>
();
...
...
@@ -137,7 +137,7 @@ void AccuracyRawKernel(const Context& dev_ctx,
PD_REGISTER_KERNEL
(
accuracy
,
GPU
,
ALL_LAYOUT
,
phi
::
Accuracy
Raw
Kernel
,
phi
::
AccuracyKernel
,
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
,
float
,
...
...
paddle/phi/kernels/gpu/qr_kernel.cu
浏览文件 @
d2b0d63f
...
...
@@ -101,8 +101,8 @@ void QrKernel(const Context& ctx,
if
(
reduced_mode
)
{
auto
trans_qr
=
TransposeLast2Dim
<
T
,
Context
>
(
ctx
,
qr
);
auto
sliced_qr
=
Slice
Kernel
<
T
,
Context
>
(
ctx
,
trans_qr
,
{
trans_qr
.
dims
().
size
()
-
2
},
{
0
},
{
min_mn
}
,
{
1
},
{}
);
auto
sliced_qr
=
Slice
<
T
,
Context
>
(
ctx
,
trans_qr
,
{
trans_qr
.
dims
().
size
()
-
2
},
{
0
},
{
min_mn
});
auto
tmp_r
=
TrilTriu
<
T
,
Context
>
(
ctx
,
sliced_qr
,
0
,
false
);
// Transpose 'tmp_r' to retore the original row-major order
phi
::
Copy
(
ctx
,
tmp_r
,
r
->
place
(),
false
,
r
);
...
...
@@ -128,8 +128,8 @@ void QrKernel(const Context& ctx,
qr_stride
,
tau_stride
);
auto
trans_q
=
TransposeLast2Dim
<
T
,
Context
>
(
ctx
,
qr
);
auto
sliced_q
=
Slice
Kernel
<
T
,
Context
>
(
ctx
,
trans_q
,
{
trans_q
.
dims
().
size
()
-
1
},
{
0
},
{
min_mn
}
,
{
1
},
{}
);
auto
sliced_q
=
Slice
<
T
,
Context
>
(
ctx
,
trans_q
,
{
trans_q
.
dims
().
size
()
-
1
},
{
0
},
{
min_mn
});
phi
::
Copy
(
ctx
,
sliced_q
,
q
->
place
(),
false
,
q
);
}
else
{
if
(
m
>
n
)
{
...
...
@@ -170,8 +170,8 @@ void QrKernel(const Context& ctx,
qr_stride
,
tau_stride
);
auto
trans_q
=
TransposeLast2Dim
<
T
,
Context
>
(
ctx
,
qr
);
auto
sliced_q
=
Slice
Kernel
<
T
,
Context
>
(
ctx
,
trans_q
,
{
trans_q
.
dims
().
size
()
-
1
},
{
0
},
{
m
}
,
{
1
},
{}
);
auto
sliced_q
=
Slice
<
T
,
Context
>
(
ctx
,
trans_q
,
{
trans_q
.
dims
().
size
()
-
1
},
{
0
},
{
m
});
phi
::
Copy
(
ctx
,
sliced_q
,
q
->
place
(),
false
,
q
);
}
}
...
...
paddle/phi/kernels/gpu/slice_kernel.cu.cc
浏览文件 @
d2b0d63f
...
...
@@ -21,7 +21,7 @@
PD_REGISTER_KERNEL
(
slice
,
GPU
,
ALL_LAYOUT
,
phi
::
Slice
Raw
Kernel
,
phi
::
SliceKernel
,
bool
,
uint8_t
,
int
,
...
...
paddle/phi/kernels/impl/qr_grad_kernel_impl.h
浏览文件 @
d2b0d63f
...
...
@@ -149,17 +149,13 @@ void QrGradKernel(const Context& ctx,
// Calculate dX and dY individually and concatenate them to get dA
ctx
.
template
Alloc
<
phi
::
dtype
::
Real
<
T
>
>
(
&
dA
);
auto
Y
=
SliceKernel
<
T
,
Context
>
(
ctx
,
A
,
{
A
.
dims
().
size
()
-
1
},
{
m
},
{
n
},
{
1
},
{});
auto
U
=
SliceKernel
<
T
,
Context
>
(
ctx
,
R
,
{
R
.
dims
().
size
()
-
1
},
{
0
},
{
m
},
{
1
},
{});
auto
Y
=
Slice
<
T
,
Context
>
(
ctx
,
A
,
{
A
.
dims
().
size
()
-
1
},
{
m
},
{
n
});
auto
U
=
Slice
<
T
,
Context
>
(
ctx
,
R
,
{
R
.
dims
().
size
()
-
1
},
{
0
},
{
m
});
DenseTensor
dY
,
dX
,
dV
,
dR_tmp
,
dQ_prime
;
if
(
dR
.
initialized
())
{
dV
=
SliceKernel
<
T
,
Context
>
(
ctx
,
dR
,
{
dR
.
dims
().
size
()
-
1
},
{
m
},
{
n
},
{
1
},
{});
dR_tmp
=
SliceKernel
<
T
,
Context
>
(
ctx
,
dR
,
{
dR
.
dims
().
size
()
-
1
},
{
0
},
{
m
},
{
1
},
{});
dV
=
Slice
<
T
,
Context
>
(
ctx
,
dR
,
{
dR
.
dims
().
size
()
-
1
},
{
m
},
{
n
});
dR_tmp
=
Slice
<
T
,
Context
>
(
ctx
,
dR
,
{
dR
.
dims
().
size
()
-
1
},
{
0
},
{
m
});
// Y * dV^H
dQ_prime
=
Matmul
<
T
,
Context
>
(
ctx
,
Y
,
TransposeLast2Dim
<
T
,
Context
>
(
ctx
,
dV
));
...
...
paddle/phi/kernels/impl/slice_kernel_impl.h
浏览文件 @
d2b0d63f
...
...
@@ -100,14 +100,14 @@ void SliceCompute(const Context& ctx,
}
template
<
typename
T
,
typename
Context
>
void
Slice
Raw
Kernel
(
const
Context
&
ctx
,
const
DenseTensor
&
input
,
const
std
::
vector
<
int64_t
>&
axes
,
const
IntArray
&
starts_arr
,
const
IntArray
&
ends_arr
,
const
std
::
vector
<
int64_t
>&
infer_flags
,
const
std
::
vector
<
int64_t
>&
decrease_axis
,
DenseTensor
*
out
)
{
void
SliceKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
input
,
const
std
::
vector
<
int64_t
>&
axes
,
const
IntArray
&
starts_arr
,
const
IntArray
&
ends_arr
,
const
std
::
vector
<
int64_t
>&
infer_flags
,
const
std
::
vector
<
int64_t
>&
decrease_axis
,
DenseTensor
*
out
)
{
int
rank
=
input
.
dims
().
size
();
auto
&
starts
=
starts_arr
.
GetData
();
...
...
paddle/phi/kernels/impl/svd_grad_kernel_impl.h
浏览文件 @
d2b0d63f
...
...
@@ -83,27 +83,17 @@ void SvdGradKernel(const Context& dev_ctx,
DenseTensor
U
,
VH
,
dU
,
dV
,
dVH
;
if
(
full_matrices
)
{
// if full_matrices is set, slice the U and VT to k columns
U
=
Slice
Kernel
<
T
,
Context
>
(
dev_ctx
,
u
,
{
u
.
dims
().
size
()
-
1
},
{
0
},
{
k
},
{
1
},
{});
VH
=
SliceKernel
<
T
,
Context
>
(
dev_ctx
,
vh
,
{
vh
.
dims
().
size
()
-
2
},
{
0
},
{
k
},
{
1
},
{
});
U
=
Slice
<
T
,
Context
>
(
dev_ctx
,
u
,
{
u
.
dims
().
size
()
-
1
},
{
0
},
{
k
});
// If m < n for input matrices A, we partition A = [X|Y] and R = [U|V]
VH
=
Slice
<
T
,
Context
>
(
dev_ctx
,
vh
,
{
vh
.
dims
().
size
()
-
2
},
{
0
},
{
k
});
if
(
u_grad
.
get_ptr
()
!=
nullptr
)
{
dU
=
SliceKernel
<
T
,
Context
>
(
dev_ctx
,
*
(
u_grad
.
get_ptr
()),
{
u
.
dims
().
size
()
-
1
},
{
0
},
{
k
},
{
1
},
{});
dU
=
Slice
<
T
,
Context
>
(
dev_ctx
,
*
(
u_grad
.
get_ptr
()),
{
u
.
dims
().
size
()
-
1
},
{
0
},
{
k
});
}
if
(
vh_grad
.
get_ptr
()
!=
nullptr
)
{
dVH
=
SliceKernel
<
T
,
Context
>
(
dev_ctx
,
*
(
vh_grad
.
get_ptr
()),
{
vh
.
dims
().
size
()
-
2
},
{
0
},
{
k
},
{
1
},
{});
dVH
=
Slice
<
T
,
Context
>
(
dev_ctx
,
*
(
vh_grad
.
get_ptr
()),
{
vh
.
dims
().
size
()
-
2
},
{
0
},
{
k
});
}
}
else
{
U
=
u
;
...
...
paddle/phi/kernels/onednn/slice_kernel.cc
浏览文件 @
d2b0d63f
...
...
@@ -20,14 +20,14 @@
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
Slice
Raw
Kernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
std
::
vector
<
int64_t
>&
axes
,
const
IntArray
&
starts
,
const
IntArray
&
ends
,
const
std
::
vector
<
int64_t
>&
infer_flags
,
const
std
::
vector
<
int64_t
>&
decrease_axis
,
DenseTensor
*
out
)
{
void
SliceKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
const
std
::
vector
<
int64_t
>&
axes
,
const
IntArray
&
starts
,
const
IntArray
&
ends
,
const
std
::
vector
<
int64_t
>&
infer_flags
,
const
std
::
vector
<
int64_t
>&
decrease_axis
,
DenseTensor
*
out
)
{
const
auto
&
onednn_engine
=
dev_ctx
.
GetEngine
();
auto
x_vec_dims
=
vectorize
(
x
.
dims
());
...
...
@@ -102,7 +102,7 @@ void SliceRawKernel(const Context& dev_ctx,
PD_REGISTER_KERNEL
(
slice
,
OneDNN
,
ONEDNN
,
phi
::
Slice
Raw
Kernel
,
phi
::
SliceKernel
,
float
,
int8_t
,
uint8_t
,
...
...
paddle/phi/kernels/slice_kernel.h
浏览文件 @
d2b0d63f
...
...
@@ -22,14 +22,14 @@
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
Slice
Raw
Kernel
(
const
Context
&
ctx
,
const
DenseTensor
&
input
,
const
std
::
vector
<
int64_t
>&
axes
,
const
IntArray
&
starts
,
const
IntArray
&
ends
,
const
std
::
vector
<
int64_t
>&
infer_flags
,
const
std
::
vector
<
int64_t
>&
decrease_axis
,
DenseTensor
*
out
);
void
SliceKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
input
,
const
std
::
vector
<
int64_t
>&
axes
,
const
IntArray
&
starts
,
const
IntArray
&
ends
,
const
std
::
vector
<
int64_t
>&
infer_flags
,
const
std
::
vector
<
int64_t
>&
decrease_axis
,
DenseTensor
*
out
);
template
<
typename
T
,
typename
Context
>
void
SliceArrayKernel
(
const
Context
&
dev_ctx
,
...
...
@@ -45,18 +45,18 @@ void SliceArrayDenseKernel(const Context& dev_ctx,
DenseTensor
*
out
);
template
<
typename
T
,
typename
Context
>
DenseTensor
SliceKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
input
,
const
std
::
vector
<
int64_t
>&
axes
,
const
IntArray
&
starts
,
const
IntArray
&
ends
,
const
std
::
vector
<
int64_t
>&
infer_flags
,
const
std
::
vector
<
int64_t
>&
decrease_axis
)
{
DenseTensor
Slice
(
const
Context
&
ctx
,
const
DenseTensor
&
input
,
const
std
::
vector
<
int64_t
>&
axes
,
const
IntArray
&
starts
,
const
IntArray
&
ends
)
{
DenseTensor
dense_out
;
MetaTensor
meta_out
(
&
dense_out
);
std
::
vector
<
int64_t
>
infer_flags
=
{
1
};
std
::
vector
<
int64_t
>
decrease_axis
=
{};
SliceRawInferMeta
(
input
,
axes
,
starts
,
ends
,
infer_flags
,
decrease_axis
,
&
meta_out
);
Slice
Raw
Kernel
<
T
,
Context
>
(
SliceKernel
<
T
,
Context
>
(
ctx
,
input
,
axes
,
starts
,
ends
,
infer_flags
,
decrease_axis
,
&
dense_out
);
return
dense_out
;
}
...
...
paddle/phi/kernels/xpu/slice_kernel.cc
浏览文件 @
d2b0d63f
...
...
@@ -21,14 +21,14 @@
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
Slice
Raw
Kernel
(
const
Context
&
ctx
,
const
DenseTensor
&
input
,
const
std
::
vector
<
int64_t
>&
axes
,
const
IntArray
&
starts_t
,
const
IntArray
&
ends_t
,
const
std
::
vector
<
int64_t
>&
infer_flags
,
const
std
::
vector
<
int64_t
>&
decrease_axis
,
DenseTensor
*
out
)
{
void
SliceKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
input
,
const
std
::
vector
<
int64_t
>&
axes
,
const
IntArray
&
starts_t
,
const
IntArray
&
ends_t
,
const
std
::
vector
<
int64_t
>&
infer_flags
,
const
std
::
vector
<
int64_t
>&
decrease_axis
,
DenseTensor
*
out
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
// Step 1: Get the accurate attribute value of starts and ends
...
...
@@ -110,7 +110,7 @@ void SliceRawKernel(const Context& ctx,
PD_REGISTER_KERNEL
(
slice
,
XPU
,
ALL_LAYOUT
,
phi
::
Slice
Raw
Kernel
,
phi
::
SliceKernel
,
float
,
int
,
phi
::
dtype
::
float16
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录