1#ifndef TMVA_SOFIE_ROPERATOR_NONZERO
2#define TMVA_SOFIE_ROPERATOR_NONZERO
11namespace Experimental{
37 throw std::runtime_error(
"TMVA SOFIE NonZero Op Input Tensor " +
fNX +
" is not found in model");
47 std::vector<size_t>
shapeY(2);
52 for (
size_t i = 0; i <
length; i++) {
56 std::vector<int64_t> indices(
shapeX.size());
57 for (
size_t j = 0;
j <
shapeX.size(); ++
j) {
67 for (
size_t i = 0; i <
shapeY[0]; i++) {
96 fShapeY[1] =
Dim{std::string(
"v_NonZero_") +
fNX,
static_cast<size_t>(-1)};
108 std::stringstream out;
120 throw std::runtime_error(
"TMVA SOFIE Operator NonZero called to Generate without being initialized first");
122 std::stringstream out;
130 out <<
"\n//------ NonZero\n";
135 out <<
SP <<
"size_t offset_" <<
opName <<
" = 0;\n";
137 for (
size_t j = 0;
j <
dims;
j++) {
138 std::string
index =
"i_" + std::to_string(
j);
139 for (
size_t k = 0; k <=
j; k++) out <<
SP;
142 for (
size_t k = 0; k <=
dims; k++) out <<
SP;
143 out <<
"if (tensor_" <<
fNX <<
"[offset_" <<
opName <<
"++]) {\n";
144 for (
size_t j = 0;
j <
dims;
j++) {
145 for (
size_t k = 0; k <=
dims+1; k++) out <<
SP;
146 out <<
"tensor_" <<
fNY <<
"[";
152 if (
j > 1) out <<
" * " <<
j;
156 out <<
vnonzero <<
"] = i_" <<
j <<
";\n";
158 for (
size_t k = 0; k <=
dims+1; k++) out <<
SP;
160 for (
size_t k = 0; k <=
dims; k++) out <<
SP;
163 for (
size_t j =
dims;
j > 0;
j--) {
164 for (
size_t k = 0; k <
j; k++) out <<
SP;
169 for (
size_t j = 1;
j <
dims;
j++) {
170 out <<
SP <<
SP <<
"std::copy(tensor_" <<
fNY;
172 if (
j>1) out <<
" * " <<
j;
173 out <<
", tensor_" <<
fNY;
175 if (
j>1) out <<
" * " <<
j;
178 if (
j>1) out <<
"* " <<
j;
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 data
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
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
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)
void AddConstantTensor(std::string tensor_name, ETensorType type, std::vector< std::size_t > shape, std::shared_ptr< void > data)
bool IsConstantTensor(const std::string &name) const
std::shared_ptr< void > GetInitializedTensorData(std::string tensor_name)
std::string GenerateSessionMembersCode(std::string) override
std::vector< Dim > fShapeX
std::string Generate(std::string opName) override
void Initialize(RModel &model) override
ROperator_NonZero(std::string nameX, std::string nameY)
std::vector< Dim > fShapeY
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::size_t ConvertShapeToLength(const std::vector< size_t > &shape)
std::string ConvertValuesToString(size_t n, const T *data)
std::vector< size_t > ConvertShapeToInt(const std::vector< Dim > &shape)
Convert shape based on Dim to integer format.
std::string ConvertDimShapeToLength(const std::vector< Dim > &shape)
std::string ConvertShapeToString(const std::vector< size_t > &shape)
create variable transformations