1#ifndef TMVA_SOFIE_ROPERATOR_Tile
2#define TMVA_SOFIE_ROPERATOR_Tile
11namespace Experimental{
41 for(
size_t i=0; i <
repeat.size(); i++) {
45 ret[i] =
Dim{ std::string(
"(" +
ret[i].GetVal() +
")*" + std::to_string(
repeat[i])),
static_cast<size_t>(-1) };
57 throw std::runtime_error(
"TMVA SOFIE Tile Op Input Tensor is not found in model");
60 throw std::runtime_error(
"TMVA SOFIE Tile Op Input Tensor is not found in model");
67 throw std::runtime_error(
"TMVA SOFIE Tile Op: non-initialized repeats input is not supported");
75 throw std::runtime_error(
"Failed to retrieve the data for the repeats tensor.");
81 throw std::runtime_error(
"Repeats tensor is not 1D.");
105 throw std::runtime_error(
"TMVA SOFIE Tile Op called to Generate without being initialized first");
108 std::stringstream out;
109 out <<
"///-------- Tile operator " <<
OpName <<
"\n";
121 out <<
SP <<
"size_t input_strides[" <<
rank <<
"];\n";
122 out <<
SP <<
"input_strides[" <<
rank - 1 <<
"] = 1;\n";
123 out <<
SP <<
"for (int i = " <<
rank - 2 <<
"; i >= 0; --i) {\n";
124 out <<
SP <<
SP <<
"input_strides[i] = input_strides[i+1] * input_shape[i+1];\n";
125 out <<
SP <<
"}\n\n";
130 out <<
SP <<
"size_t out_idx = 0;\n";
132 for (
int i = 0; i <
rank; ++i) {
133 out <<
indent <<
"for (size_t o" << i <<
" = 0, ic" << i <<
" = 0; o" << i
134 <<
" < output_shape[" << i <<
"]; ++o" << i <<
") {\n";
136 out <<
indent <<
"const size_t in_off" << i <<
" = "
137 << (i == 0 ? std::string() :
"in_off" + std::to_string(i - 1) +
" + ")
138 <<
"ic" << i <<
" * input_strides[" << i <<
"];\n";
140 out <<
indent <<
"tensor_" <<
fNY <<
"[out_idx++] = tensor_" <<
fNInput <<
"[in_off" <<
rank - 1 <<
"];\n";
141 for (
int i =
rank - 1; i >= 0; --i) {
142 out <<
indent <<
"if (++ic" << i <<
" == input_shape[" << i <<
"]) ic" << i <<
" = 0;\n";
static void indent(ostringstream &buf, int indent_level)
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)
void SetNotWritableInitializedTensor(const 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 ConvertShapeToString(const std::vector< size_t > &shape)
create variable transformations