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 std::vector<std::vector<size_t>> ShapeInference(std::vector<std::vector<size_t>>) { return {}; };
22 virtual std::vector<ETensorType> TypeInference(std::vector<ETensorType>) { return {}; };
23 virtual void Initialize(RModel&) = 0;
24 virtual std::string Generate(std::string OpName) = 0; //expect unique opName for each operator within the same RModel
25 // generate initialization code for session constructor
26 virtual std::string GenerateInitCode() { return "";}
27 // generate some specific declaration code for Session
28 virtual std::string GenerateDeclCode() { return "";}
29 // generate session data members specific to operator
30 virtual std::string GenerateSessionMembersCode(std::string /*opName*/) { return ""; }
31 virtual std::string Header() { return "";}
32
33 /// check if the output of the operator is Constant and is evaluated at initialization time
34 bool IsOutputConstant() const { return fIsOutputConstant; }
35
36 //virtual void Forward_reference() = 0;
37 //virtual void Forward_blas() = 0;
38 virtual ~ROperator(){}
39
40protected:
41
42 const std::string SP = " "; ///< space used to correctly indent the generated C++ code
43 bool fUseSession = false; ///< flag to identify if using the session class
44 bool fIsOutputConstant = false; ///< flag to identify if operator has a constant output (no need to generate code)
45 bool fIsOutputParamShape = false; ///< flag to identify of the output represents a parametric shape (can be known at compile time)
46
47 mutable std::vector<std::string_view> fInputTensorNames;
48 mutable std::vector<std::string_view> fOutputTensorNames;
49
50public:
51 std::span<const std::string_view> GetOpInputTensors() const {
52 return fInputTensorNames;
53 }
54
55 std::span<const std::string_view> GetOpOutputTensors() const {
56 return fOutputTensorNames;
57 }
58
59};
60
61} // namespace TMVA::Experimental::SOFIE
62
63#endif //TMVA_SOFIE_OPERATOR
std::vector< std::string_view > fInputTensorNames
Definition ROperator.hxx:47
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:45
bool fIsOutputConstant
flag to identify if operator has a constant output (no need to generate code)
Definition ROperator.hxx:44
virtual std::vector< std::vector< size_t > > ShapeInference(std::vector< std::vector< size_t > >)
Definition ROperator.hxx:21
virtual std::string GenerateInitCode()
Definition ROperator.hxx:26
const std::string SP
space used to correctly indent the generated C++ code
Definition ROperator.hxx:42
virtual std::vector< ETensorType > TypeInference(std::vector< ETensorType >)
Definition ROperator.hxx:22
virtual std::string GenerateSessionMembersCode(std::string)
Definition ROperator.hxx:30
std::span< const std::string_view > GetOpInputTensors() const
Definition ROperator.hxx:51
bool fUseSession
flag to identify if using the session class
Definition ROperator.hxx:43
virtual std::string Generate(std::string OpName)=0
std::span< const std::string_view > GetOpOutputTensors() const
Definition ROperator.hxx:55
virtual std::string GenerateDeclCode()
Definition ROperator.hxx:28
bool IsOutputConstant() const
check if the output of the operator is Constant and is evaluated at initialization time
Definition ROperator.hxx:34
virtual std::vector< std::string > GetStdLibs()
Definition ROperator.hxx:20
std::vector< std::string_view > fOutputTensorNames
Definition ROperator.hxx:48