15 for (
size_t i =0; i < shape.size(); i++){
25 std::vector<size_t>
ret_shape(shape.size());
26 for (
size_t i =0; i < shape.size(); i++){
27 if (shape[i].isParam) {
31 val = std::stoi(shape[i].param);
32 if (val >= 0)
ret_shape[i] =
static_cast<size_t>(val);
38 catch (
const std::invalid_argument& ) {
52 std::size_t fLength = 1;
53 for (
auto& dim: shape) fLength *= dim;
93 return "other_" + std::to_string( (
int)
type);
99 if(
type ==
"float32" ||
type ==
"float" ||
type ==
"Float"){
102 else if(
type ==
"int64" ||
type ==
"int64_t"){
105 else if (
type ==
"double" ||
type ==
"float64"){
108 else if (
type ==
"bool" ){
117 std::stringstream out;
119 for (
size_t i = 0; i < shape.size(); i++) {
121 if (i < shape.size()-1) out <<
" , ";
128 std::stringstream out;
130 for (
size_t i = 0; i < shape.size(); i++) {
131 out << shape[i].GetVal();
132 if (i < shape.size()-1) out <<
" , ";
143 for (
size_t i = 0; i < shape.size(); i++) {
144 if (shape[i].isParam) {
183 for (
size_t dim = 0; dim <
shapeA.size(); dim++) {
194 for (
size_t dim = 0; dim <
shapeA.size(); dim++) {
195 if (
shapeB[dim].isParam)
return false;
206 for (
size_t dim = 0; dim <
shapeA.size(); dim++) {
216 if (shape.size() < 2) {
218 std::runtime_error(
"TMVA::SOFIE - MultidirectionalBroadcastShape requires at least 2 input shapes.");
221 size_t n = shape.size();
224 for (
size_t i = 1; i <
n; i++) {
229 for (
size_t i = 0; i <
n; i++) {
238 for (
size_t i = 1; i <
n; i++) {
239 for (
size_t dim = 0; dim < shape[0].size(); dim++) {
240 if (shape[i][dim] != shape[0][dim]) {
254 for (
size_t i = 0; i <
n; i++) {
255 for (
size_t dim = 0; dim <
targetSize; dim++) {
261 for (
size_t i = 0; i <
n; i++) {
262 for (
size_t dim = 0; dim <
targetSize; dim++) {
276 std::stringstream
ss;
277 ss <<
"TMVA::SOFIE - Error multidirectional broadcasting shapes ";
278 for (
size_t i = 0; i <
n; i++) {
280 if (
n > 2 && i <
n - 2) {
282 }
else if (
n >=2 && i ==
n - 2) {
286 ss <<
" to the same shape.";
288 std::runtime_error(
ss.str());
293 for (
size_t i = 0; i <
n; i++) {
303 for (
size_t i = 0; i <
n; i++) {
304 for (
size_t dim = 0; dim <
targetSize; dim++) {
310 for (
size_t i = 0; i <
n; i++) {
311 for (
size_t dim = 0; dim <
targetSize; dim++) {
324 std::stringstream
ss;
325 ss <<
"TMVA::SOFIE - Error multidirectional broadcasting shapes ";
326 for (
size_t i = 0; i <
n; i++) {
328 if (
n > 2 && i <
n - 2) {
330 }
else if (
n >=2 && i ==
n - 2) {
334 ss <<
" to the same shape.";
336 std::runtime_error(
ss.str());
363 for (
size_t i = 0; i <
size; i++) {
372 for (
size_t i = 0; i <
size; i++) {
378 std::runtime_error(
"TMVA::SOFIE - Error unidirectional broadcasting tensors of shape "
380 +
" to a common shape.");
390 auto ncdata =
const_cast<std::vector<bool> &
>(
data);
403 std::replace( s.begin(), s.end(),
'-',
'_');
405 s.erase(std::remove_if(s.begin(), s.end(), [](
char const&
c ) ->
bool { return !std::isalnum(c) && c !=
'_'; } ), s.end());
411 const auto size = shape.size();
412 std::vector<size_t> strides(
size,1);
413 for (std::size_t i = 1; i <
size; i++) {
414 strides[
size - 1 - i] = strides[
size - i ] * shape[
size - i];
421 const auto size = shape.size();
422 std::vector<Dim> strides(
size);
424 for (std::size_t i = 1; i <
size; i++) {
425 if (!shape[
size-i].isParam && !strides[
size-i].isParam)
428 strides[
size - 1 - i] =
Dim{std::string(strides[
size-i].GetVal() +
"*" + shape[
size-i].GetVal())};
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
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 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 offset
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 Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
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 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 Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
const_iterator begin() const
const_iterator end() const
bool AreSameShape(const std::vector< size_t > &, const std::vector< size_t > &)
std::vector< size_t > UnidirectionalBroadcastShape(std::vector< size_t >, std::vector< size_t >)
std::string Clean_name(std::string input_tensor_name)
std::vector< size_t > MultidirectionalBroadcastShape(std::vector< std::vector< size_t > >)
T * UnidirectionalBroadcast(const T *data, const std::vector< size_t > &shape, const std::vector< size_t > &targetShape)
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::vector< Dim > ConvertShapeToDim(std::vector< size_t > shape)
Convert shape from integer format to dynamic one (based on Dim)
std::string ConvertDynamicShapeToLength(std::vector< Dim > shape)
std::string ConvertShapeToString(std::vector< size_t > shape)
std::string ConvertTypeToString(ETensorType type)
std::string ConvertDynamicShapeToString(std::vector< Dim > shape)
ETensorType ConvertStringToType(std::string type)
std::vector< size_t > ConvertShapeToInt(std::vector< Dim > shape)
Convert shape based on Dim to integer format.
std::size_t ConvertShapeToLength(std::vector< size_t > shape)
create variable transformations