Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
1712e212
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1712e212
编写于
1月 10, 2023
作者:
W
Weilong Wu
提交者:
GitHub
1月 10, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Eager] polish several ops (#49612)
* [Eager] polish several ops * rm useless code
上级
a6bd6957
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
21 addition
and
21 deletion
+21
-21
python/paddle/nn/functional/distance.py
python/paddle/nn/functional/distance.py
+4
-3
python/paddle/signal.py
python/paddle/signal.py
+0
-3
python/paddle/tensor/creation.py
python/paddle/tensor/creation.py
+1
-1
python/paddle/tensor/manipulation.py
python/paddle/tensor/manipulation.py
+6
-8
python/paddle/tensor/math.py
python/paddle/tensor/math.py
+8
-4
python/paddle/tensor/random.py
python/paddle/tensor/random.py
+2
-2
未找到文件。
python/paddle/nn/functional/distance.py
浏览文件 @
1712e212
...
...
@@ -68,9 +68,6 @@ def pairwise_distance(x, y, p=2.0, epsilon=1e-6, keepdim=False, name=None):
# [4.99999860, 4.99999860])
"""
check_type
(
p
,
'porder'
,
(
float
,
int
),
'PairwiseDistance'
)
check_type
(
epsilon
,
'epsilon'
,
(
float
),
'PairwiseDistance'
)
check_type
(
keepdim
,
'keepdim'
,
(
bool
),
'PairwiseDistance'
)
if
in_dygraph_mode
():
sub
=
_C_ops
.
subtract
(
x
,
y
)
# p_norm op has not uesd epsilon, so change it to the following.
...
...
@@ -82,6 +79,10 @@ def pairwise_distance(x, y, p=2.0, epsilon=1e-6, keepdim=False, name=None):
return
_C_ops
.
p_norm
(
sub
,
p
,
-
1
,
0.0
,
keepdim
,
False
)
else
:
check_type
(
p
,
'porder'
,
(
float
,
int
),
'PairwiseDistance'
)
check_type
(
epsilon
,
'epsilon'
,
(
float
),
'PairwiseDistance'
)
check_type
(
keepdim
,
'keepdim'
,
(
bool
),
'PairwiseDistance'
)
check_variable_and_dtype
(
x
,
'x'
,
[
'float32'
,
'float64'
],
'PairwiseDistance'
)
...
...
python/paddle/signal.py
浏览文件 @
1712e212
...
...
@@ -307,9 +307,6 @@ def stft(
y1 = stft(x, n_fft=512, center=False, onesided=False) # [8, 512, 372]
"""
check_variable_and_dtype
(
x
,
'x'
,
[
'float32'
,
'float64'
,
'complex64'
,
'complex128'
],
'stft'
)
x_rank
=
len
(
x
.
shape
)
assert
x_rank
in
[
...
...
python/paddle/tensor/creation.py
浏览文件 @
1712e212
...
...
@@ -873,7 +873,7 @@ def ones(shape, dtype=None, name=None):
# [1. 1.]]
"""
if
dtype
is
None
:
dtype
=
'float32'
dtype
=
core
.
VarDesc
.
VarType
.
FP32
return
fill_constant
(
value
=
1.0
,
shape
=
shape
,
dtype
=
dtype
,
name
=
name
)
...
...
python/paddle/tensor/manipulation.py
浏览文件 @
1712e212
...
...
@@ -1541,14 +1541,6 @@ def flatten(x, start_axis=0, stop_axis=-1, name=None):
if
not
(
isinstance
(
x
,
Variable
)):
raise
ValueError
(
"The input x should be a Tensor"
)
if
not
paddle
.
in_dynamic_mode
():
check_variable_and_dtype
(
x
,
'x'
,
[
'float32'
,
'float64'
,
'int8'
,
'int16'
,
'int32'
,
'int64'
,
'uint8'
],
'flatten'
,
)
x_dim
=
len
(
x
.
shape
)
if
x_dim
==
0
:
if
not
(
isinstance
(
start_axis
,
int
))
or
start_axis
not
in
[
0
,
-
1
]:
...
...
@@ -1586,6 +1578,12 @@ def flatten(x, start_axis=0, stop_axis=-1, name=None):
if
in_dygraph_mode
():
return
_C_ops
.
flatten
(
x
,
start_axis
,
stop_axis
)
else
:
check_variable_and_dtype
(
x
,
'x'
,
[
'float32'
,
'float64'
,
'int8'
,
'int16'
,
'int32'
,
'int64'
,
'uint8'
],
'flatten'
,
)
helper
=
LayerHelper
(
'flatten'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
x_shape
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
...
...
python/paddle/tensor/math.py
浏览文件 @
1712e212
...
...
@@ -213,6 +213,8 @@ def scale(x, scale=1.0, bias=0.0, bias_after_scale=True, act=None, name=None):
"""
if
in_dygraph_mode
():
if
act
is
None
:
return
_C_ops
.
scale
(
x
,
scale
,
float
(
bias
),
bias_after_scale
)
out
=
_C_ops
.
scale
(
x
,
scale
,
float
(
bias
),
bias_after_scale
)
return
dygraph_utils
.
_append_activation_in_dygraph
(
out
,
act
)
else
:
...
...
@@ -495,9 +497,12 @@ def _elementwise_op_in_dygraph(
OP_NAMEMAPPING
[
op_name
]
if
not
is_inplace
(
op_name
)
else
op_name
,
)
out
=
op
(
x
,
y
)
return
dygraph_utils
.
_append_activation_in_dygraph
(
out
,
act
,
use_mkldnn
=
use_mkldnn
)
if
act
is
None
:
return
out
else
:
return
dygraph_utils
.
_append_activation_in_dygraph
(
out
,
act
,
use_mkldnn
=
use_mkldnn
)
def
_elementwise_op
(
helper
):
...
...
@@ -4209,7 +4214,6 @@ def lerp(x, y, weight, name=None):
"""
if
in_dygraph_mode
():
check_type
(
weight
,
'weight'
,
(
float
,
paddle
.
Tensor
,
Variable
),
'lerp'
)
if
isinstance
(
weight
,
float
):
weight
=
paddle
.
to_tensor
(
weight
,
dtype
=
x
.
dtype
)
...
...
python/paddle/tensor/random.py
浏览文件 @
1712e212
...
...
@@ -789,8 +789,8 @@ def randint(low=0, high=None, shape=[1], dtype=None, name=None):
high
=
low
low
=
0
if
dtype
is
None
:
dtype
=
'int64'
if
not
isinstance
(
dtype
,
core
.
VarDesc
.
VarType
):
dtype
=
core
.
VarDesc
.
VarType
.
INT64
el
if
not
isinstance
(
dtype
,
core
.
VarDesc
.
VarType
):
dtype
=
convert_np_dtype_to_dtype_
(
dtype
)
if
in_dygraph_mode
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录