Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
4efca9fb
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
4efca9fb
编写于
4月 21, 2023
作者:
Z
Zhang Zheng
提交者:
GitHub
4月 21, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[AMP OP&Test] Add check_dtype for some API (part 2) (#53136)
* [AMP OP&Test] Add check_dtype for some API (part 2) * fix ci * fix ci
上级
0f99debd
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
82 addition
and
52 deletion
+82
-52
python/paddle/fluid/tests/unittests/test_unique.py
python/paddle/fluid/tests/unittests/test_unique.py
+2
-2
python/paddle/fluid/tests/unittests/test_unique_with_counts.py
...n/paddle/fluid/tests/unittests/test_unique_with_counts.py
+1
-1
python/paddle/metric/metrics.py
python/paddle/metric/metrics.py
+1
-1
python/paddle/nn/functional/activation.py
python/paddle/nn/functional/activation.py
+26
-18
python/paddle/nn/functional/conv.py
python/paddle/nn/functional/conv.py
+5
-2
python/paddle/nn/functional/norm.py
python/paddle/nn/functional/norm.py
+1
-1
python/paddle/nn/layer/norm.py
python/paddle/nn/layer/norm.py
+4
-1
python/paddle/static/nn/metric.py
python/paddle/static/nn/metric.py
+1
-1
python/paddle/tensor/creation.py
python/paddle/tensor/creation.py
+1
-1
python/paddle/tensor/linalg.py
python/paddle/tensor/linalg.py
+4
-1
python/paddle/tensor/manipulation.py
python/paddle/tensor/manipulation.py
+15
-2
python/paddle/tensor/math.py
python/paddle/tensor/math.py
+5
-5
python/paddle/tensor/ops.py
python/paddle/tensor/ops.py
+16
-16
未找到文件。
python/paddle/fluid/tests/unittests/test_unique.py
浏览文件 @
4efca9fb
...
@@ -86,7 +86,7 @@ class TestUniqueRaiseError(unittest.TestCase):
...
@@ -86,7 +86,7 @@ class TestUniqueRaiseError(unittest.TestCase):
def
test_dtype
():
def
test_dtype
():
data
=
paddle
.
static
.
data
(
data
=
paddle
.
static
.
data
(
shape
=
[
10
],
dtype
=
"
floa
t16"
,
name
=
"input"
shape
=
[
10
],
dtype
=
"
in
t16"
,
name
=
"input"
)
)
paddle
.
unique
(
data
)
paddle
.
unique
(
data
)
...
@@ -424,7 +424,7 @@ class TestUniqueError(unittest.TestCase):
...
@@ -424,7 +424,7 @@ class TestUniqueError(unittest.TestCase):
paddle
.
static
.
Program
(),
paddle
.
static
.
Program
()
paddle
.
static
.
Program
(),
paddle
.
static
.
Program
()
):
):
x
=
paddle
.
static
.
data
(
x
=
paddle
.
static
.
data
(
name
=
'x'
,
shape
=
[
10
,
10
],
dtype
=
'
floa
t16'
name
=
'x'
,
shape
=
[
10
,
10
],
dtype
=
'
in
t16'
)
)
result
=
paddle
.
unique
(
x
)
result
=
paddle
.
unique
(
x
)
...
...
python/paddle/fluid/tests/unittests/test_unique_with_counts.py
浏览文件 @
4efca9fb
...
@@ -85,7 +85,7 @@ class TestUniqueWithCountsRaiseError(unittest.TestCase):
...
@@ -85,7 +85,7 @@ class TestUniqueWithCountsRaiseError(unittest.TestCase):
def
test_dtype
():
def
test_dtype
():
data
=
paddle
.
static
.
data
(
data
=
paddle
.
static
.
data
(
shape
=
[
10
],
dtype
=
"
floa
t16"
,
name
=
"input"
shape
=
[
10
],
dtype
=
"
in
t16"
,
name
=
"input"
)
)
paddle
.
unique
(
data
)
paddle
.
unique
(
data
)
...
...
python/paddle/metric/metrics.py
浏览文件 @
4efca9fb
...
@@ -817,7 +817,7 @@ def accuracy(input, label, k=1, correct=None, total=None, name=None):
...
@@ -817,7 +817,7 @@ def accuracy(input, label, k=1, correct=None, total=None, name=None):
helper
=
LayerHelper
(
"accuracy"
,
**
locals
())
helper
=
LayerHelper
(
"accuracy"
,
**
locals
())
check_variable_and_dtype
(
check_variable_and_dtype
(
input
,
'input'
,
[
'float16'
,
'float32'
,
'float64'
],
'accuracy'
input
,
'input'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'accuracy'
)
)
topk_out
,
topk_indices
=
paddle
.
topk
(
input
,
k
=
k
)
topk_out
,
topk_indices
=
paddle
.
topk
(
input
,
k
=
k
)
acc_out
=
helper
.
create_variable_for_type_inference
(
dtype
=
"float32"
)
acc_out
=
helper
.
create_variable_for_type_inference
(
dtype
=
"float32"
)
...
...
python/paddle/nn/functional/activation.py
浏览文件 @
4efca9fb
...
@@ -62,7 +62,7 @@ def celu(x, alpha=1.0, name=None):
...
@@ -62,7 +62,7 @@ def celu(x, alpha=1.0, name=None):
return
_C_ops
.
celu
(
x
,
alpha
)
return
_C_ops
.
celu
(
x
,
alpha
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'celu'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'celu'
)
)
helper
=
LayerHelper
(
"celu"
,
**
locals
())
helper
=
LayerHelper
(
"celu"
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
...
@@ -114,7 +114,7 @@ def elu(x, alpha=1.0, name=None):
...
@@ -114,7 +114,7 @@ def elu(x, alpha=1.0, name=None):
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'elu'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'elu'
)
)
helper
=
LayerHelper
(
"elu"
,
**
locals
())
helper
=
LayerHelper
(
"elu"
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
...
@@ -234,7 +234,7 @@ def hardshrink(x, threshold=0.5, name=None):
...
@@ -234,7 +234,7 @@ def hardshrink(x, threshold=0.5, name=None):
return
_C_ops
.
hardshrink
(
x
,
threshold
)
return
_C_ops
.
hardshrink
(
x
,
threshold
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'hardshrink'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'hardshrink'
)
)
helper
=
LayerHelper
(
'hardshrink'
,
**
locals
())
helper
=
LayerHelper
(
'hardshrink'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
...
@@ -339,7 +339,7 @@ def hardsigmoid(x, slope=0.1666667, offset=0.5, name=None):
...
@@ -339,7 +339,7 @@ def hardsigmoid(x, slope=0.1666667, offset=0.5, name=None):
return
_C_ops
.
hardsigmoid
(
x
,
slope
,
offset
)
return
_C_ops
.
hardsigmoid
(
x
,
slope
,
offset
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'hardsigmoid'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'hardsigmoid'
)
)
helper
=
LayerHelper
(
'hardsigmoid'
,
**
locals
())
helper
=
LayerHelper
(
'hardsigmoid'
,
**
locals
())
...
@@ -390,7 +390,7 @@ def hardswish(x, name=None):
...
@@ -390,7 +390,7 @@ def hardswish(x, name=None):
return
_C_ops
.
hardswish
(
x
)
return
_C_ops
.
hardswish
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'hardswish'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'hardswish'
)
)
helper
=
LayerHelper
(
'hardswish'
,
**
locals
())
helper
=
LayerHelper
(
'hardswish'
,
**
locals
())
...
@@ -439,7 +439,7 @@ def leaky_relu(x, negative_slope=0.01, name=None):
...
@@ -439,7 +439,7 @@ def leaky_relu(x, negative_slope=0.01, name=None):
return
_C_ops
.
leaky_relu
(
x
,
negative_slope
)
return
_C_ops
.
leaky_relu
(
x
,
negative_slope
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'leaky_relu'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'leaky_relu'
)
)
helper
=
LayerHelper
(
'leaky_relu'
,
**
locals
())
helper
=
LayerHelper
(
'leaky_relu'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
@@ -661,7 +661,7 @@ def rrelu(x, lower=1.0 / 8.0, upper=1.0 / 3.0, training=True, name=None):
...
@@ -661,7 +661,7 @@ def rrelu(x, lower=1.0 / 8.0, upper=1.0 / 3.0, training=True, name=None):
return
_C_ops
.
rrelu
(
x
,
lower
,
upper
,
is_test
)
return
_C_ops
.
rrelu
(
x
,
lower
,
upper
,
is_test
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'X'
,
[
'float16'
,
'float32'
,
'float64'
],
'rrelu'
x
,
'X'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'rrelu'
)
)
helper
=
LayerHelper
(
'rrelu'
,
**
locals
())
helper
=
LayerHelper
(
'rrelu'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
...
@@ -709,7 +709,7 @@ def relu(x, name=None):
...
@@ -709,7 +709,7 @@ def relu(x, name=None):
return
_C_ops
.
relu
(
x
)
return
_C_ops
.
relu
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'relu'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'relu'
)
)
helper
=
LayerHelper
(
'relu'
,
**
locals
())
helper
=
LayerHelper
(
'relu'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
...
@@ -874,7 +874,9 @@ def relu6(x, name=None):
...
@@ -874,7 +874,9 @@ def relu6(x, name=None):
if
in_dynamic_mode
():
if
in_dynamic_mode
():
return
_legacy_C_ops
.
relu6
(
x
,
'threshold'
,
threshold
)
return
_legacy_C_ops
.
relu6
(
x
,
'threshold'
,
threshold
)
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'relu6'
)
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'uint16'
,
'float32'
,
'float64'
],
'relu6'
)
helper
=
LayerHelper
(
'relu6'
,
**
locals
())
helper
=
LayerHelper
(
'relu6'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
helper
.
append_op
(
helper
.
append_op
(
...
@@ -983,7 +985,7 @@ def silu(x, name=None):
...
@@ -983,7 +985,7 @@ def silu(x, name=None):
return
_C_ops
.
silu
(
x
)
return
_C_ops
.
silu
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'silu'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'silu'
)
)
helper
=
LayerHelper
(
"silu"
,
**
locals
())
helper
=
LayerHelper
(
"silu"
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
...
@@ -1197,7 +1199,7 @@ def softplus(x, beta=1, threshold=20, name=None):
...
@@ -1197,7 +1199,7 @@ def softplus(x, beta=1, threshold=20, name=None):
return
_C_ops
.
softplus
(
x
,
beta
,
threshold
)
return
_C_ops
.
softplus
(
x
,
beta
,
threshold
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'softplus'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'softplus'
)
)
helper
=
LayerHelper
(
'softplus'
,
**
locals
())
helper
=
LayerHelper
(
'softplus'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
...
@@ -1256,7 +1258,7 @@ def softshrink(x, threshold=0.5, name=None):
...
@@ -1256,7 +1258,7 @@ def softshrink(x, threshold=0.5, name=None):
return
_C_ops
.
softshrink
(
x
,
threshold
)
return
_C_ops
.
softshrink
(
x
,
threshold
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'softshrink'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'softshrink'
)
)
helper
=
LayerHelper
(
'softshrink'
,
**
locals
())
helper
=
LayerHelper
(
'softshrink'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
...
@@ -1302,7 +1304,7 @@ def softsign(x, name=None):
...
@@ -1302,7 +1304,7 @@ def softsign(x, name=None):
return
_legacy_C_ops
.
softsign
(
x
)
return
_legacy_C_ops
.
softsign
(
x
)
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'softsign'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'softsign'
)
)
helper
=
LayerHelper
(
'softsign'
,
**
locals
())
helper
=
LayerHelper
(
'softsign'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
...
@@ -1341,7 +1343,7 @@ def swish(x, name=None):
...
@@ -1341,7 +1343,7 @@ def swish(x, name=None):
return
_C_ops
.
swish
(
x
)
return
_C_ops
.
swish
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'swish'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'swish'
)
)
helper
=
LayerHelper
(
'swish'
,
**
locals
())
helper
=
LayerHelper
(
'swish'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
...
@@ -1387,7 +1389,7 @@ def mish(x, name=None):
...
@@ -1387,7 +1389,7 @@ def mish(x, name=None):
return
_C_ops
.
mish
(
x
,
20
)
return
_C_ops
.
mish
(
x
,
20
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'mish'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'mish'
)
)
helper
=
LayerHelper
(
'mish'
,
**
locals
())
helper
=
LayerHelper
(
'mish'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
...
@@ -1426,7 +1428,7 @@ def tanhshrink(x, name=None):
...
@@ -1426,7 +1428,7 @@ def tanhshrink(x, name=None):
return
_C_ops
.
tanh_shrink
(
x
)
return
_C_ops
.
tanh_shrink
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'tanhshrink'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'tanhshrink'
)
)
helper
=
LayerHelper
(
'tanh_shrink'
,
**
locals
())
helper
=
LayerHelper
(
'tanh_shrink'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
...
@@ -1476,7 +1478,10 @@ def thresholded_relu(x, threshold=1.0, name=None):
...
@@ -1476,7 +1478,10 @@ def thresholded_relu(x, threshold=1.0, name=None):
return
_C_ops
.
thresholded_relu
(
x
,
threshold
)
return
_C_ops
.
thresholded_relu
(
x
,
threshold
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'thresholded_relu'
x
,
'x'
,
[
'float16'
,
'uint16'
,
'float32'
,
'float64'
],
'thresholded_relu'
,
)
)
helper
=
LayerHelper
(
'thresholded_relu'
,
**
locals
())
helper
=
LayerHelper
(
'thresholded_relu'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
...
@@ -1554,7 +1559,10 @@ def log_softmax(x, axis=-1, dtype=None, name=None):
...
@@ -1554,7 +1559,10 @@ def log_softmax(x, axis=-1, dtype=None, name=None):
else
:
else
:
if
dtype
is
None
:
if
dtype
is
None
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'log_softmax'
x
,
'x'
,
[
'float16'
,
'uint16'
,
'float32'
,
'float64'
],
'log_softmax'
,
)
)
else
:
else
:
check_dtype
(
check_dtype
(
...
...
python/paddle/nn/functional/conv.py
浏览文件 @
4efca9fb
...
@@ -237,7 +237,7 @@ def _conv_nd(
...
@@ -237,7 +237,7 @@ def _conv_nd(
"data_format"
:
data_format
,
"data_format"
:
data_format
,
}
}
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
op_type
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
op_type
)
)
helper
=
LayerHelper
(
op_type
,
**
locals
())
helper
=
LayerHelper
(
op_type
,
**
locals
())
dtype
=
helper
.
input_dtype
(
input_param_name
=
'x'
)
dtype
=
helper
.
input_dtype
(
input_param_name
=
'x'
)
...
@@ -1344,7 +1344,10 @@ def conv2d_transpose(
...
@@ -1344,7 +1344,10 @@ def conv2d_transpose(
'data_format'
:
data_format
,
'data_format'
:
data_format
,
}
}
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'conv2d_transpose'
x
,
'x'
,
[
'float16'
,
'uint16'
,
'float32'
,
'float64'
],
'conv2d_transpose'
,
)
)
helper
=
LayerHelper
(
op_type
,
**
locals
())
helper
=
LayerHelper
(
op_type
,
**
locals
())
pre_bias
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
pre_bias
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
...
...
python/paddle/nn/functional/norm.py
浏览文件 @
4efca9fb
...
@@ -213,7 +213,7 @@ def batch_norm(
...
@@ -213,7 +213,7 @@ def batch_norm(
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'input'
,
[
'float16'
,
'float32'
,
'float64'
],
'BatchNorm'
x
,
'input'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'BatchNorm'
)
)
# for static need dict
# for static need dict
...
...
python/paddle/nn/layer/norm.py
浏览文件 @
4efca9fb
...
@@ -1561,7 +1561,10 @@ class SyncBatchNorm(_BatchNormBase):
...
@@ -1561,7 +1561,10 @@ class SyncBatchNorm(_BatchNormBase):
return
sync_batch_norm_out
return
sync_batch_norm_out
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'input'
,
[
'float16'
,
'float32'
,
'float64'
],
'SyncBatchNorm'
x
,
'input'
,
[
'float16'
,
'uint16'
,
'float32'
,
'float64'
],
'SyncBatchNorm'
,
)
)
attrs
=
{
attrs
=
{
...
...
python/paddle/static/nn/metric.py
浏览文件 @
4efca9fb
...
@@ -89,7 +89,7 @@ def accuracy(input, label, k=1, correct=None, total=None):
...
@@ -89,7 +89,7 @@ def accuracy(input, label, k=1, correct=None, total=None):
helper
=
LayerHelper
(
"accuracy"
,
**
locals
())
helper
=
LayerHelper
(
"accuracy"
,
**
locals
())
check_variable_and_dtype
(
check_variable_and_dtype
(
input
,
'input'
,
[
'float16'
,
'float32'
,
'float64'
],
'accuracy'
input
,
'input'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'accuracy'
)
)
topk_out
=
helper
.
create_variable_for_type_inference
(
dtype
=
input
.
dtype
)
topk_out
=
helper
.
create_variable_for_type_inference
(
dtype
=
input
.
dtype
)
topk_indices
=
helper
.
create_variable_for_type_inference
(
dtype
=
"int64"
)
topk_indices
=
helper
.
create_variable_for_type_inference
(
dtype
=
"int64"
)
...
...
python/paddle/tensor/creation.py
浏览文件 @
4efca9fb
...
@@ -1354,7 +1354,7 @@ def _tril_triu_op(helper):
...
@@ -1354,7 +1354,7 @@ def _tril_triu_op(helper):
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
x
,
'x'
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
,
'int32'
,
'int64'
,
'bool'
],
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
,
'int32'
,
'int64'
,
'bool'
],
op_type
,
op_type
,
)
)
if
len
(
x
.
shape
)
<
2
:
if
len
(
x
.
shape
)
<
2
:
...
...
python/paddle/tensor/linalg.py
浏览文件 @
4efca9fb
...
@@ -415,7 +415,10 @@ def norm(x, p='fro', axis=None, keepdim=False, name=None):
...
@@ -415,7 +415,10 @@ def norm(x, p='fro', axis=None, keepdim=False, name=None):
if
axis
is
not
None
:
if
axis
is
not
None
:
check_type
(
axis
,
'axis'
,
(
int
),
'p_norm'
)
check_type
(
axis
,
'axis'
,
(
int
),
'p_norm'
)
check_variable_and_dtype
(
check_variable_and_dtype
(
input
,
'input'
,
[
'float32'
,
'float64'
],
'p_norm'
input
,
'input'
,
[
'float16'
,
'uint16'
,
'float32'
,
'float64'
],
'p_norm'
,
)
)
attrs
=
{
attrs
=
{
...
...
python/paddle/tensor/manipulation.py
浏览文件 @
4efca9fb
...
@@ -2201,6 +2201,7 @@ def squeeze(x, axis=None, name=None):
...
@@ -2201,6 +2201,7 @@ def squeeze(x, axis=None, name=None):
'input'
,
'input'
,
[
[
'float16'
,
'float16'
,
'uint16'
,
'float32'
,
'float32'
,
'float64'
,
'float64'
,
'bool'
,
'bool'
,
...
@@ -2477,7 +2478,10 @@ def unique(
...
@@ -2477,7 +2478,10 @@ def unique(
return
tuple
(
outs
)
return
tuple
(
outs
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
"input"
,
[
'float32'
,
'float64'
,
'int32'
,
'int64'
],
'unique'
x
,
"input"
,
[
'float16'
,
'uint16'
,
'float32'
,
'float64'
,
'int32'
,
'int64'
],
'unique'
,
)
)
check_type
(
return_index
,
'return_index'
,
bool
,
'unique'
)
check_type
(
return_index
,
'return_index'
,
bool
,
'unique'
)
check_type
(
return_inverse
,
'return_inverse'
,
bool
,
'unique'
)
check_type
(
return_inverse
,
'return_inverse'
,
bool
,
'unique'
)
...
@@ -2597,6 +2601,7 @@ def unsqueeze(x, axis, name=None):
...
@@ -2597,6 +2601,7 @@ def unsqueeze(x, axis, name=None):
'input'
,
'input'
,
[
[
'float16'
,
'float16'
,
'uint16'
,
'float32'
,
'float32'
,
'float64'
,
'float64'
,
'bool'
,
'bool'
,
...
@@ -3867,7 +3872,15 @@ def strided_slice(x, axes, starts, ends, strides, name=None):
...
@@ -3867,7 +3872,15 @@ def strided_slice(x, axes, starts, ends, strides, name=None):
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
x
,
'x'
,
'x'
,
[
'bool'
,
'float16'
,
'float32'
,
'float64'
,
'int32'
,
'int64'
],
[
'bool'
,
'float16'
,
'uint16'
,
'float32'
,
'float64'
,
'int32'
,
'int64'
,
],
'strided_slice'
,
'strided_slice'
,
)
)
check_type
(
axes
,
'axes'
,
(
list
,
tuple
),
'strided_slice'
)
check_type
(
axes
,
'axes'
,
(
list
,
tuple
),
'strided_slice'
)
...
...
python/paddle/tensor/math.py
浏览文件 @
4efca9fb
...
@@ -288,7 +288,7 @@ def stanh(x, scale_a=0.67, scale_b=1.7159, name=None):
...
@@ -288,7 +288,7 @@ def stanh(x, scale_a=0.67, scale_b=1.7159, name=None):
return
_C_ops
.
stanh
(
x
,
scale_a
,
scale_b
)
return
_C_ops
.
stanh
(
x
,
scale_a
,
scale_b
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'stanh'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'stanh'
)
)
helper
=
LayerHelper
(
'stanh'
,
**
locals
())
helper
=
LayerHelper
(
'stanh'
,
**
locals
())
...
@@ -2717,7 +2717,7 @@ def log1p(x, name=None):
...
@@ -2717,7 +2717,7 @@ def log1p(x, name=None):
return
_C_ops
.
log1p
(
x
)
return
_C_ops
.
log1p
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
"log1p"
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
"log1p"
)
)
inputs
=
{
'X'
:
[
x
]}
inputs
=
{
'X'
:
[
x
]}
helper
=
LayerHelper
(
'log1p'
,
**
locals
())
helper
=
LayerHelper
(
'log1p'
,
**
locals
())
...
@@ -2769,7 +2769,7 @@ def log2(x, name=None):
...
@@ -2769,7 +2769,7 @@ def log2(x, name=None):
return
_C_ops
.
log2
(
x
)
return
_C_ops
.
log2
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
"log2"
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
"log2"
)
)
inputs
=
{
'X'
:
[
x
]}
inputs
=
{
'X'
:
[
x
]}
helper
=
LayerHelper
(
'log2'
,
**
locals
())
helper
=
LayerHelper
(
'log2'
,
**
locals
())
...
@@ -2821,7 +2821,7 @@ def log10(x, name=None):
...
@@ -2821,7 +2821,7 @@ def log10(x, name=None):
return
_C_ops
.
log10
(
x
)
return
_C_ops
.
log10
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
"log10"
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
"log10"
)
)
inputs
=
{
'X'
:
[
x
]}
inputs
=
{
'X'
:
[
x
]}
helper
=
LayerHelper
(
'log10'
,
**
locals
())
helper
=
LayerHelper
(
'log10'
,
**
locals
())
...
@@ -4252,7 +4252,7 @@ def logit(x, eps=None, name=None):
...
@@ -4252,7 +4252,7 @@ def logit(x, eps=None, name=None):
return
_C_ops
.
logit
(
x
,
eps
)
return
_C_ops
.
logit
(
x
,
eps
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'logit'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'logit'
)
)
helper
=
LayerHelper
(
"logit"
,
**
locals
())
helper
=
LayerHelper
(
"logit"
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
x
.
dtype
)
...
...
python/paddle/tensor/ops.py
浏览文件 @
4efca9fb
...
@@ -221,7 +221,7 @@ def acos(x, name=None):
...
@@ -221,7 +221,7 @@ def acos(x, name=None):
return
_C_ops
.
acos
(
x
)
return
_C_ops
.
acos
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'acos'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'acos'
)
)
helper
=
LayerHelper
(
'acos'
,
**
locals
())
helper
=
LayerHelper
(
'acos'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
@@ -258,7 +258,7 @@ def acosh(x, name=None):
...
@@ -258,7 +258,7 @@ def acosh(x, name=None):
return
_C_ops
.
acosh
(
x
)
return
_C_ops
.
acosh
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'acosh'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'acosh'
)
)
helper
=
LayerHelper
(
'acosh'
,
**
locals
())
helper
=
LayerHelper
(
'acosh'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
@@ -295,7 +295,7 @@ def asin(x, name=None):
...
@@ -295,7 +295,7 @@ def asin(x, name=None):
return
_C_ops
.
asin
(
x
)
return
_C_ops
.
asin
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'asin'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'asin'
)
)
helper
=
LayerHelper
(
'asin'
,
**
locals
())
helper
=
LayerHelper
(
'asin'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
@@ -332,7 +332,7 @@ def asinh(x, name=None):
...
@@ -332,7 +332,7 @@ def asinh(x, name=None):
return
_C_ops
.
asinh
(
x
)
return
_C_ops
.
asinh
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'asinh'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'asinh'
)
)
helper
=
LayerHelper
(
'asinh'
,
**
locals
())
helper
=
LayerHelper
(
'asinh'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
@@ -369,7 +369,7 @@ def atan(x, name=None):
...
@@ -369,7 +369,7 @@ def atan(x, name=None):
return
_C_ops
.
atan
(
x
)
return
_C_ops
.
atan
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'atan'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'atan'
)
)
helper
=
LayerHelper
(
'atan'
,
**
locals
())
helper
=
LayerHelper
(
'atan'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
@@ -406,7 +406,7 @@ def atanh(x, name=None):
...
@@ -406,7 +406,7 @@ def atanh(x, name=None):
return
_C_ops
.
atanh
(
x
)
return
_C_ops
.
atanh
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'atanh'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'atanh'
)
)
helper
=
LayerHelper
(
'atanh'
,
**
locals
())
helper
=
LayerHelper
(
'atanh'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
@@ -444,7 +444,7 @@ def ceil(x, name=None):
...
@@ -444,7 +444,7 @@ def ceil(x, name=None):
return
_C_ops
.
ceil
(
x
)
return
_C_ops
.
ceil
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'ceil'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'ceil'
)
)
helper
=
LayerHelper
(
'ceil'
,
**
locals
())
helper
=
LayerHelper
(
'ceil'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
@@ -522,7 +522,7 @@ def cosh(x, name=None):
...
@@ -522,7 +522,7 @@ def cosh(x, name=None):
return
_C_ops
.
cosh
(
x
)
return
_C_ops
.
cosh
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'cosh'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'cosh'
)
)
helper
=
LayerHelper
(
'cosh'
,
**
locals
())
helper
=
LayerHelper
(
'cosh'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
@@ -611,7 +611,7 @@ def expm1(x, name=None):
...
@@ -611,7 +611,7 @@ def expm1(x, name=None):
return
_C_ops
.
expm1
(
x
)
return
_C_ops
.
expm1
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'expm1'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'expm1'
)
)
helper
=
LayerHelper
(
'expm1'
,
**
locals
())
helper
=
LayerHelper
(
'expm1'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
@@ -649,7 +649,7 @@ def floor(x, name=None):
...
@@ -649,7 +649,7 @@ def floor(x, name=None):
return
_C_ops
.
floor
(
x
)
return
_C_ops
.
floor
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'floor'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'floor'
)
)
helper
=
LayerHelper
(
'floor'
,
**
locals
())
helper
=
LayerHelper
(
'floor'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
@@ -687,7 +687,7 @@ def reciprocal(x, name=None):
...
@@ -687,7 +687,7 @@ def reciprocal(x, name=None):
return
_C_ops
.
reciprocal
(
x
)
return
_C_ops
.
reciprocal
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'reciprocal'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'reciprocal'
)
)
helper
=
LayerHelper
(
'reciprocal'
,
**
locals
())
helper
=
LayerHelper
(
'reciprocal'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
@@ -734,7 +734,7 @@ def round(x, name=None):
...
@@ -734,7 +734,7 @@ def round(x, name=None):
return
_C_ops
.
round
(
x
)
return
_C_ops
.
round
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'round'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'round'
)
)
helper
=
LayerHelper
(
'round'
,
**
locals
())
helper
=
LayerHelper
(
'round'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
@@ -773,7 +773,7 @@ def rsqrt(x, name=None):
...
@@ -773,7 +773,7 @@ def rsqrt(x, name=None):
return
_C_ops
.
rsqrt
(
x
)
return
_C_ops
.
rsqrt
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'rsqrt'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'rsqrt'
)
)
helper
=
LayerHelper
(
'rsqrt'
,
**
locals
())
helper
=
LayerHelper
(
'rsqrt'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
@@ -848,7 +848,7 @@ def sin(x, name=None):
...
@@ -848,7 +848,7 @@ def sin(x, name=None):
return
_C_ops
.
sin
(
x
)
return
_C_ops
.
sin
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'sin'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'sin'
)
)
helper
=
LayerHelper
(
'sin'
,
**
locals
())
helper
=
LayerHelper
(
'sin'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
@@ -885,7 +885,7 @@ def sinh(x, name=None):
...
@@ -885,7 +885,7 @@ def sinh(x, name=None):
return
_C_ops
.
sinh
(
x
)
return
_C_ops
.
sinh
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'sinh'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'sinh'
)
)
helper
=
LayerHelper
(
'sinh'
,
**
locals
())
helper
=
LayerHelper
(
'sinh'
,
**
locals
())
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
out
=
helper
.
create_variable_for_type_inference
(
dtype
=
x
.
dtype
)
...
@@ -1010,7 +1010,7 @@ def tan(x, name=None):
...
@@ -1010,7 +1010,7 @@ def tan(x, name=None):
return
_C_ops
.
tan
(
x
)
return
_C_ops
.
tan
(
x
)
else
:
else
:
check_variable_and_dtype
(
check_variable_and_dtype
(
x
,
'x'
,
[
'float16'
,
'float32'
,
'float64'
],
'tan'
x
,
'x'
,
[
'float16'
,
'
uint16'
,
'
float32'
,
'float64'
],
'tan'
)
)
helper
=
LayerHelper
(
'tan'
,
**
locals
())
helper
=
LayerHelper
(
'tan'
,
**
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录