Adding iree_runtime_session_trim helper. This just signals IREE_VM_SIGNAL_LOW_MEMORY on the context.
diff --git a/iree/runtime/session.c b/iree/runtime/session.c index 8704654..8128879 100644 --- a/iree/runtime/session.c +++ b/iree/runtime/session.c
@@ -171,6 +171,16 @@ return iree_hal_device_allocator(device); } +IREE_API_EXPORT iree_status_t +iree_runtime_session_trim(iree_runtime_session_t* session) { + IREE_ASSERT_ARGUMENT(session); + IREE_TRACE_ZONE_BEGIN(z0); + iree_status_t status = iree_vm_context_notify( + iree_runtime_session_context(session), IREE_VM_SIGNAL_LOW_MEMORY); + IREE_TRACE_ZONE_END(z0); + return status; +} + IREE_API_EXPORT iree_status_t iree_runtime_session_append_module( iree_runtime_session_t* session, iree_vm_module_t* module) { IREE_ASSERT_ARGUMENT(session);
diff --git a/iree/runtime/session.h b/iree/runtime/session.h index 960d7fb..ec0500c 100644 --- a/iree/runtime/session.h +++ b/iree/runtime/session.h
@@ -128,6 +128,13 @@ IREE_API_EXPORT iree_hal_allocator_t* iree_runtime_session_device_allocator( const iree_runtime_session_t* session); +// Trims transient/cached resources used by the session. +// Upon resuming these resources may be expensive to rematerialize/reload and +// as such this should only be called when it is known the resources will not +// be needed soon. +IREE_API_EXPORT iree_status_t +iree_runtime_session_trim(iree_runtime_session_t* session); + // Appends the given |module| to the context. // The module will be retained by the context. //