1#ifndef TMVA_SOFIE_ROPERATOR_GatherND
2#define TMVA_SOFIE_ROPERATOR_GatherND
13namespace Experimental{
43 throw std::runtime_error(
"TMVA SOFIE GatherND Op Input Tensor " +
fNX +
" is not found in model");
56 throw std::runtime_error(
"TMVA SOFIE GatherND : rank of Indices is < 1");
59 throw std::runtime_error(
"TMVA SOFIE GatherND : rank of input tensor is < 1");
62 throw std::runtime_error(
"TMVA SOFIE GatherND : invalid batch dim value");
69 throw std::runtime_error(
"TMVA SOFIE GatherND : invalid input or index shape for " + std::to_string(i));
76 throw std::runtime_error(
"TMVA SOFIE GatherND : Index_shape(-1) is not known");
82 throw std::runtime_error(
"TMVA SOFIE GatherND : Index_shape(-1) has wrong value " +
95 <<
" and output rank should be " <<
output_rank << std::endl;
96 throw std::runtime_error(
"TMVA SOFIE GatherND : Something is wrong in initialization ");
175 return "//---------------------------------------\n";
178 std::stringstream out;
194 out <<
SP <<
"for (size_t i = 0; i < " <<
indicesLength <<
"; i++) {\n";
195 out <<
SP <<
SP <<
"if (tensor_" <<
fNIndices <<
"[i] < 0 ) {\n";
198 for (
size_t j = 1;
j <
ss;
j++) {
201 out <<
SP <<
SP <<
SP <<
"const_cast<int64_t &>(tensor_" <<
fNIndices <<
"[i]) += s_i;\n";
202 out <<
SP <<
SP <<
"}\n";
209 std::string
index =
"i_" + std::to_string(
j);
210 for (
size_t k = 0; k <=
j; k++) out <<
SP;
229 std::string
index =
"i_" + std::to_string(
j);
230 for (
size_t k = 0; k <=
j; k++) out <<
SP;
243 for (
size_t k = 0; k <=
q - 1; k++) out <<
SP;
244 out <<
"size_t inputIndex = " <<
inIndex;
246 for (
size_t l = 0;
l <
ss;
l++) {
257 for (
size_t k = 0; k <=
q - 1; k++) out <<
SP;
260 out <<
"tensor_" <<
fNY <<
"[" <<
outIndex <<
"] = "
261 <<
"tensor_" <<
fNX <<
"[inputIndex];\n";
264 out <<
"std::copy(tensor_" <<
fNX <<
" + inputIndex, tensor_" <<
fNX <<
" + inputIndex + "
271 for (
size_t j =
q-1;
j > 0;
j--) {
272 for (
size_t k = 0; k <
j; k++) 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 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_iterator end() 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)
ETensorType GetTensorType(std::string name) const
ROperator_GatherND(int batch_dims, std::string nameX, std::string nameIndices, std::string nameY)
std::vector< int64_t > fIndices
void Initialize(RModel &model) override
std::vector< Dim > fShapeIndices
std::vector< Dim > fShapeY
std::string Generate(std::string opName) override
std::vector< Dim > fShapeX
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::string ConvertTypeToString(ETensorType type)
std::string ConvertDimShapeToLength(const std::vector< Dim > &shape)
std::string ConvertShapeToString(const std::vector< size_t > &shape)
create variable transformations