Skip to content

Commit

Permalink
add clear device mem pool util (#1153)
Browse files Browse the repository at this point in the history
* add clear device mem pool util

* Apply code-format changes

* rename api

* Apply code-format changes

---------

Co-authored-by: curioyang <curioyang@users.noreply.github.com>
  • Loading branch information
curioyang and curioyang committed Dec 27, 2023
1 parent 907ae20 commit 52fe13b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Native/include/nncase/runtime/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class NNCASE_API buffer_allocator {
const buffer_attach_options &options) = 0;

static buffer_allocator &host();
virtual void shrink_memory_pool() = 0;
};

END_NS_NNCASE_RUNTIME
4 changes: 4 additions & 0 deletions src/Native/include/nncase/runtime/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -587,4 +587,8 @@ inline dims_t to_4d(dims_t in_a_shape) {
return in_a_shape;
}

inline void shrink_memory_pool() {
buffer_allocator::host().shrink_memory_pool();
}

END_NS_NNCASE_RUNTIME
2 changes: 2 additions & 0 deletions src/Native/src/runtime/host_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ class host_buffer_allocator : public buffer_allocator {
[]([[maybe_unused]] gsl::byte *p) {}, paddr, *this,
host_sync_status_t::valid));
}

void shrink_memory_pool() override {}
};

host_buffer_allocator host_allocator;
Expand Down

0 comments on commit 52fe13b

Please sign in to comment.