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 float attr_alpha = 1.0;
24 float attr_beta = 1.0;
25 int_t attr_transA = 0;
26 int_t attr_transB = 0;
27
28 switch (input_type) {
30 op.reset(new ROperator_Gemm<float>(attr_alpha, attr_beta, attr_transA, attr_transB, matmulnode.input(0),
31 matmulnode.input(1), matmulnode.output(0)));
32 break;
33 default:
34 throw std::runtime_error(
35 "TMVA::SOFIE - Unsupported - Operator for fusing MatMul and Add to Gemm does not yet support input type " +
36 std::to_string(static_cast<int>(input_type)));
37 }
38
39 std::string output_name = matmulnode.output(0);
40 if (!parser.IsRegisteredTensorType(output_name)) {
41 parser.RegisterTensorType(output_name, input_type);
42 }
43
44 return op;
45};
46
47} // namespace SOFIE
48} // namespace Experimental
49} // 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