From: Rafal Walczyna Date: Fri, 12 Mar 2021 07:55:42 +0000 (+0100) Subject: [ML][Common] Fix issues that came out after TCT tests X-Git-Tag: submit/tizen/20210315.104011~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F31%2F255131%2F1;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [ML][Common] Fix issues that came out after TCT tests - tizen.ml.single and tizen.ml.prototype should be not writable - TensorsInfo.addTensorsInfo should return newly added tensors info id - ValidateBufferForTensorsData issue [Verification] Tested in chromium console Change-Id: I9ba7e074c79ffc7acb4de32a87a42db6c5f22beb Signed-off-by: Rafal Walczyna --- diff --git a/src/ml/js/ml_common.js b/src/ml/js/ml_common.js index e38f0979..6872b88a 100755 --- a/src/ml/js/ml_common.js +++ b/src/ml/js/ml_common.js @@ -222,10 +222,7 @@ function ValidateBufferForTensorsData(tensorsData, index, buffer) { } else if (false == buffer instanceof ArrayType) { throw new WebAPIException( WebAPIException.TYPE_MISMATCH_ERR, - 'buffer array has incompatible type, expected: ' + - ArrayType.name + - ', got: ' + - buffer.constructor.name + 'buffer has incompatible type, expected: ' + ArrayType.name ); } return ret; @@ -412,6 +409,7 @@ TensorsInfo.prototype.addTensorInfo = function() { AbortError ); } + return native_.getResultObject(result); }; var TensorsInfoGettersSettersValidExceptions = [ diff --git a/src/ml/js/ml_manager.js b/src/ml/js/ml_manager.js index 69d96a3f..92167d2a 100755 --- a/src/ml/js/ml_manager.js +++ b/src/ml/js/ml_manager.js @@ -14,11 +14,20 @@ * limitations under the License. */ -var MachineLearningManager = function() {}; - -MachineLearningManager.prototype.single = new MachineLearningSingle(); - -MachineLearningManager.prototype.pipeline = new MachineLearningPipeline(); +var MachineLearningManager = function() { + Object.defineProperties(this, { + single: { + enumerable: true, + writable: false, + value: new MachineLearningSingle() + }, + pipeline: { + enumerable: true, + writable: false, + value: new MachineLearningPipeline() + } + }); +}; var NNFWType = { ANY: 'ANY', diff --git a/src/ml/ml_instance.cc b/src/ml/ml_instance.cc index 98dd2851..37e574c0 100644 --- a/src/ml/ml_instance.cc +++ b/src/ml/ml_instance.cc @@ -266,7 +266,10 @@ void MlInstance::MLTensorsInfoAddTensorInfo(const picojson::value& args, picojso return; } - ReportSuccess(out); + int count = tensorsInfo->Count() - 1; + + picojson::value val = picojson::value{static_cast(count)}; + ReportSuccess(val, out); } void MlInstance::MLTensorsInfoGetDimensions(const picojson::value& args, picojson::object& out) {