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
d76712d1
Commit
d76712d1
authored
Aug 13, 2017
by
Tianqi Chen
Committed by
GitHub
Aug 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TOPI] Move topi.nn.util to topi.util (#319)
* [TOPI] Move topi.nn.util to topi.util * update the path
parent
f08de2b6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
7 deletions
+36
-7
topi/python/topi/cuda/depthwise_conv2d_map.py
+1
-1
topi/python/topi/nn/conv.py
+1
-1
topi/python/topi/util.py
+23
-3
topi/tests/python/test_topi_basic.py
+9
-0
topi/tests/python/test_topi_conv2d_hwcn_map.py
+1
-1
topi/tests/python/test_topi_depthwise_conv2d_map.py
+1
-1
No files found.
topi/python/topi/cuda/depthwise_conv2d_map.py
View file @
d76712d1
# pylint: disable=invalid-name
"""Schedule for depthwise_conv2d with auto fusion"""
import
tvm
from
..
nn.
util
import
get_const_tuple
from
..util
import
get_const_tuple
def
schedule_depthwise_conv2d_map
(
op
):
"""Schedule for depthwise_conv2d map ops.
...
...
topi/python/topi/nn/conv.py
View file @
d76712d1
...
...
@@ -3,7 +3,7 @@
from
__future__
import
absolute_import
as
_abs
import
tvm
import
numpy
as
np
from
.util
import
get_const_tuple
from
.
.
util
import
get_const_tuple
@tvm.tag_scope
(
tag
=
"conv2d_hwcn"
)
...
...
topi/python/topi/
nn/
util.py
→
topi/python/topi/util.py
View file @
d76712d1
...
...
@@ -2,12 +2,32 @@
from
__future__
import
absolute_import
as
_abs
import
tvm
def
get_const_int
(
expr
):
"""Verifies expr is integer and get the constant value.
Parameters
----------
expr :
The input expression.
Returns
-------
out_tuple : tuple of int
The output.
"""
if
not
isinstance
(
expr
,
(
tvm
.
expr
.
IntImm
,
tvm
.
expr
.
UIntImm
)):
expr
=
tvm
.
ir_pass
.
Simplfy
(
expr
)
if
not
isinstance
(
expr
,
(
tvm
.
expr
.
IntImm
,
tvm
.
expr
.
UIntImm
)):
raise
ValueError
(
"Expect value to be constant int"
)
return
expr
.
value
def
get_const_tuple
(
in_tuple
):
"""Verifies input tuple is IntImm, returns tuple of int.
Parameters
----------
in_tuple : tuple of
tvm.expr.IntImm
in_tuple : tuple of
Expr
The input.
Returns
...
...
@@ -17,7 +37,7 @@ def get_const_tuple(in_tuple):
"""
out_tuple
=
()
for
elem
in
in_tuple
:
if
not
isinstance
(
elem
,
tvm
.
expr
.
IntImm
):
raise
ValueError
(
"Element of input tuple should be
IntImm
"
)
if
not
isinstance
(
elem
,
(
tvm
.
expr
.
IntImm
,
tvm
.
expr
.
UIntImm
)
):
raise
ValueError
(
"Element of input tuple should be
const int
"
)
out_tuple
=
out_tuple
+
(
elem
.
value
,
)
return
out_tuple
topi/tests/python/test_topi_basic.py
View file @
d76712d1
import
tvm
import
topi
from
topi
import
util
def
test_util
():
x
=
tvm
.
const
(
100
)
assert
util
.
get_const_int
(
x
)
==
100
assert
util
.
get_const_tuple
((
x
,
x
))
==
(
100
,
100
)
def
test_ewise
():
m
=
tvm
.
var
(
'm'
)
...
...
@@ -19,4 +27,5 @@ def test_ewise():
if
__name__
==
"__main__"
:
test_util
()
test_ewise
()
topi/tests/python/test_topi_conv2d_hwcn_map.py
View file @
d76712d1
...
...
@@ -3,7 +3,7 @@ import os
import
numpy
as
np
import
tvm
import
topi
from
topi.
nn.
util
import
get_const_tuple
from
topi.util
import
get_const_tuple
def
verify_conv2d_hwcn_map
(
batch
,
in_channel
,
in_size
,
num_filter
,
kernel
,
stride
,
padding
):
...
...
topi/tests/python/test_topi_depthwise_conv2d_map.py
View file @
d76712d1
...
...
@@ -2,7 +2,7 @@ import tvm
import
topi
import
numpy
as
np
from
scipy
import
signal
from
topi.
nn.
util
import
get_const_tuple
from
topi.util
import
get_const_tuple
from
topi.cuda.depthwise_conv2d_map
import
schedule_depthwise_conv2d_map
def
depthwise_conv2d_map_with_workload
(
batch
,
in_channel
,
in_height
,
channel_multiplier
,
filter_height
,
stride_h
,
padding
):
...
...
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