| 153 | |
| 154 | template <typename ctype, bool stable_sign = false> |
| 155 | void gen_nozero(HostTensorND& dest) { |
| 156 | static RNGxorshf rng{next_rand_seed()}; |
| 157 | auto ptr = dest.template ptr<ctype>(); |
| 158 | |
| 159 | if (DTypeTrait<ctype>::category == DTypeCategory::FLOAT) { |
| 160 | for (size_t i = 0, it = dest.shape().total_nr_elems(); i < it; ++i) { |
| 161 | auto v = rng() / (rng.max() + 1.0) * 3 - 1.5; |
| 162 | bool vsign = v > 0; |
| 163 | if (stable_sign) { |
| 164 | vsign = i % 2; |
| 165 | } |
| 166 | v = std::abs(v) + 0.1; |
| 167 | ptr[i] = vsign ? v : -v; |
| 168 | } |
| 169 | } else { |
| 170 | for (size_t i = 0, it = dest.shape().total_nr_elems(); i < it; ++i) { |
| 171 | ctype v = rng() / (rng.max() + 1.0) * 65536 - 32767, vsat = i % 2 * 2 - 1; |
| 172 | ptr[i] = v == 0 ? vsat : v; |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | template <class Trait> |
| 178 | struct CheckerConfig { |
nothing calls this directly
no test coverage detected