1#ifndef TMVA_SOFIE_ROPERATOR_Tile
2#define TMVA_SOFIE_ROPERATOR_Tile
11namespace Experimental{
38 for(
size_t i=0; i <
input[1].size(); i++) {
47 throw std::runtime_error(
"TMVA SOFIE Tile Op Input Tensor is not found in model");
50 throw std::runtime_error(
"TMVA SOFIE Tile Op Input Tensor is not found in model");
57 throw std::runtime_error(
"TMVA SOFIE Tile Op: non-initialized repeats input is not supported");
65 throw std::runtime_error(
"Failed to retrieve the data for the repeats tensor.");
71 throw std::runtime_error(
"Repeats tensor is not 1D.");
91 throw std::runtime_error(
"TMVA SOFIE Tile Op called to Generate without being initialized first");
98 std::stringstream out;
101 out <<
"///-------- Tile operator\n";
106 out <<
"int s = 1;\n";
108 out <<
"for (int i = " <<
fShapeInput.size()-1 <<
"; i >=0; i--) {\n";
109 out <<
SP <<
"int r = tensor_" <<
fNRepeats <<
"[i];\n";
112 out <<
SP <<
"int i_offset = 0, o_offset = 0;\n";
113 out <<
SP <<
"s = s * input_shape[i];\n";
116 out <<
SP <<
SP <<
"for (int j = 0; j < inputLength/s ; j++) {\n";
117 out <<
SP <<
SP <<
SP <<
"for (int k = 0; k < r ; k++) {\n";
118 out <<
SP <<
SP <<
SP <<
SP <<
"std::copy(" <<
input <<
"+ i_offset, "
119 <<
input <<
"+ i_offset + s, " <<
output <<
"+ o_offset);\n";
120 out <<
SP <<
SP <<
SP <<
SP <<
"o_offset += s;\n";
121 out <<
SP <<
SP <<
SP <<
"}\n";
122 out <<
SP <<
SP <<
SP <<
"i_offset += s;\n";
123 out <<
SP <<
SP <<
"}\n";
124 out <<
SP <<
"} else {\n";
126 out <<
SP <<
SP <<
"for (int j = inputLength/s - 1 ; j>=0; j--) {\n";
127 out <<
SP <<
SP <<
SP <<
"o_offset = j*s*r;\n";
128 out <<
SP <<
SP <<
SP <<
"i_offset = j*s;\n";
129 out <<
SP <<
SP <<
SP <<
"for (int k = 0; k < r ; k++) {\n";
130 out <<
SP <<
SP <<
SP <<
SP <<
"std::copy(" <<
output <<
"+ i_offset, "
131 <<
output <<
"+ i_offset + s, " <<
output <<
"+ o_offset);\n";
132 out <<
SP <<
SP <<
SP <<
SP <<
"o_offset += s;\n";
133 out <<
SP <<
SP <<
SP <<
"}\n";
134 out <<
SP <<
SP <<
"}\n";
136 out <<
SP <<
"s *= r;\n";
137 out <<
SP <<
"inputLength *= r;\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 input
const_iterator begin() const
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)
bool IsInitializedTensor(const std::string &name) const
const std::vector< size_t > & GetTensorShape(std::string name)
std::shared_ptr< void > GetInitializedTensorData(std::string tensor_name)
std::vector< std::vector< size_t > > ShapeInference(std::vector< std::vector< size_t > > input)
ROperator_Tile(std::string nameRepeat, std::string nameInput, std::string nameY)
std::vector< ETensorType > TypeInference(std::vector< ETensorType > input)
std::vector< size_t > fShapeY
std::vector< size_t > fShapeInput
std::string Generate(std::string OpName)
void Initialize(RModel &model)
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