[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 e38f097983e1a5c528af1b55e3a3386d92106260..6872b88a1cb372a84602ca801fbb5de628594b4d 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 69d96a3fdd7f8fecb42c38bc76ae10aab2eb55f5..92167d2a9a09da379d41151fd316cc5018afe5c5 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 98dd2851b5f0dc00881ab488d085e9abe0508b02..37e574c031a990712fee25854dff55b647b243e5 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) {