@@ -383,11 +383,14 @@ private protected override void SaveModel(ModelSaveContext ctx)
383383 /// </summary>
384384 private static IEnumerable < int > AdjustDimensions ( OnnxShape shape )
385385 {
386- if ( shape . Count > 0 && shape [ 0 ] < 0 )
387- shape [ 0 ] = 1 ;
388-
389- if ( shape . Count > 1 )
386+ if ( shape . Count > 0 )
387+ {
388+ if ( shape [ 0 ] < 0 )
389+ {
390+ shape [ 0 ] = 1 ;
391+ }
390392 return shape . Select ( x => ( x <= 0 ) ? 0 : x ) ;
393+ }
391394
392395 return new [ ] { 1 } ;
393396 }
@@ -795,23 +798,23 @@ private class NamedOnnxValueGetterVec<T> : INamedOnnxValueGetter
795798 private readonly string _colName ;
796799 private VBuffer < T > _vBuffer ;
797800 private VBuffer < T > _vBufferDense ;
798- private readonly bool _isKnownSize ;
799801 private readonly int _denominator ;
800802 private readonly int _zeroIndex ;
801803 private readonly GetNamedOnnxVal _namedOnnxValueDelegate ;
802804
803805 public NamedOnnxValueGetterVec ( DataViewRow input , int colIndex , OnnxShape tensorShape )
804806 {
805807 _srcGetter = input . GetGetter < VBuffer < T > > ( input . Schema [ colIndex ] ) ;
806- _isKnownSize = ( input . Schema [ colIndex ] . Type as VectorDataViewType ) . IsKnownSize ;
807808 _tensorShape = tensorShape ;
808809 _colName = input . Schema [ colIndex ] . Name ;
809810 _vBuffer = default ;
810811 _vBufferDense = default ;
811812 _denominator = _tensorShape . Where ( x => x > 0 ) . Aggregate ( ( a , x ) => a * x ) ;
812813 _zeroIndex = _tensorShape . IndexOf ( 0 ) ;
813814
814- if ( _isKnownSize )
815+ var isKnownSize = ( input . Schema [ colIndex ] . Type as VectorDataViewType ) . IsKnownSize ;
816+
817+ if ( isKnownSize )
815818 _namedOnnxValueDelegate = GetNamedOnnxValueKnownSize ;
816819 else
817820 _namedOnnxValueDelegate = GetNamedOnnxValueUnknownSize ;
0 commit comments