From: Pawel Wasowski Date: Wed, 10 Mar 2021 10:31:04 +0000 (+0100) Subject: [ML][Pipeline][Single] Fix SVACE issues X-Git-Tag: submit/tizen/20210312.072248~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F11%2F254911%2F4;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [ML][Pipeline][Single] Fix SVACE issues This commit fixes the following issues reported on analysishub.sec.samsung.net (WGIDs): - 457566 - 457567 - 457568 [Verification] Code compiles. SVACE analysis after applying the patch (https://analysishub.sec.samsung.net/service/analyses/394936) found no errors. CustomFilter tested in Chrome DevTools with the snippet below works fine // Valid CustomFilter callback - the happy scenario 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"); var rawOutputData = new Uint8Array(1200); for (var i = 0; i < rawOutputData.length; ++i) { rawOutputData[i] = 123; } output.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); }) // READY // Custom filter called // PAUSED pipeline.start() // PLAYING // Change-Id: Id1d35167532c3aeecbd3c73c3546b80e31e8f76c Signed-off-by: Pawel Wasowski --- diff --git a/src/ml/ml_pipeline_custom_filter.cc b/src/ml/ml_pipeline_custom_filter.cc index 8373d9b0..fc54c93d 100644 --- a/src/ml/ml_pipeline_custom_filter.cc +++ b/src/ml/ml_pipeline_custom_filter.cc @@ -197,7 +197,7 @@ bool CustomFilter::PrepareMessageWithInputData( *input_tensors_data_ptr = tensors_data_manager_ptr_->CreateTensorsData( input_tensors_info_ptr_, native_input_tensors_data_handle, false, true); - if (!input_tensors_data_ptr) { + if (!(*input_tensors_data_ptr)) { LogAndReportError(PlatformResult(ErrorCode::ABORT_ERR, "Internal CustomFilter error"), &message_obj, ("Could not create TensorsData. Custom filter won't be triggered.")); @@ -206,7 +206,7 @@ bool CustomFilter::PrepareMessageWithInputData( *output_tensors_data_ptr = tensors_data_manager_ptr_->CreateTensorsData( output_tensors_info_ptr_, native_output_tensors_data_handle, false, false); - if (!output_tensors_data_ptr) { + if (!(*output_tensors_data_ptr)) { LogAndReportError(PlatformResult(ErrorCode::ABORT_ERR, "Internal CustomFilter error"), &message_obj, ("Could not create TensorsData. Custom filter won't be triggered.")); diff --git a/src/ml/ml_singleshot.cc b/src/ml/ml_singleshot.cc index ad7b68f8..5bfb9e35 100644 --- a/src/ml/ml_singleshot.cc +++ b/src/ml/ml_singleshot.cc @@ -37,9 +37,15 @@ SingleShot::SingleShot(int id, ml_single_h handle, bool dynamic_mode) // 'this' owns a handle_, and invalidates 'o' SingleShot::SingleShot(SingleShot&& o) - : id_(o.id_), handle_(o.handle_), dynamic_mode_(o.dynamic_mode_) { + : id_(o.id_), + handle_(o.handle_), + dynamic_mode_(o.dynamic_mode_), + tensor_data_out_handle_(o.tensor_data_out_handle_), + tensor_info_out_handle_(o.tensor_info_out_handle_) { ScopeLogger("id: %d", id_); o.handle_ = nullptr; + o.tensor_data_out_handle_ = nullptr; + o.tensor_info_out_handle_ = nullptr; } SingleShot::~SingleShot() {