Skip to content

Commit

Permalink
tests: benchdnn: eltwise_log: update input values with inf and -inf
Browse files Browse the repository at this point in the history
  • Loading branch information
tczeszun authored and tprimak committed Apr 22, 2022
1 parent 3fd0f2e commit 732cbdd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/benchdnn/eltwise/eltwise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ int fill_data(const prb_t *prb, data_kind_t kind, dnn_mem_t &mem_dt,
/* Do fixed partitioning to have same filling for any number of threads */
const int64_t n_chunks = 16;
const int64_t chunk_size = div_up(nelems, n_chunks);
const bool is_log = prb->alg == alg_t::LOG;

dnnl::impl::parallel_nd(n_chunks, [&](int64_t idx_chunk) {
int64_t idx_start = idx_chunk * chunk_size;
Expand All @@ -241,7 +242,8 @@ int fill_data(const prb_t *prb, data_kind_t kind, dnn_mem_t &mem_dt,
std::uniform_real_distribution<> fgen(0.f, 0.09f);

for (int64_t idx = idx_start; idx < idx_end; ++idx) {
static constexpr int64_t num_of_generation_variants = 13;
const int64_t num_of_generation_variants
= 13 + (2 * static_cast<int64_t>(is_log));
float value = FLT_MAX;
switch (idx % num_of_generation_variants) {
case 0: value = (float)igen(msr); break; // [0-10] pos
Expand All @@ -263,6 +265,8 @@ int fill_data(const prb_t *prb, data_kind_t kind, dnn_mem_t &mem_dt,
break; // values close to logf(FLT_MAX)/2.0 for fwd mish alg testing
case 11: value = prb->alpha; break; // `x = alpha` corner cases
case 12: value = prb->beta; break; // `x = beta` corner cases
case 13: value = INFINITY; break; // used in LOG alg only
case 14: value = -INFINITY; break; // used in LOG alg only
}
value = round_to_nearest_representable(prb->dt, value);

Expand Down

0 comments on commit 732cbdd

Please sign in to comment.