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

Method assertSpclArraysTransform

test/transform.cpp:322–389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320 }
321
322 void assertSpclArraysTransform(const af_array gold, const af_array out,
323 TestOutputArrayInfo *metadata) {
324 // In the case of NULL_ARRAY, the output array starts out as null.
325 // After the af_* function is called, it shouldn't be null anymore
326 if (metadata->getOutputArrayType() == NULL_ARRAY) {
327 if (out == 0) {
328 ASSERT_TRUE(out != 0) << "Output af_array is null";
329 }
330 metadata->setOutput(out);
331 }
332 // For every other case, must check if the af_array generated by
333 // genTestOutputArray was used by the af_* function as its output array
334 else {
335 if (metadata->getOutput() != out) {
336 ASSERT_TRUE(metadata->getOutput() != out)
337 << "af_array POINTER MISMATCH:\n"
338 << " Actual: " << out << "\n"
339 << "Expected: " << metadata->getOutput();
340 }
341 }
342
343 af_array out_ = 0;
344 af_array gold_ = 0;
345
346 if (metadata->getOutputArrayType() == SUB_ARRAY) {
347 // There are two full arrays. One will be injected with the gold
348 // subarray, the other should have already been injected with the
349 // af_* function's output. Then we compare the two full arrays
350 af_array gold_full_array = metadata->getFullOutputCopy();
351 af_assign_seq(&gold_full_array, gold_full_array,
352 metadata->getSubArrayNumDims(),
353 metadata->getSubArrayIdxs(), gold);
354
355 gold_ = metadata->getFullOutputCopy();
356 out_ = metadata->getFullOutput();
357 } else {
358 gold_ = gold;
359 out_ = out;
360 }
361
362 // Get gold data
363 dim_t goldEl = 0;
364 af_get_elements(&goldEl, gold_);
365 vector<T> goldData(goldEl);
366 af_get_data_ptr((void *)&goldData.front(), gold_);
367
368 // Get result
369 dim_t outEl = 0;
370 af_get_elements(&outEl, out_);
371 vector<T> outData(outEl);
372 af_get_data_ptr((void *)&outData.front(), out_);
373
374 const float thr = 1.1f;
375
376 // Maximum number of wrong pixels must be <= 0.01% of number of
377 // elements, this metric is necessary due to rounding errors between
378 // different backends for AF_INTERP_NEAREST and AF_INTERP_LOWER
379 const size_t maxErr = goldEl * 0.0001f;

Callers

nothing calls this directly

Calls 12

af_get_elementsFunction · 0.85
fabsFunction · 0.85
floorFunction · 0.85
getOutputArrayTypeMethod · 0.80
setOutputMethod · 0.80
getOutputMethod · 0.80
getFullOutputCopyMethod · 0.80
getSubArrayNumDimsMethod · 0.80
getSubArrayIdxsMethod · 0.80
getFullOutputMethod · 0.80
af_assign_seqFunction · 0.50
af_get_data_ptrFunction · 0.50

Tested by

no test coverage detected