From 5e8a9a959779b017c42418dadb97212aa8659ad0 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Fri, 15 Oct 2021 18:46:20 +0800 Subject: [PATCH] feat(lite): add get static mem info function in lite c GitOrigin-RevId: f0d1b3009ea716b94eb34586a479421acd9b7545 --- lite/lite-c/include/lite-c/network_c.h | 9 +++++++++ lite/lite-c/src/network.cpp | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lite/lite-c/include/lite-c/network_c.h b/lite/lite-c/include/lite-c/network_c.h index 3e0ffef1d..64ca7a377 100644 --- a/lite/lite-c/include/lite-c/network_c.h +++ b/lite/lite-c/include/lite-c/network_c.h @@ -512,6 +512,15 @@ LITE_API int LITE_enable_io_txt_dump(LiteNetwork network, const char* io_txt_out */ LITE_API int LITE_enable_io_bin_dump(LiteNetwork network, const char* io_bin_out_dir); +/** + * \brief get static peak memory info showed by Graph visualization + * \param[in] log_dir The dumped json file directory + * \return int if the return is not zero, error happened, the error message + * can get by LITE_get_last_error + */ +LITE_API int LITE_get_static_memory_alloc_info( + LiteNetwork network, const char* log_dir); + #ifdef __cplusplus } #endif diff --git a/lite/lite-c/src/network.cpp b/lite/lite-c/src/network.cpp index c4aa631fb..d9419df60 100644 --- a/lite/lite-c/src/network.cpp +++ b/lite/lite-c/src/network.cpp @@ -558,4 +558,19 @@ int LITE_share_runtime_memroy(LiteNetwork dst_network, LiteNetwork src_network) LITE_CAPI_END(); } +int LITE_get_static_memory_alloc_info(LiteNetwork network, const char* log_dir) { + LITE_CAPI_BEGIN(); +#ifndef __IN_TEE_ENV__ +#if MGB_ENABLE_JSON + LITE_ASSERT(network, "The network pass to LITE api is null"); + static_cast(network)->get_static_memory_alloc_info(log_dir); + return 0; +#endif +#endif + LITE_MARK_USED_VAR(network); + LITE_MARK_USED_VAR(log_dir); + LITE_THROW("Doesn't support get_static_memory_alloc_info().Please check macro."); + LITE_CAPI_END(); +} + // vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}} -- GitLab