-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removed the memory leaks directly in execution session #1746
Changes from 1 commit
6c1eebc
22f6d11
da04dd2
77a8c67
f79a408
4f0f021
3c8b687
684cecc
ecc14e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,8 +103,23 @@ void omTensorListDestroy(OMTensorList *list) { | |
return; | ||
for (int64_t i = 0; i < list->_size; i++) | ||
omTensorDestroy(list->_omts[i]); | ||
if (list->_owning) | ||
if (list->_owning) { | ||
free(list->_omts); | ||
} | ||
free(list); | ||
} | ||
|
||
/* OMTensorList destroyer which does not destroy the tensors. Currently an | ||
* unpublished call that is mainly used to handle the unique tensor scheme used | ||
* in Execution Session. | ||
*/ | ||
void omTensorListDestroyWithoutDestroyingTensors(OMTensorList *list) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe shorter name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. like it better too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
if (!list) | ||
return; | ||
// Omit destruction of the OMTensors. | ||
if (list->_owning) { | ||
free(list->_omts); | ||
} | ||
free(list); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,9 +118,9 @@ bool isOMLoopTheSameAsNaiveImplFor(std::string moduleIR, | |
omTensorGetElem<bool>(condTensor.get(), {}) = true; | ||
inputs.emplace_back(move(condTensor)); | ||
|
||
auto *yInitShape = new int64_t[1]{1}; | ||
int64_t yInitShape = 1; | ||
auto yInitTensor = OMTensorUniquePtr( | ||
omTensorCreateEmpty(&yInitShape[0], 1, OM_DATA_TYPE::ONNX_TYPE_INT64), | ||
omTensorCreateEmpty(&yInitShape, 1, OM_DATA_TYPE::ONNX_TYPE_INT64), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can avoid changing this line by changing the declaration for
Same for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see the difference, but yes we can. done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Difference is the array definition serves as a reminder that shape is typically an array. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, I buy that even though there is no difference between a scalar and an array of 1 element. |
||
omTensorDestroy); | ||
omTensorGetElem<int64_t>(yInitTensor.get(), {0}) = yInit; | ||
inputs.emplace_back(move(yInitTensor)); | ||
|
@@ -135,9 +135,9 @@ bool isOMLoopTheSameAsNaiveImplFor(std::string moduleIR, | |
return false; | ||
} | ||
|
||
auto *yRefInitShape = new int64_t[1]{1}; | ||
int64_t yRefInitShape = 1; | ||
chentong319 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
auto vFinalRef = OMTensorUniquePtr( | ||
omTensorCreateEmpty(&yRefInitShape[0], 1, OM_DATA_TYPE::ONNX_TYPE_INT64), | ||
omTensorCreateEmpty(&yRefInitShape, 1, OM_DATA_TYPE::ONNX_TYPE_INT64), | ||
omTensorDestroy); | ||
|
||
omTensorGetElem<int64_t>(vFinalRef.get(), {0}) = yInit; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move into
ExecutionSession.hpp
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to expose it to anyone doing the ExecutionSession, but created a OMTensorListHelper.hpp file for that.