1#ifndef TMVA_SOFIE_SOFIE_COMMON
2#define TMVA_SOFIE_SOFIE_COMMON
20namespace Experimental{
26 UNDEFINED = 0,
FLOAT = 1,
UNINT8 = 2,
INT8 = 3,
UINT16 = 4,
INT16 = 5,
INT32 = 6,
INT64 = 7,
STRING = 8, BOOL = 9,
93 std::vector<std::size_t>
const &
shape()
const {
return fShape; }
96 template <
class T =
void>
99 return static_cast<T
const *
>(
fData.get());
107 for (std::size_t item :
fShape) {
108 fSize *=
static_cast<int>(item);
117 throw std::runtime_error(
"TMVA::SOFIE doesn't yet supports serialising data-type " +
173bool AreSameShape(
const std::vector<size_t>&,
const std::vector<size_t>&);
174bool AreSameShape(
const std::vector<size_t>&,
const std::vector<Dim>&);
175bool AreSameShape(
const std::vector<Dim>&,
const std::vector<Dim>&);
190 std::stringstream
ss;
191 ss <<
"TMVA::SOFIE - Error broadcasting Conv Bias of shape {";
192 ss << std::to_string(channel);
196 std::runtime_error(
ss.str());
209 for (
size_t i = 2; i <
size; i++)
213 for (
size_t i = 0; i < channel; i++) {
219 for (
size_t i = 1; i <
batch; i++) {
231 size_t size = shape.size();
243 for (
size_t idx = 0; idx <
size; idx++) {
244 size_t dim = shape[idx];
301 return static_cast<unsigned>(
a) <
static_cast<unsigned>(
b);
414template <
typename Dtype>
467 const float * alpha,
const float * A,
const int *
lda,
const float * B,
const int *
ldb,
468 const float * beta,
float * C,
const int *
ldc);
489 if (
t1.GetMemoryLayout() !=
t2.GetMemoryLayout())
490 throw std::runtime_error(
"TMVA RTensor Concatenate - tensors have different memory layout");
494 std::cout <<
"axis " << axis <<
" sizes " <<
t1.GetSize() <<
" " <<
t2.GetSize() <<
" ";
497 throw std::runtime_error(
"TMVA RTensor Concatenate - tensors have incompatible shapes");
502 if (
t1.GetMemoryLayout() == TMVA::Experimental::MemoryLayout::ColumnMajor) {
503 throw std::runtime_error(
"TMVA RTensor Concatenate is not yet supported for column major tensors");
510 size_t s1 = (axis > 0) ?
stride1[axis-1] :
t1.GetSize();
511 size_t s2 = (axis > 0) ?
stride2[axis-1] :
t2.GetSize();
513 size_t nb =
t1.GetSize()/
s1;
514 for (
size_t i = 0; i <
nb; i++) {
515 std::copy(
t1.GetData() + i*
s1,
t1.GetData() + (i+1)*
s1,
tout.GetData() + i *
sout );
516 std::copy(
t2.GetData() + i*
s2,
t2.GetData() + (i+1)*
s2,
tout.GetData() + i *
sout +
s1 );
529 out.edge_index =
data1.edge_index.Copy();
539 std::copy(
data.node_data.GetData(),
data.node_data.GetData()+
data.node_data.GetSize(), out.node_data.GetData());
540 std::copy(
data.edge_data.GetData(),
data.edge_data.GetData()+
data.edge_data.GetSize(), out.edge_data.GetData());
541 std::copy(
data.global_data.GetData(),
data.global_data.GetData()+
data.global_data.GetSize(), out.global_data.GetData());
542 std::copy(
data.edge_index.GetData(),
data.edge_index.GetData()+
data.edge_index.GetSize(), out.edge_index.GetData());
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.
winID h TVirtualViewer3D TVirtualGLPainter p
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 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 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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
const_iterator begin() const
RTensor is a container with contiguous memory and shape information.
std::shared_ptr< void > const & sharedptr() const
std::shared_ptr< void > fData
! Transient shared data
InitializedTensor()=default
ETensorType fType
Encodes the type of the data.
std::vector< std::size_t > const & shape() const
char * fPersistentData
[fSize] Persistent version of the data
std::vector< std::size_t > fShape
The shape of the data in terms of elements in each dimension.
InitializedTensor(ETensorType type, std::span< std::size_t > shape, std::shared_ptr< void > data)
void CastSharedToPersistent()
ETensorType const & type() const
void CastPersistentToShared()
int fSize
The size of the persistent data in bytes (not number of elements!)
void sgemm_(const char *transa, const char *transb, const int *m, const int *n, const int *k, const float *alpha, const float *A, const int *lda, const float *B, const int *ldb, const float *beta, float *C, const int *ldc)
bool AreSameShape(const std::vector< size_t > &, const std::vector< size_t > &)
void Im2col_3d(const T *data_im, const int channels, const int depth, const int height, const int width, const int kernel_d, const int kernel_h, const int kernel_w, const int pad_d, const int pad_h, const int pad_w, const int stride_d, const int stride_h, const int stride_w, const int dilation_d, const int dilation_h, const int dilation_w, T *data_col)
3d implementation
T * BroadcastConvBias(const T *data, const size_t channel, const std::vector< size_t > &targetShape)
void col2im(const Dtype *data_col, const int channels, const int height, const int width, const int kernel_h, const int kernel_w, const int pad_h, const int pad_w, const int stride_h, const int stride_w, const int dilation_h, const int dilation_w, Dtype *data_im)
T * BroadcastTensor(const T *data, const std::vector< size_t > &shape, const std::vector< size_t > &targetShape)
std::vector< size_t > UnidirectionalBroadcastShape(std::vector< size_t >, std::vector< size_t >)
std::string Clean_name(std::string input_tensor_name)
bool is_a_ge_zero_and_a_lt_b(int a, int b)
function to check if a >> 0 and a < MAX using a single comparison / use trick casting to unsigned val...
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)
void Im2col(const T *data_im, const int channels, const int height, const int width, const int kernel_h, const int kernel_w, const int pad_h, const int pad_w, const int stride_h, const int stride_w, const int dilation_h, const int dilation_w, T *data_col)
im2col : efficient function to re-arrange input data of convolution to a matrix that can be used by B...
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)
ETensorType GetTemplatedType(T)
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)
TMVA::Experimental::RTensor< T > Concatenate(TMVA::Experimental::RTensor< T > &t1, TMVA::Experimental::RTensor< T > &t2, int axis=0)
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)
GNN_Data Copy(const GNN_Data &data)
create variable transformations
Dim(const std::string &p, size_t d=0)
std::string GetVal() const
RTensor< float > global_data
RTensor< float > edge_data
RTensor< int > edge_index
RTensor< float > node_data
std::vector< size_t > shape