Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROperator.hxx
Go to the documentation of this file.
1#ifndef TMVA_SOFIE_ROPERATOR
2#define TMVA_SOFIE_ROPERATOR
3
5
6#include <ROOT/RSpan.hxx>
7
8#include <memory>
9#include <string>
10#include <vector>
11
13
14class RModel;
15
16class ROperator {
17
18public:
19 virtual std::vector<std::string> GetBlasRoutines() { return {}; }
20 virtual std::vector<std::string> GetStdLibs() { return {}; }
21 virtual void Initialize(RModel&) = 0;
22 virtual std::string Generate(std::string OpName) = 0; //expect unique opName for each operator within the same RModel
23 // generate initialization code for session constructor
24 virtual std::string GenerateInitCode() { return "";}
25 // generate some specific declaration code for Session
26 virtual std::string GenerateDeclCode() { return "";}
27 // generate session data members specific to operator
28 virtual std::string GenerateSessionMembersCode(std::string /*opName*/) { return ""; }
29 virtual std::string Header() { return "";}
30
31 /// check if the output of the operator is Constant and is evaluated at initialization time
32 bool IsOutputConstant() const { return fIsOutputConstant; }
33
34 //virtual void Forward_reference() = 0;
35 //virtual void Forward_blas() = 0;
36 virtual ~ROperator(){}
37
38protected:
39
40 const std::string SP = " "; ///< space used to correctly indent the generated C++ code
41 bool fIsOutputConstant = false; ///< flag to identify if operator has a constant output (no need to generate code)
42 bool fIsOutputParamShape = false; ///< flag to identify of the output represents a parametric shape (can be known at compile time)
43
44 mutable std::vector<std::string_view> fInputTensorNames;
45 mutable std::vector<std::string_view> fOutputTensorNames;
46
47public:
48 std::span<const std::string_view> GetOpInputTensors() const {
49 return fInputTensorNames;
50 }
51
52 std::span<const std::string_view> GetOpOutputTensors() const {
53 return fOutputTensorNames;
54 }
55
56};
57
58} // namespace TMVA::Experimental::SOFIE
59
60#endif //TMVA_SOFIE_OPERATOR
std::vector< std::string_view > fInputTensorNames
Definition ROperator.hxx:44
virtual std::vector< std::string > GetBlasRoutines()
Definition ROperator.hxx:19
virtual void Initialize(RModel &)=0
bool fIsOutputParamShape
flag to identify of the output represents a parametric shape (can be known at compile time)
Definition ROperator.hxx:42
bool fIsOutputConstant
flag to identify if operator has a constant output (no need to generate code)
Definition ROperator.hxx:41
virtual std::string GenerateInitCode()
Definition ROperator.hxx:24
const std::string SP
space used to correctly indent the generated C++ code
Definition ROperator.hxx:40
virtual std::string GenerateSessionMembersCode(std::string)
Definition ROperator.hxx:28
std::span< const std::string_view > GetOpInputTensors() const
Definition ROperator.hxx:48
virtual std::string Generate(std::string OpName)=0
std::span< const std::string_view > GetOpOutputTensors() const
Definition ROperator.hxx:52
virtual std::string GenerateDeclCode()
Definition ROperator.hxx:26
bool IsOutputConstant() const
check if the output of the operator is Constant and is evaluated at initialization time
Definition ROperator.hxx:32
virtual std::vector< std::string > GetStdLibs()
Definition ROperator.hxx:20
std::vector< std::string_view > fOutputTensorNames
Definition ROperator.hxx:45