1#ifndef TMVA_SOFIE_ROPERATOR_Pad
2#define TMVA_SOFIE_ROPERATOR_Pad
11namespace Experimental{
30 std::vector<std::pair<int64_t, int64_t>>
fPads;
36 const std::string &
nameAX,
const std::string &
nameY,
const std::string &
mode) :
42 if (
mode ==
"constant")
44 else if (
mode ==
"reflect")
46 else if (
mode ==
"edge")
48 else if (
mode ==
"wrap")
66 throw std::runtime_error(
"TMVA SOFIE Pad Op Input Tensor is not found in model");
72 throw std::runtime_error(
"TMVA SOFIE Pad Op supports now only Constant mode");
80 throw std::runtime_error(
"TMVA SOFIE Pad Op supports now only initialized Pads data");
89 throw std::runtime_error(
"TMVA SOFIE Pad Op supports now only initialized Constant Value data");
92 std::vector<int64_t> axes;
97 size_t nax = shape[0];
105 for (
size_t i = 0; i <
nax; i++)
108 throw std::runtime_error(
"TMVA SOFIE Pad Op invalid input Axes type");
111 throw std::runtime_error(
"TMVA SOFIE Pad Op supports now only initialized Axes data");
127 if (axes[i] == int64_t(i)) {
132 throw std::runtime_error(
"TMVA SOFIE Pad Op : invalid Pads values");
140 std::cout <<
"initializing Pad operator with pads .. : ";
142 std::cout <<
"{ " <<
p.first <<
" , " <<
p.second <<
"} ";
143 std::cout << std::endl;
154 throw std::runtime_error(
"TMVA SOFIE Operator Pad called to Generate without being initialized first");
156 std::stringstream out;
159 out <<
"\n//------ Pad\n";
163 out <<
"std::fill(tensor_" <<
fNY <<
", tensor_" <<
fNY <<
" + " <<
length <<
","
167 for (
int i = 0; i <
dims; i++) {
168 for (
int j = 1;
j < i;
j++) out <<
SP;
169 out <<
"for (int id" << i <<
" = 0; id" << i <<
" < " <<
fInputShape[i] <<
"; id"
174 for (
int j = 0;
j <
dims;
j++) out <<
SP;
175 out <<
"tensor_" <<
fNY <<
"[";
176 for (
int i = 0; i <
dims; i++) {
178 if (
fPads[i].first != 0) out <<
" + " <<
fPads[i].first;
182 out <<
"] =\n tensor_" <<
fNX <<
"[";
183 for (
int i = 0; i <
dims; i++) {
188 for (
int i =
dims-1; i >= 0; i--) {
189 for (
int j = 1;
j < i;
j++) out <<
SP;
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
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 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 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
Option_t Option_t TPoint TPoint const char mode
void AddIntermediateTensor(std::string tensor_name, ETensorType type, std::vector< Dim > dim_shape)
bool CheckIfTensorAlreadyExist(std::string tensor_name)
const ETensorType & GetTensorType(std::string name) const
bool IsInitializedTensor(const std::string &name) const
const std::vector< size_t > & GetTensorShape(std::string name) const
std::shared_ptr< void > GetInitializedTensorData(std::string tensor_name)
std::vector< size_t > fInputShape
std::vector< size_t > fOutputShape
void Initialize(RModel &model) override
std::vector< ETensorType > TypeInference(std::vector< ETensorType > input) override
std::string Generate(std::string OpName) override
std::vector< std::vector< size_t > > ShapeInference(std::vector< std::vector< size_t > > input) override
std::vector< std::pair< int64_t, int64_t > > fPads
ROperator_Pad(const std::string &nameX, const std::string &nameP, const std::string &nameCV, const std::string &nameAX, const std::string &nameY, const std::string &mode)
std::vector< std::string_view > fInputTensorNames
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 ConvertShapeToString(std::vector< size_t > shape)
std::size_t ConvertShapeToLength(std::vector< size_t > shape)
create variable transformations