1#ifndef TMVA_SOFIE_ROPERATOR_Split
2#define TMVA_SOFIE_ROPERATOR_Split
11namespace Experimental{
23 std::vector<std::string>
fNYs;
41 [](
const std::string& s) -> std::string_view { return s; });
55 throw std::runtime_error(
"TMVA SOFIE Split Op Input Tensor is not found in model");
62 throw std::runtime_error(
"TMVA SOFIE Split - invalid axis " + std::to_string(
fAxis));
81 throw std::runtime_error(
"TMVA SOFIE Split - non-initialized split tensors are not supported");
84 throw std::runtime_error(
"TMVA SOFIE Split - split input tensor has invalid shape");
90 for (
size_t i = 0; i <
fNYs.size(); i++) {
98 throw std::runtime_error(
"TMVA SOFIE Split - Sum of split sizes must match the input dimension along the axis");
105 std::cout << std::endl;
113 throw std::runtime_error(
"TMVA SOFIE Operator Split called to Generate without being initialized first");
119 std::stringstream out;
120 out <<
"\n" <<
SP <<
"//------ Split\n";
121 out <<
SP <<
"size_t " <<
OpName <<
"_axis_offset = 0;\n";
123 for (
size_t i = 0; i <
fNYs.size(); i++) {
127 out <<
SP <<
"for (int id = 0; id < " <<
length <<
" ; id++){\n";
129 out <<
SP <<
SP <<
"int input_index = 0;\n";
130 out <<
SP <<
SP <<
"int remaining = id;\n";
133 out <<
SP <<
SP <<
"// dim " << k <<
"\n";
137 if (k ==
static_cast<size_t>(
fAxis) && i > 0)
138 out <<
" + " <<
OpName <<
"_axis_offset";
143 out <<
SP <<
SP <<
"input_index += remaining";
144 if (k ==
static_cast<size_t>(
fAxis) && i > 0)
145 out <<
" + " <<
OpName <<
"_axis_offset";
150 out <<
SP <<
SP <<
"tensor_" <<
fNYs[i] <<
"[id] = tensor_" <<
fNX <<
"[input_index];\n";
152 if (i <
fNYs.size()-1) out <<
SP <<
OpName <<
"_axis_offset += " <<
fSplit[i] <<
";\n";
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
void AddIntermediateTensor(std::string tensor_name, ETensorType type, std::vector< Dim > dim_shape)
bool CheckIfTensorAlreadyExist(std::string tensor_name)
const ETensorType & GetTensorType(std::string name) const
bool IsInitializedTensor(const std::string &name) const
const std::vector< size_t > & GetTensorShape(std::string name) const
std::shared_ptr< void > GetInitializedTensorData(std::string tensor_name)
std::string Generate(std::string OpName) override
ROperator_Split(const std::string &nameX, const std::string &nameS, int axis, const std::vector< std::string > &namesY)
void Initialize(RModel &model) override
std::vector< size_t > fInputShape
std::vector< std::vector< size_t > > fOutputShapes
std::vector< std::string > fNYs
std::vector< ETensorType > TypeInference(std::vector< ETensorType > input) override
std::vector< std::vector< size_t > > ShapeInference(std::vector< std::vector< size_t > > input) override
std::vector< int64_t > fSplit
std::vector< std::string_view > fInputTensorNames
const std::string SP
space used to correctly indent the generated C++ code
std::vector< std::string_view > fOutputTensorNames
std::string Clean_name(std::string input_tensor_name)
std::vector< size_t > ComputeStrideFromShape(const std::vector< size_t > &shape)
compute stride of a tensor given its shape (assume layout is row-major)
std::string ConvertShapeToString(std::vector< size_t > shape)
std::size_t ConvertShapeToLength(std::vector< size_t > shape)
create variable transformations