【share_params】why modules' share_params method doesn't free allocated memory?

graph executor setup all device memory in method’s GraphExecutor::SetupStorage, the allocated memory are stored in storage_pool_.

In my opinion, share params is for memory-saving accross multi same instance. image

why not remove from storage_pool_? so that the reference of origin NDArray use count will decrease to 0, then the allocated duplicated memory will be freed.

@masahi

I use this method try to run multi same instance, but the memory not get decreased.

There migit be some small changes need to update graph_executor's share_params method, to free the multi instance’s weight memory that have different batch size or seq_len. and it works.