Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
68c03944
Commit
68c03944
authored
Feb 18, 2018
by
Siva
Committed by
Tianqi Chen
May 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NHWC] InferShape Layout conversion fix. (#372)
parent
50c20b76
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
3 deletions
+17
-3
nnvm/src/top/nn/convolution.cc
+2
-2
nnvm/src/top/nn/nn_common.h
+15
-1
No files found.
nnvm/src/top/nn/convolution.cc
View file @
68c03944
...
...
@@ -48,7 +48,7 @@ inline bool Conv2DInferShape(const nnvm::NodeAttrs& attrs,
param
.
kernel_size
[
0
],
param
.
kernel_size
[
1
]});
wshape
=
ConvertLayout
(
wshape
,
kNCHW
,
param
.
layout
);
wshape
=
ConvertLayout
(
wshape
,
kNCHW
,
param
.
layout
,
true
);
wshape
[
0
]
*=
param
.
groups
;
NNVM_ASSIGN_INPUT_SHAPE
(
attrs
,
*
in_shape
,
Conv2DParam
::
kWeight
,
wshape
);
...
...
@@ -189,7 +189,7 @@ inline bool Conv2DTransposeInferShape(const nnvm::NodeAttrs& attrs,
param
.
channels
/
param
.
groups
,
param
.
kernel_size
[
0
],
param
.
kernel_size
[
1
]});
wshape
=
ConvertLayout
(
wshape
,
kNCHW
,
param
.
layout
);
wshape
=
ConvertLayout
(
wshape
,
kNCHW
,
param
.
layout
,
true
);
NNVM_ASSIGN_INPUT_SHAPE
(
attrs
,
*
in_shape
,
Conv2DTransposeParam
::
kWeight
,
wshape
);
if
(
param
.
use_bias
)
{
...
...
nnvm/src/top/nn/nn_common.h
View file @
68c03944
...
...
@@ -40,7 +40,7 @@ inline std::vector<std::string> UseBiasListInputNames(const NodeAttrs& attrs) {
* \param dst_layout target layout
* \return shape in target layout
*/
inline
TShape
ConvertLayout
(
TShape
src
,
int
src_layout
,
int
dst_layout
)
{
inline
TShape
ConvertLayout
(
TShape
src
,
int
src_layout
,
int
dst_layout
,
bool
is_weight
=
false
)
{
if
(
src_layout
==
dst_layout
)
return
src
;
TShape
dst
=
src
;
if
(
src
.
ndim
()
==
3
)
{
...
...
@@ -68,9 +68,16 @@ inline TShape ConvertLayout(TShape src, int src_layout, int dst_layout) {
switch
(
src_layout
)
{
case
kNCHW
:
break
;
case
kNHWC
:
{
if
(
is_weight
)
{
dst
[
2
]
=
src
[
0
];
dst
[
3
]
=
src
[
1
];
dst
[
1
]
=
src
[
2
];
dst
[
0
]
=
src
[
3
];
}
else
{
dst
[
2
]
=
src
[
1
];
dst
[
3
]
=
src
[
2
];
dst
[
1
]
=
src
[
3
];
}
break
;
}
default
:
{
...
...
@@ -81,9 +88,16 @@ inline TShape ConvertLayout(TShape src, int src_layout, int dst_layout) {
switch
(
dst_layout
)
{
case
kNCHW
:
break
;
case
kNHWC
:
{
if
(
is_weight
)
{
dst
[
0
]
=
src
[
2
];
dst
[
1
]
=
src
[
3
];
dst
[
2
]
=
src
[
1
];
dst
[
3
]
=
src
[
0
];
}
else
{
dst
[
1
]
=
src
[
2
];
dst
[
2
]
=
src
[
3
];
dst
[
3
]
=
src
[
1
];
}
break
;
}
default
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment