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
1d7c52f2
Commit
1d7c52f2
authored
Aug 27, 2018
by
Jian Weng
Committed by
Yizhi Liu
Aug 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add docstring skip in hybrid script (#1668)
* add docstring skip in hybrid script * fix lint
parent
463e5c38
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
2 deletions
+9
-2
python/tvm/hybrid/parser.py
+2
-2
python/tvm/hybrid/util.py
+6
-0
tests/python/unittest/test_hybrid_script.py
+1
-0
No files found.
python/tvm/hybrid/parser.py
View file @
1d7c52f2
...
...
@@ -3,7 +3,7 @@
import
ast
import
operator
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
.var_decl
import
determine_variable_usage
from
..api
import
thread_axis
...
...
@@ -15,7 +15,7 @@ from .. import ir_pass as _ir_pass
def
list_to_block
(
visit
,
lst
):
"""Convert a list of Python IR nodes to HalideIR Block"""
lst
=
list
(
map
(
visit
,
lst
))
lst
=
[
visit
(
stmt
)
for
stmt
in
lst
if
not
is_docstring
(
stmt
)]
lst
=
[
stmt
for
stmt
in
lst
if
not
_ir_pass
.
Equal
(
stmt
,
make_nop
())]
if
not
lst
:
return
make_nop
()
...
...
python/tvm/hybrid/util.py
View file @
1d7c52f2
"""Internal utilities for parsing Python subset to HalideIR"""
import
ast
import
inspect
import
numpy
from
.intrin
import
HYBRID_GLOBALS
...
...
@@ -22,6 +23,11 @@ def make_nop():
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
):
"""Prune source code's extra leading spaces"""
lines
=
inspect
.
getsource
(
func
)
.
split
(
'
\n
'
)
...
...
tests/python/unittest/test_hybrid_script.py
View file @
1d7c52f2
...
...
@@ -43,6 +43,7 @@ def run_and_check(func, args, outs, var_dict={}, target='llvm'):
@script
def
outer_product
(
n
,
m
,
a
,
b
,
c
):
"""This is a simple outer product"""
for
i
in
range
(
n
):
for
j
in
range
(
m
):
c
[
i
,
j
]
=
a
[
i
]
*
b
[
j
]
...
...
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