From fdced328d08399998c7ea23495b52cc93e3865e4 Mon Sep 17 00:00:00 2001 From: Yongjoo Ahn Date: Wed, 11 Jun 2025 12:45:17 +0900 Subject: [PATCH] [vivante] Fix optional and required fields in JSON - Get dtype values only when they are explictly given. Signed-off-by: Yongjoo Ahn --- src/hal-backend-ml-vivante.cc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/hal-backend-ml-vivante.cc b/src/hal-backend-ml-vivante.cc index 951a4a7..4eff29f 100644 --- a/src/hal-backend-ml-vivante.cc +++ b/src/hal-backend-ml-vivante.cc @@ -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 */ -- 2.34.1