File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -401,14 +401,18 @@ class SimdOpCheckTest {
401401 inputs[i].as <double >().for_each_value ([&](double &f) { f = (rng () & 0xfff ) / 8.0 - 0xff ; });
402402 } else if (t == Float (16 )) {
403403 inputs[i].as <float16_t >().for_each_value ([&](float16_t &f) { f = float16_t ((rng () & 0xff ) / 8 .0f - 0xf ); });
404+ } else if (t == BFloat (16 )) {
405+ inputs[i].as <bfloat16_t >().for_each_value ([&](bfloat16_t &f) { f = bfloat16_t ((rng () & 0xff ) / 8 .0f - 0xf ); });
404406 } else {
405- // Random bits is fine
407+ assert (t.is_int_or_uint ());
408+ // Random bits is fine, but in the 32-bit int case we
409+ // never use the top four bits, to avoid signed integer
410+ // overflow.
411+ const uint32_t mask = (t == Int (32 )) ? 0x0fffffffU : 0xffffffffU ;
406412 for (uint32_t *ptr = (uint32_t *)inputs[i].data ();
407413 ptr != (uint32_t *)inputs[i].data () + inputs[i].size_in_bytes () / 4 ;
408414 ptr++) {
409- // Never use the top four bits, to avoid
410- // signed integer overflow.
411- *ptr = ((uint32_t )rng ()) & 0x0fffffff ;
415+ *ptr = ((uint32_t )rng ()) & mask;
412416 }
413417 }
414418 }
You can’t perform that action at this time.
0 commit comments