Skip to content

Commit

Permalink
Don't crash on 0-arg PrimFunc in ExtractBufferInfo.
Browse files Browse the repository at this point in the history
  • Loading branch information
areusch committed Sep 26, 2022
1 parent de55da7 commit 9c538e0
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/tir/usmp/analysis/extract_buffer_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -429,15 +429,17 @@ void BufferInfoExtractor::VisitExpr_(const VarNode* op) {

Array<Var> static GetMatchedBuffers(const PrimFunc& func) {
Array<Var> buffer_vars;
for (unsigned int i = 0; i < func->params.size() - 1; i++) {
Var param = func->params[i];
buffer_vars.push_back(func->buffer_map[param]->data);
}
Var last_param = func->params.back();
// Checks whether last var is present in the buffer map
// because it could be the resource handle
if (func->buffer_map.find(last_param) != func->buffer_map.end()) {
buffer_vars.push_back(func->buffer_map[last_param]->data);
if (func->params.size() > 0) {
for (unsigned int i = 0; i < func->params.size() - 1; i++) {
Var param = func->params[i];
buffer_vars.push_back(func->buffer_map[param]->data);
}
Var last_param = func->params.back();
// Checks whether last var is present in the buffer map
// because it could be the resource handle
if (func->buffer_map.find(last_param) != func->buffer_map.end()) {
buffer_vars.push_back(func->buffer_map[last_param]->data);
}
}
return buffer_vars;
}
Expand Down

0 comments on commit 9c538e0

Please sign in to comment.