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
7cd7dbff
Commit
7cd7dbff
authored
Oct 21, 2018
by
Gaoxiong
Committed by
Tianqi Chen
Oct 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix non-zero extent of access_ptr out of range (#1937) (#1939)
parent
150f7a8b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
src/lang/buffer.cc
+2
-2
tests/python/unittest/test_lang_buffer.py
+13
-0
No files found.
src/lang/buffer.cc
View file @
7cd7dbff
...
...
@@ -357,9 +357,9 @@ Expr Buffer::access_ptr(int access_mask, Type ptr_type, int content_lanes, Expr
}
else
if
(
self
->
strides
.
size
()
==
self
->
shape
.
size
())
{
int
highest_dim
=
0
;
extent
=
arith
::
ComputeExpr
<
ir
::
Mul
>
(
self
->
strides
[
highest_dim
],
self
->
shape
[
highest_dim
]);
self
->
strides
[
highest_dim
],
self
->
shape
[
highest_dim
])
-
offset
;
}
else
{
extent
=
arith
::
ComputeReduce
<
ir
::
Mul
>
(
self
->
shape
,
Expr
());
extent
=
arith
::
ComputeReduce
<
ir
::
Mul
>
(
self
->
shape
,
Expr
())
-
offset
;
}
Expr
elem_offset
=
self
->
elem_offset
+
offset
;
if
(
content_lanes
>
1
)
{
...
...
tests/python/unittest/test_lang_buffer.py
View file @
7cd7dbff
...
...
@@ -41,6 +41,18 @@ def test_buffer_access_ptr_offset():
assert
tvm
.
ir_pass
.
Equal
(
offset
,
tvm
.
call_extern
(
'int32'
,
"test_call"
,
200
+
v
))
assert
aptr
.
args
[
4
]
.
value
==
Buffer
.
READ
|
Buffer
.
WRITE
def
test_buffer_access_ptr_extent
():
m
=
tvm
.
var
(
'm'
)
n
=
tvm
.
var
(
'n'
)
Ab
=
tvm
.
decl_buffer
((
m
,
n
),
tvm
.
float32
)
aptr
=
Ab
.
access_ptr
(
"rw"
)
assert
tvm
.
ir_pass
.
Equal
(
aptr
.
args
[
3
],
m
*
n
)
aptr
=
Ab
.
access_ptr
(
"rw"
,
offset
=
100
)
assert
tvm
.
ir_pass
.
Equal
(
aptr
.
args
[
3
],
m
*
n
-
100
)
Ab
=
tvm
.
decl_buffer
((
m
,
n
),
tvm
.
float32
,
strides
=
[
n
+
1
,
1
])
aptr
=
Ab
.
access_ptr
(
"rw"
,
offset
=
100
)
assert
tvm
.
ir_pass
.
Equal
(
aptr
.
args
[
3
],
Ab
.
strides
[
0
]
*
m
-
100
)
def
test_buffer_vload
():
m
=
tvm
.
var
(
'm'
)
n
=
tvm
.
var
(
'n'
)
...
...
@@ -84,5 +96,6 @@ if __name__ == "__main__":
test_buffer
()
test_buffer_access_ptr
()
test_buffer_access_ptr_offset
()
test_buffer_access_ptr_extent
()
test_buffer_vload
()
test_buffer_index_merge_mult_mod
()
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