tqchen commented on code in PR #456:
URL: https://github.com/apache/tvm-ffi/pull/456#discussion_r2812162704


##########
src/ffi/extra/serialization.cc:
##########
@@ -364,36 +333,12 @@ class ObjectGraphDeserializer {
     ObjectPtr<Object> ptr =
         
details::ObjectUnsafe::ObjectPtrFromOwned<Object>(static_cast<TVMFFIObject*>(handle));
 
-    auto decode_field_value = [&](const TVMFFIFieldInfo* field_info,
-                                  const json::Value& data) -> Any {
-      switch (field_info->field_static_type_index) {
-        case TypeIndex::kTVMFFINone: {
-          return nullptr;
-        }
-        case TypeIndex::kTVMFFIBool: {
-          return data.cast<bool>();
-        }
-        case TypeIndex::kTVMFFIInt: {
-          return data.cast<int64_t>();
-        }
-        case TypeIndex::kTVMFFIFloat: {
-          return data.cast<double>();
-        }
-        case TypeIndex::kTVMFFIDataType: {
-          return StringToDLDataType(data.cast<String>());
-        }
-        default: {
-          return GetOrDecodeNode(data.cast<int64_t>());
-        }
-      }
-    };
-
     json::Object data_object = data.cast<json::Object>();
     reflection::ForEachFieldInfo(type_info, [&](const TVMFFIFieldInfo* 
field_info) {
       String field_name(field_info->name);
       void* field_addr = reinterpret_cast<char*>(ptr.get()) + 
field_info->offset;
       if (data_object.count(field_name) != 0) {
-        Any field_value = decode_field_value(field_info, 
data_object[field_name]);
+        Any field_value = 
GetOrDecodeNode(data_object[field_name].cast<int64_t>());

Review Comment:
   would be good to deliberate this choice a bit further. Since one motivation 
was to simplify the serialization of a known schema, so serialization of fields 
like int/bool/string, do not need to go through second level indirection. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to