forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathROperator.hxx
67 lines (46 loc) · 1.96 KB
/
ROperator.hxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef TMVA_SOFIE_ROPERATOR
#define TMVA_SOFIE_ROPERATOR
#include <vector>
#include <memory>
#include "TMVA/SOFIE_common.hxx"
//#include "RModel.hxx"
namespace TMVA{
namespace Experimental{
namespace SOFIE{
class RModel;
class ROperator{
public:
virtual std::vector<std::string> GetBlasRoutines() { return {}; }
virtual std::vector<std::string> GetStdLibs() { return {}; }
virtual std::vector<std::vector<size_t>> ShapeInference(std::vector<std::vector<size_t>>) { return {}; };
virtual std::vector<ETensorType> TypeInference(std::vector<ETensorType>) { return {}; };
virtual void Initialize(RModel&) = 0;
virtual std::string Generate(std::string OpName) = 0; //expect unique opName for each operator within the same RModel
// generate initialization code for session constructor
virtual std::string GenerateInitCode() { return "";}
// generate some specific declaration code for Session
virtual std::string GenerateDeclCode() { return "";}
// generate session data members specific to operator
virtual std::string GenerateSessionMembersCode(std::string /*opName*/) { return ""; }
virtual std::string Header() { return "";}
//virtual void Forward_reference() = 0;
//virtual void Forward_blas() = 0;
virtual ~ROperator(){}
protected:
const std::string SP = " "; ///< space used to correctly indent the generated C++ code
bool fUseSession = false; ///< flag to identify if using the session class
bool fIsOutputConstant = false; ///< flag to identify if operator has a constant output (no need to generate code)
mutable std::vector<std::string_view> fInputTensorNames;
mutable std::vector<std::string_view> fOutputTensorNames;
public:
std::span<const std::string_view> GetOpInputTensors() const {
return fInputTensorNames;
}
std::span<const std::string_view> GetOpOutputTensors() const {
return fOutputTensorNames;
}
};
}//SOFIE
}//Experimental
}//TMVA
#endif //TMVA_SOFIE_OPERATOR