Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ParseMatMul.cxx
Go to the documentation of this file.
3#include "onnx_proto3.pb.h"
4
5namespace TMVA {
6namespace Experimental {
7namespace SOFIE {
8
9ParserFuncSignature ParseMatMul = [](RModelParser_ONNX &parser, const onnx::NodeProto &matmulnode) {
11
12 // check input type - only first input from MatMul
13 auto input_name = matmulnode.input(0);
14 if (parser.IsRegisteredTensorType(input_name)) {
15 input_type = parser.GetTensorType(input_name);
16 } else {
17 throw std::runtime_error("TMVA::SOFIE ONNX Parser MatMul op has input tensor " + input_name +
18 " but its type is not yet registered");
19 }
20
21 std::unique_ptr<ROperator> op;
22
23 // for MatMul there is no alpha and beta : use alpha=1 and beta=0
24 float attr_alpha = 1.0;
25 float attr_beta = 0.0;
26 int_t attr_transA = 0;
27 int_t attr_transB = 0;
28
29 switch (input_type) {
31 op.reset(new ROperator_Gemm<float>(attr_alpha, attr_beta, attr_transA, attr_transB, matmulnode.input(0),
32 matmulnode.input(1), matmulnode.output(0)));
33 break;
34 default:
35 throw std::runtime_error(
36 "TMVA::SOFIE - Unsupported - Operator for fusing MatMul and Add to Gemm does not yet support input type " +
37 std::to_string(static_cast<int>(input_type)));
38 }
39
40 std::string output_name = matmulnode.output(0);
41 if (!parser.IsRegisteredTensorType(output_name)) {
42 parser.RegisterTensorType(output_name, input_type);
43 }
44
45 return op;
46};
47
48} // namespace SOFIE
49} // namespace Experimental
50} // namespace TMVA
void RegisterTensorType(const std::string &, ETensorType)
ETensorType GetTensorType(const std::string &name)
ParserFuncSignature ParseMatMul
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
create variable transformations