1#ifndef TMVA_SOFIE_ROPERATOR_RANGE
2#define TMVA_SOFIE_ROPERATOR_RANGE
12namespace Experimental{
33 if (std::is_same<T, float>::value) {
35 }
else if (std::is_same<T, int64_t>::value) {
38 static_assert( (std::is_same_v<T, float> || std::is_same_v<T, int64_t>),
39 "TMVA::SOFIE - Unsupported type by Range operator");
50 std::runtime_error(
"TMVA SOFIE Range Op Input Tensor " +
fNStart +
"is not found in model");
54 std::runtime_error(
"TMVA SOFIE Range Op Input Tensor " +
fNLimit +
"is not found in model");
58 std::runtime_error(
"TMVA SOFIE Range Op Input Tensor " +
fNDelta +
"is not found in model");
69 std::runtime_error(
"TMVA SOFIE Range Op Input Tensor has invalid input data");
76 value =
static_cast<T
>(dim.dim);
118 s <<
"std::max(std::ceil("<< limit <<
" - " << start <<
"),0.0f)";
120 s <<
"std::max(std::ceil(("<< limit <<
" - " << start <<
")/" << delta <<
"),0.0f)";
126 s <<
"std::max((" << limit <<
" - " << start <<
"),0L)";
129 s <<
"((" << limit <<
")/" << delta <<
")";
131 s <<
"std::max((" << limit <<
" - " << start <<
")/"<< delta <<
"),0L)";
139 fShape = {
Dim {s.str(),
static_cast<size_t>(-1)} };
147 std::cout << std::endl;
153 std::stringstream out;
159 throw std::runtime_error(
"TMVA SOFIE Range operator called to Generate without being initialized first");
163 std::string outputSize =
fShape[0].param;
164 if (outputSize.find(
"range_size") != std::string::npos) {
166 outputSize =
"static_cast<size_t>(std::max(std::ceil((static_cast<float>(*tensor_" +
fNLimit +
167 ") - static_cast<float>(*tensor_" +
fNStart +
")) / static_cast<float>(*tensor_" +
fNDelta +
")), 0.0f))";
171 out <<
SP <<
"size_t " <<
outputSizeVar <<
" = " << outputSize <<
";\n";
172 out <<
SP <<
"for (size_t i = 0; i < " <<
outputSizeVar <<
"; i++) {\n";
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 data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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 Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
bool CheckIfTensorAlreadyExist(std::string tensor_name)
void AddConstantTensor(std::string tensor_name, ETensorType type, std::vector< std::size_t > shape, std::shared_ptr< void > data)
void AddDynamicTensor(std::string tensor_name, ETensorType type, std::vector< Dim > shape)
bool IsShapeTensor(const std::string &name) const
check if a tensor is a shape tensor
bool IsInitializedTensor(const std::string &name) const
std::shared_ptr< void > GetInitializedTensorData(std::string tensor_name)
std::vector< T > GetTensorData(const std::string &name)
const std::vector< Dim > & GetShapeTensorValues(const std::string &tensor_name) const
ROperator_Range(std::string start, std::string limit, std::string delta, std::string nameOutput)
std::vector< Dim > fShape
std::string Generate(std::string opName) override
void Initialize(RModel &model) override
std::vector< std::string_view > fInputTensorNames
bool fIsOutputConstant
flag to identify if operator has a constant output (no need to generate code)
const std::string SP
space used to correctly indent the generated C++ code
std::vector< std::string_view > fOutputTensorNames
std::string ConvertDimShapeToString(const std::vector< Dim > &shape)
std::vector< Dim > ConvertShapeToDim(const std::vector< size_t > &shape)
Convert shape from integer format to dynamic one (based on Dim)
std::string ConvertValuesToString(size_t n, const T *data)
std::string ConvertTypeToString(ETensorType type)
ETensorType ConvertStringToType(std::string type)
std::string ConvertShapeToString(const std::vector< size_t > &shape)
create variable transformations