Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
609b50a8
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看板
未验证
提交
609b50a8
编写于
1月 13, 2023
作者:
W
Weilong Wu
提交者:
GitHub
1月 13, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Eager] polish some api logic (#49717)
* [Eager] polish some api logic * fix split * revover
上级
0b24d167
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
12 addition
and
22 deletion
+12
-22
python/paddle/nn/layer/norm.py
python/paddle/nn/layer/norm.py
+2
-0
python/paddle/tensor/manipulation.py
python/paddle/tensor/manipulation.py
+2
-13
python/paddle/tensor/search.py
python/paddle/tensor/search.py
+8
-9
未找到文件。
python/paddle/nn/layer/norm.py
浏览文件 @
609b50a8
...
@@ -999,6 +999,8 @@ class BatchNorm(Layer):
...
@@ -999,6 +999,8 @@ class BatchNorm(Layer):
self
.
_use_global_stats
,
self
.
_use_global_stats
,
self
.
_trainable_statistics
,
self
.
_trainable_statistics
,
)
)
if
self
.
_act
is
None
:
return
batch_norm_out
return
dygraph_utils
.
_append_activation_in_dygraph
(
return
dygraph_utils
.
_append_activation_in_dygraph
(
batch_norm_out
,
act
=
self
.
_act
,
use_mkldnn
=
self
.
_use_mkldnn
batch_norm_out
,
act
=
self
.
_act
,
use_mkldnn
=
self
.
_use_mkldnn
)
)
...
...
python/paddle/tensor/manipulation.py
浏览文件 @
609b50a8
...
@@ -1916,31 +1916,20 @@ def split(x, num_or_sections, axis=0, name=None):
...
@@ -1916,31 +1916,20 @@ def split(x, num_or_sections, axis=0, name=None):
input
=
x
input
=
x
dim
=
axis
dim
=
axis
if
in_dygraph_mode
():
if
in_dygraph_mode
():
num
=
None
attrs
=
()
if
isinstance
(
dim
,
Variable
):
if
isinstance
(
dim
,
Variable
):
dim
=
dim
.
numpy
()
dim
=
dim
.
numpy
()
dim
=
dim
.
item
(
0
)
dim
=
dim
.
item
(
0
)
assert
len
(
input
.
shape
)
+
dim
>=
0
,
"(rank(x) + axis) must >= 0"
assert
len
(
input
.
shape
)
+
dim
>=
0
,
"(rank(x) + axis) must >= 0"
dim
=
(
len
(
input
.
shape
)
+
dim
)
if
dim
<
0
else
dim
dim
=
(
len
(
input
.
shape
)
+
dim
)
if
dim
<
0
else
dim
attrs
+=
(
'axis'
,
dim
)
if
isinstance
(
num_or_sections
,
int
):
if
isinstance
(
num_or_sections
,
(
list
,
tuple
)):
num
=
num_or_sections
attrs
+=
(
'num'
,
num_or_sections
)
elif
isinstance
(
num_or_sections
,
(
list
,
tuple
)):
num
=
len
(
num_or_sections
)
if
utils
.
_contain_var
(
num_or_sections
):
if
utils
.
_contain_var
(
num_or_sections
):
for
index
,
item
in
enumerate
(
num_or_sections
):
for
index
,
item
in
enumerate
(
num_or_sections
):
if
isinstance
(
item
,
Variable
):
if
isinstance
(
item
,
Variable
):
num_or_sections
[
index
]
=
num_or_sections
[
index
].
numpy
()[
num_or_sections
[
index
]
=
num_or_sections
[
index
].
numpy
()[
0
0
]
]
attrs
+=
(
'sections'
,
list
(
num_or_sections
))
elif
not
isinstance
(
num_or_sections
,
int
):
else
:
attrs
+=
(
'sections'
,
list
(
num_or_sections
))
else
:
raise
TypeError
(
raise
TypeError
(
"The type of 'num_or_sections' in split must be int, list or tuple in imperative mode, but "
"The type of 'num_or_sections' in split must be int, list or tuple in imperative mode, but "
"received %s."
%
(
type
(
num_or_sections
))
"received %s."
%
(
type
(
num_or_sections
))
...
...
python/paddle/tensor/search.py
浏览文件 @
609b50a8
...
@@ -612,15 +612,6 @@ def where(condition, x=None, y=None, name=None):
...
@@ -612,15 +612,6 @@ def where(condition, x=None, y=None, name=None):
if
x
is
None
or
y
is
None
:
if
x
is
None
or
y
is
None
:
raise
ValueError
(
"either both or neither of x and y should be given"
)
raise
ValueError
(
"either both or neither of x and y should be given"
)
if
not
paddle
.
in_dynamic_mode
():
check_variable_and_dtype
(
condition
,
'condition'
,
[
'bool'
],
'where'
)
check_variable_and_dtype
(
x
,
'x'
,
[
'float32'
,
'float64'
,
'int32'
,
'int64'
],
'where'
)
check_variable_and_dtype
(
y
,
'y'
,
[
'float32'
,
'float64'
,
'int32'
,
'int64'
],
'where'
)
condition_shape
=
list
(
condition
.
shape
)
condition_shape
=
list
(
condition
.
shape
)
x_shape
=
list
(
x
.
shape
)
x_shape
=
list
(
x
.
shape
)
y_shape
=
list
(
y
.
shape
)
y_shape
=
list
(
y
.
shape
)
...
@@ -646,6 +637,14 @@ def where(condition, x=None, y=None, name=None):
...
@@ -646,6 +637,14 @@ def where(condition, x=None, y=None, name=None):
if
in_dygraph_mode
():
if
in_dygraph_mode
():
return
_C_ops
.
where
(
broadcast_condition
,
broadcast_x
,
broadcast_y
)
return
_C_ops
.
where
(
broadcast_condition
,
broadcast_x
,
broadcast_y
)
else
:
else
:
check_variable_and_dtype
(
condition
,
'condition'
,
[
'bool'
],
'where'
)
check_variable_and_dtype
(
x
,
'x'
,
[
'float32'
,
'float64'
,
'int32'
,
'int64'
],
'where'
)
check_variable_and_dtype
(
y
,
'y'
,
[
'float32'
,
'float64'
,
'int32'
,
'int64'
],
'where'
)
helper
=
LayerHelper
(
"where"
,
**
locals
())
helper
=
LayerHelper
(
"where"
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录