diff --git a/tmva/sofie/inc/TMVA/ROperator_BasicBinary.hxx b/tmva/sofie/inc/TMVA/ROperator_BasicBinary.hxx index e9b2078bc73a1..4194796cf3785 100644 --- a/tmva/sofie/inc/TMVA/ROperator_BasicBinary.hxx +++ b/tmva/sofie/inc/TMVA/ROperator_BasicBinary.hxx @@ -54,13 +54,13 @@ template struct BinaryOperatorTrait { static const std::string Name() { return "Mod"; } static std::string Op(const std::string & t1, const std::string t2) { return "(" + t1 + " % " + t2 + ")"; } - static T Func (T t1, T t2) { return std::pow(t1,t2);} + static T Func(T t1, T t2) { return t1 % t2; } }; template struct BinaryOperatorTrait { static const std::string Name() { return "FMod"; } static std::string Op(const std::string & t1, const std::string t2) { return "std::fmod(" + t1 + "," + t2 + ")"; } - static T Func (T t1, T t2) { return std::pow(t1,t2);} + static T Func(T t1, T t2) { return std::fmod(t1, t2); } }; template diff --git a/tmva/sofie/test/TestCustomModelsFromONNX.cxx b/tmva/sofie/test/TestCustomModelsFromONNX.cxx index 94993f601a3c4..1e152538bc77d 100644 --- a/tmva/sofie/test/TestCustomModelsFromONNX.cxx +++ b/tmva/sofie/test/TestCustomModelsFromONNX.cxx @@ -896,6 +896,17 @@ TEST(ONNX, Pow_broadcast){ } +TEST(ONNX, FMod_ConstantFolding) +{ + // Both inputs are Constant nodes, so SOFIE constant-folds via Func(). + // fmod([10, 7, 5], [3, 3, 3]) = [1, 1, 2] + std::vector correct_output = {1, 1, 2}; + ASSERT_INCLUDE_AND_RUN_0(std::vector, "FMod_ConstantFolding"); + EXPECT_EQ(output.size(), correct_output.size()); + for (size_t i = 0; i < output.size(); ++i) + EXPECT_LE(std::abs(output[i] - correct_output[i]), DEFAULT_TOLERANCE); +} + TEST(ONNX, ReduceMean){ constexpr float TOLERANCE = DEFAULT_TOLERANCE; diff --git a/tmva/sofie/test/input_models/FMod_ConstantFolding.onnx b/tmva/sofie/test/input_models/FMod_ConstantFolding.onnx new file mode 100644 index 0000000000000..5f2d78a90bf00 Binary files /dev/null and b/tmva/sofie/test/input_models/FMod_ConstantFolding.onnx differ