1#ifndef TMVA_SOFIE_ROPERATOR_Swish
2#define TMVA_SOFIE_ROPERATOR_Swish
11namespace Experimental{
22 std::vector<std::string>
fNYs;
28 ROperator_Split(
const std::string & nameX,
const std::string & nameS,
const std::vector<std::string> & namesY):
29 fNX(UTILITY::Clean_name(nameX)),
fNS(UTILITY::Clean_name(nameS)){
30 fNYs.reserve(namesY.size());
31 for (
auto &
name : namesY)
46 throw std::runtime_error(
"TMVA SOFIE Split Op Input Tensor is not found in model");
52 int nsplit =
fNYs.size();
54 if (inputShape.size() > 1)
55 throw std::runtime_error(
"TMVA SOFIE Split Op supports now only 1D tensors");
57 if (inputShape[0] % nsplit != 0)
58 throw std::runtime_error(
"TMVA SOFIE Split Op does not support splitting of " +
ConvertShapeToString(inputShape)
59 +
" into " + std::to_string(nsplit));
61 for (
size_t i = 0; i <
fNYs.size(); i++) {
62 std::vector<size_t> outputShape = { inputShape[0]/nsplit };
70 std::cout << std::endl;
76 OpName =
"op_" + OpName;
78 throw std::runtime_error(
"TMVA SOFIE Operator Split called to Generate without being initialized first");
80 std::stringstream out;
81 out <<
"\n//------ Split\n";
82 out <<
"size_t offset = 0;\n";
83 for (
size_t i = 0; i <
fNYs.size(); i++) {
85 out <<
SP <<
"for (int id = 0; id < " <<
length <<
" ; id++){\n";
86 out <<
SP <<
SP <<
"tensor_" <<
fNYs[i] <<
"[id] = tensor_" <<
fNX <<
"[offset+id];\n";
88 if (i <
fNYs.size()-1) out <<
SP <<
"offset += " <<
length <<
";\n";
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< Dim > dim_shape)
bool CheckIfTensorAlreadyExist(std::string tensor_name)
const std::vector< size_t > & GetTensorShape(std::string name)
std::vector< std::vector< size_t > > fOutputShapes
std::vector< std::vector< size_t > > ShapeInference(std::vector< std::vector< size_t > > input)
std::vector< ETensorType > TypeInference(std::vector< ETensorType > input)
void Initialize(RModel &model)
ROperator_Split(const std::string &nameX, const std::string &nameS, const std::vector< std::string > &namesY)
std::vector< std::string > fNYs
std::string Generate(std::string OpName)
const std::string SP
space used to correctly indent the generated C++ code
std::string Clean_name(std::string input_tensor_name)
std::string ConvertShapeToString(std::vector< size_t > shape)
std::size_t ConvertShapeToLength(std::vector< size_t > shape)
create variable transformations