Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/18735
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 4 Unrelated FailuresAs of commit b68ac07 with merge base b5ae0b9 ( NEW FAILURE - The following job has failed:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs failed but was present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
2b6ebde to
20234f3
Compare
- Open Model with zero-copy using dmabufheap - Improve model loading with zero-copy - Remove unncessary comments or headers. Change file name - remove enn api from default extension/file_data_loader Co-authored-by: Hoon Choi <hoon98.choi@samsung.com> Signed-off-by: Jiseong oh <jiseong.oh@samsung.com>
20234f3 to
b68ac07
Compare
|
@claude help review this PR |
|
Claude finished @SS-JIA's task in 4m 37s —— View job PR Review: Optimize Enn runner — Memory Zero-Copy
OverviewThis PR introduces zero-copy model loading for the Samsung ENN backend by:
The concept is sound — if the model data is already in a dmabuf-backed buffer, passing the fd directly avoids a copy. However, there are several issues ranging from correctness bugs to architectural concerns. Critical Issues1. If EnnReturn ret; // uninitialized
...
if (_sm_instance->query(&_out, binary_buf_addr, buf_size)) {
int fd;
if (_out->va == binary_buf_addr &&
!enn_api_inst->EnnGetFileDescriptorFromEnnBuffer(_out, &fd)) {
ret = enn_api_inst->EnnOpenModelFromFd(fd, &model_id_);
...
}
// <-- if inner condition is false, ret is still uninitialized
}
if (!model_id_) { // model_id_ may also be uninitialized garbage if query returned true but inner failed
ret = enn_api_inst->EnnOpenModelFromMemory(...);
}
// ret may be uninitialized here
ET_CHECK_OR_RETURN_ERROR(ret == ENN_RET_SUCCESS, ...);2. Test file references non-existent header and namespace — #include <executorch/backends/samsung/runtime/enn_api_wrapper.h> // does not exist
...
using executorch::backends::enn::api_wrapper::SharedMemoryManager; // wrong namespaceThe file 3.
Design Concerns4. Global replacement of if(EXECUTORCH_BUILD_ENN)
list(REMOVE_ITEM _extension_data_loader__srcs
"extension/data_loader/file_data_loader.cpp"
)
list(APPEND _extension_data_loader__srcs
"backends/samsung/runtime/extension/exynos_file_data_loader.cpp"
)
endif()This globally replaces the
Consider a more targeted approach: either subclass 5. using namespace torch::executor::enn;
6. Double initialization of ENN API — The EnnApi::EnnApi() {
auto status = loadApiLib();
if (status == Error::Ok) {
EnnInitialize(); // called in constructor
...But the runner also calls it explicitly: void exynos_npu_init() {
EnnApi::getEnnApiInstance()->EnnInitialize(); // called again
}Similarly, 7. Singleton The Minor Issues8. This function is defined in the file but not called anywhere. Dead code should be removed. 9. void SharedMemoryManager::free(void* ptr) {
free(ptr, {});
}The 10. ET_LOG(Info, "va(%p), size(%d), offset(%d) is erased from LUT",
ptr, (*it)->size, (*it)->offset);
11. ET_LOG(Info, "Start to open model %p, %ld", binary_buf_addr, buf_size);
12. Missing The original 13. Unnecessary includes — #include <android/log.h>
#include <sys/mman.h>
SummaryThe zero-copy optimization concept is good, but the PR needs work before merging:
|
Summary
cc @SS-JIA @digantdesai @kimishpatel