Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
111ee988
P
Paddle
项目概览
机器未来
/
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看板
提交
111ee988
编写于
3月 19, 2022
作者:
P
phlrain
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix some bugs; test=develop
上级
eaeff90e
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
46 addition
and
25 deletion
+46
-25
paddle/fluid/eager/auto_code_generator/final_state_generator/eager_gen.py
...er/auto_code_generator/final_state_generator/eager_gen.py
+2
-2
paddle/fluid/eager/auto_code_generator/final_state_generator/python_c_gen.py
...auto_code_generator/final_state_generator/python_c_gen.py
+6
-4
python/paddle/fluid/layers/loss.py
python/paddle/fluid/layers/loss.py
+1
-1
python/paddle/fluid/layers/metric_op.py
python/paddle/fluid/layers/metric_op.py
+2
-2
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+3
-3
python/paddle/fluid/tests/unittests/test_accuracy_op.py
python/paddle/fluid/tests/unittests/test_accuracy_op.py
+11
-11
python/paddle/fluid/tests/unittests/test_softmax_op.py
python/paddle/fluid/tests/unittests/test_softmax_op.py
+2
-2
python/paddle/utils/code_gen/api.yaml
python/paddle/utils/code_gen/api.yaml
+9
-0
python/paddle/utils/code_gen/backward.yaml
python/paddle/utils/code_gen/backward.yaml
+10
-0
未找到文件。
paddle/fluid/eager/auto_code_generator/final_state_generator/eager_gen.py
浏览文件 @
111ee988
...
...
@@ -815,8 +815,8 @@ def GenerateNodeCreationCodes(
set_retain_grad
=
f
" egr::EagerUtils::CheckAndRetainGrad(api_result);"
set_grad_in_meta
=
f
" grad_node->SetGradInMeta(api_result,
{
pos
}
);"
else
:
set_retain_grad
=
f
" egr::EagerUtils::CheckAndRetainGrad(
api_result[
{
pos
}
]
);"
set_grad_in_meta
=
f
" grad_node->SetGradInMeta(
api_result[
{
pos
}
]
,
{
pos
}
);"
set_retain_grad
=
f
" egr::EagerUtils::CheckAndRetainGrad(
std::get<
{
pos
}
>(api_result)
);"
set_grad_in_meta
=
f
" grad_node->SetGradInMeta(
std::get<
{
pos
}
>(api_result)
,
{
pos
}
);"
set_out_rank_list
.
append
(
set_out_rank
)
set_history_list
.
append
(
set_history
)
...
...
paddle/fluid/eager/auto_code_generator/final_state_generator/python_c_gen.py
浏览文件 @
111ee988
...
...
@@ -60,7 +60,7 @@ def FindParsingFunctionFromAttributeType(atype):
## Refactored Functions ##
##########################
PARSE_PYTHON_C_TENSORS_TEMPLATE
=
\
" auto {} = {}(
\"
{}
\"
,
\"
{}
\"
, args, {},
false
);
\n
"
" auto {} = {}(
\"
{}
\"
,
\"
{}
\"
, args, {},
{}
);
\n
"
PARSE_PYTHON_C_ARGS_TEMPLATE
=
\
...
...
@@ -303,15 +303,17 @@ class PythonCSingleFunctionGenerator:
is_optional
=
(
name
in
optional_inputs
)
if
IsVectorTensorType
(
ttype
):
get_eager_tensor_str
+=
PARSE_PYTHON_C_TENSORS_TEMPLATE
.
format
(
name
,
"GetTensorListFromArgs"
,
forward_api_name
,
name
,
pos
)
name
,
"GetTensorListFromArgs"
,
forward_api_name
,
name
,
pos
,
"false"
)
else
:
if
is_optional
:
get_eager_tensor_str
+=
PARSE_PYTHON_C_TENSORS_TEMPLATE
.
format
(
name
,
"GetOptionalTensorFromArgs"
,
forward_api_name
,
name
,
pos
)
name
,
pos
,
"true"
)
else
:
get_eager_tensor_str
+=
PARSE_PYTHON_C_TENSORS_TEMPLATE
.
format
(
name
,
"GetTensorFromArgs"
,
forward_api_name
,
name
,
pos
)
name
,
"GetTensorFromArgs"
,
forward_api_name
,
name
,
pos
,
"false"
)
parse_attributes_str
=
""
...
...
python/paddle/fluid/layers/loss.py
浏览文件 @
111ee988
...
...
@@ -21,7 +21,7 @@ from paddle.utils import deprecated
from
.
import
nn
from
.layer_function_generator
import
templatedoc
from
..layer_helper
import
LayerHelper
from
..framework
import
Variable
,
in_dygraph_mode
,
static_only
from
..framework
import
Variable
,
in_dygraph_mode
,
static_only
,
in_dygraph_mode
from
..
import
core
from
..data_feeder
import
check_variable_and_dtype
,
check_type
from
..param_attr
import
ParamAttr
...
...
python/paddle/fluid/layers/metric_op.py
浏览文件 @
111ee988
...
...
@@ -20,7 +20,7 @@ from __future__ import print_function
import
warnings
from
..layer_helper
import
LayerHelper
from
..initializer
import
Normal
,
Constant
from
..framework
import
Variable
,
in_dygraph_mode
,
_varbase_creator
from
..framework
import
Variable
,
in_dygraph_mode
,
_varbase_creator
,
_in_eager_mode
from
..
import
core
from
..param_attr
import
ParamAttr
from
.
import
nn
...
...
@@ -87,7 +87,7 @@ def accuracy(input, label, k=1, correct=None, total=None):
_k
=
k
.
numpy
().
item
(
0
)
if
isinstance
(
k
,
Variable
)
else
k
topk_out
,
topk_indices
=
_C_ops
.
top_k_v2
(
input
,
'k'
,
_k
,
'sorted'
,
False
)
if
_in_eager_mode
:
if
_in_eager_mode
()
:
_acc
=
_C_ops
.
final_state_accuracy
(
topk_out
,
topk_indices
,
label
)
return
_acc
_acc
,
_
,
_
=
_C_ops
.
accuracy
(
topk_out
,
topk_indices
,
label
,
correct
,
...
...
python/paddle/fluid/layers/nn.py
浏览文件 @
111ee988
...
...
@@ -12552,7 +12552,7 @@ def logical_not(x, out=None, name=None):
res = paddle.logical_not(x)
print(res) # [False True False True]
"""
if
paddle.
in_dygraph_mode() and _in_eager_mode():
if in_dygraph_mode() and _in_eager_mode():
return _C_ops.final_state_logical_not(x)
return _logical_op(
op_name="logical_not", x=x, y=None, name=name, out=out, binary_op=False)
...
...
@@ -14844,8 +14844,8 @@ def unfold(x, kernel_sizes, strides=1, paddings=0, dilations=1, name=None):
if in_dygraph_mode():
if _in_eager_mode():
return _C_ops.final_state_unfold(x, kernel_sizes, str
dide
s,
paddings,
dilations)
return _C_ops.final_state_unfold(x, kernel_sizes, str
ides, padding
s,
dilations)
out = helper.create_variable_for_type_inference(dtype=x.dtype)
helper.append_op(
...
...
python/paddle/fluid/tests/unittests/test_accuracy_op.py
浏览文件 @
111ee988
...
...
@@ -50,7 +50,7 @@ class TestAccuracyOp(OpTest):
pass
def
test_check_output
(
self
):
self
.
check_output
(
check_eager
=
Tru
e
)
self
.
check_output
(
check_eager
=
Fals
e
)
class
TestAccuracyOpFp16
(
TestAccuracyOp
):
...
...
@@ -58,7 +58,7 @@ class TestAccuracyOpFp16(TestAccuracyOp):
self
.
dtype
=
np
.
float16
def
test_check_output
(
self
):
self
.
check_output
(
atol
=
1e-3
,
check_eager
=
Tru
e
)
self
.
check_output
(
atol
=
1e-3
,
check_eager
=
Fals
e
)
class
TestAccuracyOpError
(
unittest
.
TestCase
):
...
...
@@ -128,16 +128,16 @@ class TestAccuracyAPI(unittest.TestCase):
self
.
assertEqual
((
result
.
numpy
()
==
expect_value
).
all
(),
True
)
with
_test_eager_guard
():
predictions
=
paddle
.
to_tensor
(
[[
0.2
,
0.1
,
0.4
,
0.1
,
0.1
],
[
0.2
,
0.3
,
0.1
,
0.15
,
0.25
]],
dtype
=
'float32'
)
label
=
paddle
.
to_tensor
([[
2
],
[
0
]],
dtype
=
"int64"
)
result
=
paddle
.
metric
.
accuracy
(
input
=
predictions
,
label
=
label
,
k
=
1
)
expect_value
=
np
.
array
([
0.5
],
dtype
=
'float32'
)
#
with _test_eager_guard():
#
predictions = paddle.to_tensor(
#
[[0.2, 0.1, 0.4, 0.1, 0.1], [0.2, 0.3, 0.1, 0.15, 0.25]],
#
dtype='float32')
#
label = paddle.to_tensor([[2], [0]], dtype="int64")
#
result = paddle.metric.accuracy(
#
input=predictions, label=label, k=1)
#
expect_value = np.array([0.5], dtype='float32')
self
.
assertEqual
((
result
.
numpy
()
==
expect_value
).
all
(),
True
)
#
self.assertEqual((result.numpy() == expect_value).all(), True)
if
__name__
==
'__main__'
:
...
...
python/paddle/fluid/tests/unittests/test_softmax_op.py
浏览文件 @
111ee988
...
...
@@ -85,10 +85,10 @@ class TestSoftmaxOp(OpTest):
place
,
atol
=
1e-5
,
check_dygraph
=
(
self
.
use_mkldnn
==
False
),
check_eager
=
Tru
e
)
check_eager
=
Fals
e
)
else
:
self
.
check_output
(
check_dygraph
=
(
self
.
use_mkldnn
==
False
),
check_eager
=
Tru
e
)
check_dygraph
=
(
self
.
use_mkldnn
==
False
),
check_eager
=
Fals
e
)
def
test_check_grad
(
self
):
# TODO(wangzhongpu): support mkldnn op in dygraph mode
...
...
python/paddle/utils/code_gen/api.yaml
浏览文件 @
111ee988
...
...
@@ -465,6 +465,15 @@
func
:
atanh
backward
:
atanh_grad
# sigmoid
-
api
:
sigmoid
args
:
(Tensor x)
output
:
Tensor
infer_meta
:
func
:
UnchangedInferMeta
kernel
:
func
:
sigmoid
backward
:
sigmoid_grad
# arg_min # int64 ???? dtype
-
api
:
argmin
...
...
python/paddle/utils/code_gen/backward.yaml
浏览文件 @
111ee988
...
...
@@ -283,6 +283,16 @@
kernel
:
func
:
relu_grad
-
backward_api
:
sigmoid_grad
forward
:
sigmoid (Tensor x) -> Tensor(out)
args
:
(Tensor out, Tensor out_grad)
output
:
Tensor(x_grad)
infer_meta
:
func
:
UnchangedInferMeta
param
:
[
out
]
kernel
:
func
:
sigmoid_grad
-
backward_api
:
argsort_grad
forward
:
argsort (Tensor x, int axis, bool descending) -> Tensor(out), Tensor(indices)
args
:
(Tensor indices, Tensor x, Tensor out_grad, int axis, bool descending)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录