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