@@ -824,7 +824,10 @@ def str_node(indent, node):
824824 rows .append (f"opset: domain={ opset .domain !r} version={ opset .version !r} " )
825825 if hasattr (model , "graph" ):
826826 if model .doc_string :
827- rows .append (f"doc_string: { model .doc_string } " )
827+ if len (model .doc_string ) < 55 :
828+ rows .append (f"doc_string: { model .doc_string } " )
829+ else :
830+ rows .append (f"doc_string: { model .doc_string [:55 ]} ..." )
828831 main_model = model
829832 model = model .graph
830833 else :
@@ -861,9 +864,16 @@ def str_node(indent, node):
861864 else :
862865 content = ""
863866 line_name_new [init .name ] = len (rows )
867+ if init .doc_string :
868+ t = (
869+ f"init: name={ init .name !r} type={ _get_type (init )} "
870+ f"shape={ _get_shape (init )} { content } "
871+ )
872+ rows .append (f"{ t } { ' ' * max (0 , 70 - len (t ))} -- { init .doc_string } " )
873+ continue
864874 rows .append (
865- "init: name=%r type=%r shape=%r%s "
866- % ( init . name , _get_type ( init ), _get_shape (init ), content )
875+ f "init: name={ init . name !r } type={ _get_type ( init ) } "
876+ f"shape= { _get_shape (init )} { content } "
867877 )
868878 if level == 0 :
869879 rows .append ("----- main graph ----" )
@@ -1044,7 +1054,10 @@ def _mark_link(rows, lengths, r1, r2, d):
10441054 for fct in main_model .functions :
10451055 rows .append (f"----- function name={ fct .name } domain={ fct .domain } " )
10461056 if fct .doc_string :
1047- rows .append (f"----- doc_string: { fct .doc_string } " )
1057+ if len (fct .doc_string ) < 55 :
1058+ rows .append (f"----- doc_string: { fct .doc_string } " )
1059+ else :
1060+ rows .append (f"----- doc_string: { fct .doc_string [:55 ]} ..." )
10481061 res = onnx_simple_text_plot (
10491062 fct ,
10501063 verbose = verbose ,
@@ -1103,10 +1116,19 @@ def onnx_text_plot_io(model, verbose=False, att_display=None):
11031116 )
11041117 # initializer
11051118 for init in model .initializer :
1119+
1120+ if init .doc_string :
1121+ t = (
1122+ f"init: name={ init .name !r} type={ _get_type (init )} "
1123+ f"shape={ _get_shape (init )} "
1124+ )
1125+ rows .append (f"{ t } { ' ' * max (0 , 70 - len (t ))} -- { init .doc_string } " )
1126+ continue
11061127 rows .append (
1107- "init: name=%r type=%r shape=%r "
1108- % ( init . name , _get_type ( init ), _get_shape (init ))
1128+ f "init: name={ init . name !r } type={ _get_type ( init ) } "
1129+ f"shape= { _get_shape (init )} "
11091130 )
1131+
11101132 # outputs
11111133 for out in model .output :
11121134 rows .append (
0 commit comments