Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Paddle
提交
4b1d28fc
P
Paddle
项目概览
jobily
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
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看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
4b1d28fc
编写于
9月 08, 2023
作者:
X
xiongkun
提交者:
GitHub
9月 08, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【SetItem】Fix setitem for function call. (#56810)
* fix error * fix setitem * fix bgs * fix
上级
1b8619c7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
2 deletion
+30
-2
python/paddle/jit/dy2static/basic_api_transformer.py
python/paddle/jit/dy2static/basic_api_transformer.py
+2
-2
test/dygraph_to_static/test_jit_setitem.py
test/dygraph_to_static/test_jit_setitem.py
+28
-0
未找到文件。
python/paddle/jit/dy2static/basic_api_transformer.py
浏览文件 @
4b1d28fc
...
...
@@ -152,8 +152,8 @@ class NameloadJstTransformer(BaseTransformer):
"""
Can't convert name of function call, bacause this will affect CallTransformer.
"""
node
.
args
=
[
self
.
generic_
visit
(
arg
)
for
arg
in
node
.
args
]
node
.
func
=
self
.
generic_
visit
(
node
.
func
)
node
.
args
=
[
self
.
visit
(
arg
)
for
arg
in
node
.
args
]
node
.
func
=
self
.
visit
(
node
.
func
)
return
node
def
visit_Attribute
(
self
,
node
):
...
...
test/dygraph_to_static/test_jit_setitem.py
浏览文件 @
4b1d28fc
...
...
@@ -12,11 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
unittest
import
numpy
as
np
import
paddle
import
paddle.nn.functional
as
F
class
TestSetItemBase
(
unittest
.
TestCase
):
...
...
@@ -231,5 +233,31 @@ class TestCase14(TestSetItemBase):
return
(
y
,)
class
TestCase15
(
TestSetItemBase
):
# Test gradient of value tensor
def
init_func
(
self
):
def
foo
(
x
,
H
,
W
):
B
,
_
,
_
,
C
=
x
.
shape
pad_list
=
paddle
.
zeros
([
4
],
dtype
=
"int32"
)
pad_list
[
3
]
=
H
//
2
pad_list
[
1
]
=
W
//
2
# 问题在这里,进去F.pad以后,pad_list是初始变量而非赋值后的变量
# 在修改前,赋值前后的变量是同一个,没有问题
# 修改后,期望接收赋值后的变量,接收赋值前变量结果是不对的
x
=
F
.
pad
(
x
,
pad_list
,
data_format
=
"NHWC"
)
return
x
return
foo
def
run_dygraph
(
self
,
func
):
# 注释这句看结果diff
x
=
paddle
.
ones
((
1
,
6
,
6
,
3
))
H
=
paddle
.
full
([
1
],
6
,
dtype
=
'int32'
)
W
=
paddle
.
full
([
1
],
6
,
dtype
=
'int32'
)
y
=
func
(
x
,
H
,
W
)
return
(
y
,)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录