1#ifndef TMVA_SOFIE_ROperator_BasicBinary
2#define TMVA_SOFIE_ROperator_BasicBinary
11namespace Experimental{
16template <
typename T, EBasicBinaryOperator Op1>
18 const char *
Name() {
return ""; }
19 const char *
Op() {
return ""; }
23 static const char *
Name() {
return "Add"; }
24 static const char *
Op() {
return "+"; }
29 static const char *
Name() {
return "Sub"; }
30 static const char *
Op() {
return "-"; }
35 static const char *
Name() {
return "Mul"; }
36 static const char *
Op() {
return "*"; }
41 static const char *
Name() {
return "Div"; }
42 static const char *
Op() {
return "/"; }
45template<
typename T, EBasicBinaryOperator Op>
68 auto ret = std::vector<std::vector<size_t>>(1,
input[0]);
75 throw std::runtime_error(std::string(
"TMVA SOFIE Binary Op Input Tensor ") +
fNX1 +
"is not found in model");
78 throw std::runtime_error(std::string(
"TMVA SOFIE Binary Op Input Tensor ") +
fNX2 +
"is not found in model");
84 if (shapeX1 != shapeX2) {
89 if(length1 != length2 || length1 != output_length){
90 throw std::runtime_error(std::string(
"TMVA SOFIE Binary Op does not support input tensors with different lengths. The output tensor should also have the same length as the input tensors."));
94 else if(shapeX1 == shapeX2){
102 OpName =
"op_" + OpName;
105 throw std::runtime_error(
"TMVA SOFIE Binary Op called to Generate without being initialized first");
107 std::stringstream out;
110 out <<
SP <<
"for (size_t id = 0; id < " <<
length <<
" ; id++){\n";
111 out <<
SP <<
SP <<
"tensor_" <<
fNY <<
"[id] = tensor_" <<
fNX1 <<
"[id]" +
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
const ETensorType & GetTensorType(std::string name)
void AddIntermediateTensor(std::string tensor_name, ETensorType type, std::vector< std::size_t > shape)
bool CheckIfTensorAlreadyExist(std::string tensor_name)
const std::vector< size_t > & GetTensorShape(std::string name)
std::string Generate(std::string OpName)
std::vector< ETensorType > TypeInference(std::vector< ETensorType > input)
std::vector< size_t > fShape
ROperator_BasicBinary(std::string nameX1, std::string nameX2, std::string nameY)
void Initialize(RModel &model)
std::vector< std::vector< size_t > > ShapeInference(std::vector< std::vector< size_t > > input)
const std::string SP
space used to correctly indent the generated C++ code
std::string Clean_name(std::string input_tensor_name)
std::vector< size_t > Multidirectional_broadcast(std::vector< size_t > input1_shape, std::vector< size_t > input2_shape)
std::size_t ConvertShapeToLength(std::vector< size_t > shape)
create variable transformations
static const char * Name()
static const char * Name()
static const char * Name()
static const char * Name()