From 61ffa7c8a80b8c2285fff629749e167206261eb3 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Mon, 18 Dec 2023 11:52:58 +0100 Subject: [PATCH 1/2] [tmva] Fix new warning in TMVA with gcc 13.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When compiling with gcc 13.2, there is a new warning in TMVA that is fixed by this commit: ```c++ In static member function ‘static constexpr _Up* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = long unsigned int; _Up = long unsigned int; bool _IsMove = true]’, inlined from ‘constexpr _OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = true; _II = long unsigned int*; _OI = long unsigned int*]’ at /usr/include/c++/13.2.1/bits/stl_algobase.h:506:30, inlined from ‘constexpr _OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = true; _II = long unsigned int*; _OI = long unsigned int*]’ at /usr/include/c++/13.2.1/bits/stl_algobase.h:533:42, inlined from ‘constexpr _OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = true; _II = long unsigned int*; _OI = long unsigned int*]’ at /usr/include/c++/13.2.1/bits/stl_algobase.h:540:31, inlined from ‘constexpr _OI std::copy(_II, _II, _OI) [with _II = move_iterator; _OI = long unsigned int*]’ at /usr/include/c++/13.2.1/bits/stl_algobase.h:633:7, inlined from ‘static _ForwardIterator std::__uninitialized_copy::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = std::move_iterator; _ForwardIterator = long unsigned int*]’ at /usr/include/c++/13.2.1/bits/stl_uninitialized.h:147:27, inlined from ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = move_iterator; _ForwardIterator = long unsigned int*]’ at /usr/include/c++/13.2.1/bits/stl_uninitialized.h:185:15, inlined from ‘constexpr _ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = move_iterator; _ForwardIterator = long unsigned int*; _Tp = long unsigned int]’ at /usr/include/c++/13.2.1/bits/stl_uninitialized.h:373:37, inlined from ‘constexpr _ForwardIterator std::__uninitialized_move_if_noexcept_a(_InputIterator, _InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = long unsigned int*; _ForwardIterator = long unsigned int*; _Allocator = allocator]’ at /usr/include/c++/13.2.1/bits/stl_uninitialized.h:399:2, inlined from ‘constexpr void std::vector<_Tp, _Alloc>::_M_range_insert(iterator, _ForwardIterator, _ForwardIterator, std::forward_iterator_tag) [with _ForwardIterator = const long unsigned int*; _Tp = long unsigned int; _Alloc = std::allocator]’ at /usr/include/c++/13.2.1/bits/vector.tcc:819:9, inlined from ‘constexpr std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(const_iterator, std::initializer_list<_Tp>) [with _Tp = long unsigned int; _Alloc = std::allocator]’ at /usr/include/c++/13.2.1/bits/stl_vector.h:1411:17, inlined from ‘void TMVA::MethodDL::ParseInputLayout()’ at /home/rembserj/spaces/master/root/src/root/tmva/tmva/src/MethodDL.cxx:470:24: /usr/include/c++/13.2.1/bits/stl_algobase.h:437:30: error: ‘void* __builtin_memmove(void*, const void*, long unsigned int)’ forming offset 32 is out of the bounds [0, 32] [-Werror=array-bounds=] 437 | __builtin_memmove(__result, __first, sizeof(_Tp) * _Num); | ``` The fix suggested in this commit is to directly assign from a full initializer list, which is also more readable in the code. --- tmva/tmva/src/MethodDL.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tmva/tmva/src/MethodDL.cxx b/tmva/tmva/src/MethodDL.cxx index 2a50e8edd8770..2d651257e408f 100644 --- a/tmva/tmva/src/MethodDL.cxx +++ b/tmva/tmva/src/MethodDL.cxx @@ -467,11 +467,11 @@ void MethodDL::ParseInputLayout() // when we will support 3D convolutions we would need to add extra 1's if (inputShape.size() == 2) { // case of dense layer where only width is specified - inputShape.insert(inputShape.begin() + 1, {1,1}); + inputShape = {inputShape[0], 1, 1, inputShape[1]}; } else if (inputShape.size() == 3) { //e.g. case of RNN T,W -> T,1,W - inputShape.insert(inputShape.begin() + 2, 1); + inputShape = {inputShape[0], inputShape[1], 1, inputShape[2]}; } this->SetInputShape(inputShape); From ae3f0b436df69f9f35f9223eb8d533f5792497a3 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Mon, 18 Dec 2023 11:56:55 +0100 Subject: [PATCH 2/2] [tmva] Add missing `override`s in TMVA This fixes the warnings in the nightlies: https://lcgapp-services.cern.ch/root-jenkins/view/ROOT%20Nightly/job/root-nightly-master/LABEL=ROOT-ubuntu2004-clang,SPEC=soversion,V=master/lastBuild/parsed_console/ --- tmva/sofie/inc/TMVA/ROperator_Comparision.hxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tmva/sofie/inc/TMVA/ROperator_Comparision.hxx b/tmva/sofie/inc/TMVA/ROperator_Comparision.hxx index de7cb5a3f4e15..6b997b4b7d4d8 100644 --- a/tmva/sofie/inc/TMVA/ROperator_Comparision.hxx +++ b/tmva/sofie/inc/TMVA/ROperator_Comparision.hxx @@ -68,12 +68,12 @@ public: fNX1(UTILITY::Clean_name(nameX1)), fNX2(UTILITY::Clean_name(nameX2)), fNY(UTILITY::Clean_name(nameY)){} // type of output given input - std::vector TypeInference(std::vector input){ + std::vector TypeInference(std::vector input) override { return input; } // shape of output tensors given input tensors - std::vector> ShapeInference(std::vector> input){ + std::vector> ShapeInference(std::vector> input) override { auto ret = input; // return vector size 1 with first input return ret; } @@ -132,7 +132,7 @@ public: model.AddIntermediateTensor(fNY, ETensorType::BOOL , fShapeY); } - std::string Generate(std::string OpName){ + std::string Generate(std::string OpName) override { OpName = "op_" + OpName; if (fShapeY.empty()) { @@ -176,4 +176,4 @@ public: }//TMVA -#endif //TMVA_SOFIE_ROperator_Comparision \ No newline at end of file +#endif //TMVA_SOFIE_ROperator_Comparision