[ML][Common] Fix issues that came out after TCT tests 31/255131/1
authorRafal Walczyna <r.walczyna@samsung.com>
Fri, 12 Mar 2021 07:55:42 +0000 (08:55 +0100)
committerRafal Walczyna <r.walczyna@samsung.com>
Fri, 12 Mar 2021 09:49:36 +0000 (10:49 +0100)
- 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 <r.walczyna@samsung.com>
src/ml/js/ml_common.js
src/ml/js/ml_manager.js
src/ml/ml_instance.cc

index e38f097..6872b88 100755 (executable)
@@ -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 = [
index 69d96a3..92167d2 100755 (executable)
  *    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',
index 98dd285..37e574c 100644 (file)
@@ -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<double>(count)};
+  ReportSuccess(val, out);
 }
 
 void MlInstance::MLTensorsInfoGetDimensions(const picojson::value& args, picojson::object& out) {