1#ifndef TMVA_SOFIE_ROPERATOR_GATHER
2#define TMVA_SOFIE_ROPERATOR_GATHER
13namespace Experimental{
52 throw std::runtime_error(
"TMVA SOFIE Gather Op Input Tensor " +
fNX +
" is not found in model");
57 std::runtime_error(
"TMVA::SOFIE - Tensor " +
fNIndices +
" is not initialized.");
85 for (
size_t i = 0; i <
q; i++) {
98 std::stringstream out;
108 out <<
SP <<
"std::vector<int64_t> " <<
OpName <<
"_indices = {";
118 std::string
index =
"j_" + std::to_string(
j);
122 for (
size_t i = 0; i <
q; i++) {
123 std::string
index =
"i_" + std::to_string(i);
128 std::string
index =
"j_" + std::to_string(
j);
132 out <<
SP <<
SP <<
SP <<
"size_t y_index = 0;\n";
134 out <<
SP <<
SP <<
SP <<
"y_index += j_" + std::to_string(
j) +
" * " <<
stridesY[
j] <<
";\n";
136 for (
size_t i = 0; i <
q; i++) {
140 out <<
SP <<
SP <<
SP <<
"y_index += j_" + std::to_string(
j) +
" * " <<
stridesY[
q +
j] <<
";\n";
143 out <<
SP <<
SP <<
SP <<
"size_t i_index = 0;\n";
144 for (
size_t i = 0; i <
q; i++) {
145 out <<
SP <<
SP <<
SP <<
"i_index += i_" + std::to_string(i) +
" * " <<
stridesIndices[i] <<
";\n";
148 out <<
SP <<
SP <<
SP <<
"size_t k = static_cast<size_t>(" <<
OpName <<
"_indices[i_index]" <<
");\n";
152 out <<
SP <<
SP <<
SP <<
"x_index += j_" + std::to_string(
j) +
" * " <<
stridesX[
j] <<
";\n";
155 out <<
SP <<
SP <<
SP <<
"x_index += j_" + std::to_string(
j - 1) +
" * " <<
stridesX[
j] <<
";\n";
157 out <<
SP <<
SP <<
SP <<
"tensor_" <<
fNY <<
"[y_index] = tensor_" <<
fNX <<
"[x_index];\n";
161 out <<
SP <<
SP <<
SP <<
"}\n";
164 for (
size_t i = 0; i <
q; i++) {
165 out <<
SP <<
SP <<
"}\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
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 r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
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::string Generate(std::string OpName)
std::vector< size_t > fShapeIndices
ROperator_Gather(int64_t attrAxis, std::string nameX, std::string nameIndices, std::string nameY)
void Initialize(RModel &model)
std::vector< std::vector< size_t > > ShapeInference(std::vector< std::vector< size_t > > input)
std::vector< ETensorType > TypeInference(std::vector< ETensorType > input)
std::vector< int64_t > fIndices
std::vector< size_t > fShapeY
std::vector< size_t > fShapeX
const std::string SP
space used to correctly indent the generated C++ code
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::string ConvertTypeToString(ETensorType type)
std::size_t ConvertShapeToLength(std::vector< size_t > shape)
create variable transformations