1#ifndef TMVA_SOFIE_ROPERATOR_NONZERO
2#define TMVA_SOFIE_ROPERATOR_NONZERO
11namespace Experimental{
38 throw std::runtime_error(
"TMVA SOFIE NonZero Op Input Tensor " +
fNX +
" is not found in model");
48 std::vector<size_t>
shapeY(2);
53 for (
size_t i = 0; i <
length; i++) {
57 std::vector<int64_t> indices(
shapeX.size());
58 for (
size_t j = 0;
j <
shapeX.size(); ++
j) {
68 for (
size_t i = 0; i <
shapeY[0]; i++) {
116 std::stringstream out;
117 out <<
SP <<
"size_t fV_NonZero_" <<
fNX <<
" = 0;\n";
128 throw std::runtime_error(
"TMVA SOFIE Operator NonZero called to Generate without being initialized first");
130 std::stringstream out;
143 out <<
SP <<
"size_t offset_" <<
opName <<
" = 0;\n";
144 out <<
SP <<
"size_t " <<
vnonzero <<
" = 0;\n";
145 for (
size_t j = 0;
j <
dims;
j++) {
146 std::string
index =
"i_" + std::to_string(
j);
147 for (
size_t k = 0; k <=
j; k++) out <<
SP;
150 for (
size_t k = 0; k <=
dims; k++) out <<
SP;
151 out <<
"if (tensor_" <<
fNX <<
"[offset_" <<
opName <<
"++]) {\n";
152 for (
size_t j = 0;
j <
dims;
j++) {
153 for (
size_t k = 0; k <=
dims+1; k++) out <<
SP;
154 out <<
"tensor_" <<
fNY <<
"[";
160 if (
j > 1) out <<
" * " <<
j;
164 out <<
vnonzero <<
"] = i_" <<
j <<
";\n";
166 for (
size_t k = 0; k <=
dims+1; k++) out <<
SP;
168 for (
size_t k = 0; k <=
dims; k++) out <<
SP;
171 for (
size_t j =
dims;
j > 0;
j--) {
172 for (
size_t k = 0; k <
j; k++) out <<
SP;
177 for (
size_t j = 1;
j <
dims;
j++) {
178 out <<
SP <<
SP <<
"std::copy(tensor_" <<
fNY;
180 if (
j>1) out <<
" * " <<
j;
181 out <<
", tensor_" <<
fNY;
183 if (
j>1) out <<
" * " <<
j;
186 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)
void AddExtraCodeForDimShapes(const std::string &code)
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::string fNonZeroParam
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::size_t ConvertShapeToLength(const std::vector< size_t > &shape)
std::string ConvertValuesToString(size_t n, const T *data, size_t maxprint=-1)
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