Skip to content

Alias CLIPTextModelWithProjection as CLIPTextModel #1809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,84 +18,7 @@
namespace ov {
namespace genai {

class OPENVINO_GENAI_EXPORTS CLIPTextModelWithProjection {
public:
struct OPENVINO_GENAI_EXPORTS Config {
size_t max_position_embeddings = 77;
size_t num_hidden_layers = 32;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

num_hidden_layers is not the same for CLIPTextModel:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we read this value from config anyway:

read_json_param(data, "num_hidden_layers", num_hidden_layers);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we can get into a situation where the json doesn’t contain num_hidden_layers value - in that case, read_json_param will silently use the default value
Probably we should add a warning when num_hidden_layers is missing


explicit Config(const std::filesystem::path& config_path);
};

explicit CLIPTextModelWithProjection(const std::filesystem::path& root_dir);

CLIPTextModelWithProjection(const std::filesystem::path& root_dir,
const std::string& device,
const ov::AnyMap& properties = {});

CLIPTextModelWithProjection(const std::string& model,
const Tensor& weights,
const Config& config,
const Tokenizer& clip_tokenizer);

CLIPTextModelWithProjection(const std::string& model,
const Tensor& weights,
const Config& config,
const Tokenizer& clip_tokenizer,
const std::string& device,
const ov::AnyMap& properties = {});

template <typename... Properties,
typename std::enable_if<ov::util::StringAny<Properties...>::value, bool>::type = true>
CLIPTextModelWithProjection(const std::filesystem::path& root_dir,
const std::string& device,
Properties&&... properties)
: CLIPTextModelWithProjection(root_dir, device, ov::AnyMap{std::forward<Properties>(properties)...}) { }

template <typename... Properties,
typename std::enable_if<ov::util::StringAny<Properties...>::value, bool>::type = true>
CLIPTextModelWithProjection(const std::string& model,
const Tensor& weights,
const Config& config,
const Tokenizer& clip_tokenizer,
const std::string& device,
Properties&&... properties)
: CLIPTextModelWithProjection(model,
weights,
config,
clip_tokenizer,
device,
ov::AnyMap{std::forward<Properties>(properties)...}) { }

CLIPTextModelWithProjection(const CLIPTextModelWithProjection&);

const Config& get_config() const;

CLIPTextModelWithProjection& reshape(int batch_size);

CLIPTextModelWithProjection& compile(const std::string& device, const ov::AnyMap& properties = {});

template <typename... Properties>
ov::util::EnableIfAllStringAny<CLIPTextModelWithProjection&, Properties...> compile(
const std::string& device,
Properties&&... properties) {
return compile(device, ov::AnyMap{std::forward<Properties>(properties)...});
}

void set_adapters(const std::optional<AdapterConfig>& adapters);

ov::Tensor infer(const std::string& pos_prompt, const std::string& neg_prompt, bool do_classifier_free_guidance);

ov::Tensor get_output_tensor(const size_t idx);

private:
Config m_config;
AdapterController m_adapter_controller;
ov::InferRequest m_request;
std::shared_ptr<ov::Model> m_model;

Tokenizer m_clip_tokenizer;
};
using CLIPTextModelWithProjection = CLIPTextModel;

} // namespace genai
} // namespace ov

This file was deleted.

Loading