def create_model_with_matmul(tmp_path, input_shape, weight_shape):
    """Create a test model with a MatMul operation and non-4D tensors."""
    model_path = tmp_path / "matmul_model.onnx"

    input_tensor = helper.make_tensor_value_info("input", TensorProto.FLOAT, input_shape)

    weight_data = np.random.randn(*weight_shape).astype(np.float32)
    weight_initializer = helper.make_tensor(
        name="weight",
        data_type=TensorProto.FLOAT,
        dims=weight_shape,
        vals=weight_data.flatten().tolist(),
    )

    output_shape = input_shape[:-1] + [weight_shape[-1]]
    output_tensor = helper.make_tensor_value_info("output", TensorProto.FLOAT, output_shape)

    matmul_node = helper.make_node("MatMul", inputs=["input", "weight"], outputs=["output"], name="MatMul_Node")

    graph = helper.make_graph(
        nodes=[matmul_node],
        name="MatMul-Test-Graph",
        inputs=[input_tensor],
        outputs=[output_tensor],
        initializer=[weight_initializer],
    )

    model = helper.make_model(graph, producer_name="onnx-example")
    model.opset_import[0].version = 13

    onnx.save(model, model_path)

    return str(model_path), input_shape, weight_shape, output_shape
Create a test model with a MatMul operation and non-4D tensors.
test/unit_test/passes/onnx/test_trt_dla_transforms.py