1#ifndef TMVA_SOFIE_ROPERATOR_ADD
2#define TMVA_SOFIE_ROPERATOR_ADD
11namespace Experimental{
27 ROperator_Add(std::string nameX1, std::string nameX2, std::string nameY):
28 fNX1(UTILITY::Clean_name(nameX1)),
fNX2(UTILITY::Clean_name(nameX2)),
fNY(UTILITY::Clean_name(nameY)){}
36 std::vector<std::vector<size_t>>
ShapeInference(std::vector<std::vector<size_t>> input){
38 auto ret = std::vector<std::vector<size_t>>(1, input[0]);
45 throw std::runtime_error(std::string(
"TMVA SOFIE Add Op Input Tensor ") +
fNX1 +
"is not found in model");
48 throw std::runtime_error(std::string(
"TMVA SOFIE Add Op Input Tensor ") +
fNX1 +
"is not found in model");
53 if (shapeX1 != shapeX2) {
54 std::string msg =
"TMVA SOFIE Add Op: Support only inputs with same shape, shape 1 is " +
56 throw std::runtime_error(msg);
64 OpName =
"op_" + OpName;
66 throw std::runtime_error(
"TMVA SOFIE Add called to Generate without being initialized first");
68 std::stringstream out;
74 out <<
"\n//------ Add\n";
75 out <<
SP <<
"for (size_t id = 0; id < " << length <<
" ; id++){\n";
76 out <<
SP <<
SP <<
"tensor_" <<
fNY <<
"[id] = tensor_" <<
fNX1 <<
"[id] + tensor_" <<
fNX2 <<
"[id];\n";
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)
ROperator_Add(std::string nameX1, std::string nameX2, std::string nameY)
std::string Generate(std::string OpName)
std::vector< std::vector< size_t > > ShapeInference(std::vector< std::vector< size_t > > input)
void Initialize(RModel &model)
std::vector< size_t > fShape
std::vector< ETensorType > TypeInference(std::vector< ETensorType > input)
const std::string SP
space used to correctly indent the generated C++ code
std::string ConvertShapeToString(std::vector< size_t > shape)
std::size_t ConvertShapeToLength(std::vector< size_t > shape)
create variable transformations