@@ -52,13 +52,6 @@ internal static DataViewSchema GetModelSchema(IExceptionContext ectx, Graph grap
5252 if ( mlType == null || op . NumOutputs <= 0 )
5353 continue ;
5454
55- // Construct the final ML.NET type of a Tensorflow variable.
56- var tensorShape = op . output . TensorShape . dims ;
57- var columnType = new VectorDataViewType ( mlType ) ;
58- if ( ! ( Utils . Size ( tensorShape ) == 1 && tensorShape [ 0 ] <= 0 ) &&
59- ( Utils . Size ( tensorShape ) > 0 && tensorShape . Skip ( 1 ) . All ( x => x > 0 ) ) )
60- columnType = new VectorDataViewType ( mlType , tensorShape [ 0 ] > 0 ? tensorShape : tensorShape . Skip ( 1 ) . ToArray ( ) ) ;
61-
6255 // There can be at most two metadata fields.
6356 // 1. The first field always presents. Its value is this operator's type. For example,
6457 // if an output is produced by an "Softmax" operator, the value of this field should be "Softmax".
@@ -83,7 +76,24 @@ internal static DataViewSchema GetModelSchema(IExceptionContext ectx, Graph grap
8376 ( ref VBuffer < ReadOnlyMemory < char > > value ) => { upstreamOperatorNames . CopyTo ( ref value ) ; } ) ;
8477 }
8578
86- schemaBuilder . AddColumn ( op . name , columnType , metadataBuilder . ToAnnotations ( ) ) ;
79+ // Construct the final ML.NET type of a Tensorflow variable.
80+ var tensorShape = op . output . TensorShape . dims ;
81+
82+ if ( tensorShape == null )
83+ {
84+ // primitive column type
85+ schemaBuilder . AddColumn ( op . name , mlType , metadataBuilder . ToAnnotations ( ) ) ;
86+ }
87+ else
88+ {
89+ // vector column type
90+ DataViewType columnType = new VectorDataViewType ( mlType ) ;
91+ if ( ! ( Utils . Size ( tensorShape ) == 1 && tensorShape [ 0 ] <= 0 ) &&
92+ ( Utils . Size ( tensorShape ) > 0 && tensorShape . Skip ( 1 ) . All ( x => x > 0 ) ) )
93+ columnType = new VectorDataViewType ( mlType , tensorShape [ 0 ] > 0 ? tensorShape : tensorShape . Skip ( 1 ) . ToArray ( ) ) ;
94+
95+ schemaBuilder . AddColumn ( op . name , columnType , metadataBuilder . ToAnnotations ( ) ) ;
96+ }
8797 }
8898 return schemaBuilder . ToSchema ( ) ;
8999 }
0 commit comments