[vivante] Fix optional and required fields in JSON
authorYongjoo Ahn <yongjoo1.ahn@samsung.com>
Wed, 11 Jun 2025 03:45:17 +0000 (12:45 +0900)
committerYongjoo Ahn <yongjoo1.ahn@samsung.com>
Thu, 12 Jun 2025 06:00:49 +0000 (15:00 +0900)
- Get dtype values only when they are explictly given.

Signed-off-by: Yongjoo Ahn <yongjoo1.ahn@samsung.com>
src/hal-backend-ml-vivante.cc

index 951a4a7157801030bd8988d6d43e8d5701a3e044..4eff29fedd7c4457a3477c406da0d1001116a85d 100644 (file)
@@ -191,15 +191,25 @@ _helper_parse_tensor_attributes (JsonObject *tensor_obj, vsi_nn_tensor_attr_t *v
   }
   vsi_attr->dtype.vx_type = vivante_vsi_type_from_string (vx_type_str);
 
-  // Optional fields with defaults
+  // Required: qnt_type
   vsi_attr->dtype.qnt_type
       = vivante_qnt_type_from_string (json_object_get_string_member_with_default (
           dtype_obj, "qnt_type", "VSI_NN_QNT_TYPE_NONE"));
-  vsi_attr->dtype.fl = json_object_get_int_member_with_default (dtype_obj, "fl", 0);
-  vsi_attr->dtype.zero_point
-      = json_object_get_int_member_with_default (dtype_obj, "zero_point", 0);
-  vsi_attr->dtype.scale
-      = json_object_get_double_member_with_default (dtype_obj, "scale", 0.0f);
+
+  // Optional fields with defaults
+  if (json_object_has_member (dtype_obj, "fl")) {
+    vsi_attr->dtype.fl = json_object_get_int_member_with_default (dtype_obj, "fl", 0);
+  }
+
+  if (json_object_has_member (dtype_obj, "zero_point")) {
+    vsi_attr->dtype.zero_point
+        = json_object_get_int_member_with_default (dtype_obj, "zero_point", 0);
+  }
+
+  if (json_object_has_member (dtype_obj, "scale")) {
+    vsi_attr->dtype.scale
+        = json_object_get_double_member_with_default (dtype_obj, "scale", 0.0f);
+  }
 
   /** @todo Parse scales, scale_dim, etc. for PERCHANNEL quantization */