Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
6bfdef72
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
6bfdef72
编写于
1月 10, 2021
作者:
X
XiaoguangHu
提交者:
GitHub
1月 11, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean redundant API alias in 2.0 - part 2 (#30013)
* delete paddle.nn.functional.assign * fix dynamic to static error
上级
e6a1e875
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
7 addition
and
10 deletion
+7
-10
python/paddle/fluid/dygraph/dygraph_to_static/basic_api_transformer.py
.../fluid/dygraph/dygraph_to_static/basic_api_transformer.py
+3
-3
python/paddle/fluid/layers/tensor.py
python/paddle/fluid/layers/tensor.py
+3
-3
python/paddle/fluid/tests/unittests/test_inplace.py
python/paddle/fluid/tests/unittests/test_inplace.py
+1
-1
python/paddle/nn/functional/__init__.py
python/paddle/nn/functional/__init__.py
+0
-1
python/paddle/nn/functional/common.py
python/paddle/nn/functional/common.py
+0
-2
未找到文件。
python/paddle/fluid/dygraph/dygraph_to_static/basic_api_transformer.py
浏览文件 @
6bfdef72
...
...
@@ -116,14 +116,14 @@ def is_to_variable(node):
def
to_assign_node
(
node
):
# Transform dygraph api `fluid.dygraph.to_variable` alias `paddle.to_tensor` to static api `paddle.
nn.functional.
assign`.
# Transform dygraph api `fluid.dygraph.to_variable` alias `paddle.to_tensor` to static api `paddle.assign`.
# NOTE:
# 1. Api `to_variable` supports data type {float16, float32, float64, int16, int32, int64, uint8, uint16},
# but api `assign` only supports {float32, float64, int32, int64, bool};
# 2. If the input of api `assign` is numpy.ndarray, its size cannot be greater than 1024 * 1024.
assert
isinstance
(
node
,
gast
.
Call
)
assign_api
=
gast
.
parse
(
'paddle.
nn.functional.
assign'
).
body
[
0
].
value
assign_api
=
gast
.
parse
(
'paddle.assign'
).
body
[
0
].
value
node
.
func
=
assign_api
if
node
.
args
:
...
...
@@ -132,7 +132,7 @@ def to_assign_node(node):
else
:
for
idx
,
kw
in
enumerate
(
node
.
keywords
):
if
kw
.
arg
==
'value'
or
kw
.
arg
==
'data'
:
node
.
keywords
[
idx
].
arg
=
'
input
'
node
.
keywords
[
idx
].
arg
=
'
x
'
node
.
keywords
=
[
node
.
keywords
[
idx
]]
node
.
args
=
[]
break
...
...
python/paddle/fluid/layers/tensor.py
浏览文件 @
6bfdef72
...
...
@@ -563,9 +563,9 @@ def assign(input, output=None):
[3, 4],
[1, 3]]).astype(np.int64)
result1 = paddle.zeros(shape=[3, 3], dtype='float32')
paddle.
nn.functional.
assign(array, result1) # result1 = [[1, 1], [3 4], [1, 3]]
result2 = paddle.
nn.functional.
assign(data) # result2 = [[2.5, 2.5], [2.5, 2.5], [2.5, 2.5]]
result3 = paddle.
nn.functional.
assign(np.array([[2.5, 2.5], [2.5, 2.5], [2.5, 2.5]], dtype='float32')) # result3 = [[2.5, 2.5], [2.5, 2.5], [2.5, 2.5]]
paddle.assign(array, result1) # result1 = [[1, 1], [3 4], [1, 3]]
result2 = paddle.assign(data) # result2 = [[2.5, 2.5], [2.5, 2.5], [2.5, 2.5]]
result3 = paddle.assign(np.array([[2.5, 2.5], [2.5, 2.5], [2.5, 2.5]], dtype='float32')) # result3 = [[2.5, 2.5], [2.5, 2.5], [2.5, 2.5]]
"""
helper
=
LayerHelper
(
'assign'
,
**
locals
())
check_type
(
input
,
'input'
,
(
Variable
,
numpy
.
ndarray
),
'assign'
)
...
...
python/paddle/fluid/tests/unittests/test_inplace.py
浏览文件 @
6bfdef72
...
...
@@ -30,7 +30,7 @@ class TestInplace(unittest.TestCase):
var
[
0
]
=
1.1
self
.
assertEqual
(
var
.
inplace_version
,
1
)
paddle
.
nn
.
functional
.
assign
(
paddle
.
ones
(
shape
=
[
3
]),
var
)
paddle
.
assign
(
paddle
.
ones
(
shape
=
[
3
]),
var
)
# NOTE(liym27): assign(input, output) is an inplace operation for output.
# There is inplace-related processing for api assign, var.inplace_version should be 2 not 1.
...
...
python/paddle/nn/functional/__init__.py
浏览文件 @
6bfdef72
...
...
@@ -68,7 +68,6 @@ from .common import pad #DEFINE_ALIAS
from
.common
import
cosine_similarity
#DEFINE_ALIAS
from
.common
import
unfold
#DEFINE_ALIAS
# from .common import bilinear_tensor_product #DEFINE_ALIAS
from
.common
import
assign
#DEFINE_ALIAS
from
.common
import
interpolate
#DEFINE_ALIAS
from
.common
import
upsample
#DEFINE_ALIAS
from
.common
import
bilinear
#DEFINE_ALIAS
...
...
python/paddle/nn/functional/common.py
浏览文件 @
6bfdef72
...
...
@@ -23,7 +23,6 @@ from ...fluid import dygraph_utils
# from ...fluid import one_hot #DEFINE_ALIAS
# from ...fluid.layers import pad2d #DEFINE_ALIAS
from
...fluid.layers
import
unfold
#DEFINE_ALIAS
from
...fluid.layers
import
assign
#DEFINE_ALIAS
from
...fluid.layers
import
squeeze
#DEFINE_ALIAS
from
...fluid.layers
import
unsqueeze
#DEFINE_ALIAS
from
...tensor
import
clip
...
...
@@ -53,7 +52,6 @@ __all__ = [
'pad'
,
'unfold'
,
# 'bilinear_tensor_product',
'assign'
,
'interpolate'
,
'upsample'
,
'bilinear'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录