Merge "[ML][Pipeline] Change CustomFilter interface and implementation" into tizen
authorPiotr Kosko <p.kosko@samsung.com>
Wed, 3 Mar 2021 13:12:16 +0000 (13:12 +0000)
committerGerrit Code Review <gerrit@review>
Wed, 3 Mar 2021 13:12:16 +0000 (13:12 +0000)
1  2 
src/ml/ml_instance.cc

diff --combined src/ml/ml_instance.cc
@@@ -128,8 -128,8 +128,8 @@@ MlInstance::MlInstance(
    REGISTER_METHOD(MLSingleShotInvoke);
    REGISTER_METHOD(MLSingleShotGetValue);
    REGISTER_METHOD(MLSingleShotSetValue);
 -  // SingleShot::setTimeout()
 -  // SingleShot::close()
 +  REGISTER_METHOD(MLSingleShotSetTimeout);
 +  REGISTER_METHOD(MLSingleShotClose);
  
    // Single API end
  
@@@ -564,6 -564,12 +564,12 @@@ void MlInstance::MLTensorsDataDispose(c
                        ("Could not find TensorsData handle with given id: %d", tensors_data_id));
      return;
    }
+   if (!tensors_data->DisposableFromJS()) {
+     ReportSuccess(out);
+     return;
+   }
    // Dispose underlying tensorsInfo
    PlatformResult result = GetTensorsInfoManager().DisposeTensorsInfo(tensors_data->TensorsInfoId());
    if (!result) {
@@@ -731,7 -737,6 +737,7 @@@ void MlInstance::MLTensorsDataSetTensor
  
  // TODO move to the up section with field names
  namespace {
 +const std::string kTimeout = "timeout";
  const std::string kModelPath = "modelPath";
  const std::string kInTensorsInfo = "inTensorsInfo";
  const std::string kOutTensorsInfo = "outTensorsInfo";
@@@ -953,37 -958,9 +959,37 @@@ void MlInstance::MLSingleShotSetValue(c
    ReportSuccess(out);
  }
  
 -// SingleShot::setTimeout()
 +void MlInstance::MLSingleShotSetTimeout(const picojson::value& args, picojson::object& out) {
 +  ScopeLogger("args: %s", args.serialize().c_str());
 +  CHECK_ARGS(args, kId, double, out);
 +  CHECK_ARGS(args, kTimeout, double, out);
 +
 +  auto id = static_cast<int>(args.get(kId).get<double>());
 +  auto timeout = static_cast<unsigned long>(args.get(kTimeout).get<double>());
 +
 +  auto ret = single_manager_.SetTimeout(id, timeout);
 +  if (!ret) {
 +    ReportError(ret, &out);
 +    return;
 +  }
 +
 +  ReportSuccess(out);
 +}
  
 -// SingleShot::close()
 +void MlInstance::MLSingleShotClose(const picojson::value& args, picojson::object& out) {
 +  ScopeLogger("args: %s", args.serialize().c_str());
 +  CHECK_ARGS(args, kId, double, out);
 +
 +  auto id = static_cast<int>(args.get(kId).get<double>());
 +
 +  auto ret = single_manager_.Close(id);
 +  if (!ret) {
 +    ReportError(ret, &out);
 +    return;
 +  }
 +
 +  ReportSuccess(out);
 +}
  
  // Single API end
  
@@@ -1304,17 -1281,12 +1310,12 @@@ void MlInstance::MLPipelineManagerCusto
    CHECK_ARGS(args, kName, std::string, out);
    CHECK_ARGS(args, kStatus, double, out);
    CHECK_ARGS(args, kRequestId, double, out);
-   CHECK_ARGS(args, kDataId, double, out);
-   CHECK_ARGS(args, kCallbackId, double, out);
  
    const auto& custom_filter_name = args.get(kName).get<std::string>();
    auto status = static_cast<int>(args.get(kStatus).get<double>());
    auto request_id = static_cast<int>(args.get(kRequestId).get<double>());
-   auto data_id = static_cast<int>(args.get(kDataId).get<double>());
-   auto callback_id = static_cast<int>(args.get(kCallbackId).get<double>());
  
-   auto ret = pipeline_manager_.CustomFilterOutput(custom_filter_name, request_id, status, data_id,
-                                                   callback_id);
+   auto ret = pipeline_manager_.CustomFilterOutput(custom_filter_name, request_id, status);
    if (!ret) {
      LogAndReportError(ret, &out);
      return;