@@ -554,3 +554,60 @@ def build_convtranspose_conv_residual_model():
554554 onnx .checker .check_model (model_inferred )
555555
556556 return model_inferred
557+
558+
559+ def build_matmul_relu_model_ir_12 ():
560+ # Define your model inputs and outputs
561+ input_names = ["input_0" ]
562+ output_names = ["output_0" ]
563+ input_shapes = [(1 , 1024 , 1024 )]
564+ output_shapes = [(1 , 1024 , 16 )]
565+
566+ inputs = [
567+ helper .make_tensor_value_info (input_name , onnx .TensorProto .FLOAT , input_shape )
568+ for input_name , input_shape in zip (input_names , input_shapes )
569+ ]
570+ outputs = [
571+ helper .make_tensor_value_info (output_name , onnx .TensorProto .FLOAT , output_shape )
572+ for output_name , output_shape in zip (output_names , output_shapes )
573+ ]
574+
575+ # Create the ONNX graph with the nodes
576+ nodes = [
577+ helper .make_node (
578+ op_type = "MatMul" ,
579+ inputs = ["input_0" , "weights_1" ],
580+ outputs = ["matmul1_matmul/MatMul:0" ],
581+ name = "matmul1_matmul/MatMul" ,
582+ ),
583+ helper .make_node (
584+ op_type = "Relu" ,
585+ inputs = ["matmul1_matmul/MatMul:0" ],
586+ outputs = ["output_0" ],
587+ name = "relu1_relu/Relu" ,
588+ ),
589+ ]
590+
591+ # Create the ONNX initializers
592+ initializers = [
593+ helper .make_tensor (
594+ name = "weights_1" ,
595+ data_type = onnx .TensorProto .FLOAT ,
596+ dims = (1024 , 16 ),
597+ vals = np .random .uniform (low = 0.5 , high = 1.0 , size = 1024 * 16 ),
598+ ),
599+ ]
600+
601+ # Create the ONNX graph with the nodes and initializers
602+ graph = helper .make_graph (nodes , "r1a" , inputs , outputs , initializer = initializers )
603+
604+ # Create the ONNX model
605+ model = helper .make_model (graph )
606+ model .opset_import [0 ].version = 13
607+ model .ir_version = 12
608+
609+ # Check the ONNX model
610+ model_inferred = onnx .shape_inference .infer_shapes (model )
611+ onnx .checker .check_model (model_inferred )
612+
613+ return model_inferred
0 commit comments