8namespace Experimental {
16 for (
size_t i =0; i < shape.size(); i++){
26 std::vector<size_t>
ret_shape(shape.size());
27 for (
size_t i =0; i < shape.size(); i++){
28 if (shape[i].isParam) {
32 val = std::stoi(shape[i].param);
33 if (val >= 0)
ret_shape[i] =
static_cast<size_t>(val);
39 catch (
const std::invalid_argument& ) {
53 std::size_t fLength = 1;
54 for (
auto& dim: shape) fLength *= dim;
94 return "other_" + std::to_string( (
int)
type);
100 if(
type ==
"float32" ||
type ==
"float" ||
type ==
"Float"){
103 else if(
type ==
"int64" ||
type ==
"int64_t"){
106 else if (
type ==
"double" ||
type ==
"float64"){
109 else if (
type ==
"bool" ){
118 std::stringstream out;
120 for (
size_t i = 0; i < shape.size(); i++) {
122 if (i < shape.size()-1) out <<
" , ";
129 std::stringstream out;
131 for (
size_t i = 0; i < shape.size(); i++) {
132 out << shape[i].GetVal();
133 if (i < shape.size()-1) out <<
" , ";
144 for (
size_t i = 0; i < shape.size(); i++) {
145 if (shape[i].isParam) {
184 for (
size_t dim = 0; dim <
shapeA.size(); dim++) {
195 for (
size_t dim = 0; dim <
shapeA.size(); dim++) {
196 if (
shapeB[dim].isParam)
return false;
207 for (
size_t dim = 0; dim <
shapeA.size(); dim++) {
217 if (shape.size() < 2) {
219 std::runtime_error(
"TMVA::SOFIE - MultidirectionalBroadcastShape requires at least 2 input shapes.");
222 size_t n = shape.size();
225 for (
size_t i = 1; i <
n; i++) {
230 for (
size_t i = 0; i <
n; i++) {
239 for (
size_t i = 1; i <
n; i++) {
240 for (
size_t dim = 0; dim < shape[0].size(); dim++) {
241 if (shape[i][dim] != shape[0][dim]) {
255 for (
size_t i = 0; i <
n; i++) {
256 for (
size_t dim = 0; dim <
targetSize; dim++) {
262 for (
size_t i = 0; i <
n; i++) {
263 for (
size_t dim = 0; dim <
targetSize; dim++) {
277 std::stringstream
ss;
278 ss <<
"TMVA::SOFIE - Error multidirectional broadcasting shapes ";
279 for (
size_t i = 0; i <
n; i++) {
281 if (
n > 2 && i <
n - 2) {
283 }
else if (
n >=2 && i ==
n - 2) {
287 ss <<
" to the same shape.";
289 std::runtime_error(
ss.str());
294 for (
size_t i = 0; i <
n; i++) {
304 for (
size_t i = 0; i <
n; i++) {
305 for (
size_t dim = 0; dim <
targetSize; dim++) {
311 for (
size_t i = 0; i <
n; i++) {
312 for (
size_t dim = 0; dim <
targetSize; dim++) {
325 std::stringstream
ss;
326 ss <<
"TMVA::SOFIE - Error multidirectional broadcasting shapes ";
327 for (
size_t i = 0; i <
n; i++) {
329 if (
n > 2 && i <
n - 2) {
331 }
else if (
n >=2 && i ==
n - 2) {
335 ss <<
" to the same shape.";
337 std::runtime_error(
ss.str());
364 for (
size_t i = 0; i <
size; i++) {
373 for (
size_t i = 0; i <
size; i++) {
379 std::runtime_error(
"TMVA::SOFIE - Error unidirectional broadcasting tensors of shape "
381 +
" to a common shape.");
387 std::replace( s.begin(), s.end(),
'-',
'_');
389 s.erase(std::remove_if(s.begin(), s.end(), [](
char const&
c ) ->
bool { return !std::isalnum(c) && c !=
'_'; } ), s.end());
395 const auto size = shape.size();
396 std::vector<size_t> strides(
size,1);
397 for (std::size_t i = 1; i <
size; i++) {
398 strides[
size - 1 - i] = strides[
size - i ] * shape[
size - i];
405 const auto size = shape.size();
406 std::vector<Dim> strides(
size);
408 for (std::size_t i = 1; i <
size; i++) {
409 if (!shape[
size-i].isParam && !strides[
size-i].isParam)
412 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 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 > >)
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