From 582736ed4ebf200f29f0ffb67bce9febd090908f Mon Sep 17 00:00:00 2001 From: almilosz Date: Fri, 3 Nov 2023 11:31:26 +0100 Subject: [PATCH] Add more desciptive names for cpp methods --- src/bindings/js/node/include/infer_request.hpp | 6 +++--- src/bindings/js/node/src/infer_request.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/bindings/js/node/include/infer_request.hpp b/src/bindings/js/node/include/infer_request.hpp index eb9d2acd4a2489..37bec610f5b4ee 100644 --- a/src/bindings/js/node/include/infer_request.hpp +++ b/src/bindings/js/node/include/infer_request.hpp @@ -90,7 +90,7 @@ class InferRequestWrap : public Napi::ObjectWrap { Napi::Value get_output_tensors(const Napi::CallbackInfo& info); /** @brief Checks incoming Napi::Value and calls overloaded infer() method */ - Napi::Value infer_dispatch(const Napi::CallbackInfo& info); + Napi::Value infer_sync_dispatch(const Napi::CallbackInfo& info); /** @brief Checks incoming Napi::Value and asynchronously returns the result of inference. */ Napi::Value infer_async(const Napi::CallbackInfo& info); @@ -98,12 +98,12 @@ class InferRequestWrap : public Napi::ObjectWrap { /** @brief Infers specified inputs in synchronous mode. * @param inputs An object with a collection of pairs key (input_name) and a value (tensor, tensor's data) */ - void infer(const Napi::Object& inputs); + void infer_sync(const Napi::Object& inputs); /** @brief Infers specified inputs in synchronous mode. * @param inputs An Array with values (tensors, tensors' data) */ - void infer(const Napi::Array& inputs); + void infer_sync(const Napi::Array& inputs); /** @return A Javascript CompiledModel. */ Napi::Value get_compiled_model(const Napi::CallbackInfo& info); diff --git a/src/bindings/js/node/src/infer_request.cpp b/src/bindings/js/node/src/infer_request.cpp index 7220034102b0e1..aab837c2c38bd4 100644 --- a/src/bindings/js/node/src/infer_request.cpp +++ b/src/bindings/js/node/src/infer_request.cpp @@ -27,7 +27,7 @@ Napi::Function InferRequestWrap::GetClassConstructor(Napi::Env env) { InstanceMethod("getTensor", &InferRequestWrap::get_tensor), InstanceMethod("getInputTensor", &InferRequestWrap::get_input_tensor), InstanceMethod("getOutputTensor", &InferRequestWrap::get_output_tensor), - InstanceMethod("inferSync", &InferRequestWrap::infer_dispatch), + InstanceMethod("inferSync", &InferRequestWrap::infer_sync_dispatch), InstanceMethod("infer", &InferRequestWrap::infer_async), InstanceMethod("getCompiledModel", &InferRequestWrap::get_compiled_model), }); @@ -149,7 +149,7 @@ Napi::Value InferRequestWrap::get_output_tensors(const Napi::CallbackInfo& info) return outputs_obj; } -Napi::Value InferRequestWrap::infer_dispatch(const Napi::CallbackInfo& info) { +Napi::Value InferRequestWrap::infer_sync_dispatch(const Napi::CallbackInfo& info) { if (info.Length() == 0) _infer_request.infer(); else if (info.Length() == 1 && info[0].IsTypedArray()) { @@ -157,14 +157,14 @@ Napi::Value InferRequestWrap::infer_dispatch(const Napi::CallbackInfo& info) { return info.Env().Null(); } else if (info.Length() == 1 && info[0].IsArray()) { try { - infer(info[0].As()); + infer_sync(info[0].As()); } catch (std::exception& e) { reportError(info.Env(), e.what()); return info.Env().Null(); } } else if (info.Length() == 1 && info[0].IsObject()) { try { - infer(info[0].As()); + infer_sync(info[0].As()); } catch (std::exception& e) { reportError(info.Env(), e.what()); return info.Env().Null(); @@ -175,7 +175,7 @@ Napi::Value InferRequestWrap::infer_dispatch(const Napi::CallbackInfo& info) { return get_output_tensors(info); } -void InferRequestWrap::infer(const Napi::Array& inputs) { +void InferRequestWrap::infer_sync(const Napi::Array& inputs) { for (size_t i = 0; i < inputs.Length(); ++i) { auto tensor = value_to_tensor(inputs[i], _infer_request, i); _infer_request.set_input_tensor(i, tensor); @@ -183,7 +183,7 @@ void InferRequestWrap::infer(const Napi::Array& inputs) { _infer_request.infer(); } -void InferRequestWrap::infer(const Napi::Object& inputs) { +void InferRequestWrap::infer_sync(const Napi::Object& inputs) { auto keys = inputs.GetPropertyNames(); for (size_t i = 0; i < keys.Length(); ++i) {