Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
8412d6c0
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看板
未验证
提交
8412d6c0
编写于
9月 11, 2021
作者:
王
王明冬
提交者:
GitHub
9月 11, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
register the with_quant_attr attribute for all operattor. test=develop (#35591)
上级
ec252914
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
57 addition
and
26 deletion
+57
-26
paddle/fluid/framework/ir/op_compat_sensible_pass.cc
paddle/fluid/framework/ir/op_compat_sensible_pass.cc
+1
-1
paddle/fluid/framework/op_proto_maker.cc
paddle/fluid/framework/op_proto_maker.cc
+6
-0
paddle/fluid/framework/op_proto_maker.h
paddle/fluid/framework/op_proto_maker.h
+1
-0
paddle/fluid/operators/benchmark/op_tester.cc
paddle/fluid/operators/benchmark/op_tester.cc
+2
-1
paddle/fluid/pybind/const_value.cc
paddle/fluid/pybind/const_value.cc
+3
-0
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+40
-22
python/paddle/fluid/tests/unittests/test_operator_desc.py
python/paddle/fluid/tests/unittests/test_operator_desc.py
+2
-1
python/paddle/utils/cpp_extension/extension_utils.py
python/paddle/utils/cpp_extension/extension_utils.py
+2
-1
未找到文件。
paddle/fluid/framework/ir/op_compat_sensible_pass.cc
浏览文件 @
8412d6c0
...
...
@@ -25,7 +25,7 @@ std::unordered_set<std::string> global_extra_attrs = {
"op_callstack"
,
"op_device"
,
"@ENABLE_CACHE_RUNTIME_CONTEXT@"
,
"is_test"
,
"use_mkldnn"
,
"mkldnn_data_type"
,
"use_quantizer"
,
"mkldnn_data_type"
,
"use_cudnn"
,
"name"
};
"name"
,
"with_quant_attr"
};
}
namespace
paddle
{
...
...
paddle/fluid/framework/op_proto_maker.cc
浏览文件 @
8412d6c0
...
...
@@ -98,6 +98,12 @@ void OpProtoAndCheckerMaker::operator()(proto::OpProto* proto,
AddAttr
<
std
::
string
>
(
OpDeviceAttrName
(),
"Device type of this operator."
)
.
SetDefault
(
""
)
.
AsExtra
();
AddAttr
<
bool
>
(
OpWithQuantAttrName
(),
"Whether the operator has attributes used by quantization. "
)
.
SetDefault
(
false
)
.
AsExtra
();
Validate
();
}
...
...
paddle/fluid/framework/op_proto_maker.h
浏览文件 @
8412d6c0
...
...
@@ -48,6 +48,7 @@ class OpProtoAndCheckerMaker {
static
const
char
*
OpNamescopeAttrName
()
{
return
"op_namescope"
;
}
static
const
char
*
OpCreationCallstackAttrName
()
{
return
"op_callstack"
;
}
static
const
char
*
OpDeviceAttrName
()
{
return
"op_device"
;
}
static
const
char
*
OpWithQuantAttrName
()
{
return
"with_quant_attr"
;
}
void
operator
()(
proto
::
OpProto
*
proto
,
OpAttrChecker
*
attr_checker
);
...
...
paddle/fluid/operators/benchmark/op_tester.cc
浏览文件 @
8412d6c0
...
...
@@ -142,7 +142,8 @@ OpTester::GetOpProtoAttrNames() {
framework
::
OpProtoAndCheckerMaker
::
OpRoleAttrName
(),
framework
::
OpProtoAndCheckerMaker
::
OpRoleVarAttrName
(),
framework
::
OpProtoAndCheckerMaker
::
OpNamescopeAttrName
(),
framework
::
OpProtoAndCheckerMaker
::
OpCreationCallstackAttrName
()};
framework
::
OpProtoAndCheckerMaker
::
OpCreationCallstackAttrName
(),
framework
::
OpProtoAndCheckerMaker
::
OpWithQuantAttrName
()};
for
(
int
i
=
0
;
i
!=
proto
.
attrs_size
();
++
i
)
{
const
auto
&
attr
=
proto
.
attrs
(
i
);
if
(
!
Has
(
skipped_attrs
,
attr
.
name
()))
{
...
...
paddle/fluid/pybind/const_value.cc
浏览文件 @
8412d6c0
...
...
@@ -63,6 +63,9 @@ void BindConstValue(pybind11::module* m) {
framework
::
OpProtoAndCheckerMaker
::
OpCreationCallstackAttrName
);
op_proto_and_checker_maker
.
def
(
"kOpDeviceAttrName"
,
framework
::
OpProtoAndCheckerMaker
::
OpDeviceAttrName
);
op_proto_and_checker_maker
.
def
(
"kOpWithQuantAttrName"
,
framework
::
OpProtoAndCheckerMaker
::
OpWithQuantAttrName
);
#if defined(PADDLE_WITH_DGC)
auto
dgc
=
m
->
def_submodule
(
"dgc"
);
dgc
.
def
(
"kDGCKName"
,
[]
{
return
framework
::
details
::
g_dgc_k
;
});
...
...
python/paddle/fluid/layers/nn.py
浏览文件 @
8412d6c0
...
...
@@ -11558,13 +11558,13 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.array([2, 3, 4]).astype('float32'),
"y": np.array([1, 5, 2]).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[3], dtype='float32')
y = fluid.data(name="y", shape=[3], dtype='float32')
z = fluid.layers.elementwise_add(x, y)
...
...
@@ -11582,13 +11582,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.ones((2, 3, 4, 5)).astype('float32'),
"y": np.zeros((3, 4)).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
y = fluid.data(name="y", shape=[3,4], dtype='float32')
z = fluid.layers.elementwise_add(x, y, axis=1)
...
...
@@ -11607,13 +11608,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.random.randint(1, 5, size=[2, 3, 4, 5]).astype('float32'),
"y": np.random.randint(1, 5, size=[5]).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
y = fluid.data(name="y", shape=[5], dtype='float32')
z = fluid.layers.elementwise_add(x, y, axis=3)
...
...
@@ -11649,13 +11651,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.array([2, 3, 4]).astype('float32'),
"y": np.array([1, 5, 2]).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[3], dtype='float32')
y = fluid.data(name="y", shape=[3], dtype='float32')
z = fluid.layers.elementwise_div(x, y)
...
...
@@ -11673,13 +11676,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.ones((2, 3, 4, 5)).astype('float32'),
"y": np.zeros((3, 4)).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
y = fluid.data(name="y", shape=[3,4], dtype='float32')
z = fluid.layers.elementwise_div(x, y, axis=1)
...
...
@@ -11698,13 +11702,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.random.randint(1, 5, size=[2, 3, 4, 5]).astype('float32'),
"y": np.random.randint(1, 5, size=[5]).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
y = fluid.data(name="y", shape=[5], dtype='float32')
z = fluid.layers.elementwise_div(x, y, axis=3)
...
...
@@ -11734,13 +11739,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.array([2, 3, 4]).astype('float32'),
"y": np.array([1, 5, 2]).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[3], dtype='float32')
y = fluid.data(name="y", shape=[3], dtype='float32')
z = fluid.layers.elementwise_sub(x, y)
...
...
@@ -11758,13 +11764,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.ones((2, 3, 4, 5)).astype('float32'),
"y": np.zeros((3, 4)).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
y = fluid.data(name="y", shape=[3,4], dtype='float32')
z = fluid.layers.elementwise_sub(x, y, axis=1)
...
...
@@ -11783,13 +11790,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.random.randint(1, 5, size=[2, 3, 4, 5]).astype('float32'),
"y": np.random.randint(1, 5, size=[5]).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
y = fluid.data(name="y", shape=[5], dtype='float32')
z = fluid.layers.elementwise_sub(x, y, axis=3)
...
...
@@ -11820,13 +11828,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.array([2, 3, 4]).astype('float32'),
"y": np.array([1, 5, 2]).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[3], dtype='float32')
y = fluid.data(name="y", shape=[3], dtype='float32')
z = fluid.layers.elementwise_mul(x, y)
...
...
@@ -11844,13 +11853,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.ones((2, 3, 4, 5)).astype('float32'),
"y": np.zeros((3, 4)).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
y = fluid.data(name="y", shape=[3,4], dtype='float32')
z = fluid.layers.elementwise_mul(x, y, axis=1)
...
...
@@ -11869,13 +11879,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.random.randint(1, 5, size=[2, 3, 4, 5]).astype('float32'),
"y": np.random.randint(1, 5, size=[5]).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
y = fluid.data(name="y", shape=[5], dtype='float32')
z = fluid.layers.elementwise_mul(x, y, axis=3)
...
...
@@ -11908,13 +11919,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.array([2, 3, 4]).astype('float32'),
"y": np.array([1, 5, 2]).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[3], dtype='float32')
y = fluid.data(name="y", shape=[3], dtype='float32')
z = fluid.layers.elementwise_max(x, y)
...
...
@@ -11931,13 +11943,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.ones((2, 3, 4, 5)).astype('float32'),
"y": np.zeros((3, 4)).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
y = fluid.data(name="y", shape=[3,4], dtype='float32')
z = fluid.layers.elementwise_max(x, y, axis=1)
...
...
@@ -11970,13 +11983,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.array([2, 3, 4]).astype('float32'),
"y": np.array([1, 5, 2]).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[3], dtype='float32')
y = fluid.data(name="y", shape=[3], dtype='float32')
z = fluid.layers.elementwise_min(x, y)
...
...
@@ -11992,13 +12006,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.ones((2, 3, 4, 5)).astype('float32'),
"y": np.zeros((3, 4)).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[2,3,4,5], dtype='float32')
y = fluid.data(name="y", shape=[3,4], dtype='float32')
z = fluid.layers.elementwise_min(x, y, axis=1)
...
...
@@ -12027,13 +12042,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.array([2, 3, 4]).astype('float32'),
"y": np.array([1, 5, 2]).astype('float32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[3], dtype='float32')
y = fluid.data(name="y", shape=[3], dtype='float32')
z = fluid.layers.elementwise_pow(x, y)
...
...
@@ -12061,13 +12077,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.array([10, 15, 8]).astype('int32'),
"y": np.array([3, 6, 5]).astype('int32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[3], dtype='int32')
y = fluid.data(name="y", shape=[3], dtype='int32')
z = fluid.layers.elementwise_mod(x, y)
...
...
@@ -12096,13 +12113,14 @@ Examples:
import paddle.fluid as fluid
import numpy as np
import paddle
def gen_data():
return {
"x": np.array([10, 15, 8]).astype('int32'),
"y": np.array([3, 7, 5]).astype('int32')
}
paddle.enable_static()
x = fluid.data(name="x", shape=[3], dtype='int32')
y = fluid.data(name="y", shape=[3], dtype='int32')
z = fluid.layers.elementwise_floordiv(x, y)
...
...
@@ -13423,8 +13441,8 @@ def shuffle_channel(x, group, name=None):
.. code-block:: python
import paddle
import paddle.fluid as fluid
paddle.enable_static()
import paddle.fluid as fluid
paddle.enable_static()
input = fluid.data(name='input', shape=[None,4,2,2], dtype='float32')
out = fluid.layers.shuffle_channel(x=input, group=2)
"""
...
...
python/paddle/fluid/tests/unittests/test_operator_desc.py
浏览文件 @
8412d6c0
...
...
@@ -70,7 +70,8 @@ class TestOperator(unittest.TestCase):
set
([
"x_num_col_dims"
,
"y_num_col_dims"
,
"op_role"
,
"op_role_var"
,
"use_mkldnn"
,
"scale_x"
,
"scale_y"
,
"scale_out"
,
"force_fp32_output"
,
"op_namescope"
,
"op_callstack"
,
"op_device"
"force_fp32_output"
,
"op_namescope"
,
"op_callstack"
,
"op_device"
,
"with_quant_attr"
]))
self
.
assertEqual
(
mul_op
.
has_attr
(
"x_num_col_dims"
),
True
)
self
.
assertEqual
(
mul_op
.
attr_type
(
"x_num_col_dims"
),
core
.
AttrType
.
INT
)
...
...
python/paddle/utils/cpp_extension/extension_utils.py
浏览文件 @
8412d6c0
...
...
@@ -100,7 +100,8 @@ DEFAULT_OP_ATTR_NAMES = [
core
.
op_proto_and_checker_maker
.
kOpRoleVarAttrName
(),
core
.
op_proto_and_checker_maker
.
kOpNameScopeAttrName
(),
core
.
op_proto_and_checker_maker
.
kOpCreationCallstackAttrName
(),
core
.
op_proto_and_checker_maker
.
kOpDeviceAttrName
()
core
.
op_proto_and_checker_maker
.
kOpDeviceAttrName
(),
core
.
op_proto_and_checker_maker
.
kOpWithQuantAttrName
()
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录