From: Yelin Jeong Date: Fri, 28 Jul 2023 02:25:13 +0000 (+0900) Subject: [ML] add condition for changing default value in dimension array X-Git-Tag: accepted/tizen/unified/20230818.054524~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F48%2F296448%2F1;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [ML] add condition for changing default value in dimension array To remove unnecessary initiazlied value 1 in dimension array, ml-api will save '1' only if the user explicitly defined it. So, some conditions may need to be changed. Change-Id: Iafb626d4c7b2322cd7e5e8d42525fc194a7b3456 Signed-off-by: Yelin Jeong --- diff --git a/src/ml/ml_tensors_data_manager.cc b/src/ml/ml_tensors_data_manager.cc index 2870b2e4..937cb2f1 100644 --- a/src/ml/ml_tensors_data_manager.cc +++ b/src/ml/ml_tensors_data_manager.cc @@ -105,7 +105,7 @@ PlatformResult TensorsData::GetTensorRawData( // Check if update is partial due to location change bool partial = false; for (int i = 0; i < util::kWebApiMLTensorRankLimit; i++) { - if (location[i] >= dim[i]) { + if (location[i] >= dim[i] && location[i] > 0) { // Input data starts outside of current data LoggerE("Requested data location is invalid on [%d]: %u", i, location[i]); return PlatformResult{ErrorCode::INVALID_VALUES_ERR, "Requested data location is invalid"}; @@ -204,7 +204,7 @@ PlatformResult TensorsData::SetTensorRawData( // Check if update is partial due to location change bool partial = false; for (int i = 0; i < util::kWebApiMLTensorRankLimit; i++) { - if (location[i] >= dim[i]) { + if (location[i] >= dim[i] && location[i] > 0) { // Input data starts outside of current data LoggerE("Input data location is invalid on [%d]: %u", i, location[i]); return PlatformResult{ErrorCode::INVALID_VALUES_ERR, "Input data location is invalid"}; @@ -222,7 +222,9 @@ PlatformResult TensorsData::SetTensorRawData( LoggerE("Input data will not fit in TensorData [%d]: %u > %u", i, size_rel[i], dim[i]); return PlatformResult{ErrorCode::INVALID_VALUES_ERR, "Input data will not fit in TensorData"}; } else { - data_to_be_updated_size *= size[i]; + if (size[i] != 0) { + data_to_be_updated_size *= size[i]; + } if (size_rel[i] < dim[i]) { partial = true; }