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
49d304fc
Unverified
Commit
49d304fc
authored
Apr 17, 2020
by
Animesh Jain
Committed by
GitHub
Apr 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TOPI-ARM] Do not alter layout if layout is NHWC (#5350)
* [TOPI-ARM] Do not alter layout if layout is NHWC * Add test.
parent
6dfcd375
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
25 deletions
+8
-25
tests/python/relay/test_pass_alter_op_layout.py
+4
-25
topi/python/topi/arm_cpu/conv2d_alter_op.py
+4
-0
No files found.
tests/python/relay/test_pass_alter_op_layout.py
View file @
49d304fc
...
...
@@ -940,11 +940,8 @@ def test_alter_layout_sum():
assert
tvm
.
ir
.
structural_equal
(
a
,
b
),
"Actual =
\n
"
+
str
(
a
)
# TODO(@anijain2305, @icemelon9): We should fix this. This doesn't seem to be the
# right behavior of alter_layout
@pytest.mark.skip
def
test_alter_layout_nhwc_nchw_arm
():
""" Check NHWC to NHCW conversion for a small sequence of ops."""
def
test_alter_layout_nhwc_arm
():
""" Check that AlterOplayout does not alter NHWC data layout. """
def
alter_conv2d
(
attrs
,
inputs
,
tinfos
,
out_type
):
import
topi
with
tvm
.
target
.
create
(
"llvm -device=arm_cpu"
):
...
...
@@ -974,25 +971,7 @@ def test_alter_layout_nhwc_nchw_arm():
return
y
def
expected_nhwc
():
x
=
relay
.
var
(
"x"
,
shape
=
(
1
,
56
,
56
,
64
))
weight1
=
relay
.
var
(
'weight1'
,
shape
=
(
3
,
3
,
64
,
64
))
weight2
=
relay
.
var
(
'weight2'
,
shape
=
(
3
,
3
,
64
,
64
))
y
=
relay
.
layout_transform
(
x
,
"NHWC"
,
"NCHW"
)
weight1
=
relay
.
layout_transform
(
weight1
,
"HWIO"
,
"OIHW"
)
weight2
=
relay
.
layout_transform
(
weight2
,
"HWIO"
,
"OIHW"
)
y
=
relay
.
nn
.
conv2d
(
y
,
weight1
,
channels
=
64
,
kernel_size
=
(
3
,
3
))
y
=
relay
.
nn
.
relu
(
y
)
y
=
relay
.
nn
.
avg_pool2d
(
y
,
pool_size
=
(
1
,
1
))
y
=
relay
.
nn
.
conv2d
(
y
,
weight2
,
channels
=
64
,
kernel_size
=
(
3
,
3
))
y
=
relay
.
nn
.
relu
(
y
)
y
=
relay
.
layout_transform
(
y
,
"NCHW"
,
"NHWC"
)
y
=
relay
.
Function
(
analysis
.
free_vars
(
y
),
y
)
return
y
return
before_nhwc
()
with
TempOpAttr
(
"nn.conv2d"
,
"FTVMAlterOpLayout"
,
alter_conv2d
):
a
=
before_nhwc
()
...
...
@@ -1060,5 +1039,5 @@ if __name__ == "__main__":
test_alter_layout_pad
()
test_alter_layout_pool
()
test_alter_layout_sum
()
# test_alter_layout_nhwc_nchw
_arm()
test_alter_layout_nhwc
_arm
()
test_alter_op_with_global_var
()
topi/python/topi/arm_cpu/conv2d_alter_op.py
View file @
49d304fc
...
...
@@ -59,6 +59,10 @@ def _alter_conv2d_layout(attrs, inputs, tinfos, out_type):
data
,
kernel
=
tinfos
out_dtype
=
out_type
.
dtype
# We only perform layout alteration for NCHW data layout.
if
data_layout
==
"NHWC"
:
return
None
# Extract data types
data_tensor
,
kernel_tensor
=
tinfos
data_dtype
=
data_tensor
.
dtype
...
...
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