Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
f3650201
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
f3650201
编写于
11月 17, 2022
作者:
Y
YuanRisheng
提交者:
GitHub
11月 17, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[PHI]Standardise some C++ API (Part5) (#47860)
* standard api * fix xpu bugs
上级
c374894d
变更
52
隐藏空白更改
内联
并排
Showing
52 changed file
with
309 addition
and
179 deletion
+309
-179
paddle/fluid/operators/fused/fused_dropout_test.h
paddle/fluid/operators/fused/fused_dropout_test.h
+0
-1
paddle/fluid/operators/tril_triu_op.cc
paddle/fluid/operators/tril_triu_op.cc
+1
-1
paddle/phi/api/yaml/legacy_backward.yaml
paddle/phi/api/yaml/legacy_backward.yaml
+16
-6
paddle/phi/api/yaml/legacy_ops.yaml
paddle/phi/api/yaml/legacy_ops.yaml
+14
-5
paddle/phi/infermeta/multiary.cc
paddle/phi/infermeta/multiary.cc
+2
-6
paddle/phi/infermeta/multiary.h
paddle/phi/infermeta/multiary.h
+2
-6
paddle/phi/infermeta/ternary.cc
paddle/phi/infermeta/ternary.cc
+0
-1
paddle/phi/infermeta/ternary.h
paddle/phi/infermeta/ternary.h
+0
-1
paddle/phi/infermeta/unary.cc
paddle/phi/infermeta/unary.cc
+13
-5
paddle/phi/infermeta/unary.h
paddle/phi/infermeta/unary.h
+9
-5
paddle/phi/kernels/cpu/hsigmoid_loss_grad.h
paddle/phi/kernels/cpu/hsigmoid_loss_grad.h
+0
-4
paddle/phi/kernels/cpu/hsigmoid_loss_grad_kernel.cc
paddle/phi/kernels/cpu/hsigmoid_loss_grad_kernel.cc
+0
-8
paddle/phi/kernels/cpu/hsigmoid_loss_kernel.cc
paddle/phi/kernels/cpu/hsigmoid_loss_kernel.cc
+2
-6
paddle/phi/kernels/cpu/layer_norm_grad_kernel.cc
paddle/phi/kernels/cpu/layer_norm_grad_kernel.cc
+0
-1
paddle/phi/kernels/cpu/layer_norm_kernel.cc
paddle/phi/kernels/cpu/layer_norm_kernel.cc
+0
-1
paddle/phi/kernels/cpu/matrix_rank_kernel.cc
paddle/phi/kernels/cpu/matrix_rank_kernel.cc
+1
-1
paddle/phi/kernels/cpu/tril_triu_grad_kernel.cc
paddle/phi/kernels/cpu/tril_triu_grad_kernel.cc
+23
-1
paddle/phi/kernels/cpu/tril_triu_kernel.cc
paddle/phi/kernels/cpu/tril_triu_kernel.cc
+23
-1
paddle/phi/kernels/gpu/layer_norm_grad_kernel.cu
paddle/phi/kernels/gpu/layer_norm_grad_kernel.cu
+0
-1
paddle/phi/kernels/gpu/layer_norm_kernel.cu
paddle/phi/kernels/gpu/layer_norm_kernel.cu
+0
-1
paddle/phi/kernels/gpu/lstsq_kernel.cu
paddle/phi/kernels/gpu/lstsq_kernel.cu
+3
-3
paddle/phi/kernels/gpu/matrix_rank_kernel.cu
paddle/phi/kernels/gpu/matrix_rank_kernel.cu
+1
-1
paddle/phi/kernels/gpu/qr_kernel.cu
paddle/phi/kernels/gpu/qr_kernel.cu
+3
-3
paddle/phi/kernels/gpu/tril_triu_grad_kernel.cu
paddle/phi/kernels/gpu/tril_triu_grad_kernel.cu
+23
-1
paddle/phi/kernels/gpu/tril_triu_kernel.cu
paddle/phi/kernels/gpu/tril_triu_kernel.cu
+23
-1
paddle/phi/kernels/hsigmoid_loss_grad_kernel.h
paddle/phi/kernels/hsigmoid_loss_grad_kernel.h
+0
-4
paddle/phi/kernels/hsigmoid_loss_kernel.h
paddle/phi/kernels/hsigmoid_loss_kernel.h
+2
-6
paddle/phi/kernels/impl/qr_grad_kernel_impl.h
paddle/phi/kernels/impl/qr_grad_kernel_impl.h
+3
-3
paddle/phi/kernels/impl/tril_triu_grad_kernel_impl.h
paddle/phi/kernels/impl/tril_triu_grad_kernel_impl.h
+22
-6
paddle/phi/kernels/impl/tril_triu_kernel_impl.h
paddle/phi/kernels/impl/tril_triu_kernel_impl.h
+22
-6
paddle/phi/kernels/layer_norm_grad_kernel.h
paddle/phi/kernels/layer_norm_grad_kernel.h
+0
-1
paddle/phi/kernels/layer_norm_kernel.h
paddle/phi/kernels/layer_norm_kernel.h
+0
-1
paddle/phi/kernels/matrix_rank_kernel.h
paddle/phi/kernels/matrix_rank_kernel.h
+1
-1
paddle/phi/kernels/selected_rows/hsigmoid_loss_grad_kernel.cc
...le/phi/kernels/selected_rows/hsigmoid_loss_grad_kernel.cc
+0
-8
paddle/phi/kernels/selected_rows/hsigmoid_loss_grad_kernel.h
paddle/phi/kernels/selected_rows/hsigmoid_loss_grad_kernel.h
+0
-4
paddle/phi/kernels/tril_triu_grad_kernel.h
paddle/phi/kernels/tril_triu_grad_kernel.h
+13
-1
paddle/phi/kernels/tril_triu_kernel.h
paddle/phi/kernels/tril_triu_kernel.h
+19
-7
paddle/phi/kernels/xpu/layer_norm_grad_kernel.cc
paddle/phi/kernels/xpu/layer_norm_grad_kernel.cc
+0
-1
paddle/phi/kernels/xpu/layer_norm_kernel.cc
paddle/phi/kernels/xpu/layer_norm_kernel.cc
+0
-1
paddle/phi/kernels/xpu/tril_triu_grad_kernel.cc
paddle/phi/kernels/xpu/tril_triu_grad_kernel.cc
+26
-6
paddle/phi/kernels/xpu/tril_triu_kernel.cc
paddle/phi/kernels/xpu/tril_triu_kernel.cc
+25
-6
paddle/phi/ops/compat/hierarchical_sigmoid_sig.cc
paddle/phi/ops/compat/hierarchical_sigmoid_sig.cc
+4
-22
paddle/phi/ops/compat/layer_norm_sig.cc
paddle/phi/ops/compat/layer_norm_sig.cc
+2
-2
paddle/phi/ops/compat/matrix_rank_sig.cc
paddle/phi/ops/compat/matrix_rank_sig.cc
+1
-1
paddle/phi/ops/compat/tril_triu_sig.cc
paddle/phi/ops/compat/tril_triu_sig.cc
+2
-5
python/paddle/fluid/dygraph/nn.py
python/paddle/fluid/dygraph/nn.py
+0
-1
python/paddle/fluid/tests/unittests/test_hsigmoid_op.py
python/paddle/fluid/tests/unittests/test_hsigmoid_op.py
+2
-5
python/paddle/fluid/tests/unittests/test_matrix_rank_op.py
python/paddle/fluid/tests/unittests/test_matrix_rank_op.py
+1
-1
python/paddle/nn/functional/loss.py
python/paddle/nn/functional/loss.py
+2
-6
python/paddle/nn/functional/norm.py
python/paddle/nn/functional/norm.py
+1
-1
python/paddle/tensor/creation.py
python/paddle/tensor/creation.py
+1
-1
python/paddle/tensor/linalg.py
python/paddle/tensor/linalg.py
+1
-1
未找到文件。
paddle/fluid/operators/fused/fused_dropout_test.h
浏览文件 @
f3650201
...
...
@@ -193,7 +193,6 @@ void LayerNorm(const std::vector<LayerNormParamType<T>> &scale,
bias_opt
,
1e-5
,
1
,
false
,
tensor_y
,
tensor_mean
,
tensor_variance
);
...
...
paddle/fluid/operators/tril_triu_op.cc
浏览文件 @
f3650201
...
...
@@ -93,7 +93,7 @@ namespace ops = paddle::operators;
namespace
plat
=
paddle
::
platform
;
DECLARE_INFER_SHAPE_FUNCTOR
(
tril_triu
,
TrilTriuInferShapeFunctor
,
PD_INFER_META
(
phi
::
TrilInferMeta
));
PD_INFER_META
(
phi
::
Tril
Triu
InferMeta
));
REGISTER_OPERATOR
(
tril_triu
,
ops
::
TrilTriuOp
,
ops
::
TrilTriuOpMaker
,
...
...
paddle/phi/api/yaml/legacy_backward.yaml
浏览文件 @
f3650201
...
...
@@ -655,8 +655,8 @@
inplace
:
(out_grad -> x_grad)
-
backward_op
:
hsigmoid_loss_grad
forward
:
hsigmoid_loss (Tensor x, Tensor
w, Tensor label, Tensor path, Tensor code, Tensor bias, int num_classes, bool remote_prefetch, int trainer_id, int64_t[] height_sections, str[] epmap, str[] table_names
, bool is_sparse) -> Tensor(out), Tensor(pre_out), Tensor(w_out)
args
:
(Tensor x, Tensor w, Tensor label, Tensor path, Tensor code, Tensor bias, Tensor pre_out, Tensor out_grad, int num_classes, bool remote_prefetch,
int trainer_id, int64_t[] height_sections, str[] epmap, str[] table_names,
bool is_sparse)
forward
:
hsigmoid_loss (Tensor x, Tensor
label, Tensor w, Tensor bias, Tensor path, Tensor code, int num_classes, bool remote_prefetch
, bool is_sparse) -> Tensor(out), Tensor(pre_out), Tensor(w_out)
args
:
(Tensor x, Tensor w, Tensor label, Tensor path, Tensor code, Tensor bias, Tensor pre_out, Tensor out_grad, int num_classes, bool remote_prefetch, bool is_sparse)
output
:
Tensor(x_grad), Tensor(w_grad), Tensor(bias_grad)
infer_meta
:
func
:
GeneralTernaryGradInferMeta
...
...
@@ -764,8 +764,8 @@
func
:
label_smooth_grad
-
backward_op
:
layer_norm_grad
forward
:
layer_norm (Tensor x, Tensor scale, Tensor bias, float epsilon, int begin_norm_axis
, bool is_test
) -> Tensor(out), Tensor(mean), Tensor(variance)
args
:
(Tensor x, Tensor scale, Tensor bias, Tensor mean, Tensor variance, Tensor out_grad, float epsilon, int begin_norm_axis
, bool is_test
)
forward
:
layer_norm (Tensor x, Tensor scale, Tensor bias, float epsilon, int begin_norm_axis) -> Tensor(out), Tensor(mean), Tensor(variance)
args
:
(Tensor x, Tensor scale, Tensor bias, Tensor mean, Tensor variance, Tensor out_grad, float epsilon, int begin_norm_axis)
output
:
Tensor(x_grad), Tensor(scale_grad), Tensor(bias_grad)
infer_meta
:
func
:
LayerNormGradInferMeta
...
...
@@ -1830,8 +1830,8 @@
func
:
triangular_solve_grad
-
backward_op
:
tril_grad
forward
:
tril(Tensor x, int diagonal
, bool lower
) -> Tensor(out)
args
:
(Tensor out_grad, int diagonal
, bool lower
)
forward
:
tril(Tensor x, int diagonal) -> Tensor(out)
args
:
(Tensor out_grad, int diagonal)
output
:
Tensor(x_grad)
infer_meta
:
func
:
UnchangedInferMeta
...
...
@@ -1851,6 +1851,16 @@
func
:
trilinear_interp_grad
data_type
:
output_grad
-
backward_op
:
triu_grad
forward
:
triu(Tensor x, int diagonal) -> Tensor(out)
args
:
(Tensor out_grad, int diagonal)
output
:
Tensor(x_grad)
infer_meta
:
func
:
UnchangedInferMeta
param
:
[
out_grad
]
kernel
:
func
:
triu_grad
-
backward_op
:
unbind_grad
forward
:
unbind (Tensor input, int axis) -> Tensor[](out)
args
:
(Tensor[] out_grad, int axis)
...
...
paddle/phi/api/yaml/legacy_ops.yaml
浏览文件 @
f3650201
...
...
@@ -934,7 +934,7 @@
backward
:
hardtanh_grad
-
op
:
hsigmoid_loss
args
:
(Tensor x, Tensor
w, Tensor label, Tensor path, Tensor code, Tensor bias, int num_classes, bool remote_prefetch, int trainer_id, int64_t[] height_sections, str[] epmap, str[] table_names
, bool is_sparse)
args
:
(Tensor x, Tensor
label, Tensor w, Tensor bias, Tensor path, Tensor code, int num_classes, bool remote_prefetch
, bool is_sparse)
output
:
Tensor(out), Tensor(pre_out), Tensor(w_out)
infer_meta
:
func
:
HSigmoidLossInferMeta
...
...
@@ -1091,7 +1091,7 @@
inplace
:
(param -> param_out), (moment1 -> moment1_out), (moment2 -> moment2_out), (beta1_pow -> beta1_pow_out), (beta2_pow -> beta2_pow_out), (master_param -> master_param_outs)
-
op
:
layer_norm
args
:
(Tensor x, Tensor scale, Tensor bias, float epsilon, int begin_norm_axis
, bool is_test
)
args
:
(Tensor x, Tensor scale, Tensor bias, float epsilon, int begin_norm_axis)
output
:
Tensor(out), Tensor(mean), Tensor(variance)
infer_meta
:
func
:
LayerNormInferMeta
...
...
@@ -1294,11 +1294,11 @@
backward
:
matrix_power_grad
-
op
:
matrix_rank
args
:
(Tensor x, float tol, bool
use_default_tol=true, bool hermitian=fals
e)
args
:
(Tensor x, float tol, bool
hermitian=false, bool use_default_tol=tru
e)
output
:
Tensor(out)
infer_meta
:
func
:
MatrixRankInferMeta
param
:
[
x
,
use_default_tol
,
hermitian
]
param
:
[
x
,
hermitian
,
use_default_tol
]
kernel
:
func
:
matrix_rank
...
...
@@ -2226,7 +2226,7 @@
backward
:
triangular_solve_grad
-
op
:
tril
args
:
(Tensor x, int diagonal
, bool lower
)
args
:
(Tensor x, int diagonal)
output
:
Tensor(out)
infer_meta
:
func
:
TrilInferMeta
...
...
@@ -2257,6 +2257,15 @@
data_type
:
x
backward
:
trilinear_interp_grad
-
op
:
triu
args
:
(Tensor x, int diagonal)
output
:
Tensor(out)
infer_meta
:
func
:
TriuInferMeta
kernel
:
func
:
triu
backward
:
triu_grad
-
op
:
triu_indices
args
:
(int row, int col, int offset, DataType dtype, Place place={})
output
:
Tensor(out)
...
...
paddle/phi/infermeta/multiary.cc
浏览文件 @
f3650201
...
...
@@ -1330,17 +1330,13 @@ void GraphSampleNeighborsInferMeta(const MetaTensor& row,
}
void
HSigmoidLossInferMeta
(
const
MetaTensor
&
x
,
const
MetaTensor
&
w
,
const
MetaTensor
&
label
,
const
MetaTensor
&
w
,
const
MetaTensor
&
bias
,
const
MetaTensor
&
path
,
const
MetaTensor
&
code
,
const
MetaTensor
&
bias
,
int
num_classes
,
bool
remote_prefetch
,
int
trainer_id
,
const
std
::
vector
<
int64_t
>&
height_sections
,
const
std
::
vector
<
std
::
string
>&
epmap
,
const
std
::
vector
<
std
::
string
>&
table_names
,
bool
is_sparse
,
MetaTensor
*
out
,
MetaTensor
*
pre_out
,
...
...
paddle/phi/infermeta/multiary.h
浏览文件 @
f3650201
...
...
@@ -288,17 +288,13 @@ void GraphSampleNeighborsInferMeta(const MetaTensor& row,
MetaTensor
*
out_eids
);
void
HSigmoidLossInferMeta
(
const
MetaTensor
&
x
,
const
MetaTensor
&
w
,
const
MetaTensor
&
label
,
const
MetaTensor
&
w
,
const
MetaTensor
&
bias
,
const
MetaTensor
&
path
,
const
MetaTensor
&
code
,
const
MetaTensor
&
bias
,
int
num_classes
,
bool
remote_prefetch
,
int
trainer_id
,
const
std
::
vector
<
int64_t
>&
height_sections
,
const
std
::
vector
<
std
::
string
>&
epmap
,
const
std
::
vector
<
std
::
string
>&
table_names
,
bool
is_sparse
,
MetaTensor
*
out
,
MetaTensor
*
pre_out
,
...
...
paddle/phi/infermeta/ternary.cc
浏览文件 @
f3650201
...
...
@@ -498,7 +498,6 @@ void LayerNormInferMeta(const MetaTensor& x,
const
MetaTensor
&
bias
,
float
epsilon
,
int
begin_norm_axis
,
bool
is_test
,
MetaTensor
*
out
,
MetaTensor
*
mean
,
MetaTensor
*
variance
,
...
...
paddle/phi/infermeta/ternary.h
浏览文件 @
f3650201
...
...
@@ -87,7 +87,6 @@ void LayerNormInferMeta(const MetaTensor& x,
const
MetaTensor
&
bias
,
float
epsilon
,
int
begin_norm_axis
,
bool
is_test
,
MetaTensor
*
out
,
MetaTensor
*
mean
,
MetaTensor
*
variance
,
...
...
paddle/phi/infermeta/unary.cc
浏览文件 @
f3650201
...
...
@@ -1882,8 +1882,8 @@ void LUInferMeta(const MetaTensor& x,
}
void
MatrixRankInferMeta
(
const
MetaTensor
&
x
,
bool
use_default_tol
,
bool
hermitian
,
bool
use_default_tol
,
MetaTensor
*
out
)
{
auto
dim_x
=
x
.
dims
();
PADDLE_ENFORCE_GE
(
dim_x
.
size
(),
...
...
@@ -4156,10 +4156,10 @@ void UnbindInferMeta(const MetaTensor& x,
}
}
void
TrilInferMeta
(
const
MetaTensor
&
x
,
int
diagonal
,
bool
lower
,
MetaTensor
*
out
)
{
void
Tril
Triu
InferMeta
(
const
MetaTensor
&
x
,
int
diagonal
,
bool
lower
,
MetaTensor
*
out
)
{
const
auto
&
x_dims
=
x
.
dims
();
PADDLE_ENFORCE_GE
(
x_dims
.
size
(),
2
,
...
...
@@ -4170,6 +4170,14 @@ void TrilInferMeta(const MetaTensor& x,
out
->
set_dtype
(
x
.
dtype
());
}
void
TrilInferMeta
(
const
MetaTensor
&
x
,
int
diagonal
,
MetaTensor
*
out
)
{
TrilTriuInferMeta
(
x
,
diagonal
,
true
,
out
);
}
void
TriuInferMeta
(
const
MetaTensor
&
x
,
int
diagonal
,
MetaTensor
*
out
)
{
TrilTriuInferMeta
(
x
,
diagonal
,
false
,
out
);
}
void
UnchangedInferMeta
(
const
MetaTensor
&
x
,
MetaTensor
*
out
)
{
out
->
share_meta
(
x
);
}
...
...
paddle/phi/infermeta/unary.h
浏览文件 @
f3650201
...
...
@@ -264,8 +264,8 @@ void LUInferMeta(const MetaTensor& x,
void
MatrixPowerInferMeta
(
const
MetaTensor
&
x
,
int
n
,
MetaTensor
*
out
);
void
MatrixRankInferMeta
(
const
MetaTensor
&
x
,
bool
use_default_tol
,
bool
hermitian
,
bool
use_default_tol
,
MetaTensor
*
out
);
void
MaxOutInferMeta
(
const
MetaTensor
&
x
,
...
...
@@ -601,10 +601,14 @@ void TransposeGradInferMeta(const MetaTensor& x,
const
std
::
vector
<
int
>&
axis
,
MetaTensor
*
out
);
void
TrilInferMeta
(
const
MetaTensor
&
x
,
int
diagonal
,
bool
lower
,
MetaTensor
*
out
);
void
TrilInferMeta
(
const
MetaTensor
&
x
,
int
diagonal
,
MetaTensor
*
out
);
void
TriuInferMeta
(
const
MetaTensor
&
x
,
int
diagonal
,
MetaTensor
*
out
);
void
TrilTriuInferMeta
(
const
MetaTensor
&
x
,
int
diagonal
,
bool
lower
,
MetaTensor
*
out
);
void
UnbindInferMeta
(
const
MetaTensor
&
x
,
int
axis
,
...
...
paddle/phi/kernels/cpu/hsigmoid_loss_grad.h
浏览文件 @
f3650201
...
...
@@ -37,10 +37,6 @@ void HSigmoidLossGradKernelImpl(const Context& ctx,
const
DenseTensor
&
out_grad
,
int
num_classes
,
bool
remote_prefetch
,
int
trainer_id
,
const
std
::
vector
<
int64_t
>&
height_sections
,
const
std
::
vector
<
std
::
string
>&
epmap
,
const
std
::
vector
<
std
::
string
>&
table_names
,
bool
is_sparse
,
DenseTensor
*
x_grad
,
DenseTensor
*
w_grad
,
...
...
paddle/phi/kernels/cpu/hsigmoid_loss_grad_kernel.cc
浏览文件 @
f3650201
...
...
@@ -32,10 +32,6 @@ void HSigmoidLossGradKernel(const Context& ctx,
const
DenseTensor
&
out_grad
,
int
num_classes
,
bool
remote_prefetch
,
int
trainer_id
,
const
std
::
vector
<
int64_t
>&
height_sections
,
const
std
::
vector
<
std
::
string
>&
epmap
,
const
std
::
vector
<
std
::
string
>&
table_names
,
bool
is_sparse
,
DenseTensor
*
x_grad
,
DenseTensor
*
w_grad
,
...
...
@@ -51,10 +47,6 @@ void HSigmoidLossGradKernel(const Context& ctx,
out_grad
,
num_classes
,
remote_prefetch
,
trainer_id
,
height_sections
,
epmap
,
table_names
,
is_sparse
,
x_grad
,
w_grad
,
...
...
paddle/phi/kernels/cpu/hsigmoid_loss_kernel.cc
浏览文件 @
f3650201
...
...
@@ -30,17 +30,13 @@ namespace math = paddle::operators::math;
template
<
typename
T
,
typename
Context
>
void
HSigmoidLossKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
w
,
const
DenseTensor
&
label
,
const
DenseTensor
&
w
,
const
paddle
::
optional
<
DenseTensor
>&
bias
,
const
paddle
::
optional
<
DenseTensor
>&
path
,
const
paddle
::
optional
<
DenseTensor
>&
code
,
const
paddle
::
optional
<
DenseTensor
>&
bias
,
int
num_classes
,
bool
remote_prefetch
,
int
trainer_id
,
const
std
::
vector
<
int64_t
>&
height_sections
,
const
std
::
vector
<
std
::
string
>&
epmap
,
const
std
::
vector
<
std
::
string
>&
table_names
,
bool
is_sparse
,
DenseTensor
*
out
,
DenseTensor
*
pre_out
,
...
...
paddle/phi/kernels/cpu/layer_norm_grad_kernel.cc
浏览文件 @
f3650201
...
...
@@ -40,7 +40,6 @@ void LayerNormGradKernel(const Context& dev_ctx,
const
DenseTensor
&
out_grad
,
float
epsilon
,
int
begin_norm_axis
,
bool
is_test
,
DenseTensor
*
x_grad
,
DenseTensor
*
scale_grad
,
DenseTensor
*
bias_grad
)
{
...
...
paddle/phi/kernels/cpu/layer_norm_kernel.cc
浏览文件 @
f3650201
...
...
@@ -35,7 +35,6 @@ void LayerNormKernel(const Context& dev_ctx,
const
paddle
::
optional
<
DenseTensor
>&
bias_opt
,
float
epsilon
,
int
begin_norm_axis
,
bool
is_test
,
DenseTensor
*
y
,
DenseTensor
*
mean
,
DenseTensor
*
var
)
{
...
...
paddle/phi/kernels/cpu/matrix_rank_kernel.cc
浏览文件 @
f3650201
...
...
@@ -24,8 +24,8 @@ template <typename T, typename Context>
void
MatrixRankKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
float
tol
,
bool
use_default_tol
,
bool
hermitian
,
bool
use_default_tol
,
DenseTensor
*
out
)
{
DenseTensor
atol_tensor
;
if
(
use_default_tol
)
{
...
...
paddle/phi/kernels/cpu/tril_grad_kernel.cc
→
paddle/phi/kernels/cpu/tril_
triu_
grad_kernel.cc
浏览文件 @
f3650201
...
...
@@ -14,7 +14,29 @@
#include "paddle/phi/backends/cpu/cpu_context.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/tril_grad_kernel_impl.h"
#include "paddle/phi/kernels/impl/tril_triu_grad_kernel_impl.h"
PD_REGISTER_KERNEL
(
tril_triu_grad
,
CPU
,
ALL_LAYOUT
,
phi
::
TrilTriuGradKernel
,
bool
,
float
,
double
,
int
,
int64_t
,
phi
::
dtype
::
float16
)
{}
PD_REGISTER_KERNEL
(
triu_grad
,
CPU
,
ALL_LAYOUT
,
phi
::
TriuGradKernel
,
bool
,
float
,
double
,
int
,
int64_t
,
phi
::
dtype
::
float16
)
{}
PD_REGISTER_KERNEL
(
tril_grad
,
CPU
,
...
...
paddle/phi/kernels/cpu/tril_kernel.cc
→
paddle/phi/kernels/cpu/tril_
triu_
kernel.cc
浏览文件 @
f3650201
...
...
@@ -14,7 +14,29 @@
#include "paddle/phi/backends/cpu/cpu_context.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/tril_kernel_impl.h"
#include "paddle/phi/kernels/impl/tril_triu_kernel_impl.h"
PD_REGISTER_KERNEL
(
tril_triu
,
CPU
,
ALL_LAYOUT
,
phi
::
TrilTriuKernel
,
bool
,
float
,
double
,
int
,
int64_t
,
phi
::
dtype
::
float16
)
{}
PD_REGISTER_KERNEL
(
triu
,
CPU
,
ALL_LAYOUT
,
phi
::
TriuKernel
,
bool
,
float
,
double
,
int
,
int64_t
,
phi
::
dtype
::
float16
)
{}
PD_REGISTER_KERNEL
(
tril
,
CPU
,
...
...
paddle/phi/kernels/gpu/layer_norm_grad_kernel.cu
浏览文件 @
f3650201
...
...
@@ -31,7 +31,6 @@ void LayerNormGradKernel(const Context &dev_ctx,
const
DenseTensor
&
out_grad
,
float
epsilon
,
int
begin_norm_axis
,
bool
is_test
,
DenseTensor
*
x_grad
,
DenseTensor
*
scale_grad
,
DenseTensor
*
bias_grad
)
{
...
...
paddle/phi/kernels/gpu/layer_norm_kernel.cu
浏览文件 @
f3650201
...
...
@@ -61,7 +61,6 @@ void LayerNormKernel(const Context &dev_ctx,
const
paddle
::
optional
<
DenseTensor
>
&
bias_opt
,
float
epsilon
,
int
begin_norm_axis
,
bool
is_test
,
DenseTensor
*
y
,
DenseTensor
*
mean
,
DenseTensor
*
var
)
{
...
...
paddle/phi/kernels/gpu/lstsq_kernel.cu
浏览文件 @
f3650201
...
...
@@ -23,7 +23,7 @@
#include "paddle/phi/kernels/funcs/slice.h"
#include "paddle/phi/kernels/impl/lstsq_kernel_impl.h"
#include "paddle/phi/kernels/impl/qr_kernel_impl.h"
#include "paddle/phi/kernels/impl/tril_kernel_impl.h"
#include "paddle/phi/kernels/impl/tril_
triu_
kernel_impl.h"
#include "paddle/phi/kernels/lstsq_kernel.h"
#include "paddle/phi/kernels/matmul_kernel.h"
#include "paddle/phi/kernels/transpose_kernel.h"
...
...
@@ -110,7 +110,7 @@ void LstsqKernel(const Context& dev_ctx,
DenseTensor
*
res_r
=
new
DenseTensor
();
res_r
->
Resize
(
phi
::
make_ddim
({
batch_count
,
min_mn
,
min_mn
}));
dev_ctx
.
template
Alloc
<
T
>(
res_r
);
phi
::
TrilKernel
<
T
>
(
dev_ctx
,
slice_r
,
0
,
false
,
res_r
);
phi
::
Tril
Triu
Kernel
<
T
>
(
dev_ctx
,
slice_r
,
0
,
false
,
res_r
);
DenseTensor
trans_y
=
phi
::
TransposeLast2Dim
<
T
>
(
dev_ctx
,
tmp_y
);
DenseTensor
slice_y
=
...
...
@@ -135,7 +135,7 @@ void LstsqKernel(const Context& dev_ctx,
DenseTensor
*
res_r
=
new
DenseTensor
();
res_r
->
Resize
(
phi
::
make_ddim
({
batch_count
,
min_mn
,
min_mn
}));
dev_ctx
.
template
Alloc
<
T
>(
res_r
);
phi
::
TrilKernel
<
T
>
(
dev_ctx
,
slice_r
,
0
,
false
,
res_r
);
phi
::
Tril
Triu
Kernel
<
T
>
(
dev_ctx
,
slice_r
,
0
,
false
,
res_r
);
phi
::
TriangularSolveKernel
<
T
,
Context
>
(
dev_ctx
,
*
res_r
,
*
new_y
,
true
,
true
,
false
,
solution
);
...
...
paddle/phi/kernels/gpu/matrix_rank_kernel.cu
浏览文件 @
f3650201
...
...
@@ -27,8 +27,8 @@ template <typename T, typename Context>
void
MatrixRankKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
float
tol
,
bool
use_default_tol
,
bool
hermitian
,
bool
use_default_tol
,
DenseTensor
*
out
)
{
DenseTensor
atol_tensor
;
if
(
use_default_tol
)
{
...
...
paddle/phi/kernels/gpu/qr_kernel.cu
浏览文件 @
f3650201
...
...
@@ -31,7 +31,7 @@
#include "paddle/phi/kernels/qr_kernel.h"
#include "paddle/phi/kernels/slice_kernel.h"
#include "paddle/phi/kernels/transpose_kernel.h"
#include "paddle/phi/kernels/tril_kernel.h"
#include "paddle/phi/kernels/tril_
triu_
kernel.h"
namespace
phi
{
...
...
@@ -103,12 +103,12 @@ void QrKernel(const Context& ctx,
auto
trans_qr
=
TransposeLast2Dim
<
T
,
Context
>
(
ctx
,
qr
);
auto
sliced_qr
=
SliceKernel
<
T
,
Context
>
(
ctx
,
trans_qr
,
{
trans_qr
.
dims
().
size
()
-
2
},
{
0
},
{
min_mn
},
{
1
},
{});
auto
tmp_r
=
Tril
<
T
,
Context
>
(
ctx
,
sliced_qr
,
0
,
false
);
auto
tmp_r
=
Tril
Triu
<
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
);
}
else
{
auto
trans_qr
=
TransposeLast2Dim
<
T
,
Context
>
(
ctx
,
qr
);
auto
tmp_r
=
Tril
<
T
,
Context
>
(
ctx
,
trans_qr
,
0
,
false
);
auto
tmp_r
=
Tril
Triu
<
T
,
Context
>
(
ctx
,
trans_qr
,
0
,
false
);
// Transpose 'tmp_r' to retore the original row-major order
phi
::
Copy
(
ctx
,
tmp_r
,
r
->
place
(),
false
,
r
);
}
...
...
paddle/phi/kernels/gpu/tril_grad_kernel.cu
→
paddle/phi/kernels/gpu/tril_
triu_
grad_kernel.cu
浏览文件 @
f3650201
...
...
@@ -14,7 +14,7 @@
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/tril_grad_kernel_impl.h"
#include "paddle/phi/kernels/impl/tril_
triu_
grad_kernel_impl.h"
PD_REGISTER_KERNEL
(
tril_grad
,
GPU
,
...
...
@@ -26,3 +26,25 @@ PD_REGISTER_KERNEL(tril_grad,
int
,
int64_t
,
phi
::
dtype
::
float16
)
{}
PD_REGISTER_KERNEL
(
triu_grad
,
GPU
,
ALL_LAYOUT
,
phi
::
TriuGradKernel
,
bool
,
float
,
double
,
int
,
int64_t
,
phi
::
dtype
::
float16
)
{}
PD_REGISTER_KERNEL
(
tril_triu_grad
,
GPU
,
ALL_LAYOUT
,
phi
::
TrilTriuGradKernel
,
bool
,
float
,
double
,
int
,
int64_t
,
phi
::
dtype
::
float16
)
{}
paddle/phi/kernels/gpu/tril_kernel.cu
→
paddle/phi/kernels/gpu/tril_
triu_
kernel.cu
浏览文件 @
f3650201
...
...
@@ -14,7 +14,29 @@
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/tril_kernel_impl.h"
#include "paddle/phi/kernels/impl/tril_triu_kernel_impl.h"
PD_REGISTER_KERNEL
(
tril_triu
,
GPU
,
ALL_LAYOUT
,
phi
::
TrilTriuKernel
,
bool
,
float
,
double
,
int
,
int64_t
,
phi
::
dtype
::
float16
)
{}
PD_REGISTER_KERNEL
(
triu
,
GPU
,
ALL_LAYOUT
,
phi
::
TriuKernel
,
bool
,
float
,
double
,
int
,
int64_t
,
phi
::
dtype
::
float16
)
{}
PD_REGISTER_KERNEL
(
tril
,
GPU
,
...
...
paddle/phi/kernels/hsigmoid_loss_grad_kernel.h
浏览文件 @
f3650201
...
...
@@ -30,10 +30,6 @@ void HSigmoidLossGradKernel(const Context& ctx,
const
DenseTensor
&
out_grad
,
int
num_classes
,
bool
remote_prefetch
,
int
trainer_id
,
const
std
::
vector
<
int64_t
>&
height_sections
,
const
std
::
vector
<
std
::
string
>&
epmap
,
const
std
::
vector
<
std
::
string
>&
table_names
,
bool
is_sparse
,
DenseTensor
*
x_grad
,
DenseTensor
*
w_grad
,
...
...
paddle/phi/kernels/hsigmoid_loss_kernel.h
浏览文件 @
f3650201
...
...
@@ -21,17 +21,13 @@ namespace phi {
template
<
typename
T
,
typename
Context
>
void
HSigmoidLossKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
x
,
const
DenseTensor
&
w
,
const
DenseTensor
&
label
,
const
DenseTensor
&
w
,
const
paddle
::
optional
<
DenseTensor
>&
bias
,
const
paddle
::
optional
<
DenseTensor
>&
path
,
const
paddle
::
optional
<
DenseTensor
>&
code
,
const
paddle
::
optional
<
DenseTensor
>&
bias
,
int
num_classes
,
bool
remote_prefetch
,
int
trainer_id
,
const
std
::
vector
<
int64_t
>&
height_sections
,
const
std
::
vector
<
std
::
string
>&
epmap
,
const
std
::
vector
<
std
::
string
>&
table_names
,
bool
is_sparse
,
DenseTensor
*
out
,
DenseTensor
*
pre_out
,
...
...
paddle/phi/kernels/impl/qr_grad_kernel_impl.h
浏览文件 @
f3650201
...
...
@@ -29,7 +29,7 @@
#include "paddle/phi/kernels/slice_kernel.h"
#include "paddle/phi/kernels/transpose_kernel.h"
#include "paddle/phi/kernels/triangular_solve_kernel.h"
#include "paddle/phi/kernels/tril_kernel.h"
#include "paddle/phi/kernels/tril_
triu_
kernel.h"
namespace
phi
{
...
...
@@ -116,8 +116,8 @@ void QrGradKernel(const Context& ctx,
DenseTensor
M_tmp1
=
Subtract
<
T
,
Context
>
(
ctx
,
R_term
,
Q_term
);
// Compute M = (tril(M) + tril(M).mH()) * 0.5 Identity
DenseTensor
M_tril_0
=
Tril
<
T
,
Context
>
(
ctx
,
M_tmp1
,
0
,
true
);
DenseTensor
M_tril_1
=
Tril
<
T
,
Context
>
(
ctx
,
M_tmp1
,
-
1
,
true
);
DenseTensor
M_tril_0
=
Tril
Triu
<
T
,
Context
>
(
ctx
,
M_tmp1
,
0
,
true
);
DenseTensor
M_tril_1
=
Tril
Triu
<
T
,
Context
>
(
ctx
,
M_tmp1
,
-
1
,
true
);
DenseTensor
M
=
Add
<
T
,
Context
>
(
ctx
,
M_tril_0
,
TransposeLast2Dim
<
T
,
Context
>
(
ctx
,
M_tril_1
));
...
...
paddle/phi/kernels/impl/tril_grad_kernel_impl.h
→
paddle/phi/kernels/impl/tril_
triu_
grad_kernel_impl.h
浏览文件 @
f3650201
...
...
@@ -16,16 +16,16 @@
#include "paddle/phi/kernels/funcs/for_range.h"
#include "paddle/phi/kernels/funcs/tril_triu_compute.h"
#include "paddle/phi/kernels/tril_grad_kernel.h"
#include "paddle/phi/kernels/tril_
triu_
grad_kernel.h"
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
TrilGradKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
out_grad
,
int
diagonal
,
bool
lower
,
DenseTensor
*
x_grad
)
{
void
Tril
Triu
GradKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
out_grad
,
int
diagonal
,
bool
lower
,
DenseTensor
*
x_grad
)
{
const
auto
*
dout_data
=
out_grad
.
data
<
T
>
();
auto
*
dx_data
=
ctx
.
template
Alloc
<
T
>(
x_grad
);
...
...
@@ -40,4 +40,20 @@ void TrilGradKernel(const Context& ctx,
for_range
(
tril_triu_grad_computer
);
}
template
<
typename
T
,
typename
Context
>
void
TrilGradKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
out_grad
,
int
diagonal
,
DenseTensor
*
x_grad
)
{
TrilTriuGradKernel
<
T
,
Context
>
(
ctx
,
out_grad
,
diagonal
,
true
,
x_grad
);
}
template
<
typename
T
,
typename
Context
>
void
TriuGradKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
out_grad
,
int
diagonal
,
DenseTensor
*
x_grad
)
{
TrilTriuGradKernel
<
T
,
Context
>
(
ctx
,
out_grad
,
diagonal
,
false
,
x_grad
);
}
}
// namespace phi
paddle/phi/kernels/impl/tril_kernel_impl.h
→
paddle/phi/kernels/impl/tril_
triu_
kernel_impl.h
浏览文件 @
f3650201
...
...
@@ -16,16 +16,16 @@
#include "paddle/phi/kernels/funcs/for_range.h"
#include "paddle/phi/kernels/funcs/tril_triu_compute.h"
#include "paddle/phi/kernels/tril_kernel.h"
#include "paddle/phi/kernels/tril_
triu_
kernel.h"
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
TrilKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
x
,
int
diagonal
,
bool
lower
,
DenseTensor
*
out
)
{
void
Tril
Triu
Kernel
(
const
Context
&
ctx
,
const
DenseTensor
&
x
,
int
diagonal
,
bool
lower
,
DenseTensor
*
out
)
{
const
auto
*
x_data
=
x
.
data
<
T
>
();
auto
*
out_data
=
ctx
.
template
Alloc
<
T
>(
out
);
...
...
@@ -39,4 +39,20 @@ void TrilKernel(const Context& ctx,
for_range
(
tril_triu_computer
);
}
template
<
typename
T
,
typename
Context
>
void
TrilKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
x
,
int
diagonal
,
DenseTensor
*
out
)
{
TrilTriuKernel
<
T
,
Context
>
(
ctx
,
x
,
diagonal
,
true
,
out
);
}
template
<
typename
T
,
typename
Context
>
void
TriuKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
x
,
int
diagonal
,
DenseTensor
*
out
)
{
TrilTriuKernel
<
T
,
Context
>
(
ctx
,
x
,
diagonal
,
false
,
out
);
}
}
// namespace phi
paddle/phi/kernels/layer_norm_grad_kernel.h
浏览文件 @
f3650201
...
...
@@ -28,7 +28,6 @@ void LayerNormGradKernel(const Context& ctx,
const
DenseTensor
&
out_grad
,
float
epsilon
,
int
begin_norm_axis
,
bool
is_test
,
DenseTensor
*
x_grad
,
DenseTensor
*
scale_grad
,
DenseTensor
*
bias_grad
);
...
...
paddle/phi/kernels/layer_norm_kernel.h
浏览文件 @
f3650201
...
...
@@ -26,7 +26,6 @@ void LayerNormKernel(const Context& ctx,
const
paddle
::
optional
<
DenseTensor
>&
bias
,
float
epsilon
,
int
begin_norm_axis
,
bool
is_test
,
DenseTensor
*
out
,
DenseTensor
*
mean
,
DenseTensor
*
variance
);
...
...
paddle/phi/kernels/matrix_rank_kernel.h
浏览文件 @
f3650201
...
...
@@ -22,8 +22,8 @@ template <typename T, typename Context>
void
MatrixRankKernel
(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
float
tol
,
bool
use_default_tol
,
bool
hermitian
,
bool
use_default_tol
,
DenseTensor
*
out
);
}
// namespace phi
paddle/phi/kernels/selected_rows/hsigmoid_loss_grad_kernel.cc
浏览文件 @
f3650201
...
...
@@ -47,10 +47,6 @@ void HSigmoidLossGradKernel(const Context& ctx,
const
DenseTensor
&
out_grad
,
int
num_classes
,
bool
remote_prefetch
,
int
trainer_id
,
const
std
::
vector
<
int64_t
>&
height_sections
,
const
std
::
vector
<
std
::
string
>&
epmap
,
const
std
::
vector
<
std
::
string
>&
table_names
,
bool
is_sparse
,
DenseTensor
*
x_grad
,
SelectedRows
*
w_grad
,
...
...
@@ -77,10 +73,6 @@ void HSigmoidLossGradKernel(const Context& ctx,
out_grad
,
num_classes
,
remote_prefetch
,
trainer_id
,
height_sections
,
epmap
,
table_names
,
is_sparse
,
x_grad
,
w_grad_value
,
...
...
paddle/phi/kernels/selected_rows/hsigmoid_loss_grad_kernel.h
浏览文件 @
f3650201
...
...
@@ -32,10 +32,6 @@ void HSigmoidLossGradKernel(const Context& ctx,
const
DenseTensor
&
out_grad
,
int
num_classes
,
bool
remote_prefetch
,
int
trainer_id
,
const
std
::
vector
<
int64_t
>&
height_sections
,
const
std
::
vector
<
std
::
string
>&
epmap
,
const
std
::
vector
<
std
::
string
>&
table_names
,
bool
is_sparse
,
DenseTensor
*
x_grad
,
SelectedRows
*
w_grad
,
...
...
paddle/phi/kernels/tril_grad_kernel.h
→
paddle/phi/kernels/tril_
triu_
grad_kernel.h
浏览文件 @
f3650201
...
...
@@ -18,11 +18,23 @@
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
TrilTriuGradKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
out_grad
,
int
diagonal
,
bool
lower
,
DenseTensor
*
x_grad
);
template
<
typename
T
,
typename
Context
>
void
TrilGradKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
out_grad
,
int
diagonal
,
bool
lower
,
DenseTensor
*
x_grad
);
template
<
typename
T
,
typename
Context
>
void
TriuGradKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
out_grad
,
int
diagonal
,
DenseTensor
*
x_grad
);
}
// namespace phi
paddle/phi/kernels/tril_kernel.h
→
paddle/phi/kernels/tril_
triu_
kernel.h
浏览文件 @
f3650201
...
...
@@ -19,22 +19,34 @@
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
TrilTriuKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
x
,
int
diagonal
,
bool
lower
,
DenseTensor
*
out
);
template
<
typename
T
,
typename
Context
>
void
TrilKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
x
,
int
diagonal
,
bool
lower
,
DenseTensor
*
out
);
template
<
typename
T
,
typename
Context
>
DenseTensor
Tril
(
const
Context
&
ctx
,
const
DenseTensor
&
x
,
int
diagonal
,
bool
lower
)
{
void
TriuKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
x
,
int
diagonal
,
DenseTensor
*
out
);
template
<
typename
T
,
typename
Context
>
DenseTensor
TrilTriu
(
const
Context
&
ctx
,
const
DenseTensor
&
x
,
int
diagonal
,
bool
lower
)
{
DenseTensor
dense_out
;
MetaTensor
meta_out
(
&
dense_out
);
TrilInferMeta
(
x
,
diagonal
,
lower
,
&
meta_out
);
TrilKernel
<
T
,
Context
>
(
ctx
,
x
,
diagonal
,
lower
,
&
dense_out
);
Tril
Triu
InferMeta
(
x
,
diagonal
,
lower
,
&
meta_out
);
Tril
Triu
Kernel
<
T
,
Context
>
(
ctx
,
x
,
diagonal
,
lower
,
&
dense_out
);
return
dense_out
;
}
...
...
paddle/phi/kernels/xpu/layer_norm_grad_kernel.cc
浏览文件 @
f3650201
...
...
@@ -29,7 +29,6 @@ void LayerNormGradKernel(const Context& ctx,
const
DenseTensor
&
out_grad
,
float
epsilon
,
int
begin_norm_axis
,
bool
is_test
,
DenseTensor
*
x_grad
,
DenseTensor
*
scale_grad
,
DenseTensor
*
bias_grad
)
{
...
...
paddle/phi/kernels/xpu/layer_norm_kernel.cc
浏览文件 @
f3650201
...
...
@@ -26,7 +26,6 @@ void LayerNormKernel(const Context& ctx,
const
paddle
::
optional
<
DenseTensor
>&
bias
,
float
epsilon
,
int
begin_norm_axis
,
bool
is_test
,
DenseTensor
*
out
,
DenseTensor
*
mean
,
DenseTensor
*
variance
)
{
...
...
paddle/phi/kernels/xpu/tril_grad_kernel.cc
→
paddle/phi/kernels/xpu/tril_
triu_
grad_kernel.cc
浏览文件 @
f3650201
...
...
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/phi/kernels/tril_grad_kernel.h"
#include "paddle/phi/kernels/tril_
triu_
grad_kernel.h"
#include "paddle/phi/backends/xpu/enforce_xpu.h"
#include "paddle/phi/core/kernel_registry.h"
...
...
@@ -20,11 +20,11 @@
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
TrilGradKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
out_grad
,
int
diagonal
,
bool
lower
,
DenseTensor
*
x_grad
)
{
void
Tril
Triu
GradKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
out_grad
,
int
diagonal
,
bool
lower
,
DenseTensor
*
x_grad
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
ctx
.
template
Alloc
<
T
>(
x_grad
);
auto
dy_shape
=
vectorize
<
int
>
(
out_grad
.
dims
());
...
...
@@ -46,7 +46,27 @@ void TrilGradKernel(const Context& ctx,
}
}
template
<
typename
T
,
typename
Context
>
void
TrilGradKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
out_grad
,
int
diagonal
,
DenseTensor
*
x_grad
)
{
TrilTriuGradKernel
<
T
,
Context
>
(
ctx
,
out_grad
,
diagonal
,
true
,
x_grad
);
}
template
<
typename
T
,
typename
Context
>
void
TriuGradKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
out_grad
,
int
diagonal
,
DenseTensor
*
x_grad
)
{
TrilTriuGradKernel
<
T
,
Context
>
(
ctx
,
out_grad
,
diagonal
,
false
,
x_grad
);
}
}
// namespace phi
PD_REGISTER_KERNEL
(
tril_grad
,
XPU
,
ALL_LAYOUT
,
phi
::
TrilGradKernel
,
int
,
float
)
{}
PD_REGISTER_KERNEL
(
triu_grad
,
XPU
,
ALL_LAYOUT
,
phi
::
TriuGradKernel
,
int
,
float
)
{}
PD_REGISTER_KERNEL
(
tril_triu_grad
,
XPU
,
ALL_LAYOUT
,
phi
::
TrilTriuGradKernel
,
int
,
float
)
{}
paddle/phi/kernels/xpu/tril_kernel.cc
→
paddle/phi/kernels/xpu/tril_
triu_
kernel.cc
浏览文件 @
f3650201
...
...
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/phi/kernels/tril_kernel.h"
#include "paddle/phi/kernels/tril_
triu_
kernel.h"
#include "paddle/phi/backends/xpu/enforce_xpu.h"
#include "paddle/phi/core/kernel_registry.h"
...
...
@@ -20,11 +20,11 @@
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
TrilKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
x
,
int
diagonal
,
bool
lower
,
DenseTensor
*
out
)
{
void
Tril
Triu
Kernel
(
const
Context
&
ctx
,
const
DenseTensor
&
x
,
int
diagonal
,
bool
lower
,
DenseTensor
*
out
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
ctx
.
template
Alloc
<
T
>(
out
);
auto
xshape
=
vectorize
<
int
>
(
x
.
dims
());
...
...
@@ -46,6 +46,25 @@ void TrilKernel(const Context& ctx,
}
}
template
<
typename
T
,
typename
Context
>
void
TrilKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
x
,
int
diagonal
,
DenseTensor
*
out
)
{
TrilTriuKernel
<
T
,
Context
>
(
ctx
,
x
,
diagonal
,
true
,
out
);
}
template
<
typename
T
,
typename
Context
>
void
TriuKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
x
,
int
diagonal
,
DenseTensor
*
out
)
{
TrilTriuKernel
<
T
,
Context
>
(
ctx
,
x
,
diagonal
,
false
,
out
);
}
}
// namespace phi
PD_REGISTER_KERNEL
(
tril_triu
,
XPU
,
ALL_LAYOUT
,
phi
::
TrilTriuKernel
,
int
,
float
)
{}
PD_REGISTER_KERNEL
(
tril
,
XPU
,
ALL_LAYOUT
,
phi
::
TrilKernel
,
int
,
float
)
{}
PD_REGISTER_KERNEL
(
triu
,
XPU
,
ALL_LAYOUT
,
phi
::
TriuKernel
,
int
,
float
)
{}
paddle/phi/ops/compat/hierarchical_sigmoid_sig.cc
浏览文件 @
f3650201
...
...
@@ -19,14 +19,8 @@ namespace phi {
KernelSignature
HierarchicalSigmoidOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
)
{
return
KernelSignature
(
"hsigmoid_loss"
,
{
"X"
,
"W"
,
"Label"
,
"PathTable"
,
"PathCode"
,
"Bias"
},
{
"num_classes"
,
"remote_prefetch"
,
"trainer_id"
,
"height_sections"
,
"epmap"
,
"table_names"
,
"is_sparse"
},
{
"X"
,
"Label"
,
"W"
,
"Bias"
,
"PathTable"
,
"PathCode"
},
{
"num_classes"
,
"remote_prefetch"
,
"is_sparse"
},
{
"Out"
,
"PreOut"
,
"W_Out"
});
}
...
...
@@ -42,13 +36,7 @@ KernelSignature HierarchicalSigmoidGradOpArgumentMapping(
"Bias"
,
"PreOut"
,
"Out@GRAD"
},
{
"num_classes"
,
"remote_prefetch"
,
"trainer_id"
,
"height_sections"
,
"epmap"
,
"table_names"
,
"is_sparse"
},
{
"num_classes"
,
"remote_prefetch"
,
"is_sparse"
},
{
"X@GRAD"
,
"W@GRAD"
,
"Bias@GRAD"
});
}
else
if
(
ctx
.
IsSelectedRowsOutput
(
"W@GRAD"
))
{
return
KernelSignature
(
"hsigmoid_loss_grad_sr"
,
...
...
@@ -60,13 +48,7 @@ KernelSignature HierarchicalSigmoidGradOpArgumentMapping(
"Bias"
,
"PreOut"
,
"Out@GRAD"
},
{
"num_classes"
,
"remote_prefetch"
,
"trainer_id"
,
"height_sections"
,
"epmap"
,
"table_names"
,
"is_sparse"
},
{
"num_classes"
,
"remote_prefetch"
,
"is_sparse"
},
{
"X@GRAD"
,
"W@GRAD"
,
"Bias@GRAD"
});
}
else
{
return
KernelSignature
(
"unregistered"
,
{},
{},
{});
...
...
paddle/phi/ops/compat/layer_norm_sig.cc
浏览文件 @
f3650201
...
...
@@ -19,7 +19,7 @@ namespace phi {
KernelSignature
LayerNormOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
)
{
return
KernelSignature
(
"layer_norm"
,
{
"X"
,
"Scale"
,
"Bias"
},
{
"epsilon"
,
"begin_norm_axis"
,
"is_test"
},
{
"epsilon"
,
"begin_norm_axis"
},
{
"Y"
,
"Mean"
,
"Variance"
});
}
...
...
@@ -27,7 +27,7 @@ KernelSignature LayerNormGradOpArgumentMapping(
const
ArgumentMappingContext
&
ctx
)
{
return
KernelSignature
(
"layer_norm_grad"
,
{
"X"
,
"Scale"
,
"Bias"
,
"Mean"
,
"Variance"
,
"Y@GRAD"
},
{
"epsilon"
,
"begin_norm_axis"
,
"is_test"
},
{
"epsilon"
,
"begin_norm_axis"
},
{
"X@GRAD"
,
"Scale@GRAD"
,
"Bias@GRAD"
});
}
...
...
paddle/phi/ops/compat/matrix_rank_sig.cc
浏览文件 @
f3650201
...
...
@@ -28,8 +28,8 @@ KernelSignature MatrixRankOpArgumentMapping(const ArgumentMappingContext& ctx) {
{
"X"
},
{
"tol"
,
"use_default_tol"
,
"hermitian"
,
"use_default_tol"
,
},
{
"Out"
});
}
...
...
paddle/phi/ops/compat/tril_triu_sig.cc
浏览文件 @
f3650201
...
...
@@ -17,19 +17,16 @@ limitations under the License. */
namespace
phi
{
KernelSignature
TrilTriuOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
)
{
return
KernelSignature
(
"tril"
,
{
"X"
},
{
"diagonal"
,
"lower"
},
{
"Out"
});
return
KernelSignature
(
"tril
_triu
"
,
{
"X"
},
{
"diagonal"
,
"lower"
},
{
"Out"
});
}
KernelSignature
TrilTriuGradOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
)
{
return
KernelSignature
(
"tril_grad"
,
{
"Out@GRAD"
},
{
"diagonal"
,
"lower"
},
{
"X@GRAD"
});
"tril_
triu_
grad"
,
{
"Out@GRAD"
},
{
"diagonal"
,
"lower"
},
{
"X@GRAD"
});
}
}
// namespace phi
PD_REGISTER_BASE_KERNEL_NAME
(
tril_triu
,
tril
);
PD_REGISTER_BASE_KERNEL_NAME
(
tril_triu_grad
,
tril_grad
);
PD_REGISTER_ARG_MAPPING_FN
(
tril_triu
,
phi
::
TrilTriuOpArgumentMapping
);
PD_REGISTER_ARG_MAPPING_FN
(
tril_triu_grad
,
phi
::
TrilTriuGradOpArgumentMapping
);
python/paddle/fluid/dygraph/nn.py
浏览文件 @
f3650201
...
...
@@ -1782,7 +1782,6 @@ class LayerNorm(layers.Layer):
self
.
bias
,
self
.
_epsilon
,
self
.
_begin_norm_axis
,
False
,
)
return
dygraph_utils
.
_append_activation_in_dygraph
(
pre_act
,
act
=
self
.
_act
...
...
python/paddle/fluid/tests/unittests/test_hsigmoid_op.py
浏览文件 @
f3650201
...
...
@@ -170,18 +170,15 @@ def hsigmoidWithCustomTree(
def
python_api
(
input
,
weight
,
label
,
weight
,
bias
=
None
,
path_table
=
None
,
path_code
=
None
,
bias
=
None
,
num_classes
=-
1
,
is_sparse
=
False
,
remote_prefetch
=
False
,
):
assert
(
is_sparse
==
remote_prefetch
),
"is_sparse is equal to remote_prefetch in dygraph."
return
paddle
.
nn
.
functional
.
hsigmoid_loss
(
input
,
label
,
...
...
python/paddle/fluid/tests/unittests/test_matrix_rank_op.py
浏览文件 @
f3650201
...
...
@@ -26,7 +26,7 @@ SEED = 2049
np
.
random
.
seed
(
SEED
)
def
matrix_rank_wraper
(
x
,
tol
=
None
,
use_default_tol
=
True
,
hermitian
=
Fals
e
):
def
matrix_rank_wraper
(
x
,
tol
=
None
,
hermitian
=
False
,
use_default_tol
=
Tru
e
):
return
paddle
.
linalg
.
matrix_rank
(
x
,
tol
,
hermitian
)
...
...
python/paddle/nn/functional/loss.py
浏览文件 @
f3650201
...
...
@@ -1017,17 +1017,13 @@ def hsigmoid_loss(
if
in_dygraph_mode
():
out
,
_
,
_
=
_C_ops
.
hsigmoid_loss
(
input
,
weight
,
label
,
weight
,
bias
,
path_table
,
path_code
,
bias
,
num_classes
,
is_sparse
,
0
,
[],
[],
[],
is_sparse
,
)
return
out
...
...
python/paddle/nn/functional/norm.py
浏览文件 @
f3650201
...
...
@@ -385,7 +385,7 @@ def layer_norm(
pre_act
,
_
,
_
,
)
=
_C_ops
.
layer_norm
(
x
,
weight
,
bias
,
epsilon
,
begin_norm_axis
,
False
)
)
=
_C_ops
.
layer_norm
(
x
,
weight
,
bias
,
epsilon
,
begin_norm_axis
)
return
dygraph_utils
.
_append_activation_in_dygraph
(
pre_act
,
act
=
None
)
...
...
python/paddle/tensor/creation.py
浏览文件 @
f3650201
...
...
@@ -1183,7 +1183,7 @@ def triu(x, diagonal=0, name=None):
"""
if
in_dygraph_mode
():
return
_C_ops
.
tri
l
(
x
,
diagonal
,
False
)
return
_C_ops
.
tri
u
(
x
,
diagonal
,
False
)
if
_in_legacy_dygraph
():
op
=
getattr
(
_legacy_C_ops
,
'tril_triu'
)
...
...
python/paddle/tensor/linalg.py
浏览文件 @
f3650201
...
...
@@ -1601,7 +1601,7 @@ def matrix_rank(x, tol=None, hermitian=False, name=None):
else
:
tol_attr
=
float
(
tol
)
use_default_tol
=
False
return
_C_ops
.
matrix_rank
(
x
,
tol_attr
,
use_default_tol
,
hermitian
)
return
_C_ops
.
matrix_rank
(
x
,
tol_attr
,
hermitian
,
use_default_tol
)
if
_in_legacy_dygraph
():
if
tol
is
None
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录