From e84dcf1d46b9e524380b6d05fb4192b23678093a Mon Sep 17 00:00:00 2001 From: Pawel Wasowski Date: Wed, 10 Mar 2021 11:31:04 +0100 Subject: [PATCH] [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 --- src/ml/ml_pipeline_custom_filter.cc | 4 ++-- src/ml/ml_singleshot.cc | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) 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() { -- 2.34.1