Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov committed Dec 31, 2024
2 parents 2205bcb + b041c15 commit db135f4
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/cpp/src/continuous_batching_adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ContinuousBatchingAdapter final : public LLMPipelineImplBase {
const std::string& device,
const ov::AnyMap& plugin_config
): LLMPipelineImplBase{tokenizer, GenerationConfig()}, m_impl{
models_path.string(),
models_path,
tokenizer,
scheduler_config,
device,
Expand Down Expand Up @@ -64,7 +64,7 @@ class ContinuousBatchingAdapter final : public LLMPipelineImplBase {
const std::string& device,
const ov::AnyMap& plugin_config
): LLMPipelineImplBase{Tokenizer(models_path), GenerationConfig()}, m_impl{
models_path.string(),
models_path,
m_tokenizer,
scheduler_config,
device,
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/src/llm_pipeline_stateful.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ StatefulLLMPipeline::StatefulLLMPipeline(
const std::string& device,
const ov::AnyMap& properties)
: StatefulLLMPipeline{
utils::singleton_core().read_model(models_path, {}, properties),
utils::singleton_core().read_model(models_path / "openvino_model.xml", {}, properties),
tokenizer,
device,
properties,
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/src/visual_language/processor_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

ov::genai::ProcessorConfig::ProcessorConfig(const std::filesystem::path& json_path) {
std::ifstream stream(json_path);
OPENVINO_ASSERT(stream.is_open(), "Failed to open '" + json_path.string() + "' with processor config");
OPENVINO_ASSERT(stream.is_open(), "Failed to open '", json_path, "' with processor config");
nlohmann::json parsed = nlohmann::json::parse(stream);
using ov::genai::utils::read_json_param;
read_json_param(parsed, "patch_size", patch_size); // For llava - stored in config.json vision_config
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/src/visual_language/vlm_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

ov::genai::VLMConfig::VLMConfig(const std::filesystem::path& json_path) {
std::ifstream stream(json_path);
OPENVINO_ASSERT(stream.is_open(), "Failed to open '" + json_path.string() + "' with processor config");
OPENVINO_ASSERT(stream.is_open(), "Failed to open '", json_path, "' with processor config");
nlohmann::json parsed = nlohmann::json::parse(stream);
using ov::genai::utils::read_json_param;
model_type = to_vlm_model_type(parsed.at("model_type"));
Expand Down
2 changes: 1 addition & 1 deletion src/python/py_llm_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ py::object call_common_generate(
DecodedResults res = pipe.generate(string_input, updated_config, streamer);
// If input was a string return a single string otherwise return DecodedResults.
if (updated_config.has_value() && (*updated_config).num_return_sequences == 1) {
results = py::cast<py::object>(pyutils::handle_utf8(res.texts)[0]);
results = py::cast<py::object>(pyutils::handle_utf8(res.texts[0]));
} else {
results = py::cast(res);
}
Expand Down
11 changes: 7 additions & 4 deletions src/python/py_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ py::list handle_utf8(const std::vector<std::string>& decoded_res) {
return res;
}

namespace {

bool py_object_is_any_map(const py::object& py_obj) {
if (!py::isinstance<py::dict>(py_obj)) {
return false;
Expand Down Expand Up @@ -291,15 +293,16 @@ ov::Any py_object_to_any(const py::object& py_obj, std::string property_name) {
OPENVINO_THROW("Property \"" + property_name + "\" got unsupported type.");
}

std::map<std::string, ov::Any> properties_to_any_map(const std::map<std::string, py::object>& properties) {
std::map<std::string, ov::Any> properties_to_cpp;
} // namespace

ov::AnyMap properties_to_any_map(const std::map<std::string, py::object>& properties) {
ov::AnyMap properties_to_cpp;
for (const auto& property : properties) {
properties_to_cpp[property.first] = py_object_to_any(property.second, property.first);
}
return properties_to_cpp;
}


ov::AnyMap kwargs_to_any_map(const py::kwargs& kwargs) {
ov::AnyMap params = {};

Expand Down Expand Up @@ -357,7 +360,7 @@ ov::genai::OptionalGenerationConfig update_config_from_kwargs(const ov::genai::O
return std::nullopt;

ov::genai::GenerationConfig res_config;
if(config.has_value())
if (config.has_value())
res_config = *config;

if (!kwargs.empty())
Expand Down
8 changes: 1 addition & 7 deletions src/python/py_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@ py::list handle_utf8(const std::vector<std::string>& decoded_res);

py::str handle_utf8(const std::string& text);

ov::Any py_object_to_any(const py::object& py_obj, std::string property_name);

bool py_object_is_any_map(const py::object& py_obj);

ov::AnyMap py_object_to_any_map(const py::object& py_obj);

std::map<std::string, ov::Any> properties_to_any_map(const std::map<std::string, py::object>& properties);
ov::AnyMap properties_to_any_map(const std::map<std::string, py::object>& properties);

ov::AnyMap kwargs_to_any_map(const py::kwargs& kwargs);

Expand Down

0 comments on commit db135f4

Please sign in to comment.