Skip to content

Commit 9dfbd50

Browse files
committed
add comments to backend loading in test-backend-ops.cpp [no ci]
1 parent 5e77fae commit 9dfbd50

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tests/test-backend-ops.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7150,10 +7150,12 @@ static void print_backend_features(ggml_backend_t backend) {
71507150

71517151
static bool test_cpu_variant(const char * variant_name, const char * op_names_filter,
71527152
const char * params_filter, printer * output_printer) {
7153-
std::string backend_ref_name = "CPU-ref";
7154-
std::string variant = std::string(variant_name).substr(4);
7155-
ggml_backend_load_variant("cpu", variant.c_str());
7153+
// Load the variant first so that extra buffer types created only use that
7154+
// backend as the features of the backend can determine if the extra buf
7155+
// types are enabled or not.
7156+
ggml_backend_load_variant("cpu", std::string(variant_name).substr(4).c_str());
71567157

7158+
// Load extra buffer types and allocate a buffer from each type.
71577159
std::unordered_map<ggml_backend_buffer_type_t, ggml_backend_buffer_t> extra_buf_map;
71587160
{
71597161
auto * cpu_dev = ggml_backend_dev_by_type(GGML_BACKEND_DEVICE_TYPE_CPU);
@@ -7165,7 +7167,7 @@ static bool test_cpu_variant(const char * variant_name, const char * op_names_fi
71657167
ggml_backend_buffer_type_t * extra_bufts = ggml_backend_dev_get_extra_bufts_fn(cpu_dev);
71667168
while (extra_bufts && *extra_bufts) {
71677169
// TODO: What should the size be here? Do extra buffer types need a size even?
7168-
// We need to have a value larger than 0 to avoid the default buffer to be used.
7170+
// We need to have a value larger than 0 to avoid the dummy backend buffer to be used.
71697171
extra_buf_map[*extra_bufts] = ggml_backend_buft_alloc_buffer(*extra_bufts, 1);
71707172
++extra_bufts;
71717173
}
@@ -7178,7 +7180,8 @@ static bool test_cpu_variant(const char * variant_name, const char * op_names_fi
71787180
}
71797181
printf("\n");
71807182

7181-
ggml_backend_load_variant("cpu", "ref");
7183+
std::string backend_ref_name = "CPU-ref";
7184+
ggml_backend_load_variant("cpu", std::string(backend_ref_name).substr(4).c_str());
71827185

71837186
ggml_backend_t backend_ref = ggml_backend_init_by_name(backend_ref_name.c_str(), nullptr);
71847187
if (backend_ref == nullptr) {

0 commit comments

Comments
 (0)