1#ifndef TMVA_SOFIE_ROPERATOR_RESHAPE
2#define TMVA_SOFIE_ROPERATOR_RESHAPE
14namespace Experimental{
77 auto ret = std::vector<ETensorType>(1,
input[0]);
86 std::vector<std::vector<Dim>>
ret;
102 tmp.erase(tmp.begin() + i);
128 token.erase(std::remove_if(token.begin(), token.end(),
129 [](
unsigned char x) { return std::isspace(x); }), token.end());
134 if ((
il %
tl) == 0) {
150 if (
res_shape.find(
'*') != std::string::npos)
199 for (
size_t i = 0; i < axes.size(); i++) {
203 throw std::runtime_error(
"TMVA Squeeze Op : Invalid axis value " + std::to_string(axes[i]) +
212 std::cout <<
"doing unsqueeze....\n";
217 int64_t
r =
input[0].size() + axes.size();
218 for (
auto &
a : axes) {
219 int64_t i =
static_cast<int64_t
>(
a);
221 throw std::runtime_error(
"TMVA Unsqueeze Op - axes input is not in correct range");
235 std::cout <<
"initialize reshape op type " <<
fOpMode <<
" - " <<
fNInput2 <<
" " <<
fNData << std::endl;
239 throw std::runtime_error(
"TMVA Reshape Op Input Tensor " +
fNData +
" is not found in model");
249 auto values =
static_cast<int64_t *
>(
dptr.get());
256 fShape = std::vector<int64_t>(values, values +
n);
258 fAttrAxes = std::vector<int64_t>(values, values +
n);
274 throw std::runtime_error(
"TMVA Reshape Op 2nd input Tensor " +
fNInput2 +
" is not found in model");
278 std::cout <<
"attribute axes exists\n";
283 throw std::runtime_error(
"TMVA Reshape Op : Invalid Input/Attribute data");
291 throw std::runtime_error(
"TMVA Reshape Op : Invalid Input/Output lengths");
319 std::stringstream out;
320 std::string
opType =
"Reshape";
337 out <<
SP <<
"if (tensor_" <<
fNInput2 <<
"[" << i <<
"] <= 0 ) "
348 out <<
"throw std::runtime_error(\"TMVA SOFIE Reshape Op : output lengths is different than input one\");\n";
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 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 r
const_iterator begin() const
const_iterator end() const
std::vector< size_t > GetTensorShape(const std::string &name) const
std::vector< Dim > GetDimTensorShape(const std::string &name) const
bool IsDynamicTensor(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 IsShapeTensor(const std::string &name) const
check if a tensor is a shape tensor
bool IsInitializedTensor(const std::string &name) const
bool IsConstantTensor(const std::string &name) const
std::shared_ptr< void > GetInitializedTensorData(std::string tensor_name)
void SetNotWritableInitializedTensor(const std::string &tensor_name)
ETensorType GetTensorType(std::string name) const
const std::vector< Dim > & GetShapeTensorValues(const std::string &tensor_name) const
void AddShapeTensor(const std::string &name, const std::vector< Dim > &shapeValues, bool scalar=false)
std::vector< Dim > fShapeInput
std::vector< int64_t > fShape
ROperator_Reshape(ReshapeOpMode opMode, std::vector< int64_t > attrAxes, std::string nameData, std::string nameOutput)
std::vector< std::vector< size_t > > ShapeInference(std::vector< std::vector< size_t > > input) override
void Initialize(RModel &model) override
std::vector< Dim > fShapeOutput
ROperator_Reshape(ReshapeOpMode opMode, int attr_value, std::string nameData, std::string nameInput2, std::string nameOutput)
std::vector< int64_t > fAttrAxes
std::vector< std::vector< Dim > > ShapeInference(const std::vector< std::vector< Dim > > &input)
std::string Generate(std::string opName) override
std::vector< ETensorType > TypeInference(std::vector< ETensorType > input) override
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::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)
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)
bool IsInteger(const std::string &s)
create variable transformations