MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / test_dataset

Function test_dataset

external/ggml/tests/test-opt.cpp:198–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198static std::pair<int, int> test_dataset(
199 enum ggml_opt_optimizer_type optim,
200 ggml_backend_sched_t backend_sched, ggml_backend_t backend, const bool shuffle) {
201 int ntest = 0;
202 int npass = 0;
203
204 struct helper_ctx_data cd = helper_get_ctx_data(optim, backend_sched, backend);
205
206 for (int64_t ndata_shard = 1; ndata_shard <= ndata; ++ndata_shard) {
207 ggml_opt_dataset_t dataset = cd.datasets_supervised[ndata_shard-1];
208
209 if (shuffle) {
210 ggml_opt_dataset_shuffle(cd.opt_ctx, dataset, -1);
211 }
212
213 for (int64_t ndata_batch = 1; ndata_batch <= ndata; ++ndata_batch) {
214 if (ndata_batch % ndata_shard != 0) {
215 continue;
216 }
217 bool subtest_ok = true;
218
219 struct ggml_tensor * data_batch = cd.data_batch[ndata_batch-1];
220 struct ggml_tensor * labels_batch = cd.labels_batch[ndata_batch-1];
221
222 std::vector<float> data(ggml_nelements( data_batch));
223 std::vector<float> labels(ggml_nelements(labels_batch));
224
225 std::vector<int64_t> idata_shuffled;
226 const int64_t nbatches = ndata / ndata_batch;
227 for (int64_t ibatch = 0; ibatch < nbatches; ++ibatch) {
228 ggml_opt_dataset_get_batch(dataset, data_batch, labels_batch, ibatch);
229
230 ggml_backend_tensor_get( data_batch, data.data(), 0, ggml_nbytes( data_batch));
231 ggml_backend_tensor_get(labels_batch, labels.data(), 0, ggml_nbytes(labels_batch));
232
233 for (int64_t idata_batch = 0; idata_batch < ndata_batch; ++idata_batch) {
234 const int64_t idata = ibatch*ndata_batch + idata_batch;
235 const int64_t idata_found = data[idata_batch*ne_datapoint] / 16;
236 subtest_ok = subtest_ok && (shuffle || idata_found == idata);
237 idata_shuffled.push_back(idata_found);
238
239 for (int64_t id = 0; id < ne_datapoint; ++id) {
240 if (data[ idata_batch*ne_datapoint + id] != 16*idata_found + id) {
241 subtest_ok = false;
242 }
243 }
244 for (int64_t il = 0; il < ne_label; ++il) {
245 if (labels[idata_batch*ne_label + il] != 16*(16*idata_found + il)) {
246 subtest_ok = false;
247 }
248 }
249 }
250 }
251
252 if (!shuffle || ndata % ndata_batch == 0) {
253 const int ndata_max = (ndata / ndata_batch) * ndata_batch;
254
255 for (int64_t idata = 0; subtest_ok && idata < ndata_max; ++idata) {

Callers 1

test_backendFunction · 0.85

Calls 8

helper_get_ctx_dataFunction · 0.85
ggml_opt_dataset_shuffleFunction · 0.85
ggml_nelementsFunction · 0.85
ggml_backend_tensor_getFunction · 0.85
ggml_nbytesFunction · 0.85
helper_free_ctx_dataFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected