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
537b70e4
Commit
537b70e4
authored
7 years ago
by
Chris Nuernberger
Committed by
Tianqi Chen
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Assert dont crash on null strides (#976)
parent
e380c8a4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pass/arg_binder.cc
+7
-3
7 additions, 3 deletions
src/pass/arg_binder.cc
with
7 additions
and
3 deletions
src/pass/arg_binder.cc
+
7
−
3
View file @
537b70e4
...
...
@@ -194,6 +194,9 @@ void ArgBinder::BindDLTensor(const Buffer& buffer,
init_nest_
.
emplace_back
(
LetStmt
::
make
(
v_strides
,
TVMArrayGet
(
Handle
(),
handle
,
intrinsic
::
kArrStrides
),
nop
));
Expr
is_null
=
Call
::
make
(
Bool
(
1
),
intrinsic
::
tvm_handle_is_null
,
{
v_strides
},
Call
::
PureIntrinsic
);
if
(
buffer
->
strides
.
size
()
==
0
)
{
// Assert the buffer is compact
Type
stype
=
buffer
->
DefaultIndexType
();
...
...
@@ -215,13 +218,14 @@ void ArgBinder::BindDLTensor(const Buffer& buffer,
Stmt
check
=
AssertStmt
::
make
(
arith
::
ComputeReduce
<
ir
::
And
>
(
conds
,
Expr
()),
stride_err_msg
.
str
(),
Evaluate
::
make
(
0
));
Expr
is_null
=
Call
::
make
(
Bool
(
1
),
intrinsic
::
tvm_handle_is_null
,
{
v_strides
},
Call
::
PureIntrinsic
);
check
=
IfThenElse
::
make
(
Not
::
make
(
is_null
),
check
,
Stmt
());
init_nest_
.
emplace_back
(
Block
::
make
(
check
,
Evaluate
::
make
(
0
)));
}
}
else
{
std
::
ostringstream
stride_null_err_msg
;
stride_null_err_msg
<<
arg_name
<<
".strides: expected non-null strides."
;
asserts_
.
emplace_back
(
AssertStmt
::
make
(
Not
::
make
(
is_null
),
stride_null_err_msg
.
str
(),
nop
));
for
(
size_t
k
=
0
;
k
<
buffer
->
strides
.
size
();
++
k
)
{
std
::
ostringstream
field_name
;
field_name
<<
v_strides
->
name_hint
<<
'['
<<
k
<<
']'
;
...
...
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