[TE] Make elem_offset
of the buffers created by te.extern
a variable to avoid crash
#13297
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, when compiling MobileBERT on x86, we get a crash from
tvm/src/tir/transforms/arg_binder.cc
Lines 102 to 106 in 11d22bd
This is caused from the subgraph attached in the test. Since #11341,
concatenate
is implemented as a TE extern on x86.te.extern(...)
doesn't explicitly set theelem_offset
parameter of input / output buffers it creates, which ends upelem_offset
of these buffers being the default value, 0. This causes a problem from the above check inBindBuffer
, since the subgraph does create a non-zeroelem_offset
slice from a buffer whoseelem_offset
is set to zero.Since we don't require buffers created in
te.extern(...)
to have zeroelem_offset
, we can avoid this problem by explicitly settingelem_offset
to be a variable there. This fix was found by @Lunderberg and I'm sending this PR on behalf of him. He also suggested making thestrides
parameter an array ofVar
as well, but I didn't do it to keep the change minimal.cc @Lunderberg @tkonolige @shtinsa