Skip to content

Commit 347a45a

Browse files
committed
[SOFIE] Add regression test for ELU with alpha != 1.0
Adds EluAlpha.onnx (alpha=0.5) and a corresponding test case to prevent regressions for non-default alpha values in ELU codegen. Refs #21539
1 parent 2b87371 commit 347a45a

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

tmva/sofie/test/TestCustomModelsFromONNX.cxx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ constexpr auto modelDataSuffix = "_FromONNX.dat";
9292
#include "input_models/references/Log.ref.hxx"
9393
#include "input_models/references/Elu.ref.hxx"
9494
#include "input_models/references/Equal.ref.hxx"
95+
#include "input_models/references/EluAlpha.ref.hxx"
9596
#include "input_models/references/LessOrEqual.ref.hxx"
9697
#include "input_models/references/GreaterOrEqual.ref.hxx"
9798
#include "input_models/references/Less.ref.hxx"
@@ -308,6 +309,22 @@ TEST(ONNX, Elu)
308309
EXPECT_LE(std::abs(output[i] - correct[i]), TOLERANCE);
309310
}
310311
}
312+
TEST(ONNX, EluAlpha)
313+
{
314+
constexpr float TOLERANCE = DEFAULT_TOLERANCE;
315+
// Regression test for alpha != 1.0 (fixes #21539)
316+
std::vector<float> input({
317+
1.0, -2.0, 3.0, 0.5, -1.0, 2.0
318+
});
319+
ASSERT_INCLUDE_AND_RUN(std::vector<float>, "EluAlpha", input);
320+
// Checking output size
321+
EXPECT_EQ(output.size(), sizeof(EluAlpha_ExpectedOutput::outputs) / sizeof(float));
322+
float *correct = EluAlpha_ExpectedOutput::outputs;
323+
// Checking every output value, one by one
324+
for (size_t i = 0; i < output.size(); ++i) {
325+
EXPECT_LE(std::abs(output[i] - correct[i]), TOLERANCE);
326+
}
327+
}
311328

312329
TEST(ONNX, Constant)
313330
{
120 Bytes
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace EluAlpha_ExpectedOutput{
2+
float outputs[] = {
3+
1.0000, -0.4323, 3.0000,
4+
0.5000, -0.3161, 2.0000
5+
};
6+
} // namespace EluAlpha_ExpectedOutput

0 commit comments

Comments
 (0)