Skip to content
Closed
Changes from all commits
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
12 changes: 10 additions & 2 deletions src/model_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ bool is_unused_tensor(const std::string& name) {
return false;
}

// The U1.5 vision filter also matches raw tensor names in standalone CLIP-Vision files.
bool should_skip_tensor(const std::string& name, const std::string& prefix) {
if (prefix == "clip_vision." && starts_with(name, "vision_model.")) {
return false;
}
return is_unused_tensor(name);
}

void f64_to_f32_vec(double* src, float* dst, int64_t n) {
// support inplace op
for (int64_t i = 0; i < n; i++) {
Expand Down Expand Up @@ -285,7 +293,7 @@ bool ModelLoader::init_from_safetensors_file(const std::string& file_path, const
size_t file_index = add_file_path(file_path);

for (auto& tensor_storage : tensor_storages) {
if (is_unused_tensor(tensor_storage.name)) {
if (should_skip_tensor(tensor_storage.name, prefix)) {
continue;
}

Expand Down Expand Up @@ -357,7 +365,7 @@ bool ModelLoader::init_from_torch_legacy_file(const std::string& file_path, cons
size_t file_index = add_file_path(file_path);

for (auto& tensor_storage : tensor_storages) {
if (is_unused_tensor(tensor_storage.name)) {
if (should_skip_tensor(tensor_storage.name, prefix)) {
continue;
}

Expand Down
Loading