This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 86c5df8923 [Runtime][RPC] Fix FreeObject in minrpc server (#16647)
86c5df8923 is described below
commit 86c5df8923b1784fc3af6b33c1ba1cc4c5d7516c
Author: Siyuan Feng <[email protected]>
AuthorDate: Mon Mar 11 03:02:38 2024 +0800
[Runtime][RPC] Fix FreeObject in minrpc server (#16647)
As a followup PR to #16635, this PR fixes the FreeObject in minrpc server.
---
src/runtime/crt/common/crt_runtime_api.c | 2 ++
src/runtime/minrpc/minrpc_server.h | 2 ++
tests/python/runtime/test_runtime_rpc.py | 4 ++++
3 files changed, 8 insertions(+)
diff --git a/src/runtime/crt/common/crt_runtime_api.c
b/src/runtime/crt/common/crt_runtime_api.c
index a9c40c4583..99b3201b95 100644
--- a/src/runtime/crt/common/crt_runtime_api.c
+++ b/src/runtime/crt/common/crt_runtime_api.c
@@ -139,6 +139,8 @@ int TVMStreamCreate(int device_type, int device_id,
TVMStreamHandle* out) {
return 0;
}
+int TVMObjectFree(TVMObjectHandle obj) { return 0; }
+
int TVMStreamFree(int device_type, int device_id, TVMStreamHandle stream) {
return 0; }
int TVMSetStream(int device_type, int device_id, TVMStreamHandle stream) {
return 0; }
diff --git a/src/runtime/minrpc/minrpc_server.h
b/src/runtime/minrpc/minrpc_server.h
index 96a4dbce79..fce57f104e 100644
--- a/src/runtime/minrpc/minrpc_server.h
+++ b/src/runtime/minrpc/minrpc_server.h
@@ -344,6 +344,8 @@ class MinRPCExecute : public MinRPCExecInterface {
call_ecode = TVMArrayFree(static_cast<TVMArrayHandle>(handle));
} else if (type_code == kTVMPackedFuncHandle) {
call_ecode = TVMFuncFree(handle);
+ } else if (type_code == kTVMObjectHandle) {
+ call_ecode = TVMObjectFree(handle);
} else {
MINRPC_CHECK(type_code == kTVMModuleHandle);
call_ecode = TVMModFree(handle);
diff --git a/tests/python/runtime/test_runtime_rpc.py
b/tests/python/runtime/test_runtime_rpc.py
index 2cdbb248cf..4963124b62 100644
--- a/tests/python/runtime/test_runtime_rpc.py
+++ b/tests/python/runtime/test_runtime_rpc.py
@@ -447,6 +447,10 @@ def test_rpc_return_remote_object():
assert get_elem(shape, 0) == 2
assert get_elem(shape, 1) == 3
assert get_size(shape) == 2
+ # Test free object by assigning to the same variable
+ shape = make_shape(0)
+ assert get_size(shape) == 1
+ assert get_elem(shape, 0) == 0
# start server