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
1587038e
Commit
1587038e
authored
Mar 15, 2018
by
Tianqi Chen
Committed by
GitHub
Mar 15, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PASS] Fix reuse small buffer in storage rewrite (#1012)
parent
6b0950dd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
1 deletions
+34
-1
src/pass/storage_rewrite.cc
+1
-0
tests/python/unittest/test_pass_storage_rewrite.py
+33
-1
No files found.
src/pass/storage_rewrite.cc
View file @
1587038e
...
@@ -824,6 +824,7 @@ class StoragePlanRewriter : public IRMutator {
...
@@ -824,6 +824,7 @@ class StoragePlanRewriter : public IRMutator {
if
(
e
->
attach_scope_
!=
attach_scope
)
continue
;
if
(
e
->
attach_scope_
!=
attach_scope
)
continue
;
if
(
e
->
scope
!=
scope
)
continue
;
if
(
e
->
scope
!=
scope
)
continue
;
if
(
e
->
elem_type
!=
op
->
type
.
element_of
())
continue
;
if
(
e
->
elem_type
!=
op
->
type
.
element_of
())
continue
;
e
->
const_nbits
=
std
::
max
(
const_nbits
,
e
->
const_nbits
);
const_free_map_
.
erase
(
it
);
const_free_map_
.
erase
(
it
);
return
e
;
return
e
;
}
}
...
...
tests/python/unittest/test_pass_storage_rewrite.py
View file @
1587038e
...
@@ -411,6 +411,38 @@ def test_alloc_seq_type2():
...
@@ -411,6 +411,38 @@ def test_alloc_seq_type2():
tvm
.
ir_pass
.
PostOrderVisit
(
body
,
verify
)
tvm
.
ir_pass
.
PostOrderVisit
(
body
,
verify
)
assert
num_alloc
[
0
]
==
1
assert
num_alloc
[
0
]
==
1
def
test_reuse_small_buffer
():
ib
=
tvm
.
ir_builder
.
create
()
n
=
tvm
.
var
(
"n"
)
with
ib
.
for_range
(
0
,
n
,
name
=
"i"
)
as
i
:
with
ib
.
for_range
(
0
,
10
,
name
=
"j"
)
as
j
:
A
=
ib
.
allocate
(
"int16"
,
200
,
name
=
"A"
,
scope
=
"local.L0A"
)
A
[
j
]
=
tvm
.
const
(
1
,
"int16"
)
B
=
ib
.
allocate
(
"int16"
,
200
,
name
=
"B"
,
scope
=
"local.L0A"
)
B
[
j
]
=
tvm
.
const
(
1
,
"int16"
)
B1
=
ib
.
allocate
(
"int16"
,
200
,
name
=
"B1"
,
scope
=
"local.L0A"
)
B1
[
j
]
=
A
[
j
]
+
B
[
j
]
C
=
ib
.
allocate
(
"int16"
,
400
,
name
=
"C"
,
scope
=
"local.L0A"
)
C
[
j
]
=
tvm
.
const
(
1
,
"int16"
)
D
=
ib
.
allocate
(
"int16"
,
400
,
name
=
"D"
,
scope
=
"local.L0A"
)
D
[
j
]
=
tvm
.
const
(
1
,
"int16"
)
E
=
ib
.
allocate
(
"int16"
,
400
,
name
=
"E"
,
scope
=
"local.L0A"
)
E
[
j
]
=
C
[
j
]
body
=
ib
.
get
()
body
=
tvm
.
ir_pass
.
StorageRewrite
(
body
)
num_alloc
=
[
0
]
def
verify
(
n
):
if
isinstance
(
n
,
tvm
.
stmt
.
Allocate
):
num_alloc
[
0
]
+=
1
assert
n
.
extents
[
0
]
.
value
==
800
tvm
.
ir_pass
.
PostOrderVisit
(
body
,
verify
)
assert
num_alloc
[
0
]
==
1
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_alloc_seq
()
test_alloc_seq
()
test_alloc_different_dtypes
()
test_alloc_different_dtypes
()
...
@@ -423,4 +455,4 @@ if __name__ == "__main__":
...
@@ -423,4 +455,4 @@ if __name__ == "__main__":
test_inplace_rule3
()
test_inplace_rule3
()
test_alloc_seq_type
()
test_alloc_seq_type
()
test_alloc_seq_type2
()
test_alloc_seq_type2
()
test_reuse_small_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