1#ifndef TMVA_SOFIE_ROPERATOR_GatherND
2#define TMVA_SOFIE_ROPERATOR_GatherND
13namespace Experimental{
42 if (!model.CheckIfTensorAlreadyExist(
fNX)) {
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 ");
101 model.AddIntermediateTensor(
fNY, model.GetTensorType(
fNX),
fShapeY);
175 return "//---------------------------------------\n";
178 std::stringstream out;
199 std::string
index =
"i_" + std::to_string(
j);
200 for (
size_t k = 0; k <=
j; k++) out <<
SP;
219 std::string
index =
"i_" + std::to_string(
j);
220 for (
size_t k = 0; k <=
j; k++) out <<
SP;
235 for (
size_t l = 0;
l <
ss;
l++) {
238 for (
size_t k = 0; k <=
q - 1; k++)
241 for (
size_t k = 0; k <=
q - 1; k++)
245 for (
size_t k = 0; k <=
q - 1; k++) out <<
SP;
246 out <<
"size_t inputIndex = " <<
inIndex;
247 for (
size_t l = 0;
l <
ss;
l++) {
251 out <<
"index_" <<
l;
256 for (
size_t k = 0; k <=
q - 1; k++) out <<
SP;
259 out <<
"tensor_" <<
fNY <<
"[" <<
outIndex <<
"] = "
260 <<
"tensor_" <<
fNX <<
"[inputIndex];\n";
263 out <<
"std::copy(tensor_" <<
fNX <<
" + inputIndex, tensor_" <<
fNX <<
" + inputIndex + "
270 for (
size_t j =
q-1;
j > 0;
j--) {
271 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
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 ConvertDimShapeToString(const std::vector< Dim > &shape)
std::string ConvertTypeToString(ETensorType type)
create variable transformations