Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TMVA_SOFIE_ONNX.C File Reference

Detailed Description

View in nbviewer Open in SWAN
This macro provides a simple example for the parsing of ONNX files into RModel object and further generating the .hxx header files for inference.

using namespace TMVA::Experimental;
void TMVA_SOFIE_ONNX(std::string inputFile = ""){
if (inputFile.empty() )
inputFile = std::string(gROOT->GetTutorialsDir()) + "/machine_learning/Linear_16.onnx";
//Creating parser object to parse ONNX files
SOFIE::RModel model = parser.Parse(inputFile, true);
//Generating inference code
model.Generate();
// write the code in a file (by default Linear_16.hxx and Linear_16.dat
model.OutputGenerated();
//Printing required input tensors
//Printing initialized tensors (weights)
std::cout<<"\n\n";
//Printing intermediate tensors
std::cout<<"\n\n";
//Checking if tensor already exist in model
std::cout<<"\n\nTensor \"16weight\" already exist: "<<std::boolalpha<<model.CheckIfTensorAlreadyExist("16weight")<<"\n\n";
std::vector<size_t> tensorShape = model.GetTensorShape("16weight");
std::cout<<"Shape of tensor \"16weight\": ";
for(auto& it:tensorShape){
std::cout<<it<<",";
}
std::cout<<"\n\nData type of tensor \"16weight\": ";
SOFIE::ETensorType tensorType = model.GetTensorType("16weight");
std::cout<<SOFIE::ConvertTypeToString(tensorType);
//Printing generated inference code
std::cout<<"\n\n";
model.PrintGenerated();
}
#define gROOT
Definition TROOT.h:417
RModel Parse(std::string const &filename, bool verbose=false)
void PrintGenerated(std::ostream &os=std::cout)
std::vector< size_t > GetTensorShape(const std::string &name) const
Definition RModel.cxx:64
bool CheckIfTensorAlreadyExist(std::string tensor_name)
Definition RModel.cxx:157
void OutputGenerated(std::string filename="", bool append=false)
Definition RModel.cxx:1959
void Generate(std::underlying_type_t< Options > options, int batchSize=-1, long pos=0, bool verbose=false)
Definition RModel.cxx:1477
ETensorType GetTensorType(std::string name) const
Definition RModel.cxx:125
std::string ConvertTypeToString(ETensorType type)
ONNX Version 6
Parsing Graph - Linear_16.onnx
Parsing model inputs....
graph input 0 name input.1 type 1
Parsing graph initializer list and fill model initialized tensors
initializer 0 name 0.bias type 1 and length 50
add initialized tensor 0.biaswith shape { 50 }and float data: 0.0687436 0.121526 -0.0379632
initializer 1 name 0.weight type 1 and length 5000
add initialized tensor 0.weightwith shape { 50 , 100 }and float data: -0.0508145 0.0380448 0.0639992
initializer 2 name 10.bias type 1 and length 50
add initialized tensor 10.biaswith shape { 50 }and float data: 0.127874 0.0175432 0.122976
initializer 3 name 10.weight type 1 and length 2500
add initialized tensor 10.weightwith shape { 50 , 50 }and float data: -0.0212359 0.122198 -0.0510823
initializer 4 name 12.bias type 1 and length 50
add initialized tensor 12.biaswith shape { 50 }and float data: -0.0650987 0.0561347 -0.0524961
initializer 5 name 12.weight type 1 and length 2500
add initialized tensor 12.weightwith shape { 50 , 50 }and float data: -0.028364 -0.0221013 0.133199
initializer 6 name 14.bias type 1 and length 50
add initialized tensor 14.biaswith shape { 50 }and float data: 0.0160144 0.0659305 -0.134516
initializer 7 name 14.weight type 1 and length 2500
add initialized tensor 14.weightwith shape { 50 , 50 }and float data: -0.0543761 0.0856281 0.0533403
initializer 8 name 16.bias type 1 and length 50
add initialized tensor 16.biaswith shape { 50 }and float data: -0.142527 0.168874 -0.0887829
initializer 9 name 16.weight type 1 and length 2500
add initialized tensor 16.weightwith shape { 50 , 50 }and float data: -0.00417223 0.0333769 -0.0680738
initializer 10 name 18.bias type 1 and length 10
add initialized tensor 18.biaswith shape { 10 }and float data: -0.0286833 0.0315114 -0.015858
initializer 11 name 18.weight type 1 and length 500
add initialized tensor 18.weightwith shape { 10 , 50 }and float data: 0.116833 -0.0357757 -0.131794
initializer 12 name 2.bias type 1 and length 50
add initialized tensor 2.biaswith shape { 50 }and float data: -0.0447339 0.0537878 0.0785958
initializer 13 name 2.weight type 1 and length 2500
add initialized tensor 2.weightwith shape { 50 , 50 }and float data: -0.0597149 -0.0791021 -0.00306094
initializer 14 name 4.bias type 1 and length 50
add initialized tensor 4.biaswith shape { 50 }and float data: 0.0420063 -0.0531012 -0.040592
initializer 15 name 4.weight type 1 and length 2500
add initialized tensor 4.weightwith shape { 50 , 50 }and float data: 0.0806723 -0.0843014 0.0457266
initializer 16 name 6.bias type 1 and length 50
add initialized tensor 6.biaswith shape { 50 }and float data: -0.130149 -0.0166716 0.0930551
initializer 17 name 6.weight type 1 and length 2500
add initialized tensor 6.weightwith shape { 50 , 50 }and float data: 0.0649254 0.129902 -0.0820777
initializer 18 name 8.bias type 1 and length 50
add initialized tensor 8.biaswith shape { 50 }and float data: 0.0448136 -0.0294533 0.00591958
initializer 19 name 8.weight type 1 and length 2500
add initialized tensor 8.weightwith shape { 50 , 50 }and float data: 0.0268759 0.139096 0.0821819
Graph operator list (ONNX order)
Operator 0 : Gemm , 3 inputs : {input.1, 0.weight, 0.bias }
Operator 1 : Relu , 1 inputs : {21 }
Operator 2 : Gemm , 3 inputs : {22, 2.weight, 2.bias }
Operator 3 : Relu , 1 inputs : {23 }
Operator 4 : Gemm , 3 inputs : {24, 4.weight, 4.bias }
Operator 5 : Relu , 1 inputs : {25 }
Operator 6 : Gemm , 3 inputs : {26, 6.weight, 6.bias }
Operator 7 : Relu , 1 inputs : {27 }
Operator 8 : Gemm , 3 inputs : {28, 8.weight, 8.bias }
Operator 9 : Relu , 1 inputs : {29 }
Operator 10 : Gemm , 3 inputs : {30, 10.weight, 10.bias }
Operator 11 : Relu , 1 inputs : {31 }
Operator 12 : Gemm , 3 inputs : {32, 12.weight, 12.bias }
Operator 13 : Relu , 1 inputs : {33 }
Operator 14 : Gemm , 3 inputs : {34, 14.weight, 14.bias }
Operator 15 : Relu , 1 inputs : {35 }
Operator 16 : Gemm , 3 inputs : {36, 16.weight, 16.bias }
Operator 17 : Relu , 1 inputs : {37 }
Operator 18 : Gemm , 3 inputs : {38, 18.weight, 18.bias }
***********************
Re-Order graph operator list
*************************
Checking input of Node 0 : Gemm_0
input input.1 1 0 1
input 0.weight 0 1 1
input 0.bias 0 1 1
===> New node Gemm Gemm_0 order 0
output : 21
Checking input of Node 1 : Relu_1
input 21 1 0 1
===> New node Relu Relu_1 order 1
output : 22
Checking input of Node 2 : Gemm_2
input 22 1 0 1
input 2.weight 0 1 1
input 2.bias 0 1 1
===> New node Gemm Gemm_2 order 2
output : 23
Checking input of Node 3 : Relu_3
input 23 1 0 1
===> New node Relu Relu_3 order 3
output : 24
Checking input of Node 4 : Gemm_4
input 24 1 0 1
input 4.weight 0 1 1
input 4.bias 0 1 1
===> New node Gemm Gemm_4 order 4
output : 25
Checking input of Node 5 : Relu_5
input 25 1 0 1
===> New node Relu Relu_5 order 5
output : 26
Checking input of Node 6 : Gemm_6
input 26 1 0 1
input 6.weight 0 1 1
input 6.bias 0 1 1
===> New node Gemm Gemm_6 order 6
output : 27
Checking input of Node 7 : Relu_7
input 27 1 0 1
===> New node Relu Relu_7 order 7
output : 28
Checking input of Node 8 : Gemm_8
input 28 1 0 1
input 8.weight 0 1 1
input 8.bias 0 1 1
===> New node Gemm Gemm_8 order 8
output : 29
Checking input of Node 9 : Relu_9
input 29 1 0 1
===> New node Relu Relu_9 order 9
output : 30
Checking input of Node 10 : Gemm_10
input 30 1 0 1
input 10.weight 0 1 1
input 10.bias 0 1 1
===> New node Gemm Gemm_10 order 10
output : 31
Checking input of Node 11 : Relu_11
input 31 1 0 1
===> New node Relu Relu_11 order 11
output : 32
Checking input of Node 12 : Gemm_12
input 32 1 0 1
input 12.weight 0 1 1
input 12.bias 0 1 1
===> New node Gemm Gemm_12 order 12
output : 33
Checking input of Node 13 : Relu_13
input 33 1 0 1
===> New node Relu Relu_13 order 13
output : 34
Checking input of Node 14 : Gemm_14
input 34 1 0 1
input 14.weight 0 1 1
input 14.bias 0 1 1
===> New node Gemm Gemm_14 order 14
output : 35
Checking input of Node 15 : Relu_15
input 35 1 0 1
===> New node Relu Relu_15 order 15
output : 36
Checking input of Node 16 : Gemm_16
input 36 1 0 1
input 16.weight 0 1 1
input 16.bias 0 1 1
===> New node Gemm Gemm_16 order 16
output : 37
Checking input of Node 17 : Relu_17
input 37 1 0 1
===> New node Relu Relu_17 order 17
output : 38
Checking input of Node 18 : Gemm_18
input 38 1 0 1
input 18.weight 0 1 1
input 18.bias 0 1 1
===> New node Gemm Gemm_18 order 18
output : 39
Graph operator list (re-ordered)
Operator 0 : Gemm , Gemm_0 input tensors : {input.1, 0.weight, 0.bias } children : { [ 1 Relu , Relu_1]}
Operator 1 : Relu , Relu_1 input tensors : {21 } children : { [ 2 Gemm , Gemm_2]}
Operator 2 : Gemm , Gemm_2 input tensors : {22, 2.weight, 2.bias } children : { [ 3 Relu , Relu_3]}
Operator 3 : Relu , Relu_3 input tensors : {23 } children : { [ 4 Gemm , Gemm_4]}
Operator 4 : Gemm , Gemm_4 input tensors : {24, 4.weight, 4.bias } children : { [ 5 Relu , Relu_5]}
Operator 5 : Relu , Relu_5 input tensors : {25 } children : { [ 6 Gemm , Gemm_6]}
Operator 6 : Gemm , Gemm_6 input tensors : {26, 6.weight, 6.bias } children : { [ 7 Relu , Relu_7]}
Operator 7 : Relu , Relu_7 input tensors : {27 } children : { [ 8 Gemm , Gemm_8]}
Operator 8 : Gemm , Gemm_8 input tensors : {28, 8.weight, 8.bias } children : { [ 9 Relu , Relu_9]}
Operator 9 : Relu , Relu_9 input tensors : {29 } children : { [ 10 Gemm , Gemm_10]}
Operator 10 : Gemm , Gemm_10 input tensors : {30, 10.weight, 10.bias } children : { [ 11 Relu , Relu_11]}
Operator 11 : Relu , Relu_11 input tensors : {31 } children : { [ 12 Gemm , Gemm_12]}
Operator 12 : Gemm , Gemm_12 input tensors : {32, 12.weight, 12.bias } children : { [ 13 Relu , Relu_13]}
Operator 13 : Relu , Relu_13 input tensors : {33 } children : { [ 14 Gemm , Gemm_14]}
Operator 14 : Gemm , Gemm_14 input tensors : {34, 14.weight, 14.bias } children : { [ 15 Relu , Relu_15]}
Operator 15 : Relu , Relu_15 input tensors : {35 } children : { [ 16 Gemm , Gemm_16]}
Operator 16 : Gemm , Gemm_16 input tensors : {36, 16.weight, 16.bias } children : { [ 17 Relu , Relu_17]}
Operator 17 : Relu , Relu_17 input tensors : {37 } children : { [ 18 Gemm , Gemm_18]}
Operator 18 : Gemm , Gemm_18 input tensors : {38, 18.weight, 18.bias } children : {}
Fill RModel with operators...
0 0 parsing operator Gemm
Parsing operator Gemm
skipping operator since it is fused with previous one
1 1 parsing operator Relu
Parsing operator Relu
Fusing operators Gemm_0 with Gemm_0
2 2 parsing operator Gemm
Parsing operator Gemm
skipping operator since it is fused with previous one
3 3 parsing operator Relu
Parsing operator Relu
Fusing operators Gemm_2 with Gemm_2
4 4 parsing operator Gemm
Parsing operator Gemm
skipping operator since it is fused with previous one
5 5 parsing operator Relu
Parsing operator Relu
Fusing operators Gemm_4 with Gemm_4
6 6 parsing operator Gemm
Parsing operator Gemm
skipping operator since it is fused with previous one
7 7 parsing operator Relu
Parsing operator Relu
Fusing operators Gemm_6 with Gemm_6
8 8 parsing operator Gemm
Parsing operator Gemm
skipping operator since it is fused with previous one
9 9 parsing operator Relu
Parsing operator Relu
Fusing operators Gemm_8 with Gemm_8
10 10 parsing operator Gemm
Parsing operator Gemm
skipping operator since it is fused with previous one
11 11 parsing operator Relu
Parsing operator Relu
Fusing operators Gemm_10 with Gemm_10
12 12 parsing operator Gemm
Parsing operator Gemm
skipping operator since it is fused with previous one
13 13 parsing operator Relu
Parsing operator Relu
Fusing operators Gemm_12 with Gemm_12
14 14 parsing operator Gemm
Parsing operator Gemm
skipping operator since it is fused with previous one
15 15 parsing operator Relu
Parsing operator Relu
Fusing operators Gemm_14 with Gemm_14
16 16 parsing operator Gemm
Parsing operator Gemm
skipping operator since it is fused with previous one
17 17 parsing operator Relu
Parsing operator Relu
Fusing operators Gemm_16 with Gemm_16
18 18 parsing operator Gemm
Parsing operator Gemm
Creating operator Gemm
Parsing Graph output list
output 0 name 39
Model requires following inputs:
Fully Specified Tensor name: input1 type: float shape: [16,100]
Model initialized the following tensors:
Tensor name: "8weight" type: float shape: [50,50]
Tensor name: "8bias" type: float shape: [50]
Tensor name: "4bias" type: float shape: [50]
Tensor name: "2weight" type: float shape: [50,50]
Tensor name: "0bias" type: float shape: [50]
Tensor name: "12bias" type: float shape: [50]
Tensor name: "18bias" type: float shape: [10]
Tensor name: "14bias" type: float shape: [50]
Tensor name: "4weight" type: float shape: [50,50]
Tensor name: "10weight" type: float shape: [50,50]
Tensor name: "6bias" type: float shape: [50]
Tensor name: "18weight" type: float shape: [10,50]
Tensor name: "0weight" type: float shape: [50,100]
Tensor name: "10bias" type: float shape: [50]
Tensor name: "2bias" type: float shape: [50]
Tensor name: "6weight" type: float shape: [50,50]
Tensor name: "14weight" type: float shape: [50,50]
Tensor name: "16weight" type: float shape: [50,50]
Tensor name: "12weight" type: float shape: [50,50]
Tensor name: "16bias" type: float shape: [50]
Model specify the following intermediate tensors:
Tensor name: "38" type: float shape: [16,50]
Tensor name: "39" type: float shape: [16,10]
Tensor name: "34" type: float shape: [16,50]
Tensor name: "32" type: float shape: [16,50]
Tensor name: "28" type: float shape: [16,50]
Tensor name: "26" type: float shape: [16,50]
Tensor name: "24" type: float shape: [16,50]
Tensor name: "36" type: float shape: [16,50]
Tensor name: "30" type: float shape: [16,50]
Tensor name: "22" type: float shape: [16,50]
Tensor "16weight" already exist: true
Shape of tensor "16weight": 50,50,
Data type of tensor "16weight": float
//Code generated automatically by TMVA for Inference of Model file [Linear_16.onnx] at [Thu Jun 25 10:18:27 2026]
#ifndef ROOT_TMVA_SOFIE_LINEAR_16
#define ROOT_TMVA_SOFIE_LINEAR_16
#include <algorithm>
#include <vector>
#include "TMVA/SOFIE_common.hxx"
#include <fstream>
namespace TMVA_SOFIE_Linear_16{
namespace BLAS{
extern "C" void sgemv_(const char * trans, const int * m, const int * n, const float * alpha, const float * A,
const int * lda, const float * X, const int * incx, const float * beta, const float * Y, const int * incy);
extern "C" 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);
}//BLAS
struct Session;
inline void doInfer(Session const &session, float const* tensor_input1, float *tensor_39 );
struct Session {
// initialized (weights and constant) tensors
std::vector<float> fTensor_8weight = std::vector<float>(2500);
float * tensor_8weight = fTensor_8weight.data();
std::vector<float> fTensor_8bias = std::vector<float>(50);
float * tensor_8bias = fTensor_8bias.data();
std::vector<float> fTensor_4bias = std::vector<float>(50);
float * tensor_4bias = fTensor_4bias.data();
std::vector<float> fTensor_2weight = std::vector<float>(2500);
float * tensor_2weight = fTensor_2weight.data();
std::vector<float> fTensor_0bias = std::vector<float>(50);
float * tensor_0bias = fTensor_0bias.data();
std::vector<float> fTensor_12bias = std::vector<float>(50);
float * tensor_12bias = fTensor_12bias.data();
std::vector<float> fTensor_18bias = std::vector<float>(10);
float * tensor_18bias = fTensor_18bias.data();
std::vector<float> fTensor_14bias = std::vector<float>(50);
float * tensor_14bias = fTensor_14bias.data();
std::vector<float> fTensor_4weight = std::vector<float>(2500);
float * tensor_4weight = fTensor_4weight.data();
std::vector<float> fTensor_10weight = std::vector<float>(2500);
float * tensor_10weight = fTensor_10weight.data();
std::vector<float> fTensor_6bias = std::vector<float>(50);
float * tensor_6bias = fTensor_6bias.data();
std::vector<float> fTensor_18weight = std::vector<float>(500);
float * tensor_18weight = fTensor_18weight.data();
std::vector<float> fTensor_0weight = std::vector<float>(5000);
float * tensor_0weight = fTensor_0weight.data();
std::vector<float> fTensor_10bias = std::vector<float>(50);
float * tensor_10bias = fTensor_10bias.data();
std::vector<float> fTensor_2bias = std::vector<float>(50);
float * tensor_2bias = fTensor_2bias.data();
std::vector<float> fTensor_6weight = std::vector<float>(2500);
float * tensor_6weight = fTensor_6weight.data();
std::vector<float> fTensor_14weight = std::vector<float>(2500);
float * tensor_14weight = fTensor_14weight.data();
std::vector<float> fTensor_16weight = std::vector<float>(2500);
float * tensor_16weight = fTensor_16weight.data();
std::vector<float> fTensor_12weight = std::vector<float>(2500);
float * tensor_12weight = fTensor_12weight.data();
std::vector<float> fTensor_16bias = std::vector<float>(50);
float * tensor_16bias = fTensor_16bias.data();
//--- Allocating session memory pool to be used for allocating intermediate tensors
std::vector<char> fIntermediateMemoryPool = std::vector<char>(6400);
// --- Positioning intermediate tensor memory --
// Allocating memory for intermediate tensor 22 with size 3200 bytes
float* tensor_22 = reinterpret_cast<float*>(fIntermediateMemoryPool.data() + 0);
// Allocating memory for intermediate tensor 24 with size 3200 bytes
float* tensor_24 = reinterpret_cast<float*>(fIntermediateMemoryPool.data() + 3200);
// Allocating memory for intermediate tensor 26 with size 3200 bytes
float* tensor_26 = reinterpret_cast<float*>(fIntermediateMemoryPool.data() + 0);
// Allocating memory for intermediate tensor 28 with size 3200 bytes
float* tensor_28 = reinterpret_cast<float*>(fIntermediateMemoryPool.data() + 3200);
// Allocating memory for intermediate tensor 30 with size 3200 bytes
float* tensor_30 = reinterpret_cast<float*>(fIntermediateMemoryPool.data() + 0);
// Allocating memory for intermediate tensor 32 with size 3200 bytes
float* tensor_32 = reinterpret_cast<float*>(fIntermediateMemoryPool.data() + 3200);
// Allocating memory for intermediate tensor 34 with size 3200 bytes
float* tensor_34 = reinterpret_cast<float*>(fIntermediateMemoryPool.data() + 0);
// Allocating memory for intermediate tensor 36 with size 3200 bytes
float* tensor_36 = reinterpret_cast<float*>(fIntermediateMemoryPool.data() + 3200);
// Allocating memory for intermediate tensor 38 with size 3200 bytes
float* tensor_38 = reinterpret_cast<float*>(fIntermediateMemoryPool.data() + 0);
// Allocating memory for intermediate tensor 39 with size 640 bytes
float* tensor_39 = reinterpret_cast<float*>(fIntermediateMemoryPool.data() + 5760);
Session(std::string filename ="Linear_16.dat") {
//--- reading weights from file
std::ifstream f;
f.open(filename);
if (!f.is_open()) {
throw std::runtime_error("tmva-sofie failed to open file " + filename + " for input weights");
}
using TMVA::Experimental::SOFIE::ReadTensorFromStream;
ReadTensorFromStream(f, tensor_8weight, "tensor_8weight", 2500);
ReadTensorFromStream(f, tensor_8bias, "tensor_8bias", 50);
ReadTensorFromStream(f, tensor_4bias, "tensor_4bias", 50);
ReadTensorFromStream(f, tensor_2weight, "tensor_2weight", 2500);
ReadTensorFromStream(f, tensor_0bias, "tensor_0bias", 50);
ReadTensorFromStream(f, tensor_12bias, "tensor_12bias", 50);
ReadTensorFromStream(f, tensor_18bias, "tensor_18bias", 10);
ReadTensorFromStream(f, tensor_14bias, "tensor_14bias", 50);
ReadTensorFromStream(f, tensor_4weight, "tensor_4weight", 2500);
ReadTensorFromStream(f, tensor_10weight, "tensor_10weight", 2500);
ReadTensorFromStream(f, tensor_6bias, "tensor_6bias", 50);
ReadTensorFromStream(f, tensor_18weight, "tensor_18weight", 500);
ReadTensorFromStream(f, tensor_0weight, "tensor_0weight", 5000);
ReadTensorFromStream(f, tensor_10bias, "tensor_10bias", 50);
ReadTensorFromStream(f, tensor_2bias, "tensor_2bias", 50);
ReadTensorFromStream(f, tensor_6weight, "tensor_6weight", 2500);
ReadTensorFromStream(f, tensor_14weight, "tensor_14weight", 2500);
ReadTensorFromStream(f, tensor_16weight, "tensor_16weight", 2500);
ReadTensorFromStream(f, tensor_12weight, "tensor_12weight", 2500);
ReadTensorFromStream(f, tensor_16bias, "tensor_16bias", 50);
f.close();
}
std::vector<float> infer(float const* tensor_input1){
std::vector<float > output_tensor_39(160);
doInfer(*this, tensor_input1, output_tensor_39.data() );
return {output_tensor_39};
}
}; // end of Session
// Input tensor dimensions
using TMVA::Experimental::SOFIE::SingleDim;
using TMVA::Experimental::SOFIE::TensorDims;
using TMVA::Experimental::SOFIE::makeDims;
constexpr std::array<SingleDim, 2> dim_input1{SingleDim{16}, SingleDim{100}};
constexpr std::array<TensorDims, 1> inputTensorDims{
makeDims(dim_input1)
};
constexpr bool hasDynamicInputTensors{false};
// Output tensor dimensions
constexpr std::array<SingleDim, 2> dim_39{SingleDim{16}, SingleDim{10}};
constexpr std::array<TensorDims, 1> outputTensorDims{
makeDims(dim_39)
};
constexpr bool hasDynamicOutputTensors{false};
inline void doInfer(Session const &session, float const* tensor_input1, float *tensor_39 ) {
auto &tensor_0bias = session.tensor_0bias;
auto &tensor_0weight = session.tensor_0weight;
auto &tensor_10bias = session.tensor_10bias;
auto &tensor_10weight = session.tensor_10weight;
auto &tensor_12bias = session.tensor_12bias;
auto &tensor_12weight = session.tensor_12weight;
auto &tensor_14bias = session.tensor_14bias;
auto &tensor_14weight = session.tensor_14weight;
auto &tensor_16bias = session.tensor_16bias;
auto &tensor_16weight = session.tensor_16weight;
auto &tensor_18bias = session.tensor_18bias;
auto &tensor_18weight = session.tensor_18weight;
auto &tensor_22 = session.tensor_22;
auto &tensor_24 = session.tensor_24;
auto &tensor_26 = session.tensor_26;
auto &tensor_28 = session.tensor_28;
auto &tensor_2bias = session.tensor_2bias;
auto &tensor_2weight = session.tensor_2weight;
auto &tensor_30 = session.tensor_30;
auto &tensor_32 = session.tensor_32;
auto &tensor_34 = session.tensor_34;
auto &tensor_36 = session.tensor_36;
auto &tensor_38 = session.tensor_38;
auto &tensor_4bias = session.tensor_4bias;
auto &tensor_4weight = session.tensor_4weight;
auto &tensor_6bias = session.tensor_6bias;
auto &tensor_6weight = session.tensor_6weight;
auto &tensor_8bias = session.tensor_8bias;
auto &tensor_8weight = session.tensor_8weight;
//--------- Gemm op_0 { 16 , 100 } * { 50 , 100 } -> { 16 , 50 }
for (size_t j = 0; j < 16; j++) {
size_t y_index = 50 * j;
TMVA::Experimental::SOFIE::Copy(tensor_22 + y_index, tensor_0bias, 50);
}
TMVA::Experimental::SOFIE::Gemm_Call(tensor_22, true, false, 50, 16, 100, 1, tensor_0weight, tensor_input1, 1,nullptr);
//--- applying RELU to output
TMVA::Experimental::SOFIE::Relu(tensor_22, tensor_22, 800);
//--------- Gemm op_1 { 16 , 50 } * { 50 , 50 } -> { 16 , 50 }
for (size_t j = 0; j < 16; j++) {
size_t y_index = 50 * j;
TMVA::Experimental::SOFIE::Copy(tensor_24 + y_index, tensor_2bias, 50);
}
TMVA::Experimental::SOFIE::Gemm_Call(tensor_24, true, false, 50, 16, 50, 1, tensor_2weight, tensor_22, 1,nullptr);
//--- applying RELU to output
TMVA::Experimental::SOFIE::Relu(tensor_24, tensor_24, 800);
//--------- Gemm op_2 { 16 , 50 } * { 50 , 50 } -> { 16 , 50 }
for (size_t j = 0; j < 16; j++) {
size_t y_index = 50 * j;
TMVA::Experimental::SOFIE::Copy(tensor_26 + y_index, tensor_4bias, 50);
}
TMVA::Experimental::SOFIE::Gemm_Call(tensor_26, true, false, 50, 16, 50, 1, tensor_4weight, tensor_24, 1,nullptr);
//--- applying RELU to output
TMVA::Experimental::SOFIE::Relu(tensor_26, tensor_26, 800);
//--------- Gemm op_3 { 16 , 50 } * { 50 , 50 } -> { 16 , 50 }
for (size_t j = 0; j < 16; j++) {
size_t y_index = 50 * j;
TMVA::Experimental::SOFIE::Copy(tensor_28 + y_index, tensor_6bias, 50);
}
TMVA::Experimental::SOFIE::Gemm_Call(tensor_28, true, false, 50, 16, 50, 1, tensor_6weight, tensor_26, 1,nullptr);
//--- applying RELU to output
TMVA::Experimental::SOFIE::Relu(tensor_28, tensor_28, 800);
//--------- Gemm op_4 { 16 , 50 } * { 50 , 50 } -> { 16 , 50 }
for (size_t j = 0; j < 16; j++) {
size_t y_index = 50 * j;
TMVA::Experimental::SOFIE::Copy(tensor_30 + y_index, tensor_8bias, 50);
}
TMVA::Experimental::SOFIE::Gemm_Call(tensor_30, true, false, 50, 16, 50, 1, tensor_8weight, tensor_28, 1,nullptr);
//--- applying RELU to output
TMVA::Experimental::SOFIE::Relu(tensor_30, tensor_30, 800);
//--------- Gemm op_5 { 16 , 50 } * { 50 , 50 } -> { 16 , 50 }
for (size_t j = 0; j < 16; j++) {
size_t y_index = 50 * j;
TMVA::Experimental::SOFIE::Copy(tensor_32 + y_index, tensor_10bias, 50);
}
TMVA::Experimental::SOFIE::Gemm_Call(tensor_32, true, false, 50, 16, 50, 1, tensor_10weight, tensor_30, 1,nullptr);
//--- applying RELU to output
TMVA::Experimental::SOFIE::Relu(tensor_32, tensor_32, 800);
//--------- Gemm op_6 { 16 , 50 } * { 50 , 50 } -> { 16 , 50 }
for (size_t j = 0; j < 16; j++) {
size_t y_index = 50 * j;
TMVA::Experimental::SOFIE::Copy(tensor_34 + y_index, tensor_12bias, 50);
}
TMVA::Experimental::SOFIE::Gemm_Call(tensor_34, true, false, 50, 16, 50, 1, tensor_12weight, tensor_32, 1,nullptr);
//--- applying RELU to output
TMVA::Experimental::SOFIE::Relu(tensor_34, tensor_34, 800);
//--------- Gemm op_7 { 16 , 50 } * { 50 , 50 } -> { 16 , 50 }
for (size_t j = 0; j < 16; j++) {
size_t y_index = 50 * j;
TMVA::Experimental::SOFIE::Copy(tensor_36 + y_index, tensor_14bias, 50);
}
TMVA::Experimental::SOFIE::Gemm_Call(tensor_36, true, false, 50, 16, 50, 1, tensor_14weight, tensor_34, 1,nullptr);
//--- applying RELU to output
TMVA::Experimental::SOFIE::Relu(tensor_36, tensor_36, 800);
//--------- Gemm op_8 { 16 , 50 } * { 50 , 50 } -> { 16 , 50 }
for (size_t j = 0; j < 16; j++) {
size_t y_index = 50 * j;
TMVA::Experimental::SOFIE::Copy(tensor_38 + y_index, tensor_16bias, 50);
}
TMVA::Experimental::SOFIE::Gemm_Call(tensor_38, true, false, 50, 16, 50, 1, tensor_16weight, tensor_36, 1,nullptr);
//--- applying RELU to output
TMVA::Experimental::SOFIE::Relu(tensor_38, tensor_38, 800);
//--------- Gemm op_9 { 16 , 50 } * { 10 , 50 } -> { 16 , 10 }
for (size_t j = 0; j < 16; j++) {
size_t y_index = 10 * j;
TMVA::Experimental::SOFIE::Copy(tensor_39 + y_index, tensor_18bias, 10);
}
TMVA::Experimental::SOFIE::Gemm_Call(tensor_39, true, false, 10, 16, 50, 1, tensor_18weight, tensor_38, 1,nullptr);
}
} //TMVA_SOFIE_Linear_16
#endif // ROOT_TMVA_SOFIE_LINEAR_16
Author
Sanjiban Sengupta

Definition in file TMVA_SOFIE_ONNX.C.