1#ifndef TMVA_SOFIE_ROPERATOR_Tile
2#define TMVA_SOFIE_ROPERATOR_Tile
11namespace Experimental{
40 for(
size_t i=0; i <
repeat.size(); i++) {
43 ret[i] =
Dim{ std::string(
ret[i].GetVal() +
"*" + std::to_string(
repeat[i])),
static_cast<size_t>(-1) };
55 throw std::runtime_error(
"TMVA SOFIE Tile Op Input Tensor is not found in model");
58 throw std::runtime_error(
"TMVA SOFIE Tile Op Input Tensor is not found in model");
65 throw std::runtime_error(
"TMVA SOFIE Tile Op: non-initialized repeats input is not supported");
73 throw std::runtime_error(
"Failed to retrieve the data for the repeats tensor.");
79 throw std::runtime_error(
"Repeats tensor is not 1D.");
99 throw std::runtime_error(
"TMVA SOFIE Tile Op called to Generate without being initialized first");
106 std::stringstream out;
109 out <<
"///-------- Tile operator\n";
114 out <<
"int s = 1;\n";
116 out <<
"for (int i = " <<
fShapeInput.size()-1 <<
"; i >=0; i--) {\n";
117 out <<
SP <<
"int r = tensor_" <<
fNRepeats <<
"[i];\n";
120 out <<
SP <<
"int i_offset = 0, o_offset = 0;\n";
121 out <<
SP <<
"s = s * input_shape[i];\n";
124 out <<
SP <<
SP <<
"for (int j = 0; j < inputLength/s ; j++) {\n";
125 out <<
SP <<
SP <<
SP <<
"for (int k = 0; k < r ; k++) {\n";
126 out <<
SP <<
SP <<
SP <<
SP <<
"std::copy(" <<
input <<
"+ i_offset, "
127 <<
input <<
"+ i_offset + s, " <<
output <<
"+ o_offset);\n";
128 out <<
SP <<
SP <<
SP <<
SP <<
"o_offset += s;\n";
129 out <<
SP <<
SP <<
SP <<
"}\n";
130 out <<
SP <<
SP <<
SP <<
"i_offset += s;\n";
131 out <<
SP <<
SP <<
"}\n";
132 out <<
SP <<
"} else {\n";
134 out <<
SP <<
SP <<
"for (int j = inputLength/s - 1 ; j>=0; j--) {\n";
135 out <<
SP <<
SP <<
SP <<
"o_offset = j*s*r;\n";
136 out <<
SP <<
SP <<
SP <<
"i_offset = j*s;\n";
137 out <<
SP <<
SP <<
SP <<
"for (int k = 0; k < r ; k++) {\n";
138 out <<
SP <<
SP <<
SP <<
SP <<
"std::copy(" <<
output <<
"+ i_offset, "
139 <<
output <<
"+ i_offset + s, " <<
output <<
"+ o_offset);\n";
140 out <<
SP <<
SP <<
SP <<
SP <<
"o_offset += s;\n";
141 out <<
SP <<
SP <<
SP <<
"}\n";
142 out <<
SP <<
SP <<
"}\n";
144 out <<
SP <<
"s *= r;\n";
145 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
std::vector< size_t > GetTensorShape(const std::string &name) const
std::vector< Dim > GetDimTensorShape(const std::string &name) const
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
std::shared_ptr< void > GetInitializedTensorData(std::string tensor_name)
ETensorType GetTensorType(std::string name) const
std::vector< Dim > fShapeY
ROperator_Tile(std::string nameRepeat, std::string nameInput, std::string nameY)
std::vector< Dim > fShapeInput
std::vector< ETensorType > TypeInference(std::vector< ETensorType > input) override
std::vector< Dim > DoShapeInference(const std::vector< Dim > &input, const std::vector< size_t > repeat)
std::string Generate(std::string OpName) override
void Initialize(RModel &model) override
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 ConvertDimShapeToString(const std::vector< Dim > &shape)
std::string ConvertDimShapeToLength(const std::vector< Dim > &shape)
std::string ConvertShapeToString(const std::vector< size_t > &shape)
create variable transformations