Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
666c3bb9
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看板
提交
666c3bb9
编写于
12月 19, 2019
作者:
W
Wojciech Uss
提交者:
Tao Luo
12月 19, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
handle multi-inputs with empty inputs for mkldnn_concat_op (#21827)
test=develop
上级
a9af87ed
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
6 deletion
+31
-6
paddle/fluid/operators/mkldnn/concat_mkldnn_op.cc
paddle/fluid/operators/mkldnn/concat_mkldnn_op.cc
+11
-1
paddle/fluid/operators/roi_align_op.h
paddle/fluid/operators/roi_align_op.h
+0
-2
python/paddle/fluid/tests/unittests/mkldnn/test_concat_mkldnn_op.py
...dle/fluid/tests/unittests/mkldnn/test_concat_mkldnn_op.py
+20
-3
未找到文件。
paddle/fluid/operators/mkldnn/concat_mkldnn_op.cc
浏览文件 @
666c3bb9
...
@@ -59,6 +59,16 @@ static const mkldnn::engine& GetMKLDNNEngine(
...
@@ -59,6 +59,16 @@ static const mkldnn::engine& GetMKLDNNEngine(
return
dev_ctx
.
GetEngine
();
return
dev_ctx
.
GetEngine
();
}
}
// From a multi-input, gather only nonempty inputs
static
const
std
::
vector
<
const
Tensor
*>
ReduceMultiInput
(
const
std
::
vector
<
const
Tensor
*>&
inputs
)
{
std
::
vector
<
const
Tensor
*>
reduced
(
inputs
.
size
());
auto
end_it
=
std
::
copy_if
(
inputs
.
begin
(),
inputs
.
end
(),
reduced
.
begin
(),
[](
const
Tensor
*
t
)
{
return
t
->
numel
()
>
0
;
});
reduced
.
resize
(
std
::
distance
(
reduced
.
begin
(),
end_it
));
return
reduced
;
}
template
<
typename
T
>
template
<
typename
T
>
class
ConcatPrimitiveFactory
{
class
ConcatPrimitiveFactory
{
public:
public:
...
@@ -120,7 +130,7 @@ template <typename T>
...
@@ -120,7 +130,7 @@ template <typename T>
class
ConcatMKLDNNOpKernel
:
public
paddle
::
framework
::
OpKernel
<
T
>
{
class
ConcatMKLDNNOpKernel
:
public
paddle
::
framework
::
OpKernel
<
T
>
{
public:
public:
void
Compute
(
const
paddle
::
framework
::
ExecutionContext
&
ctx
)
const
override
{
void
Compute
(
const
paddle
::
framework
::
ExecutionContext
&
ctx
)
const
override
{
auto
multi_input
=
ctx
.
MultiInput
<
Tensor
>
(
"X"
);
auto
multi_input
=
ReduceMultiInput
(
ctx
.
MultiInput
<
Tensor
>
(
"X"
)
);
EnforceLayouts
(
multi_input
);
EnforceLayouts
(
multi_input
);
Tensor
*
output
=
ctx
.
Output
<
Tensor
>
(
"Out"
);
Tensor
*
output
=
ctx
.
Output
<
Tensor
>
(
"Out"
);
int
concat_axis
=
ctx
.
Attr
<
int
>
(
"axis"
);
int
concat_axis
=
ctx
.
Attr
<
int
>
(
"axis"
);
...
...
paddle/fluid/operators/roi_align_op.h
浏览文件 @
666c3bb9
...
@@ -154,8 +154,6 @@ class CPUROIAlignOpKernel : public framework::OpKernel<T> {
...
@@ -154,8 +154,6 @@ class CPUROIAlignOpKernel : public framework::OpKernel<T> {
int
width
=
in_dims
[
3
];
int
width
=
in_dims
[
3
];
int
rois_num
=
rois
->
dims
()[
0
];
int
rois_num
=
rois
->
dims
()[
0
];
if
(
rois_num
==
0
)
return
;
auto
in_stride
=
framework
::
stride
(
in_dims
);
auto
in_stride
=
framework
::
stride
(
in_dims
);
auto
roi_stride
=
framework
::
stride
(
rois
->
dims
());
auto
roi_stride
=
framework
::
stride
(
rois
->
dims
());
auto
out_stride
=
framework
::
stride
(
out
->
dims
());
auto
out_stride
=
framework
::
stride
(
out
->
dims
());
...
...
python/paddle/fluid/tests/unittests/mkldnn/test_concat_mkldnn_op.py
浏览文件 @
666c3bb9
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
from
__future__
import
print_function
from
__future__
import
print_function
import
unittest
import
unittest
from
paddle.fluid.tests.unittests.test_concat_op
import
TestConcatOp
,
TestConcatOp2
,
TestConcatOp3
from
paddle.fluid.tests.unittests.test_concat_op
import
TestConcatOp
,
TestConcatOp2
,
TestConcatOp3
,
TestConcatOp4
class
TestMKLDNNConcatOp
(
TestConcatOp
):
class
TestMKLDNNConcatOp
(
TestConcatOp
):
...
@@ -42,7 +42,7 @@ class TestMKLDNNConcatOp2(TestConcatOp2):
...
@@ -42,7 +42,7 @@ class TestMKLDNNConcatOp2(TestConcatOp2):
self
.
_cpu_only
=
True
self
.
_cpu_only
=
True
def
test_check_output
(
self
):
def
test_check_output
(
self
):
# TODO(wangzhongpu): support mkldnn op in dygraph mode
# TODO(wangzhongpu): support mkldnn op in dygraph mode
self
.
check_output
(
check_dygraph
=
(
self
.
attrs
[
"use_mkldnn"
]
==
False
))
self
.
check_output
(
check_dygraph
=
(
self
.
attrs
[
"use_mkldnn"
]
==
False
))
def
test_check_grad
(
self
):
def
test_check_grad
(
self
):
...
@@ -59,7 +59,24 @@ class TestMKLDNNConcatOp3(TestConcatOp3):
...
@@ -59,7 +59,24 @@ class TestMKLDNNConcatOp3(TestConcatOp3):
self
.
_cpu_only
=
True
self
.
_cpu_only
=
True
def
test_check_output
(
self
):
def
test_check_output
(
self
):
# TODO(wangzhongpu): support mkldnn op in dygraph mode
# TODO(wangzhongpu): support mkldnn op in dygraph mode
self
.
check_output
(
check_dygraph
=
(
self
.
attrs
[
"use_mkldnn"
]
==
False
))
def
test_check_grad
(
self
):
pass
def
init_kernel_type
(
self
):
self
.
use_mkldnn
=
True
class
TestMKLDNNConcatOp4
(
TestConcatOp4
):
def
setUp
(
self
):
super
(
TestMKLDNNConcatOp4
,
self
).
setUp
()
self
.
attrs
[
"use_mkldnn"
]
=
True
self
.
_cpu_only
=
True
def
test_check_output
(
self
):
# TODO(wangzhongpu): support mkldnn op in dygraph mode
self
.
check_output
(
check_dygraph
=
(
self
.
attrs
[
"use_mkldnn"
]
==
False
))
self
.
check_output
(
check_dygraph
=
(
self
.
attrs
[
"use_mkldnn"
]
==
False
))
def
test_check_grad
(
self
):
def
test_check_grad
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录