Skip to content

Commit a386ba9

Browse files
committed
fix imatrix collection on CPU backend
1 parent 71eed14 commit a386ba9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Diff for: imatrix.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ bool IMatrixCollector::collect_imatrix(struct ggml_tensor* t, bool ask, void* us
4242
return false;
4343
// why are small batches ignored (<16 tokens)?
4444
// if (src1->ne[1] < 16 || src1->type != GGML_TYPE_F32) return false;
45-
if (!(wname.substr(0, 6) == "model." || wname.substr(0, 17) == "cond_stage_model." || wname.substr(0,14) == "text_encoders."))
45+
if (!(wname.substr(0, 6) == "model." || wname.substr(0, 17) == "cond_stage_model." || wname.substr(0, 14) == "text_encoders."))
4646
return false;
4747
return true;
4848
}
@@ -51,7 +51,7 @@ bool IMatrixCollector::collect_imatrix(struct ggml_tensor* t, bool ask, void* us
5151
std::lock_guard<std::mutex> lock(m_mutex);
5252

5353
// copy the data from the GPU memory if needed
54-
const bool is_host = ggml_backend_buffer_is_host(src1->buffer);
54+
const bool is_host = src1->buffer == NULL || ggml_backend_buffer_is_host(src1->buffer);
5555

5656
if (!is_host) {
5757
m_src1_data.resize(ggml_nelements(src1));
@@ -144,10 +144,9 @@ bool IMatrixCollector::collect_imatrix(struct ggml_tensor* t, bool ask, void* us
144144
}
145145
}
146146
return true;
147-
148147
}
149148

150-
void IMatrixCollector::save_imatrix(std::string fname,int ncall) const {
149+
void IMatrixCollector::save_imatrix(std::string fname, int ncall) const {
151150
LOG_INFO("SAVING_IMATRIX to %s\n", fname.c_str());
152151

153152
if (ncall > 0) {

0 commit comments

Comments
 (0)