MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / TEST_P

Function TEST_P

test/select.cpp:353–376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351 testNameGenerator);
352
353TEST_P(Select_, Batch) {
354 select_params params = GetParam();
355
356 float aval = 5.0f;
357 float bval = 10.0f;
358 array a = constant(aval, params.a);
359 array b = constant(bval, params.b);
360 array cond = (iota(params.cond) % 2).as(b8);
361
362 array out = select(cond, a, b);
363
364 EXPECT_EQ(out.dims(), params.out);
365
366 vector<float> h_out(out.elements());
367 out.host(h_out.data());
368 vector<unsigned char> h_cond(cond.elements());
369 cond.host(h_cond.data());
370
371 vector<float> gold(params.out.elements());
372 for (size_t i = 0; i < gold.size(); i++) {
373 gold[i] = h_cond[i % h_cond.size()] ? aval : bval;
374 ASSERT_FLOAT_EQ(gold[i], h_out[i]) << "at: " << i;
375 }
376}
377
378struct selectlr_params {
379 dim4 out;

Callers

nothing calls this directly

Calls 7

constantFunction · 0.85
asMethod · 0.80
hostMethod · 0.80
iotaFunction · 0.50
selectFunction · 0.50
dimsMethod · 0.45
elementsMethod · 0.45

Tested by

no test coverage detected