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
53428606
Commit
53428606
authored
Oct 15, 2018
by
Gaoxiong
Committed by
Tianqi Chen
Oct 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support double buffer to use in ir builder DSL(#1897) (#1898)
parent
2d9bc751
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
1 deletions
+35
-1
src/pass/storage_flatten.cc
+2
-1
tests/python/unittest/test_pass_storage_flatten.py
+33
-0
No files found.
src/pass/storage_flatten.cc
View file @
53428606
...
@@ -59,7 +59,8 @@ class StorageFlattener : public IRMutator {
...
@@ -59,7 +59,8 @@ class StorageFlattener : public IRMutator {
if
(
op
->
attr_key
==
attr
::
realize_scope
)
{
if
(
op
->
attr_key
==
attr
::
realize_scope
)
{
storage_scope_
[
op
->
node
.
get
()]
=
op
->
value
.
as
<
StringImm
>
()
->
value
;
storage_scope_
[
op
->
node
.
get
()]
=
op
->
value
.
as
<
StringImm
>
()
->
value
;
return
this
->
Mutate
(
op
->
body
);
return
this
->
Mutate
(
op
->
body
);
}
else
if
(
op
->
attr_key
==
attr
::
double_buffer_scope
)
{
}
else
if
(
op
->
attr_key
==
attr
::
double_buffer_scope
&&
op
->
node
.
node_
->
derived_from
<
OperationNode
>
())
{
Operation
func
(
op
->
node
.
node_
);
Operation
func
(
op
->
node
.
node_
);
Stmt
body
=
Mutate
(
op
->
body
);
Stmt
body
=
Mutate
(
op
->
body
);
for
(
int
i
=
0
;
i
<
func
->
num_outputs
();
++
i
)
{
for
(
int
i
=
0
;
i
<
func
->
num_outputs
();
++
i
)
{
...
...
tests/python/unittest/test_pass_storage_flatten.py
View file @
53428606
...
@@ -51,8 +51,41 @@ def test_flatten_storage_align():
...
@@ -51,8 +51,41 @@ def test_flatten_storage_align():
stmt
=
tvm
.
ir_pass
.
Simplify
(
stmt
)
stmt
=
tvm
.
ir_pass
.
Simplify
(
stmt
)
assert
(
stmt
.
body
.
extents
[
0
]
.
value
==
17
*
8
)
assert
(
stmt
.
body
.
extents
[
0
]
.
value
==
17
*
8
)
def
test_flatten_double_buffer
():
dtype
=
'int64'
n
=
100
m
=
4
tx
=
tvm
.
thread_axis
(
"threadIdx.x"
)
ib
=
tvm
.
ir_builder
.
create
()
A
=
ib
.
pointer
(
"float32"
,
name
=
"A"
)
C
=
ib
.
pointer
(
"float32"
,
name
=
"C"
)
ib
.
scope_attr
(
tx
,
"thread_extent"
,
1
)
with
ib
.
for_range
(
0
,
n
)
as
i
:
B
=
ib
.
allocate
(
"float32"
,
m
,
name
=
"B"
,
scope
=
"shared"
)
with
ib
.
new_scope
():
ib
.
scope_attr
(
B
.
asnode
(),
"double_buffer_scope"
,
1
)
with
ib
.
for_range
(
0
,
m
)
as
j
:
B
[
j
]
=
A
[
i
*
4
+
j
]
with
ib
.
for_range
(
0
,
m
)
as
j
:
C
[
j
]
=
B
[
j
]
+
1
stmt
=
ib
.
get
()
stmt
=
tvm
.
ir_pass
.
StorageFlatten
(
stmt
,
{},
64
)
stmt
=
tvm
.
ir_pass
.
InjectDoubleBuffer
(
stmt
,
2
)
stmt
=
tvm
.
ir_pass
.
Simplify
(
stmt
)
assert
isinstance
(
stmt
.
body
.
body
,
tvm
.
stmt
.
Allocate
)
assert
stmt
.
body
.
body
.
extents
[
0
]
.
value
==
2
f
=
tvm
.
ir_pass
.
MakeAPI
(
stmt
,
"db"
,
[
A
.
asnode
(),
C
.
asnode
()],
2
,
True
)
f
=
tvm
.
ir_pass
.
ThreadSync
(
f
,
"shared"
)
count
=
[
0
]
def
count_sync
(
op
):
if
isinstance
(
op
,
tvm
.
expr
.
Call
)
and
op
.
name
==
"tvm_storage_sync"
:
count
[
0
]
+=
1
tvm
.
ir_pass
.
PostOrderVisit
(
f
.
body
,
count_sync
)
assert
count
[
0
]
==
4
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_flatten_storage_align
()
test_flatten_storage_align
()
test_flatten2
()
test_flatten2
()
test_flatten_prefetch
()
test_flatten_prefetch
()
test_flatten_double_buffer
()
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