Skip to content

Commit

Permalink
tests: benchdnn: softmax: relax threshold for ACL #1819
Browse files Browse the repository at this point in the history
ACL softmax accumulates in F16, but oneDNN now expects accumulation in
F32, so the tests fail. This commit partially reverts 6727bbe.
Fixes #1819
  • Loading branch information
jondea authored and mgouicem committed Mar 12, 2024
1 parent 64e5fc5 commit e44b78f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/benchdnn/softmax/softmax.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*******************************************************************************
* Copyright 2019-2024 Intel Corporation
* Copyright 2024 Arm Ltd. and affiliates
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -230,7 +231,14 @@ void setup_cmp(compare::compare_t &cmp, const prb_t *prb, data_kind_t kind,
const float trh_coeff_bwd = (prb->dir & FLAG_FWD) ? 1.f : 4.f;
const float trh_f32 = trh_coeff_log * trh_coeff_bwd * trh_coeff_f32
* epsilon_dt(trh_dt);
#if DNNL_AARCH64_USE_ACL
// ACL softmax accumulates in F16, but oneDNN now expects accumulation in
// F32, this partially reverts 6727bbe8. For more information, see
// https://github.com/oneapi-src/oneDNN/issues/1819
const float trh = trh_f32;
#else
const float trh = is_flt_or_dbl ? trh_f32 : 0.f;
#endif
cmp.set_threshold(trh);

// LogSoftMax is unstable enough when there are attributes on top.
Expand All @@ -253,12 +261,17 @@ void setup_cmp(compare::compare_t &cmp, const prb_t *prb, data_kind_t kind,

const auto softmax_add_check
= [&](const compare::compare_t::driver_check_func_args_t &args) {
#if DNNL_AARCH64_USE_ACL
auto diff_trh = epsilon_dt(args.dt);
#else
auto diff_trh = epsilon_dt(dnnl_f32);
#endif
// SSE4.1 and OpenCL rdiff tolerance is too high for
// certain scenarios.
// Additionally, OpenCL expf implementation may return 1e-38f
// values for big negative numbers. This is the guard from
// such values.
return args.diff < epsilon_dt(dnnl_f32);
return args.diff < diff_trh;
};
cmp.set_driver_check_function(softmax_add_check);
}
Expand Down

0 comments on commit e44b78f

Please sign in to comment.