Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tvm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cld
ml
tvm
Commits
1d7c52f2
Commit
1d7c52f2
authored
6 years ago
by
Jian Weng
Committed by
Yizhi Liu
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add docstring skip in hybrid script (#1668)
* add docstring skip in hybrid script * fix lint
parent
463e5c38
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
python/tvm/hybrid/parser.py
+2
-2
2 additions, 2 deletions
python/tvm/hybrid/parser.py
python/tvm/hybrid/util.py
+6
-0
6 additions, 0 deletions
python/tvm/hybrid/util.py
tests/python/unittest/test_hybrid_script.py
+1
-0
1 addition, 0 deletions
tests/python/unittest/test_hybrid_script.py
with
9 additions
and
2 deletions
python/tvm/hybrid/parser.py
+
2
−
2
View file @
1d7c52f2
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
import
ast
import
ast
import
operator
import
operator
import
sys
import
sys
from
.util
import
make_nop
,
halide_imm_types
from
.util
import
make_nop
,
halide_imm_types
,
is_docstring
from
.intrin
import
LOOP_INTRIN
,
MATH_INTRIN
from
.intrin
import
LOOP_INTRIN
,
MATH_INTRIN
from
.var_decl
import
determine_variable_usage
from
.var_decl
import
determine_variable_usage
from
..api
import
thread_axis
from
..api
import
thread_axis
...
@@ -15,7 +15,7 @@ from .. import ir_pass as _ir_pass
...
@@ -15,7 +15,7 @@ from .. import ir_pass as _ir_pass
def
list_to_block
(
visit
,
lst
):
def
list_to_block
(
visit
,
lst
):
"""
Convert a list of Python IR nodes to HalideIR Block
"""
"""
Convert a list of Python IR nodes to HalideIR Block
"""
lst
=
l
ist
(
map
(
visit
,
lst
))
lst
=
[
v
is
i
t
(
stmt
)
for
stmt
in
lst
if
not
is_docstring
(
stmt
)]
lst
=
[
stmt
for
stmt
in
lst
if
not
_ir_pass
.
Equal
(
stmt
,
make_nop
())]
lst
=
[
stmt
for
stmt
in
lst
if
not
_ir_pass
.
Equal
(
stmt
,
make_nop
())]
if
not
lst
:
if
not
lst
:
return
make_nop
()
return
make_nop
()
...
...
This diff is collapsed.
Click to expand it.
python/tvm/hybrid/util.py
+
6
−
0
View file @
1d7c52f2
"""
Internal utilities for parsing Python subset to HalideIR
"""
"""
Internal utilities for parsing Python subset to HalideIR
"""
import
ast
import
inspect
import
inspect
import
numpy
import
numpy
from
.intrin
import
HYBRID_GLOBALS
from
.intrin
import
HYBRID_GLOBALS
...
@@ -22,6 +23,11 @@ def make_nop():
...
@@ -22,6 +23,11 @@ def make_nop():
return
_make
.
Evaluate
(
_api
.
const
(
0
,
dtype
=
'
int32
'
))
return
_make
.
Evaluate
(
_api
.
const
(
0
,
dtype
=
'
int32
'
))
def
is_docstring
(
node
):
"""
Checks if a Python AST node is a docstring
"""
return
isinstance
(
node
,
ast
.
Expr
)
and
isinstance
(
node
.
value
,
ast
.
Str
)
def
_pruned_source
(
func
):
def
_pruned_source
(
func
):
"""
Prune source code
'
s extra leading spaces
"""
"""
Prune source code
'
s extra leading spaces
"""
lines
=
inspect
.
getsource
(
func
).
split
(
'
\n
'
)
lines
=
inspect
.
getsource
(
func
).
split
(
'
\n
'
)
...
...
This diff is collapsed.
Click to expand it.
tests/python/unittest/test_hybrid_script.py
+
1
−
0
View file @
1d7c52f2
...
@@ -43,6 +43,7 @@ def run_and_check(func, args, outs, var_dict={}, target='llvm'):
...
@@ -43,6 +43,7 @@ def run_and_check(func, args, outs, var_dict={}, target='llvm'):
@script
@script
def
outer_product
(
n
,
m
,
a
,
b
,
c
):
def
outer_product
(
n
,
m
,
a
,
b
,
c
):
"""
This is a simple outer product
"""
for
i
in
range
(
n
):
for
i
in
range
(
n
):
for
j
in
range
(
m
):
for
j
in
range
(
m
):
c
[
i
,
j
]
=
a
[
i
]
*
b
[
j
]
c
[
i
,
j
]
=
a
[
i
]
*
b
[
j
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment