Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
d7652d5f
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
提交
d7652d5f
编写于
10月 04, 2022
作者:
J
Jacek Czaja
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
first commit
上级
19746835
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
7 addition
and
363 deletion
+7
-363
paddle/fluid/operators/mkldnn/activation_mkldnn_op.cc
paddle/fluid/operators/mkldnn/activation_mkldnn_op.cc
+0
-1
paddle/fluid/operators/mkldnn/dequantize_mkldnn_op.cc
paddle/fluid/operators/mkldnn/dequantize_mkldnn_op.cc
+0
-1
paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc
paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc
+0
-1
paddle/fluid/operators/mkldnn/interpolate_mkldnn_op.cc
paddle/fluid/operators/mkldnn/interpolate_mkldnn_op.cc
+0
-1
paddle/fluid/operators/mkldnn/matmul_v2_mkldnn_op.cc
paddle/fluid/operators/mkldnn/matmul_v2_mkldnn_op.cc
+0
-1
paddle/fluid/operators/mkldnn/prelu_mkldnn_op.cc
paddle/fluid/operators/mkldnn/prelu_mkldnn_op.cc
+0
-1
paddle/fluid/operators/mkldnn/quantize_mkldnn_op.cc
paddle/fluid/operators/mkldnn/quantize_mkldnn_op.cc
+0
-1
paddle/fluid/operators/mkldnn/reshape_mkldnn_op.cc
paddle/fluid/operators/mkldnn/reshape_mkldnn_op.cc
+6
-11
paddle/fluid/platform/mkldnn_helper.h
paddle/fluid/platform/mkldnn_helper.h
+0
-158
paddle/fluid/platform/mkldnn_utils.h
paddle/fluid/platform/mkldnn_utils.h
+0
-172
paddle/phi/core/dense_tensor.inl
paddle/phi/core/dense_tensor.inl
+0
-6
paddle/phi/core/dense_tensor_impl.cc
paddle/phi/core/dense_tensor_impl.cc
+1
-9
未找到文件。
paddle/fluid/operators/mkldnn/activation_mkldnn_op.cc
浏览文件 @
d7652d5f
...
...
@@ -28,7 +28,6 @@ using dnnl::primitive;
using
dnnl
::
stream
;
using
framework
::
DataLayout
;
using
platform
::
GetMKLDNNFormat
;
using
platform
::
MKLDNNDeviceContext
;
using
platform
::
to_void_cast
;
...
...
paddle/fluid/operators/mkldnn/dequantize_mkldnn_op.cc
浏览文件 @
d7652d5f
...
...
@@ -30,7 +30,6 @@ using platform::to_void_cast;
using
Tensor
=
phi
::
DenseTensor
;
using
dnnl
::
stream
;
using
framework
::
DataLayout
;
using
platform
::
GetMKLDNNFormat
;
template
<
typename
T
>
class
DeQuantOpKernel
:
public
framework
::
OpKernel
<
T
>
{
...
...
paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc
浏览文件 @
d7652d5f
...
...
@@ -30,7 +30,6 @@ using framework::DataLayout;
using
framework
::
DDim
;
using
framework
::
ExecutionContext
;
using
framework
::
LoDTensor
;
using
platform
::
GetMKLDNNFormat
;
using
platform
::
MKLDNNDeviceContext
;
using
platform
::
MKLDNNGetDataType
;
using
platform
::
to_void_cast
;
...
...
paddle/fluid/operators/mkldnn/interpolate_mkldnn_op.cc
浏览文件 @
d7652d5f
...
...
@@ -25,7 +25,6 @@ using dnnl::reorder;
using
dnnl
::
resampling_forward
;
using
dnnl
::
stream
;
using
framework
::
DataLayout
;
using
platform
::
GetMKLDNNFormat
;
using
platform
::
to_void_cast
;
template
<
typename
T
=
float
>
...
...
paddle/fluid/operators/mkldnn/matmul_v2_mkldnn_op.cc
浏览文件 @
d7652d5f
...
...
@@ -17,7 +17,6 @@ namespace {
using
dnnl
::
memory
;
using
paddle
::
framework
::
DataLayout
;
using
paddle
::
framework
::
ExecutionContext
;
using
paddle
::
platform
::
GetMKLDNNFormat
;
using
paddle
::
platform
::
MatMulV2MKLDNNHandler
;
using
paddle
::
platform
::
MKLDNNDeviceContext
;
using
paddle
::
platform
::
MKLDNNFormatForSize
;
...
...
paddle/fluid/operators/mkldnn/prelu_mkldnn_op.cc
浏览文件 @
d7652d5f
...
...
@@ -20,7 +20,6 @@ namespace operators {
using
dnnl
::
memory
;
using
platform
::
GetMKLDNNFormat
;
using
platform
::
MKLDNNDeviceContext
;
using
platform
::
MKLDNNGetDataType
;
using
platform
::
to_void_cast
;
...
...
paddle/fluid/operators/mkldnn/quantize_mkldnn_op.cc
浏览文件 @
d7652d5f
...
...
@@ -29,7 +29,6 @@ using platform::to_void_cast;
using
Tensor
=
phi
::
DenseTensor
;
using
dnnl
::
stream
;
using
framework
::
DataLayout
;
using
platform
::
GetMKLDNNFormat
;
template
<
typename
T
>
class
QuantOpKernel
:
public
framework
::
OpKernel
<
T
>
{
...
...
paddle/fluid/operators/mkldnn/reshape_mkldnn_op.cc
浏览文件 @
d7652d5f
...
...
@@ -31,7 +31,6 @@ namespace paddle {
namespace
operators
{
using
paddle
::
framework
::
LoDTensor
;
using
platform
::
GetMKLDNNFormat
;
using
platform
::
to_void_cast
;
static
std
::
vector
<
int
>
extract_shape
(
...
...
@@ -89,8 +88,8 @@ class ReshapeMKLDNNKernel : public framework::OpKernel<T> {
// reorder is done into a plain tag to allow usage with blocked formats
auto
reorder_dst_memory_p
=
reorder_handler
.
AcquireDstMemory
(
out
,
getPlainFormatTag
(
x
),
ctx
.
GetPlace
());
auto
reorder_p
=
reorder_handler
.
AcquireReorder
(
reorder_
src
_memory_p
,
reorder_
dst
_memory_p
);
auto
reorder_p
=
reorder_handler
.
AcquireReorder
(
reorder_
dst
_memory_p
,
reorder_
src
_memory_p
);
auto
&
astream
=
platform
::
MKLDNNDeviceContext
::
tls
().
get_stream
();
reorder_p
->
execute
(
astream
,
*
reorder_src_memory_p
,
*
reorder_dst_memory_p
);
...
...
@@ -98,9 +97,7 @@ class ReshapeMKLDNNKernel : public framework::OpKernel<T> {
astream
.
wait
();
out
->
Resize
(
out_dims
);
out
->
set_layout
(
framework
::
DataLayout
::
kMKLDNN
);
out
->
set_format
(
GetMKLDNNFormat
(
reorder_dst_memory_p
->
get_desc
().
reshape
(
phi
::
vectorize
(
out_dims
))));
out
->
set_mem_desc
(
reorder_dst_memory_p
->
get_desc
().
reshape
(
phi
::
vectorize
(
out_dims
)));
}
void
InferInOutShape
(
const
framework
::
ExecutionContext
&
ctx
,
...
...
@@ -362,17 +359,15 @@ class ReshapeGradMKLDNNKernel : public ReshapeMKLDNNKernel<T, op_name> {
dout
->
format
(),
platform
::
to_void_cast
(
dout
->
data
<
T
>
()));
auto
reorder_dst_memory_p
=
reorder_handler
.
AcquireDstMemory
(
dx
,
this
->
getPlainFormatTag
(
dout
),
ctx
.
GetPlace
());
auto
reorder_p
=
reorder_handler
.
AcquireReorder
(
reorder_
src
_memory_p
,
reorder_
dst
_memory_p
);
auto
reorder_p
=
reorder_handler
.
AcquireReorder
(
reorder_
dst
_memory_p
,
reorder_
src
_memory_p
);
auto
&
astream
=
platform
::
MKLDNNDeviceContext
::
tls
().
get_stream
();
reorder_p
->
execute
(
astream
,
*
reorder_src_memory_p
,
*
reorder_dst_memory_p
);
astream
.
wait
();
dx
->
Resize
(
dx_dims
);
dx
->
set_layout
(
framework
::
DataLayout
::
kMKLDNN
);
dx
->
set_format
(
GetMKLDNNFormat
(
reorder_dst_memory_p
->
get_desc
().
reshape
(
phi
::
vectorize
(
dx_dims
))));
dx
->
set_mem_desc
(
reorder_dst_memory_p
->
get_desc
().
reshape
(
phi
::
vectorize
(
dx_dims
)));
}
void
InferOutputShapeInGrad
(
const
framework
::
ExecutionContext
&
ctx
,
...
...
paddle/fluid/platform/mkldnn_helper.h
浏览文件 @
d7652d5f
...
...
@@ -202,164 +202,6 @@ inline void Reorder(dnnl::memory src,
astream
.
wait
();
}
inline
dnnl
::
memory
::
format_tag
GetMKLDNNFormat
(
dnnl
::
memory
::
desc
mem_desc
)
{
auto
ndims
=
mem_desc
.
data
.
ndims
;
auto
strides
=
mem_desc
.
data
.
format_desc
.
blocking
.
strides
;
auto
inner_nblks
=
mem_desc
.
data
.
format_desc
.
blocking
.
inner_nblks
;
auto
inner_blks
=
mem_desc
.
data
.
format_desc
.
blocking
.
inner_blks
;
auto
inner_idxs
=
mem_desc
.
data
.
format_desc
.
blocking
.
inner_idxs
;
if
(
ndims
==
1
)
{
return
dnnl
::
memory
::
format_tag
::
x
;
}
else
if
(
ndims
==
2
)
{
if
(
inner_nblks
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
1
])
{
return
dnnl
::
memory
::
format_tag
::
nc
;
}
else
{
return
dnnl
::
memory
::
format_tag
::
cn
;
}
}
}
else
if
(
ndims
==
3
)
{
if
(
inner_nblks
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
2
])
{
return
dnnl
::
memory
::
format_tag
::
ncw
;
}
else
if
(
strides
[
1
]
>=
strides
[
0
]
&&
strides
[
0
]
>=
strides
[
2
])
{
return
dnnl
::
memory
::
format_tag
::
ntc
;
}
else
{
return
dnnl
::
memory
::
format_tag
::
nwc
;
}
}
}
else
if
(
ndims
==
4
)
{
if
(
inner_nblks
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
])
{
return
dnnl
::
memory
::
format_tag
::
abcd
;
}
else
if
(
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
0
])
{
return
dnnl
::
memory
::
format_tag
::
cdba
;
}
else
if
(
strides
[
0
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
1
])
{
return
dnnl
::
memory
::
format_tag
::
acdb
;
}
else
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
2
])
{
return
dnnl
::
memory
::
format_tag
::
abdc
;
}
else
if
(
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
0
])
{
return
dnnl
::
memory
::
format_tag
::
cdba
;
}
else
{
return
dnnl
::
memory
::
format_tag
::
dcab
;
}
}
else
if
(
inner_nblks
==
1
)
{
if
(
inner_blks
[
0
]
==
16
&&
inner_idxs
[
0
]
==
1
)
{
return
dnnl
::
memory
::
format_tag
::
nChw16c
;
}
else
if
(
inner_blks
[
0
]
==
8
&&
inner_idxs
[
0
]
==
1
)
{
return
dnnl
::
memory
::
format_tag
::
nChw8c
;
}
else
if
(
inner_blks
[
0
]
==
8
&&
inner_idxs
[
0
]
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
1
])
{
return
dnnl
::
memory
::
format_tag
::
Acdb8a
;
}
}
else
if
(
inner_blks
[
0
]
==
4
&&
inner_idxs
[
0
]
==
1
)
{
return
dnnl
::
memory
::
format_tag
::
nChw4c
;
}
else
if
(
inner_blks
[
0
]
==
16
&&
inner_idxs
[
0
]
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
1
])
{
return
dnnl
::
memory
::
format_tag
::
Acdb16a
;
}
}
}
else
if
(
inner_nblks
==
2
)
{
if
(
inner_blks
[
0
]
==
16
&&
inner_blks
[
1
]
==
16
)
{
if
(
inner_idxs
[
0
]
==
1
&&
inner_idxs
[
1
]
==
0
)
{
return
dnnl
::
memory
::
format_tag
::
OIhw16i16o
;
}
}
else
if
(
inner_blks
[
0
]
==
8
&&
inner_blks
[
1
]
==
8
)
{
if
(
inner_idxs
[
0
]
==
1
&&
inner_idxs
[
1
]
==
0
)
{
return
dnnl
::
memory
::
format_tag
::
OIhw8i8o
;
}
}
}
}
else
if
(
ndims
==
5
)
{
if
(
inner_nblks
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
])
{
return
dnnl
::
memory
::
format_tag
::
abcde
;
}
else
if
(
strides
[
0
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
])
{
return
dnnl
::
memory
::
format_tag
::
acbde
;
}
else
if
(
strides
[
0
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
]
&&
strides
[
4
]
>=
strides
[
1
])
{
return
dnnl
::
memory
::
format_tag
::
acdeb
;
}
}
else
if
(
inner_nblks
==
1
)
{
if
(
inner_blks
[
0
]
==
4
&&
inner_idxs
[
0
]
==
1
)
{
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
])
{
return
dnnl
::
memory
::
format_tag
::
aBcde4b
;
}
}
else
if
(
inner_blks
[
0
]
==
8
&&
inner_idxs
[
0
]
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
]
&&
strides
[
4
]
>=
strides
[
1
])
{
return
dnnl
::
memory
::
format_tag
::
Acdeb8a
;
}
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
])
{
return
dnnl
::
memory
::
format_tag
::
Abcde8a
;
}
}
else
if
(
inner_blks
[
0
]
==
8
&&
inner_idxs
[
0
]
==
1
)
{
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
])
{
return
dnnl
::
memory
::
format_tag
::
aBcde8b
;
}
}
else
if
(
inner_blks
[
0
]
==
16
&&
inner_idxs
[
0
]
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
]
&&
strides
[
4
]
>=
strides
[
1
])
{
return
dnnl
::
memory
::
format_tag
::
Acdeb16a
;
}
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
])
{
return
dnnl
::
memory
::
format_tag
::
Abcde16a
;
}
}
else
if
(
inner_blks
[
0
]
==
16
&&
inner_idxs
[
0
]
==
1
)
{
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
])
{
return
dnnl
::
memory
::
format_tag
::
aBcde16b
;
}
}
}
}
else
if
(
ndims
==
6
)
{
if
(
inner_nblks
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
]
&&
strides
[
4
]
>=
strides
[
5
])
{
return
dnnl
::
memory
::
format_tag
::
abcdef
;
}
else
if
(
strides
[
0
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
]
&&
strides
[
4
]
>=
strides
[
5
])
{
return
dnnl
::
memory
::
format_tag
::
acbdef
;
}
}
}
// DEBUG CODE - KEEP UNTILL TENSOR.MEMORY_DESC IMPLEMENTED
// std::cout<<"@@@@@@@@@@ UNDEFINED FORMAT @@@@@@@@@@@@@@@@@@@"<<std::endl;
// std::cout<<"NDIMS: "<<ndims<<std::endl;
// std::cout<<"INNER_NBLKS: "<<inner_nblks<<std::endl;
// for (int i=0;i<ndims;++i) {
// std::cout<<"STRIDE["<<i<<"]: "<<strides[i]<<std::endl;
// }
// for (int i=0;i<inner_nblks;++i) {
// std::cout<<"INNER_BLKS["<<i<<"]: "<<inner_blks[i]<<std::endl;
// }
// for (int i=0;i<inner_nblks;++i) {
// std::cout<<"INNER_IDXS["<<i<<"]: "<<inner_idxs[i]<<std::endl;
// }
return
dnnl
::
memory
::
format_tag
::
undef
;
}
inline
dnnl
::
memory
::
format_tag
GetMKLDNNFormat
(
const
dnnl
::
memory
memory
)
{
auto
mem_desc
=
memory
.
get_desc
();
return
GetMKLDNNFormat
(
mem_desc
);
}
inline
dnnl
::
memory
::
format_tag
GetPlainMKLDNNFormat
(
int
tensor_rank
)
{
switch
(
tensor_rank
)
{
case
1
:
...
...
paddle/fluid/platform/mkldnn_utils.h
已删除
100644 → 0
浏览文件 @
19746835
/* Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
// NOTE:
// GetMKLDNNFormat function is here temporarily. It is
// needed because without them forward declaration was causing an error when
// building with "-DWITH_TESTING=ON". This file will be deleted after completing
// md-related refactoring
namespace
paddle
{
namespace
platform
{
inline
dnnl
::
memory
::
format_tag
GetMKLDNNFormat
(
dnnl
::
memory
::
desc
mem_desc
)
{
auto
ndims
=
mem_desc
.
data
.
ndims
;
auto
strides
=
mem_desc
.
data
.
format_desc
.
blocking
.
strides
;
auto
inner_nblks
=
mem_desc
.
data
.
format_desc
.
blocking
.
inner_nblks
;
auto
inner_blks
=
mem_desc
.
data
.
format_desc
.
blocking
.
inner_blks
;
auto
inner_idxs
=
mem_desc
.
data
.
format_desc
.
blocking
.
inner_idxs
;
if
(
ndims
==
1
)
{
return
dnnl
::
memory
::
format_tag
::
x
;
}
else
if
(
ndims
==
2
)
{
if
(
inner_nblks
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
1
])
{
return
dnnl
::
memory
::
format_tag
::
nc
;
}
else
{
return
dnnl
::
memory
::
format_tag
::
cn
;
}
}
}
else
if
(
ndims
==
3
)
{
if
(
inner_nblks
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
2
])
{
return
dnnl
::
memory
::
format_tag
::
ncw
;
}
else
if
(
strides
[
1
]
>=
strides
[
0
]
&&
strides
[
0
]
>=
strides
[
2
])
{
return
dnnl
::
memory
::
format_tag
::
ntc
;
}
else
{
return
dnnl
::
memory
::
format_tag
::
nwc
;
}
}
}
else
if
(
ndims
==
4
)
{
if
(
inner_nblks
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
])
{
return
dnnl
::
memory
::
format_tag
::
abcd
;
}
else
if
(
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
0
])
{
return
dnnl
::
memory
::
format_tag
::
cdba
;
}
else
if
(
strides
[
0
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
1
])
{
return
dnnl
::
memory
::
format_tag
::
acdb
;
}
else
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
2
])
{
return
dnnl
::
memory
::
format_tag
::
abdc
;
}
else
if
(
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
0
])
{
return
dnnl
::
memory
::
format_tag
::
cdba
;
}
else
{
return
dnnl
::
memory
::
format_tag
::
dcab
;
}
}
else
if
(
inner_nblks
==
1
)
{
if
(
inner_blks
[
0
]
==
16
&&
inner_idxs
[
0
]
==
1
)
{
return
dnnl
::
memory
::
format_tag
::
nChw16c
;
}
else
if
(
inner_blks
[
0
]
==
8
&&
inner_idxs
[
0
]
==
1
)
{
return
dnnl
::
memory
::
format_tag
::
nChw8c
;
}
else
if
(
inner_blks
[
0
]
==
8
&&
inner_idxs
[
0
]
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
1
])
{
return
dnnl
::
memory
::
format_tag
::
Acdb8a
;
}
}
else
if
(
inner_blks
[
0
]
==
4
&&
inner_idxs
[
0
]
==
1
)
{
return
dnnl
::
memory
::
format_tag
::
nChw4c
;
}
else
if
(
inner_blks
[
0
]
==
16
&&
inner_idxs
[
0
]
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
1
])
{
return
dnnl
::
memory
::
format_tag
::
Acdb16a
;
}
}
}
else
if
(
inner_nblks
==
2
)
{
if
(
inner_blks
[
0
]
==
16
&&
inner_blks
[
1
]
==
16
)
{
if
(
inner_idxs
[
0
]
==
1
&&
inner_idxs
[
1
]
==
0
)
{
return
dnnl
::
memory
::
format_tag
::
OIhw16i16o
;
}
}
else
if
(
inner_blks
[
0
]
==
8
&&
inner_blks
[
1
]
==
8
)
{
if
(
inner_idxs
[
0
]
==
1
&&
inner_idxs
[
1
]
==
0
)
{
return
dnnl
::
memory
::
format_tag
::
OIhw8i8o
;
}
}
}
}
else
if
(
ndims
==
5
)
{
if
(
inner_nblks
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
])
{
return
dnnl
::
memory
::
format_tag
::
abcde
;
}
else
if
(
strides
[
0
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
])
{
return
dnnl
::
memory
::
format_tag
::
acbde
;
}
else
if
(
strides
[
0
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
]
&&
strides
[
4
]
>=
strides
[
1
])
{
return
dnnl
::
memory
::
format_tag
::
acdeb
;
}
}
else
if
(
inner_nblks
==
1
)
{
if
(
inner_blks
[
0
]
==
8
&&
inner_idxs
[
0
]
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
]
&&
strides
[
4
]
>=
strides
[
1
])
{
return
dnnl
::
memory
::
format_tag
::
Acdeb8a
;
}
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
])
{
return
dnnl
::
memory
::
format_tag
::
Abcde8a
;
}
}
else
if
(
inner_blks
[
0
]
==
8
&&
inner_idxs
[
0
]
==
1
)
{
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
])
{
return
dnnl
::
memory
::
format_tag
::
aBcde8b
;
}
}
else
if
(
inner_blks
[
0
]
==
16
&&
inner_idxs
[
0
]
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
]
&&
strides
[
4
]
>=
strides
[
1
])
{
return
dnnl
::
memory
::
format_tag
::
Acdeb16a
;
}
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
])
{
return
dnnl
::
memory
::
format_tag
::
Abcde16a
;
}
}
else
if
(
inner_blks
[
0
]
==
16
&&
inner_idxs
[
0
]
==
1
)
{
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
])
{
return
dnnl
::
memory
::
format_tag
::
aBcde16b
;
}
}
}
}
else
if
(
ndims
==
6
)
{
if
(
inner_nblks
==
0
)
{
if
(
strides
[
0
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
]
&&
strides
[
4
]
>=
strides
[
5
])
{
return
dnnl
::
memory
::
format_tag
::
abcdef
;
}
else
if
(
strides
[
0
]
>=
strides
[
2
]
&&
strides
[
2
]
>=
strides
[
1
]
&&
strides
[
1
]
>=
strides
[
3
]
&&
strides
[
3
]
>=
strides
[
4
]
&&
strides
[
4
]
>=
strides
[
5
])
{
return
dnnl
::
memory
::
format_tag
::
acbdef
;
}
}
}
// DEBUG CODE - KEEP UNTILL TENSOR.MEMORY_DESC IMPLEMENTED
// std::cout<<"@@@@@@@@@@ UNDEFINED FORMAT @@@@@@@@@@@@@@@@@@@"<<std::endl;
// std::cout<<"NDIMS: "<<ndims<<std::endl;
// std::cout<<"INNER_NBLKS: "<<inner_nblks<<std::endl;
// for (int i=0;i<ndims;++i) {
// std::cout<<"STRIDE["<<i<<"]: "<<strides[i]<<std::endl;
// }
// for (int i=0;i<inner_nblks;++i) {
// std::cout<<"INNER_BLKS["<<i<<"]: "<<inner_blks[i]<<std::endl;
// }
// for (int i=0;i<inner_nblks;++i) {
// std::cout<<"INNER_IDXS["<<i<<"]: "<<inner_idxs[i]<<std::endl;
// }
return
dnnl
::
memory
::
format_tag
::
undef
;
}
}
// namespace platform
}
// namespace paddle
paddle/phi/core/dense_tensor.inl
浏览文件 @
d7652d5f
...
...
@@ -123,12 +123,6 @@ inline void set_mem_desc(const dnnl::memory::desc& mem_desc) {
meta_.layout = DataLayout::kMKLDNN;
}
dnnl::memory::format_tag format() const;
inline void set_format(const dnnl::memory::format_tag format) {
format_ = format;
}
#endif
/* ------------------------------ */
...
...
paddle/phi/core/dense_tensor_impl.cc
浏览文件 @
d7652d5f
...
...
@@ -351,15 +351,7 @@ std::vector<DenseTensor> DenseTensor::Chunk(int64_t chunks,
#ifdef PADDLE_WITH_MKLDNN
dnnl
::
memory
::
desc
DenseTensor
::
mem_desc
()
const
{
return
mem_desc_
?
mem_desc_
:
dnnl
::
memory
::
desc
(
phi
::
vectorize
(
meta_
.
dims
),
phi
::
TransToOneDNNDataType
(
meta_
.
dtype
),
format_
);
}
dnnl
::
memory
::
format_tag
DenseTensor
::
format
()
const
{
return
mem_desc_
?
paddle
::
platform
::
GetMKLDNNFormat
(
mem_desc_
)
:
format_
;
}
return
mem_desc_
;
#endif
// NOTE: For historical reasons, this interface has a special behavior,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录