1#ifndef TMVA_SOFIE_ROperator_ScatterElements 
    2#define TMVA_SOFIE_ROperator_ScatterElements 
   11namespace Experimental{
 
   36      else if (
name == 
"add")
 
   37         return t1 + 
" + " + 
t2;
 
   38      else if (
name == 
"mul")
 
   39         return t1 + 
" * " + 
t2;
 
   40      else if (
name == 
"max")
 
   41         return "std::max(" + 
t1 + 
"," + 
t2 + 
")";
 
   42      else if (
name == 
"min")
 
   43         return "std::min(" + 
t1 + 
"," + 
t2 + 
")";
 
   45         throw std::runtime_error(
"TMVA SOFIE ScatterElements : invalid reduction attribute");
 
 
   70      auto ret = std::vector<std::vector<size_t>>(1, 
input[0]); 
 
 
   77         throw std::runtime_error(std::string(
"TMVA SOFIE ScatterElements Op Input Tensor ") + 
fNX + 
"is not found in model");
 
   80         throw std::runtime_error(std::string(
"TMVA SOFIE ScatterElements Op Input Tensor ") + 
fNI + 
"is not found in model");
 
   83         throw std::runtime_error(std::string(
"TMVA SOFIE ScatterElements Op Input Tensor ") + 
fNU + 
"is not found in model");
 
   90         throw std::runtime_error(std::string(
"TMVA SOFIE ScatterElements - update tensor has invalid shape ")) ;
 
   92         throw std::runtime_error(std::string(
"TMVA SOFIE ScatterElements - input tensor has zero rank  ")) ;
 
   94         throw std::runtime_error(std::string(
"TMVA SOFIE ScatterElements - index tensor has invalid rank  ")) ;
 
 
  104      std::stringstream out;
 
 
  113         throw std::runtime_error(
"TMVA SOFIE ScatterElements Op called to Generate without being initialized first");
 
  115      std::stringstream out;
 
  116      out << 
SP << 
"\n//-------- ScatterElements  --- " << 
opName << 
"\n";
 
  124      auto tensorIndex = [](
const std::vector<size_t> & 
stride, 
const std::vector<std::string> & idx) {
 
  125         std::stringstream 
strst;
 
  126         int dims = idx.size();
 
  128         for (
int i = 0; i < 
dims; i++) {
 
  141      out << 
SP << 
"std::copy(tensor_" << 
fNX << 
", tensor_" << 
fNX << 
" + " << 
length << 
", tensor_" << 
fNY << 
");\n";
 
  145      std::vector<std::string> idx(
dims);
 
  146      for (
int i = 0; i < 
dims; i++) {
 
  147         idx[i] = std::string(
"i") + std::to_string(i);
 
  148         for (
int j = 0; 
j <= i; 
j++) out << 
SP;
 
  149         out << 
"for (int " << idx[i] << 
" = 0; " << idx[i] << 
" < " << 
fShapeI[i] << 
"; " << idx[i] << 
"++) {\n";
 
  152      for (
int j = 0; 
j <= 
dims; 
j++) out << 
SP;
 
  154      for (
int j = 0; 
j <= 
dims; 
j++) out << 
SP;
 
  155      out << 
"int iAxis = tensor_" << 
fNI << 
"[updateIndex];\n";
 
  156      for (
int j = 0; 
j <= 
dims; 
j++) out << 
SP;
 
  157      out << 
"if (iAxis < 0) iAxis += " << 
fShapeY[
fAxis] << 
";\n";
 
  158      idx[
fAxis] = 
"iAxis";
 
  159      for (
int j = 0; 
j <= 
dims; 
j++) out << 
SP;
 
  161      for (
int j = 0; 
j <= 
dims; 
j++) out << 
SP;
 
  162      out << 
"tensor_" << 
fNY << 
"[outIndex] = " 
  163         << 
ReductionFunction(std::string(
"tensor_") + 
fNY + 
"[outIndex]", std::string(
"tensor_") + 
fNU + 
"[updateIndex]") << 
";\n";
 
  165      for (
int i = 
dims; i > 0; i--) {
 
  166         for (
int j = 0; 
j < i; 
j++) out << 
SP;
 
 
 
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
 
const std::vector< size_t > & GetTensorShape(std::string name) const
 
std::vector< ETensorType > TypeInference(std::vector< ETensorType > input) override
 
std::string ReductionFunction(const std::string &t1, const std::string &t2)
 
std::vector< size_t > fShapeY
 
std::vector< std::vector< size_t > > ShapeInference(std::vector< std::vector< size_t > > input) override
 
std::vector< size_t > fShapeI
 
std::string GenerateInitCode() override
 
ROperator_ScatterElements(const std::string &nameX, const std::string &nameI, const std::string &nameU, const std::string &nameY, int axis, std::string reduction)
 
void Initialize(RModel &model) override
 
std::vector< size_t > fShapeX
 
std::string Generate(std::string opName) override
 
ROperator_ScatterElements()
 
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::vector< size_t > ComputeStrideFromShape(const std::vector< size_t > &shape)
compute stride of a tensor given its shape (assume layout is row-major)
 
std::size_t ConvertShapeToLength(std::vector< size_t > shape)
 
create variable transformations