From 358c36403c8027e23d4e260d01b7d8cf4b5ef4f8 Mon Sep 17 00:00:00 2001
From: Pawel Wasowski
Date: Wed, 17 Mar 2021 18:26:29 +0100
Subject: [PATCH] [ML][Pipeline] Remove InvalidValuesError from createPipeline
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit
ACR: TWDAPI-274
This commit removes InvalidValuesError from the list of valid
tizen.ml.pipeline.createPipeline() exceptions, because we cannot
reliably detect, when a pipeline description is invalid.
Instead, AbortError with custom message, suggesting that the
description may be invalid, will be used.
[Verification] Tested in Chrome DevTools with the snippets below, works
fine
// Invalid pipeline definition
var pipeline_def = "invalid";
var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
state => {console.log(state);})
// WebAPIException {name: "AbortError", message: "Could not create pipeline:
// invalid pipeline description or an internal error"}
//////////////////////////////////////////////////////////////////////
// Valid pipeline definition
var inputTI = new tizen.ml.TensorsInfo();
inputTI.addTensorInfo('ti1', 'UINT8', [4, 20, 15, 1]);
var outputTI = new tizen.ml.TensorsInfo();
outputTI.addTensorInfo('ti1', 'UINT8', [1200]);
var flattenAndSet123 = function(input, output) {
console.log("Custom filter called");
// dispose should have no efect
input.dispose();
console.log('input count: ' + input.tensorsInfo.count);
// dispose should have no efect
input.dispose();
console.log('output count: ' + output.tensorsInfo.count);
var rawOutputData = new Uint8Array(1200);
for (var i = 0; i < rawOutputData.length; ++i) {
rawOutputData[i] = 123;
}
output.setTensorRawData(0, rawOutputData);
// this call should have no effect
input.setTensorRawData(0, rawOutputData);
return 0;
}
tizen.ml.pipeline.registerCustomFilter('testfilter2', flattenAndSet123, inputTI,
outputTI, function errorCallback(error) {
console.warn('custom filter error:') ; console.warn(error);
});
var pipeline_def = "videotestsrc num-buffers=3 "
+ "! video/x-raw,width=20,height=15,format=BGRA "
+ "! tensor_converter "
+ "! tensor_filter framework=custom-easy model=testfilter2 "
+ "! appsink name=mysink";
var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def,
state => {console.log(state);})
pipeline.registerSinkListener('mysink', function(sinkName, data) {
console.log('SinkListener for "' + sinkName + '" sink called');
console.log(data);
})
// pipeline starts properly
Change-Id: If8d08160cb98b3acc34812f47b2741c2cce83cd8
Signed-off-by: Pawel Wasowski
---
src/ml/js/ml_pipeline.js | 1 -
src/ml/ml_pipeline.cc | 5 +++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/ml/js/ml_pipeline.js b/src/ml/js/ml_pipeline.js
index b7204bf4..f25550bd 100755
--- a/src/ml/js/ml_pipeline.js
+++ b/src/ml/js/ml_pipeline.js
@@ -27,7 +27,6 @@ function NextPipelineId() {
}
var ValidPipelineManagerCreatePipelineExceptions = [
- 'InvalidValuesError',
'TypeMismatchError',
'NotSupportedError',
'SecurityError',
diff --git a/src/ml/ml_pipeline.cc b/src/ml/ml_pipeline.cc
index 0719a2d9..02aa3c01 100644
--- a/src/ml/ml_pipeline.cc
+++ b/src/ml/ml_pipeline.cc
@@ -103,6 +103,11 @@ PlatformResult Pipeline::CreatePipeline(int id, const std::string& definition,
if (ML_ERROR_NONE != ret) {
LoggerE("ml_pipeline_construct() failed: [%d] (%s)", ret, get_error_message(ret));
+ if (ML_ERROR_STREAMS_PIPE == ret) {
+ return PlatformResult{
+ ErrorCode::ABORT_ERR,
+ "Could not create pipeline: invalid pipeline description or an internal error"};
+ }
return util::ToPlatformResult(ret, "Could not create a pipeline");
}
LoggerD("ml_pipeline_construct() succeeded");
--
2.34.1